author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Dashboard Widget Administration Screen API |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
10 |
* Registers dashboard widgets. |
|
11 |
* |
|
12 |
* Handles POST data, sets up filters. |
|
13 |
* |
|
14 |
* @since 2.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* @global array $wp_registered_widgets |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
* @global array $wp_registered_widget_controls |
18 | 18 |
* @global callable[] $wp_dashboard_control_callbacks |
0 | 19 |
*/ |
20 |
function wp_dashboard_setup() { |
|
21 |
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; |
|
18 | 22 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
23 |
$screen = get_current_screen(); |
0 | 24 |
|
25 |
/* Register Widgets and Controls */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
26 |
$wp_dashboard_control_callbacks = array(); |
0 | 27 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
28 |
// Browser version |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
29 |
$check_browser = wp_check_browser_version(); |
0 | 30 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
31 |
if ( $check_browser && $check_browser['upgrade'] ) { |
0 | 32 |
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
18 | 33 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
34 |
if ( $check_browser['insecure'] ) { |
0 | 35 |
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
9 | 36 |
} else { |
0 | 37 |
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
9 | 38 |
} |
39 |
} |
|
40 |
||
41 |
// PHP Version. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
$check_php = wp_check_php_version(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
43 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
44 |
if ( $check_php && current_user_can( 'update_php' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
45 |
// If "not acceptable" the widget will be shown. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
46 |
if ( isset( $check_php['is_acceptable'] ) && ! $check_php['is_acceptable'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' ); |
18 | 48 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
49 |
if ( $check_php['is_lower_than_future_minimum'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
51 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
52 |
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
53 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
54 |
} |
0 | 55 |
} |
56 |
||
16 | 57 |
// Site Health. |
58 |
if ( current_user_can( 'view_site_health_checks' ) && ! is_network_admin() ) { |
|
59 |
if ( ! class_exists( 'WP_Site_Health' ) ) { |
|
60 |
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; |
|
61 |
} |
|
62 |
||
63 |
WP_Site_Health::get_instance(); |
|
64 |
||
65 |
wp_enqueue_style( 'site-health' ); |
|
66 |
wp_enqueue_script( 'site-health' ); |
|
67 |
||
68 |
wp_add_dashboard_widget( 'dashboard_site_health', __( 'Site Health Status' ), 'wp_dashboard_site_health' ); |
|
69 |
} |
|
70 |
||
71 |
// Right Now. |
|
9 | 72 |
if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { |
5 | 73 |
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
9 | 74 |
} |
0 | 75 |
|
9 | 76 |
if ( is_network_admin() ) { |
0 | 77 |
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
9 | 78 |
} |
0 | 79 |
|
16 | 80 |
// Activity Widget. |
5 | 81 |
if ( is_blog_admin() ) { |
82 |
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); |
|
0 | 83 |
} |
84 |
||
16 | 85 |
// QuickPress Widget. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) ); |
5 | 88 |
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); |
0 | 89 |
} |
5 | 90 |
|
16 | 91 |
// WordPress Events and News. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); |
5 | 93 |
|
94 |
if ( is_network_admin() ) { |
|
0 | 95 |
|
5 | 96 |
/** |
97 |
* Fires after core widgets for the Network Admin dashboard have been registered. |
|
98 |
* |
|
99 |
* @since 3.1.0 |
|
100 |
*/ |
|
101 |
do_action( 'wp_network_dashboard_setup' ); |
|
0 | 102 |
|
5 | 103 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
* Filters the list of widgets to load for the Network Admin dashboard. |
5 | 105 |
* |
106 |
* @since 3.1.0 |
|
107 |
* |
|
9 | 108 |
* @param string[] $dashboard_widgets An array of dashboard widget IDs. |
5 | 109 |
*/ |
0 | 110 |
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); |
111 |
} elseif ( is_user_admin() ) { |
|
5 | 112 |
|
113 |
/** |
|
114 |
* Fires after core widgets for the User Admin dashboard have been registered. |
|
115 |
* |
|
116 |
* @since 3.1.0 |
|
117 |
*/ |
|
0 | 118 |
do_action( 'wp_user_dashboard_setup' ); |
5 | 119 |
|
120 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
* Filters the list of widgets to load for the User Admin dashboard. |
5 | 122 |
* |
123 |
* @since 3.1.0 |
|
124 |
* |
|
9 | 125 |
* @param string[] $dashboard_widgets An array of dashboard widget IDs. |
5 | 126 |
*/ |
0 | 127 |
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); |
128 |
} else { |
|
5 | 129 |
|
130 |
/** |
|
131 |
* Fires after core widgets for the admin dashboard have been registered. |
|
132 |
* |
|
133 |
* @since 2.5.0 |
|
134 |
*/ |
|
0 | 135 |
do_action( 'wp_dashboard_setup' ); |
5 | 136 |
|
137 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
* Filters the list of widgets to load for the admin dashboard. |
5 | 139 |
* |
140 |
* @since 2.5.0 |
|
141 |
* |
|
9 | 142 |
* @param string[] $dashboard_widgets An array of dashboard widget IDs. |
5 | 143 |
*/ |
0 | 144 |
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); |
145 |
} |
|
146 |
||
147 |
foreach ( $dashboard_widgets as $widget_id ) { |
|
9 | 148 |
$name = empty( $wp_registered_widgets[ $widget_id ]['all_link'] ) ? $wp_registered_widgets[ $widget_id ]['name'] : $wp_registered_widgets[ $widget_id ]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all' ) . '</a>'; |
149 |
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] ); |
|
0 | 150 |
} |
151 |
||
16 | 152 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { |
0 | 153 |
check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); |
16 | 154 |
ob_start(); // Hack - but the same hack wp-admin/widgets.php uses. |
0 | 155 |
wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); |
156 |
ob_end_clean(); |
|
157 |
wp_redirect( remove_query_arg( 'edit' ) ); |
|
158 |
exit; |
|
159 |
} |
|
160 |
||
9 | 161 |
/** This action is documented in wp-admin/includes/meta-boxes.php */ |
5 | 162 |
do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); |
0 | 163 |
|
9 | 164 |
/** This action is documented in wp-admin/includes/meta-boxes.php */ |
5 | 165 |
do_action( 'do_meta_boxes', $screen->id, 'side', '' ); |
0 | 166 |
} |
167 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
* Adds a new dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
* @since 2.7.0 |
18 | 172 |
* @since 5.6.0 The `$context` and `$priority` parameters were added. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
* |
18 | 174 |
* @global callable[] $wp_dashboard_control_callbacks |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
* @param string $widget_name Title of the widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
* @param callable $callback Function that fills the widget with the desired content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
* The function should echo its output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
* (which is the second parameter passed to your callback). Default null. |
18 | 183 |
* @param string $context Optional. The context within the screen where the box should display. |
184 |
* Accepts 'normal', 'side', 'column3', or 'column4'. Default 'normal'. |
|
185 |
* @param string $priority Optional. The priority within the context where the box should show. |
|
186 |
* Accepts 'high', 'core', 'default', or 'low'. Default 'core'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
*/ |
18 | 188 |
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null, $context = 'normal', $priority = 'core' ) { |
189 |
global $wp_dashboard_control_callbacks; |
|
190 |
||
0 | 191 |
$screen = get_current_screen(); |
192 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
$private_callback_args = array( '__widget_basename' => $widget_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
if ( is_null( $callback_args ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
$callback_args = $private_callback_args; |
9 | 197 |
} elseif ( is_array( $callback_args ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
$callback_args = array_merge( $callback_args, $private_callback_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
|
18 | 201 |
if ( $control_callback && is_callable( $control_callback ) && current_user_can( 'edit_dashboard' ) ) { |
9 | 202 |
$wp_dashboard_control_callbacks[ $widget_id ] = $control_callback; |
18 | 203 |
|
204 |
if ( isset( $_GET['edit'] ) && $widget_id === $_GET['edit'] ) { |
|
9 | 205 |
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); |
0 | 206 |
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>'; |
9 | 207 |
$callback = '_wp_dashboard_control_callback'; |
0 | 208 |
} else { |
9 | 209 |
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); |
0 | 210 |
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>'; |
211 |
} |
|
212 |
} |
|
213 |
||
5 | 214 |
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); |
0 | 215 |
|
16 | 216 |
if ( in_array( $widget_id, $side_widgets, true ) ) { |
18 | 217 |
$context = 'side'; |
9 | 218 |
} |
219 |
||
220 |
$high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' ); |
|
0 | 221 |
|
9 | 222 |
if ( in_array( $widget_id, $high_priority_widgets, true ) ) { |
0 | 223 |
$priority = 'high'; |
9 | 224 |
} |
0 | 225 |
|
18 | 226 |
if ( empty( $context ) ) { |
227 |
$context = 'normal'; |
|
228 |
} |
|
229 |
||
230 |
if ( empty( $priority ) ) { |
|
231 |
$priority = 'core'; |
|
232 |
} |
|
233 |
||
234 |
add_meta_box( $widget_id, $widget_name, $callback, $screen, $context, $priority, $callback_args ); |
|
0 | 235 |
} |
236 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
* Outputs controls for the current dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
* @param mixed $dashboard |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
* @param array $meta_box |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
*/ |
0 | 246 |
function _wp_dashboard_control_callback( $dashboard, $meta_box ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
247 |
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">'; |
0 | 248 |
wp_dashboard_trigger_widget_control( $meta_box['id'] ); |
249 |
wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); |
|
9 | 250 |
echo '<input type="hidden" name="widget_id" value="' . esc_attr( $meta_box['id'] ) . '" />'; |
19 | 251 |
submit_button( __( 'Save Changes' ) ); |
0 | 252 |
echo '</form>'; |
253 |
} |
|
254 |
||
255 |
/** |
|
256 |
* Displays the dashboard. |
|
257 |
* |
|
258 |
* @since 2.5.0 |
|
259 |
*/ |
|
260 |
function wp_dashboard() { |
|
9 | 261 |
$screen = get_current_screen(); |
262 |
$columns = absint( $screen->get_columns() ); |
|
5 | 263 |
$columns_css = ''; |
18 | 264 |
|
5 | 265 |
if ( $columns ) { |
266 |
$columns_css = " columns-$columns"; |
|
267 |
} |
|
9 | 268 |
?> |
5 | 269 |
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>"> |
270 |
<div id="postbox-container-1" class="postbox-container"> |
|
0 | 271 |
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?> |
272 |
</div> |
|
5 | 273 |
<div id="postbox-container-2" class="postbox-container"> |
0 | 274 |
<?php do_meta_boxes( $screen->id, 'side', '' ); ?> |
275 |
</div> |
|
5 | 276 |
<div id="postbox-container-3" class="postbox-container"> |
0 | 277 |
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?> |
278 |
</div> |
|
5 | 279 |
<div id="postbox-container-4" class="postbox-container"> |
0 | 280 |
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?> |
281 |
</div> |
|
282 |
</div> |
|
283 |
||
9 | 284 |
<?php |
0 | 285 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
286 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
287 |
} |
|
288 |
||
5 | 289 |
// |
16 | 290 |
// Dashboard Widgets. |
5 | 291 |
// |
0 | 292 |
|
5 | 293 |
/** |
294 |
* Dashboard widget that displays some basic stats about the site. |
|
295 |
* |
|
296 |
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8. |
|
297 |
* |
|
298 |
* @since 2.7.0 |
|
299 |
*/ |
|
300 |
function wp_dashboard_right_now() { |
|
9 | 301 |
?> |
5 | 302 |
<div class="main"> |
303 |
<ul> |
|
304 |
<?php |
|
16 | 305 |
// Posts and Pages. |
5 | 306 |
foreach ( array( 'post', 'page' ) as $post_type ) { |
307 |
$num_posts = wp_count_posts( $post_type ); |
|
18 | 308 |
|
5 | 309 |
if ( $num_posts && $num_posts->publish ) { |
16 | 310 |
if ( 'post' === $post_type ) { |
311 |
/* translators: %s: Number of posts. */ |
|
5 | 312 |
$text = _n( '%s Post', '%s Posts', $num_posts->publish ); |
313 |
} else { |
|
16 | 314 |
/* translators: %s: Number of pages. */ |
5 | 315 |
$text = _n( '%s Page', '%s Pages', $num_posts->publish ); |
316 |
} |
|
18 | 317 |
|
9 | 318 |
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
5 | 319 |
$post_type_object = get_post_type_object( $post_type ); |
18 | 320 |
|
5 | 321 |
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { |
322 |
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text ); |
|
323 |
} else { |
|
324 |
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text ); |
|
325 |
} |
|
326 |
} |
|
0 | 327 |
} |
18 | 328 |
|
16 | 329 |
// Comments. |
5 | 330 |
$num_comm = wp_count_comments(); |
18 | 331 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { |
16 | 333 |
/* translators: %s: Number of comments. */ |
5 | 334 |
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); |
335 |
?> |
|
18 | 336 |
<li class="comment-count"> |
337 |
<a href="edit-comments.php"><?php echo $text; ?></a> |
|
338 |
</li> |
|
5 | 339 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated ); |
16 | 341 |
/* translators: %s: Number of comments. */ |
9 | 342 |
$text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
?> |
18 | 344 |
<li class="comment-mod-count<?php echo ! $num_comm->moderated ? ' hidden' : ''; ?>"> |
345 |
<a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a> |
|
346 |
</li> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
<?php |
0 | 348 |
} |
349 |
||
5 | 350 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
* Filters the array of extra elements to list in the 'At a Glance' |
5 | 352 |
* dashboard widget. |
353 |
* |
|
354 |
* Prior to 3.8.0, the widget was named 'Right Now'. Each element |
|
355 |
* is wrapped in list-item tags on output. |
|
356 |
* |
|
357 |
* @since 3.8.0 |
|
358 |
* |
|
9 | 359 |
* @param string[] $items Array of extra 'At a Glance' widget items. |
5 | 360 |
*/ |
361 |
$elements = apply_filters( 'dashboard_glance_items', array() ); |
|
0 | 362 |
|
5 | 363 |
if ( $elements ) { |
364 |
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n"; |
|
365 |
} |
|
0 | 366 |
|
5 | 367 |
?> |
368 |
</ul> |
|
369 |
<?php |
|
370 |
update_right_now_message(); |
|
0 | 371 |
|
372 |
// Check if search engines are asked not to index this site. |
|
18 | 373 |
if ( ! is_network_admin() && ! is_user_admin() |
374 |
&& current_user_can( 'manage_options' ) && ! get_option( 'blog_public' ) |
|
375 |
) { |
|
5 | 376 |
|
377 |
/** |
|
16 | 378 |
* Filters the link title attribute for the 'Search engines discouraged' |
5 | 379 |
* message displayed in the 'At a Glance' dashboard widget. |
380 |
* |
|
381 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
382 |
* |
|
383 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
* @since 4.5.0 The default for `$title` was updated to an empty string. |
5 | 385 |
* |
386 |
* @param string $title Default attribute text. |
|
387 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
$title = apply_filters( 'privacy_on_link_title', '' ); |
5 | 389 |
|
390 |
/** |
|
16 | 391 |
* Filters the link label for the 'Search engines discouraged' message |
5 | 392 |
* displayed in the 'At a Glance' dashboard widget. |
393 |
* |
|
394 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
395 |
* |
|
396 |
* @since 3.0.0 |
|
397 |
* |
|
398 |
* @param string $content Default text. |
|
399 |
*/ |
|
18 | 400 |
$content = apply_filters( 'privacy_on_link_text', __( 'Search engines discouraged' ) ); |
401 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
$title_attr = '' === $title ? '' : " title='$title'"; |
0 | 403 |
|
16 | 404 |
echo "<p class='search-engines-info'><a href='options-reading.php'$title_attr>$content</a></p>"; |
0 | 405 |
} |
5 | 406 |
?> |
407 |
</div> |
|
408 |
<?php |
|
409 |
/* |
|
410 |
* activity_box_end has a core action, but only prints content when multisite. |
|
411 |
* Using an output buffer is the only way to really check if anything's displayed here. |
|
412 |
*/ |
|
413 |
ob_start(); |
|
0 | 414 |
|
5 | 415 |
/** |
416 |
* Fires at the end of the 'At a Glance' dashboard widget. |
|
417 |
* |
|
418 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
419 |
* |
|
420 |
* @since 2.5.0 |
|
421 |
*/ |
|
0 | 422 |
do_action( 'rightnow_end' ); |
5 | 423 |
|
424 |
/** |
|
425 |
* Fires at the end of the 'At a Glance' dashboard widget. |
|
426 |
* |
|
427 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
428 |
* |
|
429 |
* @since 2.0.0 |
|
430 |
*/ |
|
0 | 431 |
do_action( 'activity_box_end' ); |
5 | 432 |
|
433 |
$actions = ob_get_clean(); |
|
434 |
||
9 | 435 |
if ( ! empty( $actions ) ) : |
436 |
?> |
|
5 | 437 |
<div class="sub"> |
438 |
<?php echo $actions; ?> |
|
439 |
</div> |
|
9 | 440 |
<?php |
441 |
endif; |
|
0 | 442 |
} |
443 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
*/ |
0 | 447 |
function wp_network_dashboard_right_now() { |
448 |
$actions = array(); |
|
18 | 449 |
|
9 | 450 |
if ( current_user_can( 'create_sites' ) ) { |
451 |
$actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>'; |
|
452 |
} |
|
453 |
if ( current_user_can( 'create_users' ) ) { |
|
454 |
$actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>'; |
|
455 |
} |
|
0 | 456 |
|
457 |
$c_users = get_user_count(); |
|
458 |
$c_blogs = get_blog_count(); |
|
459 |
||
16 | 460 |
/* translators: %s: Number of users on the network. */ |
0 | 461 |
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); |
16 | 462 |
/* translators: %s: Number of sites on the network. */ |
0 | 463 |
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); |
464 |
||
16 | 465 |
/* translators: 1: Text indicating the number of sites on the network, 2: Text indicating the number of users on the network. */ |
0 | 466 |
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); |
467 |
||
468 |
if ( $actions ) { |
|
469 |
echo '<ul class="subsubsub">'; |
|
470 |
foreach ( $actions as $class => $action ) { |
|
9 | 471 |
$actions[ $class ] = "\t<li class='$class'>$action"; |
0 | 472 |
} |
473 |
echo implode( " |</li>\n", $actions ) . "</li>\n"; |
|
474 |
echo '</ul>'; |
|
475 |
} |
|
9 | 476 |
?> |
0 | 477 |
<br class="clear" /> |
478 |
||
479 |
<p class="youhave"><?php echo $sentence; ?></p> |
|
5 | 480 |
|
481 |
||
482 |
<?php |
|
483 |
/** |
|
484 |
* Fires in the Network Admin 'Right Now' dashboard widget |
|
485 |
* just before the user and site search form fields. |
|
486 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
* @since MU (3.0.0) |
5 | 488 |
*/ |
9 | 489 |
do_action( 'wpmuadminresult' ); |
5 | 490 |
?> |
0 | 491 |
|
18 | 492 |
<form action="<?php echo esc_url( network_admin_url( 'users.php' ) ); ?>" method="get"> |
0 | 493 |
<p> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
494 |
<label class="screen-reader-text" for="search-users"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
495 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
496 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
497 |
_e( 'Search Users' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
498 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
499 |
</label> |
18 | 500 |
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
501 |
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?> |
0 | 502 |
</p> |
503 |
</form> |
|
504 |
||
18 | 505 |
<form action="<?php echo esc_url( network_admin_url( 'sites.php' ) ); ?>" method="get"> |
0 | 506 |
<p> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
507 |
<label class="screen-reader-text" for="search-sites"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
508 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
509 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
510 |
_e( 'Search Sites' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
511 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
512 |
</label> |
18 | 513 |
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?> |
0 | 515 |
</p> |
516 |
</form> |
|
9 | 517 |
<?php |
5 | 518 |
/** |
519 |
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard. |
|
520 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
* @since MU (3.0.0) |
5 | 522 |
*/ |
0 | 523 |
do_action( 'mu_rightnow_end' ); |
5 | 524 |
|
525 |
/** |
|
526 |
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard. |
|
527 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
* @since MU (3.0.0) |
5 | 529 |
*/ |
0 | 530 |
do_action( 'mu_activity_box_end' ); |
531 |
} |
|
532 |
||
5 | 533 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
534 |
* Displays the Quick Draft widget. |
5 | 535 |
* |
536 |
* @since 3.8.0 |
|
537 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
* @global int $post_ID |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
* |
18 | 540 |
* @param string|false $error_msg Optional. Error message. Default false. |
5 | 541 |
*/ |
542 |
function wp_dashboard_quick_press( $error_msg = false ) { |
|
0 | 543 |
global $post_ID; |
544 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
if ( ! current_user_can( 'edit_posts' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
|
18 | 549 |
// Check if a new auto-draft (= no new post_ID) is needed or if the old can be used. |
16 | 550 |
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID. |
18 | 551 |
|
0 | 552 |
if ( $last_post_id ) { |
553 |
$post = get_post( $last_post_id ); |
|
18 | 554 |
|
16 | 555 |
if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore. |
5 | 556 |
$post = get_default_post_to_edit( 'post', true ); |
16 | 557 |
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. |
0 | 558 |
} else { |
16 | 559 |
$post->post_title = ''; // Remove the auto draft title. |
0 | 560 |
} |
561 |
} else { |
|
9 | 562 |
$post = get_default_post_to_edit( 'post', true ); |
0 | 563 |
$user_id = get_current_user_id(); |
18 | 564 |
|
0 | 565 |
// Don't create an option if this is a super admin who does not belong to this site. |
16 | 566 |
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) { |
567 |
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. |
|
9 | 568 |
} |
0 | 569 |
} |
570 |
||
571 |
$post_ID = (int) $post->ID; |
|
9 | 572 |
?> |
0 | 573 |
|
5 | 574 |
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js"> |
575 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
576 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
577 |
if ( $error_msg ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
578 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
579 |
$error_msg, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
580 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
581 |
'additional_classes' => array( 'error' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
582 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
583 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
584 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
585 |
?> |
5 | 586 |
|
0 | 587 |
<div class="input-text-wrap" id="title-wrap"> |
9 | 588 |
<label for="title"> |
5 | 589 |
<?php |
590 |
/** This filter is documented in wp-admin/edit-form-advanced.php */ |
|
591 |
echo apply_filters( 'enter_title_here', __( 'Title' ), $post ); |
|
592 |
?> |
|
593 |
</label> |
|
594 |
<input type="text" name="post_title" id="title" autocomplete="off" /> |
|
0 | 595 |
</div> |
596 |
||
5 | 597 |
<div class="textarea-wrap" id="description-wrap"> |
9 | 598 |
<label for="content"><?php _e( 'Content' ); ?></label> |
599 |
<textarea name="content" id="content" placeholder="<?php esc_attr_e( 'What’s on your mind?' ); ?>" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea> |
|
0 | 600 |
</div> |
601 |
||
602 |
<p class="submit"> |
|
5 | 603 |
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" /> |
0 | 604 |
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" /> |
605 |
<input type="hidden" name="post_type" value="post" /> |
|
5 | 606 |
<?php wp_nonce_field( 'add-post' ); ?> |
607 |
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?> |
|
0 | 608 |
<br class="clear" /> |
609 |
</p> |
|
610 |
||
611 |
</form> |
|
5 | 612 |
<?php |
613 |
wp_dashboard_recent_drafts(); |
|
0 | 614 |
} |
615 |
||
616 |
/** |
|
5 | 617 |
* Show recent drafts of the user on the dashboard. |
0 | 618 |
* |
5 | 619 |
* @since 2.7.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
* |
18 | 621 |
* @param WP_Post[]|false $drafts Optional. Array of posts to display. Default false. |
0 | 622 |
*/ |
5 | 623 |
function wp_dashboard_recent_drafts( $drafts = false ) { |
624 |
if ( ! $drafts ) { |
|
625 |
$query_args = array( |
|
626 |
'post_type' => 'post', |
|
627 |
'post_status' => 'draft', |
|
628 |
'author' => get_current_user_id(), |
|
629 |
'posts_per_page' => 4, |
|
630 |
'orderby' => 'modified', |
|
9 | 631 |
'order' => 'DESC', |
5 | 632 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
* Filters the post query arguments for the 'Recent Drafts' dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
|
5 | 643 |
$drafts = get_posts( $query_args ); |
644 |
if ( ! $drafts ) { |
|
645 |
return; |
|
9 | 646 |
} |
647 |
} |
|
0 | 648 |
|
5 | 649 |
echo '<div class="drafts">'; |
18 | 650 |
|
5 | 651 |
if ( count( $drafts ) > 3 ) { |
16 | 652 |
printf( |
653 |
'<p class="view-all"><a href="%s">%s</a></p>' . "\n", |
|
654 |
esc_url( admin_url( 'edit.php?post_status=draft' ) ), |
|
655 |
__( 'View all drafts' ) |
|
656 |
); |
|
9 | 657 |
} |
18 | 658 |
|
659 |
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n"; |
|
660 |
echo '<ul>'; |
|
0 | 661 |
|
16 | 662 |
/* translators: Maximum number of words used in a preview of a draft on the dashboard. */ |
18 | 663 |
$draft_length = (int) _x( '10', 'draft_length' ); |
16 | 664 |
|
5 | 665 |
$drafts = array_slice( $drafts, 0, 3 ); |
666 |
foreach ( $drafts as $draft ) { |
|
9 | 667 |
$url = get_edit_post_link( $draft->ID ); |
5 | 668 |
$title = _draft_or_post_title( $draft->ID ); |
18 | 669 |
|
5 | 670 |
echo "<li>\n"; |
16 | 671 |
printf( |
672 |
'<div class="draft-title"><a href="%s" aria-label="%s">%s</a><time datetime="%s">%s</time></div>', |
|
673 |
esc_url( $url ), |
|
674 |
/* translators: %s: Post title. */ |
|
675 |
esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), |
|
676 |
esc_html( $title ), |
|
677 |
get_the_time( 'c', $draft ), |
|
678 |
get_the_time( __( 'F j, Y' ), $draft ) |
|
679 |
); |
|
18 | 680 |
|
16 | 681 |
$the_content = wp_trim_words( $draft->post_content, $draft_length ); |
18 | 682 |
|
16 | 683 |
if ( $the_content ) { |
5 | 684 |
echo '<p>' . $the_content . '</p>'; |
9 | 685 |
} |
5 | 686 |
echo "</li>\n"; |
9 | 687 |
} |
18 | 688 |
|
689 |
echo "</ul>\n"; |
|
690 |
echo '</div>'; |
|
0 | 691 |
} |
692 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
* Outputs a row for the Recent Comments widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
* |
16 | 699 |
* @global WP_Comment $comment Global comment object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
* @param WP_Comment $comment The current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
* @param bool $show_date Optional. Whether to display the date. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
*/ |
0 | 704 |
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
$GLOBALS['comment'] = clone $comment; |
0 | 706 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
if ( $comment->comment_post_ID > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); |
9 | 709 |
$comment_post_url = get_the_permalink( $comment->comment_post_ID ); |
19 | 710 |
$comment_post_link = '<a href="' . esc_url( $comment_post_url ) . '">' . $comment_post_title . '</a>'; |
5 | 711 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
$comment_post_link = ''; |
5 | 713 |
} |
714 |
||
0 | 715 |
$actions_string = ''; |
716 |
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
5 | 717 |
// Pre-order it: Approve | Reply | Edit | Spam | Trash. |
0 | 718 |
$actions = array( |
9 | 719 |
'approve' => '', |
720 |
'unapprove' => '', |
|
721 |
'reply' => '', |
|
722 |
'edit' => '', |
|
723 |
'spam' => '', |
|
724 |
'trash' => '', |
|
725 |
'delete' => '', |
|
726 |
'view' => '', |
|
0 | 727 |
); |
728 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
729 |
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'approve-comment_' . $comment->comment_ID ) ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
730 |
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
731 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
732 |
$action_string = 'comment.php?action=%s&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . '&%s'; |
0 | 733 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
734 |
$approve_url = sprintf( $action_string, 'approvecomment', $approve_nonce ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
735 |
$unapprove_url = sprintf( $action_string, 'unapprovecomment', $approve_nonce ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
736 |
$spam_url = sprintf( $action_string, 'spamcomment', $del_nonce ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
737 |
$trash_url = sprintf( $action_string, 'trashcomment', $del_nonce ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
738 |
$delete_url = sprintf( $action_string, 'deletecomment', $del_nonce ); |
0 | 739 |
|
16 | 740 |
$actions['approve'] = sprintf( |
741 |
'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>', |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
742 |
esc_url( $approve_url ), |
16 | 743 |
"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved", |
744 |
esc_attr__( 'Approve this comment' ), |
|
745 |
__( 'Approve' ) |
|
746 |
); |
|
747 |
||
748 |
$actions['unapprove'] = sprintf( |
|
749 |
'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>', |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
750 |
esc_url( $unapprove_url ), |
16 | 751 |
"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved", |
752 |
esc_attr__( 'Unapprove this comment' ), |
|
753 |
__( 'Unapprove' ) |
|
754 |
); |
|
755 |
||
756 |
$actions['edit'] = sprintf( |
|
757 |
'<a href="%s" aria-label="%s">%s</a>', |
|
758 |
"comment.php?action=editcomment&c={$comment->comment_ID}", |
|
759 |
esc_attr__( 'Edit this comment' ), |
|
760 |
__( 'Edit' ) |
|
761 |
); |
|
762 |
||
763 |
$actions['reply'] = sprintf( |
|
764 |
'<button type="button" onclick="window.commentReply && commentReply.open(\'%s\',\'%s\');" class="vim-r button-link hide-if-no-js" aria-label="%s">%s</button>', |
|
765 |
$comment->comment_ID, |
|
766 |
$comment->comment_post_ID, |
|
767 |
esc_attr__( 'Reply to this comment' ), |
|
768 |
__( 'Reply' ) |
|
769 |
); |
|
770 |
||
771 |
$actions['spam'] = sprintf( |
|
772 |
'<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>', |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
773 |
esc_url( $spam_url ), |
16 | 774 |
"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1", |
775 |
esc_attr__( 'Mark this comment as spam' ), |
|
776 |
/* translators: "Mark as spam" link. */ |
|
777 |
_x( 'Spam', 'verb' ) |
|
778 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
if ( ! EMPTY_TRASH_DAYS ) { |
16 | 781 |
$actions['delete'] = sprintf( |
782 |
'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
783 |
esc_url( $delete_url ), |
16 | 784 |
"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", |
785 |
esc_attr__( 'Delete this comment permanently' ), |
|
786 |
__( 'Delete Permanently' ) |
|
787 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
} else { |
16 | 789 |
$actions['trash'] = sprintf( |
790 |
'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
791 |
esc_url( $trash_url ), |
16 | 792 |
"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", |
793 |
esc_attr__( 'Move this comment to the Trash' ), |
|
794 |
_x( 'Trash', 'verb' ) |
|
795 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
|
16 | 798 |
$actions['view'] = sprintf( |
799 |
'<a class="comment-link" href="%s" aria-label="%s">%s</a>', |
|
800 |
esc_url( get_comment_link( $comment ) ), |
|
801 |
esc_attr__( 'View this comment' ), |
|
802 |
__( 'View' ) |
|
803 |
); |
|
0 | 804 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
805 |
/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */ |
9 | 806 |
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); |
0 | 807 |
|
808 |
$i = 0; |
|
16 | 809 |
|
0 | 810 |
foreach ( $actions as $action => $link ) { |
811 |
++$i; |
|
812 |
||
16 | 813 |
if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) |
814 |
|| 1 === $i |
|
815 |
) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
816 |
$separator = ''; |
16 | 817 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
818 |
$separator = ' | '; |
16 | 819 |
} |
820 |
||
821 |
// Reply and quickedit need a hide-if-no-js span. |
|
822 |
if ( 'reply' === $action || 'quickedit' === $action ) { |
|
0 | 823 |
$action .= ' hide-if-no-js'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
824 |
} |
0 | 825 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
826 |
if ( 'view' === $action && '1' !== $comment->comment_approved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
827 |
$action .= ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
828 |
} |
16 | 829 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
830 |
$actions_string .= "<span class='$action'>{$separator}{$link}</span>"; |
0 | 831 |
} |
832 |
} |
|
9 | 833 |
?> |
0 | 834 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>> |
0 | 836 |
|
16 | 837 |
<?php |
838 |
$comment_row_class = ''; |
|
0 | 839 |
|
16 | 840 |
if ( get_option( 'show_avatars' ) ) { |
841 |
echo get_avatar( $comment, 50, 'mystery' ); |
|
842 |
$comment_row_class .= ' has-avatar'; |
|
843 |
} |
|
844 |
?> |
|
5 | 845 |
|
16 | 846 |
<?php if ( ! $comment->comment_type || 'comment' === $comment->comment_type ) : ?> |
847 |
||
848 |
<div class="dashboard-comment-wrap has-row-actions <?php echo $comment_row_class; ?>"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
<p class="comment-meta"> |
9 | 850 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
// Comments might not have a post they relate to, e.g. programmatically created ones. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
852 |
if ( $comment_post_link ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
printf( |
16 | 854 |
/* translators: 1: Comment author, 2: Post link, 3: Notification if the comment is pending. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
__( 'From %1$s on %2$s %3$s' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
856 |
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
857 |
$comment_post_link, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
858 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
printf( |
16 | 862 |
/* translators: 1: Comment author, 2: Notification if the comment is pending. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
__( 'From %1$s %2$s' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
866 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
867 |
} |
9 | 868 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
869 |
</p> |
0 | 870 |
|
9 | 871 |
<?php |
0 | 872 |
else : |
5 | 873 |
switch ( $comment->comment_type ) { |
9 | 874 |
case 'pingback': |
5 | 875 |
$type = __( 'Pingback' ); |
876 |
break; |
|
9 | 877 |
case 'trackback': |
5 | 878 |
$type = __( 'Trackback' ); |
879 |
break; |
|
9 | 880 |
default: |
5 | 881 |
$type = ucwords( $comment->comment_type ); |
882 |
} |
|
0 | 883 |
$type = esc_html( $type ); |
9 | 884 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
885 |
<div class="dashboard-comment-wrap has-row-actions"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
886 |
<p class="comment-meta"> |
9 | 887 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
889 |
if ( $comment_post_link ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
printf( |
16 | 891 |
/* translators: 1: Type of comment, 2: Post link, 3: Notification if the comment is pending. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
892 |
_x( '%1$s on %2$s %3$s', 'dashboard' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
"<strong>$type</strong>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
894 |
$comment_post_link, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
895 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
896 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
897 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
printf( |
16 | 899 |
/* translators: 1: Type of comment, 2: Notification if the comment is pending. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
_x( '%1$s %2$s', 'dashboard' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
"<strong>$type</strong>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
} |
9 | 905 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
<p class="comment-author"><?php comment_author_link( $comment ); ?></p> |
0 | 908 |
|
909 |
<?php endif; // comment_type ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
910 |
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
<?php if ( $actions_string ) : ?> |
0 | 912 |
<p class="row-actions"><?php echo $actions_string; ?></p> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
<?php endif; ?> |
0 | 914 |
</div> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
</li> |
9 | 916 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
$GLOBALS['comment'] = null; |
0 | 918 |
} |
919 |
||
920 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
921 |
* Outputs the Activity widget. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
922 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
923 |
* Callback function for {@see 'dashboard_activity'}. |
0 | 924 |
* |
5 | 925 |
* @since 3.8.0 |
0 | 926 |
*/ |
5 | 927 |
function wp_dashboard_site_activity() { |
928 |
||
929 |
echo '<div id="activity-widget">'; |
|
0 | 930 |
|
9 | 931 |
$future_posts = wp_dashboard_recent_posts( |
932 |
array( |
|
933 |
'max' => 5, |
|
934 |
'status' => 'future', |
|
935 |
'order' => 'ASC', |
|
936 |
'title' => __( 'Publishing Soon' ), |
|
937 |
'id' => 'future-posts', |
|
938 |
) |
|
939 |
); |
|
940 |
$recent_posts = wp_dashboard_recent_posts( |
|
941 |
array( |
|
942 |
'max' => 5, |
|
943 |
'status' => 'publish', |
|
944 |
'order' => 'DESC', |
|
945 |
'title' => __( 'Recently Published' ), |
|
946 |
'id' => 'published-posts', |
|
947 |
) |
|
948 |
); |
|
0 | 949 |
|
5 | 950 |
$recent_comments = wp_dashboard_recent_comments(); |
951 |
||
9 | 952 |
if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) { |
5 | 953 |
echo '<div class="no-activity">'; |
954 |
echo '<p>' . __( 'No activity yet!' ) . '</p>'; |
|
955 |
echo '</div>'; |
|
0 | 956 |
} |
957 |
||
5 | 958 |
echo '</div>'; |
0 | 959 |
} |
960 |
||
961 |
/** |
|
5 | 962 |
* Generates Publishing Soon and Recently Published sections. |
963 |
* |
|
964 |
* @since 3.8.0 |
|
965 |
* |
|
966 |
* @param array $args { |
|
967 |
* An array of query and display arguments. |
|
0 | 968 |
* |
5 | 969 |
* @type int $max Number of posts to display. |
970 |
* @type string $status Post status. |
|
971 |
* @type string $order Designates ascending ('ASC') or descending ('DESC') order. |
|
972 |
* @type string $title Section title. |
|
973 |
* @type string $id The container id. |
|
974 |
* } |
|
975 |
* @return bool False if no posts were found. True otherwise. |
|
0 | 976 |
*/ |
5 | 977 |
function wp_dashboard_recent_posts( $args ) { |
978 |
$query_args = array( |
|
979 |
'post_type' => 'post', |
|
980 |
'post_status' => $args['status'], |
|
981 |
'orderby' => 'date', |
|
982 |
'order' => $args['order'], |
|
18 | 983 |
'posts_per_page' => (int) $args['max'], |
5 | 984 |
'no_found_rows' => true, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
985 |
'cache_results' => true, |
5 | 986 |
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', |
987 |
); |
|
988 |
||
989 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
* Filters the query arguments used for the Recent Posts widget. |
5 | 991 |
* |
992 |
* @since 4.2.0 |
|
993 |
* |
|
994 |
* @param array $query_args The arguments passed to WP_Query to produce the list of posts. |
|
995 |
*/ |
|
996 |
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args ); |
|
18 | 997 |
|
998 |
$posts = new WP_Query( $query_args ); |
|
0 | 999 |
|
5 | 1000 |
if ( $posts->have_posts() ) { |
1001 |
||
1002 |
echo '<div id="' . $args['id'] . '" class="activity-block">'; |
|
1003 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
echo '<h3>' . $args['title'] . '</h3>'; |
5 | 1005 |
|
1006 |
echo '<ul>'; |
|
1007 |
||
9 | 1008 |
$today = current_time( 'Y-m-d' ); |
16 | 1009 |
$tomorrow = current_datetime()->modify( '+1 day' )->format( 'Y-m-d' ); |
9 | 1010 |
$year = current_time( 'Y' ); |
5 | 1011 |
|
1012 |
while ( $posts->have_posts() ) { |
|
1013 |
$posts->the_post(); |
|
1014 |
||
1015 |
$time = get_the_time( 'U' ); |
|
18 | 1016 |
|
1017 |
if ( gmdate( 'Y-m-d', $time ) === $today ) { |
|
5 | 1018 |
$relative = __( 'Today' ); |
18 | 1019 |
} elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { |
5 | 1020 |
$relative = __( 'Tomorrow' ); |
16 | 1021 |
} elseif ( gmdate( 'Y', $time ) !== $year ) { |
18 | 1022 |
/* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1023 |
$relative = date_i18n( __( 'M jS Y' ), $time ); |
5 | 1024 |
} else { |
18 | 1025 |
/* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */ |
5 | 1026 |
$relative = date_i18n( __( 'M jS' ), $time ); |
1027 |
} |
|
1028 |
||
1029 |
// Use the post edit link for those who can edit, the permalink otherwise. |
|
1030 |
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); |
|
1031 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1032 |
$draft_or_post_title = _draft_or_post_title(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>', |
16 | 1035 |
/* translators: 1: Relative date, 2: Time. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
$recent_post_link, |
16 | 1038 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
$draft_or_post_title |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
); |
0 | 1042 |
} |
1043 |
||
5 | 1044 |
echo '</ul>'; |
1045 |
echo '</div>'; |
|
1046 |
||
1047 |
} else { |
|
1048 |
return false; |
|
0 | 1049 |
} |
1050 |
||
5 | 1051 |
wp_reset_postdata(); |
0 | 1052 |
|
5 | 1053 |
return true; |
0 | 1054 |
} |
1055 |
||
1056 |
/** |
|
5 | 1057 |
* Show Comments section. |
1058 |
* |
|
1059 |
* @since 3.8.0 |
|
1060 |
* |
|
1061 |
* @param int $total_items Optional. Number of comments to query. Default 5. |
|
1062 |
* @return bool False if no comments were found. True otherwise. |
|
1063 |
*/ |
|
1064 |
function wp_dashboard_recent_comments( $total_items = 5 ) { |
|
1065 |
// Select all comment types and filter out spam later for better query performance. |
|
1066 |
$comments = array(); |
|
1067 |
||
1068 |
$comments_query = array( |
|
1069 |
'number' => $total_items * 5, |
|
9 | 1070 |
'offset' => 0, |
5 | 1071 |
); |
18 | 1072 |
|
9 | 1073 |
if ( ! current_user_can( 'edit_posts' ) ) { |
5 | 1074 |
$comments_query['status'] = 'approve'; |
9 | 1075 |
} |
5 | 1076 |
|
1077 |
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
if ( ! is_array( $possible ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1080 |
} |
18 | 1081 |
|
5 | 1082 |
foreach ( $possible as $comment ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1083 |
if ( ! current_user_can( 'edit_post', $comment->comment_post_ID ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1084 |
&& ( post_password_required( $comment->comment_post_ID ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1085 |
|| ! current_user_can( 'read_post', $comment->comment_post_ID ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1086 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1087 |
// The user has no access to the post and thus cannot see the comments. |
5 | 1088 |
continue; |
9 | 1089 |
} |
18 | 1090 |
|
5 | 1091 |
$comments[] = $comment; |
18 | 1092 |
|
1093 |
if ( count( $comments ) === $total_items ) { |
|
5 | 1094 |
break 2; |
9 | 1095 |
} |
5 | 1096 |
} |
18 | 1097 |
|
5 | 1098 |
$comments_query['offset'] += $comments_query['number']; |
9 | 1099 |
$comments_query['number'] = $total_items * 10; |
5 | 1100 |
} |
1101 |
||
1102 |
if ( $comments ) { |
|
18 | 1103 |
echo '<div id="latest-comments" class="activity-block table-view-list">'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
echo '<h3>' . __( 'Recent Comments' ) . '</h3>'; |
5 | 1105 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
echo '<ul id="the-comment-list" data-wp-lists="list:comment">'; |
9 | 1107 |
foreach ( $comments as $comment ) { |
5 | 1108 |
_wp_dashboard_recent_comments_row( $comment ); |
9 | 1109 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
echo '</ul>'; |
5 | 1111 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
if ( current_user_can( 'edit_posts' ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1113 |
echo '<h3 class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1114 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1115 |
__( 'View more comments' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1116 |
'</h3>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
_get_list_table( 'WP_Comments_List_Table' )->views(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1118 |
} |
5 | 1119 |
|
1120 |
wp_comment_reply( -1, false, 'dashboard', false ); |
|
1121 |
wp_comment_trashnotice(); |
|
1122 |
||
1123 |
echo '</div>'; |
|
1124 |
} else { |
|
1125 |
return false; |
|
1126 |
} |
|
1127 |
return true; |
|
1128 |
} |
|
1129 |
||
1130 |
/** |
|
1131 |
* Display generic dashboard RSS widget feed. |
|
0 | 1132 |
* |
1133 |
* @since 2.5.0 |
|
1134 |
* |
|
1135 |
* @param string $widget_id |
|
1136 |
*/ |
|
1137 |
function wp_dashboard_rss_output( $widget_id ) { |
|
1138 |
$widgets = get_option( 'dashboard_widget_options' ); |
|
1139 |
echo '<div class="rss-widget">'; |
|
5 | 1140 |
wp_widget_rss_output( $widgets[ $widget_id ] ); |
9 | 1141 |
echo '</div>'; |
0 | 1142 |
} |
1143 |
||
1144 |
/** |
|
1145 |
* Checks to see if all of the feed url in $check_urls are cached. |
|
1146 |
* |
|
1147 |
* If $check_urls is empty, look for the rss feed url found in the dashboard |
|
1148 |
* widget options of $widget_id. If cached, call $callback, a function that |
|
1149 |
* echoes out output for this widget. If not cache, echo a "Loading..." stub |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
* which is later replaced by Ajax call (see top of /wp-admin/index.php) |
0 | 1151 |
* |
1152 |
* @since 2.5.0 |
|
16 | 1153 |
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter |
1154 |
* by adding it to the function signature. |
|
0 | 1155 |
* |
16 | 1156 |
* @param string $widget_id The widget ID. |
1157 |
* @param callable $callback The callback function used to display each feed. |
|
1158 |
* @param array $check_urls RSS feeds. |
|
1159 |
* @param mixed ...$args Optional additional parameters to pass to the callback function. |
|
1160 |
* @return bool True on success, false on failure. |
|
0 | 1161 |
*/ |
16 | 1162 |
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
$doing_ajax = wp_doing_ajax(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1164 |
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1165 |
$loading .= wp_get_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1166 |
__( 'This widget requires JavaScript.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1167 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1168 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1169 |
'additional_classes' => array( 'inline', 'hide-if-js' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1170 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1171 |
); |
0 | 1172 |
|
9 | 1173 |
if ( empty( $check_urls ) ) { |
0 | 1174 |
$widgets = get_option( 'dashboard_widget_options' ); |
18 | 1175 |
|
9 | 1176 |
if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) { |
0 | 1177 |
echo $loading; |
1178 |
return false; |
|
1179 |
} |
|
18 | 1180 |
|
9 | 1181 |
$check_urls = array( $widgets[ $widget_id ]['url'] ); |
0 | 1182 |
} |
1183 |
||
9 | 1184 |
$locale = get_user_locale(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1185 |
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); |
16 | 1186 |
$output = get_transient( $cache_key ); |
18 | 1187 |
|
16 | 1188 |
if ( false !== $output ) { |
0 | 1189 |
echo $output; |
1190 |
return true; |
|
1191 |
} |
|
1192 |
||
1193 |
if ( ! $doing_ajax ) { |
|
1194 |
echo $loading; |
|
1195 |
return false; |
|
1196 |
} |
|
1197 |
||
1198 |
if ( $callback && is_callable( $callback ) ) { |
|
5 | 1199 |
array_unshift( $args, $widget_id, $check_urls ); |
0 | 1200 |
ob_start(); |
1201 |
call_user_func_array( $callback, $args ); |
|
16 | 1202 |
// Default lifetime in cache of 12 hours (same as the feeds). |
1203 |
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); |
|
0 | 1204 |
} |
1205 |
||
1206 |
return true; |
|
1207 |
} |
|
1208 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
// |
16 | 1210 |
// Dashboard Widgets Controls. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
// |
0 | 1212 |
|
1213 |
/** |
|
1214 |
* Calls widget control callback. |
|
1215 |
* |
|
1216 |
* @since 2.5.0 |
|
1217 |
* |
|
18 | 1218 |
* @global callable[] $wp_dashboard_control_callbacks |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
* |
18 | 1220 |
* @param int|false $widget_control_id Optional. Registered widget ID. Default false. |
0 | 1221 |
*/ |
1222 |
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { |
|
1223 |
global $wp_dashboard_control_callbacks; |
|
1224 |
||
18 | 1225 |
if ( is_scalar( $widget_control_id ) && $widget_control_id |
1226 |
&& isset( $wp_dashboard_control_callbacks[ $widget_control_id ] ) |
|
1227 |
&& is_callable( $wp_dashboard_control_callbacks[ $widget_control_id ] ) |
|
1228 |
) { |
|
9 | 1229 |
call_user_func( |
1230 |
$wp_dashboard_control_callbacks[ $widget_control_id ], |
|
1231 |
'', |
|
1232 |
array( |
|
1233 |
'id' => $widget_control_id, |
|
1234 |
'callback' => $wp_dashboard_control_callbacks[ $widget_control_id ], |
|
1235 |
) |
|
1236 |
); |
|
0 | 1237 |
} |
1238 |
} |
|
1239 |
||
1240 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1241 |
* Sets up the RSS dashboard widget control and $args to be used as input to wp_widget_rss_form(). |
0 | 1242 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1243 |
* Handles POST data from RSS-type widgets. |
0 | 1244 |
* |
1245 |
* @since 2.5.0 |
|
1246 |
* |
|
1247 |
* @param string $widget_id |
|
16 | 1248 |
* @param array $form_inputs |
0 | 1249 |
*/ |
1250 |
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
|
16 | 1251 |
$widget_options = get_option( 'dashboard_widget_options' ); |
18 | 1252 |
|
16 | 1253 |
if ( ! $widget_options ) { |
0 | 1254 |
$widget_options = array(); |
9 | 1255 |
} |
0 | 1256 |
|
9 | 1257 |
if ( ! isset( $widget_options[ $widget_id ] ) ) { |
1258 |
$widget_options[ $widget_id ] = array(); |
|
1259 |
} |
|
0 | 1260 |
|
16 | 1261 |
$number = 1; // Hack to use wp_widget_rss_form(). |
1262 |
||
9 | 1263 |
$widget_options[ $widget_id ]['number'] = $number; |
0 | 1264 |
|
16 | 1265 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) { |
9 | 1266 |
$_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] ); |
1267 |
$widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] ); |
|
1268 |
$widget_options[ $widget_id ]['number'] = $number; |
|
5 | 1269 |
|
1270 |
// Title is optional. If black, fill it if possible. |
|
9 | 1271 |
if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) { |
1272 |
$rss = fetch_feed( $widget_options[ $widget_id ]['url'] ); |
|
1273 |
if ( is_wp_error( $rss ) ) { |
|
1274 |
$widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) ); |
|
0 | 1275 |
} else { |
9 | 1276 |
$widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) ); |
0 | 1277 |
$rss->__destruct(); |
9 | 1278 |
unset( $rss ); |
0 | 1279 |
} |
1280 |
} |
|
18 | 1281 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1282 |
update_option( 'dashboard_widget_options', $widget_options, false ); |
18 | 1283 |
|
9 | 1284 |
$locale = get_user_locale(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); |
0 | 1286 |
delete_transient( $cache_key ); |
1287 |
} |
|
1288 |
||
9 | 1289 |
wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs ); |
0 | 1290 |
} |
1291 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1292 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
* Renders the Events and News dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1296 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1297 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
function wp_dashboard_events_news() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
wp_print_community_events_markup(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
<div class="wordpress-news hide-if-no-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
<?php wp_dashboard_primary(); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
<p class="community-events-footer"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1308 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1310 |
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
'https://make.wordpress.org/community/meetups-landing-page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
__( 'Meetups' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1313 |
/* translators: Hidden accessibility text. */ |
9 | 1314 |
__( '(opens in a new tab)' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
| |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1319 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1322 |
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
'https://central.wordcamp.org/schedule/', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
__( 'WordCamps' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1325 |
/* translators: Hidden accessibility text. */ |
9 | 1326 |
__( '(opens in a new tab)' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
| |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1331 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1332 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1334 |
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
__( 'News' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1338 |
/* translators: Hidden accessibility text. */ |
9 | 1339 |
__( '(opens in a new tab)' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1341 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1343 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
* Prints the markup for the Community Events section of the Events and News Dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
function wp_print_community_events_markup() { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1353 |
$community_events_notice = '<p class="hide-if-js">' . ( 'This widget requires JavaScript.' ) . '</p>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1354 |
$community_events_notice .= '<p class="community-events-error-occurred" aria-hidden="true">' . __( 'An error occurred. Please try again.' ) . '</p>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1355 |
$community_events_notice .= '<p class="community-events-could-not-locate" aria-hidden="true"></p>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1357 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1358 |
$community_events_notice, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1359 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1360 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1361 |
'additional_classes' => array( 'community-events-errors', 'inline', 'hide-if-js' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1362 |
'paragraph_wrap' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1363 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1364 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1366 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1367 |
* Hide the main element when the page first loads, because the content |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
* won't be ready until wp.communityEvents.renderEventsTemplate() has run. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
<div id="community-events" class="community-events" aria-hidden="true"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
<div class="activity-block"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
<span id="community-events-location-message"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1375 |
|
19 | 1376 |
<button class="button-link community-events-toggle-location" aria-expanded="false"> |
1377 |
<span class="dashicons dashicons-location" aria-hidden="true"></span> |
|
1378 |
<span class="community-events-location-edit"><?php _e( 'Select location' ); ?></span> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1379 |
</button> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1381 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1382 |
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
<label for="community-events-location"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
<?php _e( 'City:' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
</label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
/* translators: Replace with a city related to your locale. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
* Test that it matches the expected location and has upcoming |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1389 |
* events before including it. If no cities related to your |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
* locale have events, then use a city related to your locale |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* that would be recognizable to most users. Use only the city |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* name itself, without any region or country. Use the endonym |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
* (native locale name) instead of the English name if possible. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
<button class="community-events-cancel button-link" type="button" aria-expanded="false"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
<?php _e( 'Cancel' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
</button> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1404 |
<span class="spinner"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1407 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1408 |
<ul class="community-events-results activity-block last"></ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1410 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
* Renders the events templates for the Event and News widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1417 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1418 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
function wp_print_community_events_templates() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1420 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1421 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1422 |
<script id="tmpl-community-events-attend-event-near" type="text/template"> |
9 | 1423 |
<?php |
1424 |
printf( |
|
16 | 1425 |
/* translators: %s: The name of a city. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
__( 'Attend an upcoming event near %s.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
'<strong>{{ data.location.description }}</strong>' |
9 | 1428 |
); |
1429 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
<script id="tmpl-community-events-could-not-locate" type="text/template"> |
9 | 1433 |
<?php |
1434 |
printf( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1435 |
/* translators: %s is the name of the city we couldn't locate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1436 |
* Replace the examples with cities in your locale, but test |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1437 |
* that they match the expected location before including them. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
* Use endonyms (native locale names) whenever possible. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
*/ |
19 | 1440 |
__( '%s could not be located. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
'<em>{{data.unknownCity}}</em>' |
9 | 1442 |
); |
1443 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
<script id="tmpl-community-events-event-list" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
<# _.each( data.events, function( event ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
<li class="event event-{{ event.type }} wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
<div class="event-info"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
<div class="dashicons event-icon" aria-hidden="true"></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
<div class="event-info-inner"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1453 |
<# if ( event.type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1454 |
const titleCaseEventType = event.type.replace( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1455 |
/\w\S*/g, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1456 |
function ( type ) { return type.charAt(0).toUpperCase() + type.substr(1).toLowerCase(); } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1457 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1458 |
#> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1459 |
{{ 'wordcamp' === event.type ? 'WordCamp' : titleCaseEventType }} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1460 |
<span class="ce-separator"></span> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1461 |
<# } #> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
<span class="event-city">{{ event.location.location }}</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
<div class="event-date-time"> |
18 | 1467 |
<span class="event-date">{{ event.user_formatted_date }}</span> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
<# if ( 'meetup' === event.type ) { #> |
18 | 1469 |
<span class="event-time"> |
1470 |
{{ event.user_formatted_time }} {{ event.timeZoneAbbreviation }} |
|
1471 |
</span> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
<# } ) #> |
18 | 1476 |
|
1477 |
<# if ( data.events.length <= 2 ) { #> |
|
1478 |
<li class="event-none"> |
|
1479 |
<?php |
|
1480 |
printf( |
|
1481 |
/* translators: %s: Localized meetup organization documentation URL. */ |
|
1482 |
__( 'Want more events? <a href="%s">Help organize the next one</a>!' ), |
|
1483 |
__( 'https://make.wordpress.org/community/organize-event-landing-page/' ) |
|
1484 |
); |
|
1485 |
?> |
|
1486 |
</li> |
|
1487 |
<# } #> |
|
1488 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1489 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1490 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1491 |
<script id="tmpl-community-events-no-upcoming-events" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1492 |
<li class="event-none"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1493 |
<# if ( data.location.description ) { #> |
9 | 1494 |
<?php |
1495 |
printf( |
|
16 | 1496 |
/* translators: 1: The city the user searched for, 2: Meetup organization documentation URL. */ |
19 | 1497 |
__( 'There are no events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize a WordPress event</a>?' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1498 |
'{{ data.location.description }}', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1499 |
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
9 | 1500 |
); |
1501 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
<# } else { #> |
9 | 1504 |
<?php |
1505 |
printf( |
|
16 | 1506 |
/* translators: %s: Meetup organization documentation URL. */ |
19 | 1507 |
__( 'There are no events scheduled near you at the moment. Would you like to <a href="%s">organize a WordPress event</a>?' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1508 |
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
9 | 1509 |
); |
1510 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1512 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1515 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
|
0 | 1517 |
/** |
9 | 1518 |
* 'WordPress Events and News' dashboard widget. |
5 | 1519 |
* |
1520 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1521 |
* @since 4.8.0 Removed popular plugins feed. |
5 | 1522 |
*/ |
1523 |
function wp_dashboard_primary() { |
|
1524 |
$feeds = array( |
|
9 | 1525 |
'news' => array( |
5 | 1526 |
|
1527 |
/** |
|
9 | 1528 |
* Filters the primary link URL for the 'WordPress Events and News' dashboard widget. |
5 | 1529 |
* |
1530 |
* @since 2.5.0 |
|
1531 |
* |
|
1532 |
* @param string $link The widget's primary link URL. |
|
1533 |
*/ |
|
9 | 1534 |
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ), |
5 | 1535 |
|
1536 |
/** |
|
9 | 1537 |
* Filters the primary feed URL for the 'WordPress Events and News' dashboard widget. |
5 | 1538 |
* |
1539 |
* @since 2.3.0 |
|
1540 |
* |
|
1541 |
* @param string $url The widget's primary feed URL. |
|
1542 |
*/ |
|
9 | 1543 |
'url' => apply_filters( 'dashboard_primary_feed', __( 'https://wordpress.org/news/feed/' ) ), |
5 | 1544 |
|
1545 |
/** |
|
9 | 1546 |
* Filters the primary link title for the 'WordPress Events and News' dashboard widget. |
5 | 1547 |
* |
1548 |
* @since 2.3.0 |
|
1549 |
* |
|
1550 |
* @param string $title Title attribute for the widget's primary link. |
|
1551 |
*/ |
|
1552 |
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), |
|
18 | 1553 |
'items' => 2, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1554 |
'show_summary' => 0, |
5 | 1555 |
'show_author' => 0, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1556 |
'show_date' => 0, |
5 | 1557 |
), |
1558 |
'planet' => array( |
|
1559 |
||
1560 |
/** |
|
9 | 1561 |
* Filters the secondary link URL for the 'WordPress Events and News' dashboard widget. |
5 | 1562 |
* |
1563 |
* @since 2.3.0 |
|
1564 |
* |
|
1565 |
* @param string $link The widget's secondary link URL. |
|
1566 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1567 |
'link' => apply_filters( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1568 |
'dashboard_secondary_link', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1569 |
/* translators: Link to the Planet website of the locale. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1570 |
__( 'https://planet.wordpress.org/' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1571 |
), |
5 | 1572 |
|
1573 |
/** |
|
9 | 1574 |
* Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget. |
5 | 1575 |
* |
1576 |
* @since 2.3.0 |
|
1577 |
* |
|
1578 |
* @param string $url The widget's secondary feed URL. |
|
1579 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1580 |
'url' => apply_filters( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1581 |
'dashboard_secondary_feed', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1582 |
/* translators: Link to the Planet feed of the locale. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1583 |
__( 'https://planet.wordpress.org/feed/' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1584 |
), |
5 | 1585 |
|
1586 |
/** |
|
9 | 1587 |
* Filters the secondary link title for the 'WordPress Events and News' dashboard widget. |
5 | 1588 |
* |
1589 |
* @since 2.3.0 |
|
1590 |
* |
|
1591 |
* @param string $title Title attribute for the widget's secondary link. |
|
1592 |
*/ |
|
1593 |
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1594 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1595 |
/** |
9 | 1596 |
* Filters the number of secondary link items for the 'WordPress Events and News' dashboard widget. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1597 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1598 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1599 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1600 |
* @param string $items How many items to show in the secondary feed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1601 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1602 |
'items' => apply_filters( 'dashboard_secondary_items', 3 ), |
5 | 1603 |
'show_summary' => 0, |
1604 |
'show_author' => 0, |
|
1605 |
'show_date' => 0, |
|
9 | 1606 |
), |
5 | 1607 |
); |
1608 |
||
1609 |
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds ); |
|
1610 |
} |
|
1611 |
||
1612 |
/** |
|
16 | 1613 |
* Displays the WordPress events and news feeds. |
5 | 1614 |
* |
1615 |
* @since 3.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1616 |
* @since 4.8.0 Removed popular plugins feed. |
5 | 1617 |
* |
1618 |
* @param string $widget_id Widget ID. |
|
1619 |
* @param array $feeds Array of RSS feeds. |
|
1620 |
*/ |
|
1621 |
function wp_dashboard_primary_output( $widget_id, $feeds ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1622 |
foreach ( $feeds as $type => $args ) { |
5 | 1623 |
$args['type'] = $type; |
1624 |
echo '<div class="rss-widget">'; |
|
1625 |
wp_widget_rss_output( $args['url'], $args ); |
|
9 | 1626 |
echo '</div>'; |
5 | 1627 |
} |
1628 |
} |
|
1629 |
||
1630 |
/** |
|
16 | 1631 |
* Displays file upload quota on dashboard. |
0 | 1632 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1633 |
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now(). |
0 | 1634 |
* |
1635 |
* @since 3.0.0 |
|
1636 |
* |
|
18 | 1637 |
* @return true|void True if not multisite, user can't upload files, or the space check option is disabled. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1638 |
*/ |
0 | 1639 |
function wp_dashboard_quota() { |
18 | 1640 |
if ( ! is_multisite() || ! current_user_can( 'upload_files' ) |
1641 |
|| get_site_option( 'upload_space_check_disabled' ) |
|
1642 |
) { |
|
0 | 1643 |
return true; |
9 | 1644 |
} |
0 | 1645 |
|
1646 |
$quota = get_space_allowed(); |
|
9 | 1647 |
$used = get_space_used(); |
0 | 1648 |
|
9 | 1649 |
if ( $used > $quota ) { |
0 | 1650 |
$percentused = '100'; |
9 | 1651 |
} else { |
0 | 1652 |
$percentused = ( $used / $quota ) * 100; |
9 | 1653 |
} |
18 | 1654 |
|
9 | 1655 |
$used_class = ( $percentused >= 70 ) ? ' warning' : ''; |
1656 |
$used = round( $used, 2 ); |
|
0 | 1657 |
$percentused = number_format( $percentused ); |
1658 |
||
1659 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1660 |
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3> |
5 | 1661 |
<div class="mu-storage"> |
1662 |
<ul> |
|
1663 |
<li class="storage-count"> |
|
9 | 1664 |
<?php |
1665 |
$text = sprintf( |
|
16 | 1666 |
/* translators: %s: Number of megabytes. */ |
5 | 1667 |
__( '%s MB Space Allowed' ), |
1668 |
number_format_i18n( $quota ) |
|
1669 |
); |
|
1670 |
printf( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1671 |
'<a href="%1$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>', |
5 | 1672 |
esc_url( admin_url( 'upload.php' ) ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1673 |
$text, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1674 |
/* translators: Hidden accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1675 |
__( 'Manage Uploads' ) |
9 | 1676 |
); |
1677 |
?> |
|
5 | 1678 |
</li><li class="storage-count <?php echo $used_class; ?>"> |
9 | 1679 |
<?php |
1680 |
$text = sprintf( |
|
16 | 1681 |
/* translators: 1: Number of megabytes, 2: Percentage. */ |
5 | 1682 |
__( '%1$s MB (%2$s%%) Space Used' ), |
1683 |
number_format_i18n( $used, 2 ), |
|
1684 |
$percentused |
|
1685 |
); |
|
1686 |
printf( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1687 |
'<a href="%1$s" class="musublink">%2$s<span class="screen-reader-text"> (%3$s)</span></a>', |
5 | 1688 |
esc_url( admin_url( 'upload.php' ) ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1689 |
$text, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1690 |
/* translators: Hidden accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1691 |
__( 'Manage Uploads' ) |
9 | 1692 |
); |
1693 |
?> |
|
5 | 1694 |
</li> |
1695 |
</ul> |
|
0 | 1696 |
</div> |
1697 |
<?php |
|
1698 |
} |
|
1699 |
||
16 | 1700 |
/** |
1701 |
* Displays the browser update nag. |
|
1702 |
* |
|
1703 |
* @since 3.2.0 |
|
18 | 1704 |
* @since 5.8.0 Added a special message for Internet Explorer users. |
1705 |
* |
|
1706 |
* @global bool $is_IE |
|
16 | 1707 |
*/ |
0 | 1708 |
function wp_dashboard_browser_nag() { |
18 | 1709 |
global $is_IE; |
1710 |
||
9 | 1711 |
$notice = ''; |
0 | 1712 |
$response = wp_check_browser_version(); |
1713 |
||
1714 |
if ( $response ) { |
|
18 | 1715 |
if ( $is_IE ) { |
1716 |
$msg = __( 'Internet Explorer does not give you the best WordPress experience. Switch to Microsoft Edge, or another more modern browser to get the most from your site.' ); |
|
1717 |
} elseif ( $response['insecure'] ) { |
|
9 | 1718 |
$msg = sprintf( |
16 | 1719 |
/* translators: %s: Browser name and link. */ |
9 | 1720 |
__( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1721 |
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1722 |
); |
0 | 1723 |
} else { |
9 | 1724 |
$msg = sprintf( |
16 | 1725 |
/* translators: %s: Browser name and link. */ |
9 | 1726 |
__( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1727 |
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1728 |
); |
0 | 1729 |
} |
1730 |
||
1731 |
$browser_nag_class = ''; |
|
9 | 1732 |
if ( ! empty( $response['img_src'] ) ) { |
1733 |
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src']; |
|
0 | 1734 |
|
19 | 1735 |
$notice .= '<div class="alignright browser-icon"><img src="' . esc_url( $img_src ) . '" alt="" /></div>'; |
0 | 1736 |
$browser_nag_class = ' has-browser-icon'; |
1737 |
} |
|
1738 |
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; |
|
1739 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1740 |
$browsehappy = 'https://browsehappy.com/'; |
9 | 1741 |
$locale = get_user_locale(); |
1742 |
if ( 'en_US' !== $locale ) { |
|
0 | 1743 |
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
9 | 1744 |
} |
0 | 1745 |
|
18 | 1746 |
if ( $is_IE ) { |
1747 |
$msg_browsehappy = sprintf( |
|
1748 |
/* translators: %s: Browse Happy URL. */ |
|
1749 |
__( 'Learn how to <a href="%s" class="update-browser-link">browse happy</a>' ), |
|
1750 |
esc_url( $browsehappy ) |
|
1751 |
); |
|
1752 |
} else { |
|
1753 |
$msg_browsehappy = sprintf( |
|
1754 |
/* translators: 1: Browser update URL, 2: Browser name, 3: Browse Happy URL. */ |
|
1755 |
__( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), |
|
1756 |
esc_attr( $response['update_url'] ), |
|
1757 |
esc_html( $response['name'] ), |
|
1758 |
esc_url( $browsehappy ) |
|
1759 |
); |
|
1760 |
} |
|
1761 |
||
1762 |
$notice .= '<p>' . $msg_browsehappy . '</p>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1763 |
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; |
0 | 1764 |
$notice .= '<div class="clear"></div>'; |
1765 |
} |
|
1766 |
||
5 | 1767 |
/** |
9 | 1768 |
* Filters the notice output for the 'Browse Happy' nag meta box. |
1769 |
* |
|
1770 |
* @since 3.2.0 |
|
1771 |
* |
|
19 | 1772 |
* @param string $notice The notice content. |
1773 |
* @param array|false $response An array containing web browser information, or |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1774 |
* false on failure. See wp_check_browser_version(). |
9 | 1775 |
*/ |
16 | 1776 |
echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
0 | 1777 |
} |
1778 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1779 |
/** |
16 | 1780 |
* Adds an additional class to the browser nag if the current version is insecure. |
1781 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1782 |
* @since 3.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1783 |
* |
16 | 1784 |
* @param string[] $classes Array of meta box classes. |
1785 |
* @return string[] Modified array of meta box classes. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1786 |
*/ |
0 | 1787 |
function dashboard_browser_nag_class( $classes ) { |
1788 |
$response = wp_check_browser_version(); |
|
1789 |
||
9 | 1790 |
if ( $response && $response['insecure'] ) { |
0 | 1791 |
$classes[] = 'browser-insecure'; |
9 | 1792 |
} |
0 | 1793 |
|
1794 |
return $classes; |
|
1795 |
} |
|
1796 |
||
1797 |
/** |
|
16 | 1798 |
* Checks if the user needs a browser update. |
0 | 1799 |
* |
1800 |
* @since 3.2.0 |
|
1801 |
* |
|
18 | 1802 |
* @return array|false Array of browser data on success, false on failure. |
0 | 1803 |
*/ |
1804 |
function wp_check_browser_version() { |
|
9 | 1805 |
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
0 | 1806 |
return false; |
9 | 1807 |
} |
0 | 1808 |
|
1809 |
$key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
|
1810 |
||
16 | 1811 |
$response = get_site_transient( 'browser_' . $key ); |
18 | 1812 |
|
16 | 1813 |
if ( false === $response ) { |
9 | 1814 |
$url = 'http://api.wordpress.org/core/browse-happy/1.1/'; |
0 | 1815 |
$options = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1816 |
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1817 |
'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ), |
0 | 1818 |
); |
1819 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1820 |
if ( wp_http_supports( array( 'ssl' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1821 |
$url = set_url_scheme( $url, 'https' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1822 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1823 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1824 |
$response = wp_remote_post( $url, $options ); |
0 | 1825 |
|
18 | 1826 |
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { |
0 | 1827 |
return false; |
9 | 1828 |
} |
0 | 1829 |
|
1830 |
/** |
|
1831 |
* Response should be an array with: |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1832 |
* 'platform' - string - A user-friendly platform name, if it can be determined |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1833 |
* 'name' - string - A user-friendly browser name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1834 |
* 'version' - string - The version of the browser the user is using |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1835 |
* 'current_version' - string - The most recent version of the browser |
0 | 1836 |
* 'upgrade' - boolean - Whether the browser needs an upgrade |
1837 |
* 'insecure' - boolean - Whether the browser is deemed insecure |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1838 |
* 'update_url' - string - The url to visit to upgrade |
0 | 1839 |
* 'img_src' - string - An image representing the browser |
1840 |
* 'img_src_ssl' - string - An image (over SSL) representing the browser |
|
1841 |
*/ |
|
1842 |
$response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
1843 |
||
9 | 1844 |
if ( ! is_array( $response ) ) { |
0 | 1845 |
return false; |
9 | 1846 |
} |
0 | 1847 |
|
1848 |
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); |
|
1849 |
} |
|
1850 |
||
1851 |
return $response; |
|
1852 |
} |
|
1853 |
||
1854 |
/** |
|
9 | 1855 |
* Displays the PHP update nag. |
1856 |
* |
|
1857 |
* @since 5.1.0 |
|
1858 |
*/ |
|
1859 |
function wp_dashboard_php_nag() { |
|
1860 |
$response = wp_check_php_version(); |
|
1861 |
||
1862 |
if ( ! $response ) { |
|
1863 |
return; |
|
1864 |
} |
|
1865 |
||
1866 |
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1867 |
// The `is_secure` array key name doesn't actually imply this is a secure version of PHP. It only means it receives security updates. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1868 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1869 |
if ( $response['is_lower_than_future_minimum'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1870 |
$message = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1871 |
/* translators: %s: The server PHP version. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1872 |
__( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates and soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1873 |
PHP_VERSION |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1874 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1875 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1876 |
$message = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1877 |
/* translators: %s: The server PHP version. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1878 |
__( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates. It should be updated.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1879 |
PHP_VERSION |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1880 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1881 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1882 |
} elseif ( $response['is_lower_than_future_minimum'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1883 |
$message = sprintf( |
18 | 1884 |
/* translators: %s: The server PHP version. */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1885 |
__( 'Your site is running on an outdated version of PHP (%s), which soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ), |
18 | 1886 |
PHP_VERSION |
1887 |
); |
|
9 | 1888 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1889 |
$message = sprintf( |
18 | 1890 |
/* translators: %s: The server PHP version. */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1891 |
__( 'Your site is running on an outdated version of PHP (%s), which should be updated.' ), |
18 | 1892 |
PHP_VERSION |
1893 |
); |
|
9 | 1894 |
} |
1895 |
?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1896 |
<p class="bigger-bolder-text"><?php echo $message; ?></p> |
9 | 1897 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1898 |
<p><?php _e( 'What is PHP and how does it affect my site?' ); ?></p> |
18 | 1899 |
<p> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1900 |
<?php _e( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site’s performance.' ); ?> |
18 | 1901 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1902 |
if ( ! empty( $response['recommended_version'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1903 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1904 |
/* translators: %s: The minimum recommended PHP version. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1905 |
__( 'The minimum recommended version of PHP is %s.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1906 |
$response['recommended_version'] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1907 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1908 |
} |
18 | 1909 |
?> |
1910 |
</p> |
|
9 | 1911 |
|
1912 |
<p class="button-container"> |
|
1913 |
<?php |
|
1914 |
printf( |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1915 |
'<a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
9 | 1916 |
esc_url( wp_get_update_php_url() ), |
1917 |
__( 'Learn more about updating PHP' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1918 |
/* translators: Hidden accessibility text. */ |
9 | 1919 |
__( '(opens in a new tab)' ) |
1920 |
); |
|
1921 |
?> |
|
1922 |
</p> |
|
1923 |
<?php |
|
1924 |
||
1925 |
wp_update_php_annotation(); |
|
1926 |
wp_direct_php_update_button(); |
|
1927 |
} |
|
1928 |
||
1929 |
/** |
|
1930 |
* Adds an additional class to the PHP nag if the current version is insecure. |
|
1931 |
* |
|
1932 |
* @since 5.1.0 |
|
1933 |
* |
|
16 | 1934 |
* @param string[] $classes Array of meta box classes. |
1935 |
* @return string[] Modified array of meta box classes. |
|
9 | 1936 |
*/ |
1937 |
function dashboard_php_nag_class( $classes ) { |
|
1938 |
$response = wp_check_php_version(); |
|
1939 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1940 |
if ( ! $response ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1941 |
return $classes; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1942 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1943 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1944 |
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1945 |
$classes[] = 'php-no-security-updates'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1946 |
} elseif ( $response['is_lower_than_future_minimum'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1947 |
$classes[] = 'php-version-lower-than-future-minimum'; |
9 | 1948 |
} |
1949 |
||
1950 |
return $classes; |
|
1951 |
} |
|
1952 |
||
1953 |
/** |
|
16 | 1954 |
* Displays the Site Health Status widget. |
1955 |
* |
|
1956 |
* @since 5.4.0 |
|
1957 |
*/ |
|
1958 |
function wp_dashboard_site_health() { |
|
1959 |
$get_issues = get_transient( 'health-check-site-status-result' ); |
|
1960 |
||
1961 |
$issue_counts = array(); |
|
1962 |
||
1963 |
if ( false !== $get_issues ) { |
|
1964 |
$issue_counts = json_decode( $get_issues, true ); |
|
1965 |
} |
|
1966 |
||
1967 |
if ( ! is_array( $issue_counts ) || ! $issue_counts ) { |
|
1968 |
$issue_counts = array( |
|
1969 |
'good' => 0, |
|
1970 |
'recommended' => 0, |
|
1971 |
'critical' => 0, |
|
1972 |
); |
|
1973 |
} |
|
1974 |
||
1975 |
$issues_total = $issue_counts['recommended'] + $issue_counts['critical']; |
|
1976 |
?> |
|
18 | 1977 |
<div class="health-check-widget"> |
1978 |
<div class="health-check-widget-title-section site-health-progress-wrapper loading hide-if-no-js"> |
|
1979 |
<div class="site-health-progress"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1980 |
<svg aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg"> |
18 | 1981 |
<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> |
1982 |
<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> |
|
1983 |
</svg> |
|
1984 |
</div> |
|
1985 |
<div class="site-health-progress-label"> |
|
1986 |
<?php if ( false === $get_issues ) : ?> |
|
1987 |
<?php _e( 'No information yet…' ); ?> |
|
1988 |
<?php else : ?> |
|
1989 |
<?php _e( 'Results are still loading…' ); ?> |
|
1990 |
<?php endif; ?> |
|
1991 |
</div> |
|
16 | 1992 |
</div> |
18 | 1993 |
|
1994 |
<div class="site-health-details"> |
|
16 | 1995 |
<?php if ( false === $get_issues ) : ?> |
18 | 1996 |
<p> |
1997 |
<?php |
|
1998 |
printf( |
|
1999 |
/* translators: %s: URL to Site Health screen. */ |
|
2000 |
__( 'Site health checks will automatically run periodically to gather information about your site. You can also <a href="%s">visit the Site Health screen</a> to gather information about your site now.' ), |
|
2001 |
esc_url( admin_url( 'site-health.php' ) ) |
|
2002 |
); |
|
2003 |
?> |
|
2004 |
</p> |
|
16 | 2005 |
<?php else : ?> |
18 | 2006 |
<p> |
2007 |
<?php if ( $issues_total <= 0 ) : ?> |
|
2008 |
<?php _e( 'Great job! Your site currently passes all site health checks.' ); ?> |
|
2009 |
<?php elseif ( 1 === (int) $issue_counts['critical'] ) : ?> |
|
2010 |
<?php _e( 'Your site has a critical issue that should be addressed as soon as possible to improve its performance and security.' ); ?> |
|
2011 |
<?php elseif ( $issue_counts['critical'] > 1 ) : ?> |
|
2012 |
<?php _e( 'Your site has critical issues that should be addressed as soon as possible to improve its performance and security.' ); ?> |
|
2013 |
<?php elseif ( 1 === (int) $issue_counts['recommended'] ) : ?> |
|
2014 |
<?php _e( 'Your site’s health is looking good, but there is still one thing you can do to improve its performance and security.' ); ?> |
|
2015 |
<?php else : ?> |
|
2016 |
<?php _e( 'Your site’s health is looking good, but there are still some things you can do to improve its performance and security.' ); ?> |
|
2017 |
<?php endif; ?> |
|
2018 |
</p> |
|
2019 |
<?php endif; ?> |
|
2020 |
||
2021 |
<?php if ( $issues_total > 0 && false !== $get_issues ) : ?> |
|
2022 |
<p> |
|
2023 |
<?php |
|
2024 |
printf( |
|
2025 |
/* translators: 1: Number of issues. 2: URL to Site Health screen. */ |
|
2026 |
_n( |
|
2027 |
'Take a look at the <strong>%1$d item</strong> on the <a href="%2$s">Site Health screen</a>.', |
|
2028 |
'Take a look at the <strong>%1$d items</strong> on the <a href="%2$s">Site Health screen</a>.', |
|
2029 |
$issues_total |
|
2030 |
), |
|
2031 |
$issues_total, |
|
2032 |
esc_url( admin_url( 'site-health.php' ) ) |
|
2033 |
); |
|
2034 |
?> |
|
2035 |
</p> |
|
16 | 2036 |
<?php endif; ?> |
2037 |
</div> |
|
2038 |
</div> |
|
2039 |
||
2040 |
<?php |
|
2041 |
} |
|
2042 |
||
2043 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2044 |
* Outputs empty dashboard widget to be populated by JS later. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2045 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2046 |
* Usable by plugins. |
16 | 2047 |
* |
2048 |
* @since 2.5.0 |
|
0 | 2049 |
*/ |
2050 |
function wp_dashboard_empty() {} |
|
2051 |
||
2052 |
/** |
|
2053 |
* Displays a welcome panel to introduce users to WordPress. |
|
2054 |
* |
|
2055 |
* @since 3.3.0 |
|
19 | 2056 |
* @since 5.9.0 Send users to the Site Editor if the active theme is block-based. |
0 | 2057 |
*/ |
2058 |
function wp_welcome_panel() { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2059 |
list( $display_version ) = explode( '-', wp_get_wp_version() ); |
19 | 2060 |
$can_customize = current_user_can( 'customize' ); |
2061 |
$is_block_theme = wp_is_block_theme(); |
|
0 | 2062 |
?> |
2063 |
<div class="welcome-panel-content"> |
|
19 | 2064 |
<div class="welcome-panel-header"> |
2065 |
<div class="welcome-panel-header-image"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2066 |
<?php echo file_get_contents( dirname( __DIR__ ) . '/images/dashboard-background.svg' ); ?> |
19 | 2067 |
</div> |
2068 |
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2> |
|
2069 |
<p> |
|
2070 |
<a href="<?php echo esc_url( admin_url( 'about.php' ) ); ?>"> |
|
2071 |
<?php |
|
2072 |
/* translators: %s: Current WordPress version. */ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2073 |
printf( __( 'Learn more about the %s version.' ), esc_html( $display_version ) ); |
19 | 2074 |
?> |
2075 |
</a> |
|
2076 |
</p> |
|
0 | 2077 |
</div> |
19 | 2078 |
<div class="welcome-panel-column-container"> |
2079 |
<div class="welcome-panel-column"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2080 |
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2081 |
<rect width="48" height="48" rx="4" fill="#1E1E1E"/> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2082 |
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.0668 17.0854L28.8221 13.9454L18.2008 24.671L16.8983 29.0827L21.4257 27.8309L32.0668 17.0854ZM16 32.75H24V31.25H16V32.75Z" fill="white"/> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2083 |
</svg> |
19 | 2084 |
<div class="welcome-panel-column-content"> |
2085 |
<h3><?php _e( 'Author rich content with blocks and patterns' ); ?></h3> |
|
2086 |
<p><?php _e( 'Block patterns are pre-configured block layouts. Use them to get inspired or create new pages in a flash.' ); ?></p> |
|
2087 |
<a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=page' ) ); ?>"><?php _e( 'Add a new page' ); ?></a> |
|
2088 |
</div> |
|
2089 |
</div> |
|
2090 |
<div class="welcome-panel-column"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2091 |
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2092 |
<rect width="48" height="48" rx="4" fill="#1E1E1E"/> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2093 |
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 16h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H18a2 2 0 0 1-2-2V18a2 2 0 0 1 2-2zm12 1.5H18a.5.5 0 0 0-.5.5v3h13v-3a.5.5 0 0 0-.5-.5zm.5 5H22v8h8a.5.5 0 0 0 .5-.5v-7.5zm-10 0h-3V30a.5.5 0 0 0 .5.5h2.5v-8z" fill="#fff"/> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2094 |
</svg> |
19 | 2095 |
<div class="welcome-panel-column-content"> |
2096 |
<?php if ( $is_block_theme ) : ?> |
|
2097 |
<h3><?php _e( 'Customize your entire site with block themes' ); ?></h3> |
|
2098 |
<p><?php _e( 'Design everything on your site — from the header down to the footer, all using blocks and patterns.' ); ?></p> |
|
2099 |
<a href="<?php echo esc_url( admin_url( 'site-editor.php' ) ); ?>"><?php _e( 'Open site editor' ); ?></a> |
|
2100 |
<?php else : ?> |
|
2101 |
<h3><?php _e( 'Start Customizing' ); ?></h3> |
|
2102 |
<p><?php _e( 'Configure your site’s logo, header, menus, and more in the Customizer.' ); ?></p> |
|
2103 |
<?php if ( $can_customize ) : ?> |
|
2104 |
<a class="load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Open the Customizer' ); ?></a> |
|
2105 |
<?php endif; ?> |
|
2106 |
<?php endif; ?> |
|
2107 |
</div> |
|
2108 |
</div> |
|
2109 |
<div class="welcome-panel-column"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2110 |
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2111 |
<rect width="48" height="48" rx="4" fill="#1E1E1E"/> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2112 |
<path fill-rule="evenodd" clip-rule="evenodd" d="M31 24a7 7 0 0 1-7 7V17a7 7 0 0 1 7 7zm-7-8a8 8 0 1 1 0 16 8 8 0 0 1 0-16z" fill="#fff"/> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2113 |
</svg> |
19 | 2114 |
<div class="welcome-panel-column-content"> |
2115 |
<?php if ( $is_block_theme ) : ?> |
|
2116 |
<h3><?php _e( 'Switch up your site’s look & feel with Styles' ); ?></h3> |
|
2117 |
<p><?php _e( 'Tweak your site, or give it a whole new look! Get creative — how about a new color palette or font?' ); ?></p> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2118 |
<a href="<?php echo esc_url( admin_url( '/site-editor.php?path=%2Fwp_global_styles' ) ); ?>"><?php _e( 'Edit styles' ); ?></a> |
19 | 2119 |
<?php else : ?> |
2120 |
<h3><?php _e( 'Discover a new way to build your site.' ); ?></h3> |
|
2121 |
<p><?php _e( 'There is a new kind of WordPress theme, called a block theme, that lets you build the site you’ve always wanted — with blocks and styles.' ); ?></p> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2122 |
<a href="<?php echo esc_url( __( 'https://wordpress.org/documentation/article/block-themes/' ) ); ?>"><?php _e( 'Learn about block themes' ); ?></a> |
19 | 2123 |
<?php endif; ?> |
2124 |
</div> |
|
2125 |
</div> |
|
0 | 2126 |
</div> |
2127 |
</div> |
|
2128 |
<?php |
|
2129 |
} |