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