40 if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) { |
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' ); |
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' ); |
42 wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' ); |
43 } |
43 } |
44 |
44 |
45 // Right Now |
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. |
46 if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { |
60 if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { |
47 wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
61 wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
48 } |
62 } |
49 |
63 |
50 if ( is_network_admin() ) { |
64 if ( is_network_admin() ) { |
51 wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
65 wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
52 } |
66 } |
53 |
67 |
54 // Activity Widget |
68 // Activity Widget. |
55 if ( is_blog_admin() ) { |
69 if ( is_blog_admin() ) { |
56 wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); |
70 wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); |
57 } |
71 } |
58 |
72 |
59 // QuickPress Widget |
73 // QuickPress Widget. |
60 if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
74 if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
61 $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' ) ); |
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' ) ); |
62 wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); |
76 wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); |
63 } |
77 } |
64 |
78 |
65 // WordPress Events and News |
79 // WordPress Events and News. |
66 wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); |
80 wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); |
67 |
81 |
68 if ( is_network_admin() ) { |
82 if ( is_network_admin() ) { |
69 |
83 |
70 /** |
84 /** |
121 foreach ( $dashboard_widgets as $widget_id ) { |
135 foreach ( $dashboard_widgets as $widget_id ) { |
122 $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>'; |
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>'; |
123 wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] ); |
137 wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] ); |
124 } |
138 } |
125 |
139 |
126 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { |
140 if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { |
127 check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); |
141 check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); |
128 ob_start(); // hack - but the same hack wp-admin/widgets.php uses |
142 ob_start(); // Hack - but the same hack wp-admin/widgets.php uses. |
129 wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); |
143 wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); |
130 ob_end_clean(); |
144 ob_end_clean(); |
131 wp_redirect( remove_query_arg( 'edit' ) ); |
145 wp_redirect( remove_query_arg( 'edit' ) ); |
132 exit; |
146 exit; |
133 } |
147 } |
262 function wp_dashboard_right_now() { |
276 function wp_dashboard_right_now() { |
263 ?> |
277 ?> |
264 <div class="main"> |
278 <div class="main"> |
265 <ul> |
279 <ul> |
266 <?php |
280 <?php |
267 // Posts and Pages |
281 // Posts and Pages. |
268 foreach ( array( 'post', 'page' ) as $post_type ) { |
282 foreach ( array( 'post', 'page' ) as $post_type ) { |
269 $num_posts = wp_count_posts( $post_type ); |
283 $num_posts = wp_count_posts( $post_type ); |
270 if ( $num_posts && $num_posts->publish ) { |
284 if ( $num_posts && $num_posts->publish ) { |
271 if ( 'post' == $post_type ) { |
285 if ( 'post' === $post_type ) { |
|
286 /* translators: %s: Number of posts. */ |
272 $text = _n( '%s Post', '%s Posts', $num_posts->publish ); |
287 $text = _n( '%s Post', '%s Posts', $num_posts->publish ); |
273 } else { |
288 } else { |
|
289 /* translators: %s: Number of pages. */ |
274 $text = _n( '%s Page', '%s Pages', $num_posts->publish ); |
290 $text = _n( '%s Page', '%s Pages', $num_posts->publish ); |
275 } |
291 } |
276 $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
292 $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
277 $post_type_object = get_post_type_object( $post_type ); |
293 $post_type_object = get_post_type_object( $post_type ); |
278 if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { |
294 if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { |
280 } else { |
296 } else { |
281 printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text ); |
297 printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text ); |
282 } |
298 } |
283 } |
299 } |
284 } |
300 } |
285 // Comments |
301 // Comments. |
286 $num_comm = wp_count_comments(); |
302 $num_comm = wp_count_comments(); |
287 if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { |
303 if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { |
|
304 /* translators: %s: Number of comments. */ |
288 $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); |
305 $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); |
289 ?> |
306 ?> |
290 <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li> |
307 <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li> |
291 <?php |
308 <?php |
292 $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated ); |
309 $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated ); |
293 /* translators: %s: number of comments in moderation */ |
310 /* translators: %s: Number of comments. */ |
294 $text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n ); |
311 $text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n ); |
295 ?> |
312 ?> |
296 <li class="comment-mod-count |
313 <li class="comment-mod-count |
297 <?php |
314 <?php |
298 if ( ! $num_comm->moderated ) { |
315 if ( ! $num_comm->moderated ) { |
340 * @param string $title Default attribute text. |
357 * @param string $title Default attribute text. |
341 */ |
358 */ |
342 $title = apply_filters( 'privacy_on_link_title', '' ); |
359 $title = apply_filters( 'privacy_on_link_title', '' ); |
343 |
360 |
344 /** |
361 /** |
345 * Filters the link label for the 'Search Engines Discouraged' message |
362 * Filters the link label for the 'Search engines discouraged' message |
346 * displayed in the 'At a Glance' dashboard widget. |
363 * displayed in the 'At a Glance' dashboard widget. |
347 * |
364 * |
348 * Prior to 3.8.0, the widget was named 'Right Now'. |
365 * Prior to 3.8.0, the widget was named 'Right Now'. |
349 * |
366 * |
350 * @since 3.0.0 |
367 * @since 3.0.0 |
351 * |
368 * |
352 * @param string $content Default text. |
369 * @param string $content Default text. |
353 */ |
370 */ |
354 $content = apply_filters( 'privacy_on_link_text', __( 'Search Engines Discouraged' ) ); |
371 $content = apply_filters( 'privacy_on_link_text', __( 'Search engines discouraged' ) ); |
355 $title_attr = '' === $title ? '' : " title='$title'"; |
372 $title_attr = '' === $title ? '' : " title='$title'"; |
356 |
373 |
357 echo "<p><a href='options-reading.php'$title_attr>$content</a></p>"; |
374 echo "<p class='search-engines-info'><a href='options-reading.php'$title_attr>$content</a></p>"; |
358 } |
375 } |
359 ?> |
376 ?> |
360 </div> |
377 </div> |
361 <?php |
378 <?php |
362 /* |
379 /* |
407 } |
424 } |
408 |
425 |
409 $c_users = get_user_count(); |
426 $c_users = get_user_count(); |
410 $c_blogs = get_blog_count(); |
427 $c_blogs = get_blog_count(); |
411 |
428 |
412 /* translators: %s: number of users on the network */ |
429 /* translators: %s: Number of users on the network. */ |
413 $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); |
430 $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); |
414 /* translators: %s: number of sites on the network */ |
431 /* translators: %s: Number of sites on the network. */ |
415 $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); |
432 $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); |
416 |
433 |
417 /* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */ |
434 /* translators: 1: Text indicating the number of sites on the network, 2: Text indicating the number of users on the network. */ |
418 $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); |
435 $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); |
419 |
436 |
420 if ( $actions ) { |
437 if ( $actions ) { |
421 echo '<ul class="subsubsub">'; |
438 echo '<ul class="subsubsub">'; |
422 foreach ( $actions as $class => $action ) { |
439 foreach ( $actions as $class => $action ) { |
487 if ( ! current_user_can( 'edit_posts' ) ) { |
504 if ( ! current_user_can( 'edit_posts' ) ) { |
488 return; |
505 return; |
489 } |
506 } |
490 |
507 |
491 /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ |
508 /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ |
492 $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID |
509 $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID. |
493 if ( $last_post_id ) { |
510 if ( $last_post_id ) { |
494 $post = get_post( $last_post_id ); |
511 $post = get_post( $last_post_id ); |
495 if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore |
512 if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore. |
496 $post = get_default_post_to_edit( 'post', true ); |
513 $post = get_default_post_to_edit( 'post', true ); |
497 update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
514 update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. |
498 } else { |
515 } else { |
499 $post->post_title = ''; // Remove the auto draft title |
516 $post->post_title = ''; // Remove the auto draft title. |
500 } |
517 } |
501 } else { |
518 } else { |
502 $post = get_default_post_to_edit( 'post', true ); |
519 $post = get_default_post_to_edit( 'post', true ); |
503 $user_id = get_current_user_id(); |
520 $user_id = get_current_user_id(); |
504 // Don't create an option if this is a super admin who does not belong to this site. |
521 // Don't create an option if this is a super admin who does not belong to this site. |
505 if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) { |
522 if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) { |
506 update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
523 update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. |
507 } |
524 } |
508 } |
525 } |
509 |
526 |
510 $post_ID = (int) $post->ID; |
527 $post_ID = (int) $post->ID; |
511 ?> |
528 ?> |
578 } |
595 } |
579 } |
596 } |
580 |
597 |
581 echo '<div class="drafts">'; |
598 echo '<div class="drafts">'; |
582 if ( count( $drafts ) > 3 ) { |
599 if ( count( $drafts ) > 3 ) { |
583 echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n"; |
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 ); |
584 } |
605 } |
585 echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>"; |
606 echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>"; |
|
607 |
|
608 /* translators: Maximum number of words used in a preview of a draft on the dashboard. */ |
|
609 $draft_length = intval( _x( '10', 'draft_length' ) ); |
586 |
610 |
587 $drafts = array_slice( $drafts, 0, 3 ); |
611 $drafts = array_slice( $drafts, 0, 3 ); |
588 foreach ( $drafts as $draft ) { |
612 foreach ( $drafts as $draft ) { |
589 $url = get_edit_post_link( $draft->ID ); |
613 $url = get_edit_post_link( $draft->ID ); |
590 $title = _draft_or_post_title( $draft->ID ); |
614 $title = _draft_or_post_title( $draft->ID ); |
591 echo "<li>\n"; |
615 echo "<li>\n"; |
592 /* translators: %s: post title */ |
616 printf( |
593 echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>'; |
617 '<div class="draft-title"><a href="%s" aria-label="%s">%s</a><time datetime="%s">%s</time></div>', |
594 echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>'; |
618 esc_url( $url ), |
595 if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) { |
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 ) { |
596 echo '<p>' . $the_content . '</p>'; |
627 echo '<p>' . $the_content . '</p>'; |
597 } |
628 } |
598 echo "</li>\n"; |
629 echo "</li>\n"; |
599 } |
630 } |
600 echo "</ul>\n</div>"; |
631 echo "</ul>\n</div>"; |
644 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
675 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
645 $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
676 $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
646 $trash_url = esc_url( "comment.php?action=trashcomment&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" ); |
647 $delete_url = esc_url( "comment.php?action=deletecomment&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" ); |
648 |
679 |
649 $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
680 $actions['approve'] = sprintf( |
650 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
681 '<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>', |
651 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>'; |
682 $approve_url, |
652 $actions['reply'] = '<button type="button" onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\'' . $comment->comment_post_ID . '\');" class="vim-r button-link hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '">' . __( 'Reply' ) . '</button>'; |
683 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved", |
653 $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
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 ); |
654 |
719 |
655 if ( ! EMPTY_TRASH_DAYS ) { |
720 if ( ! EMPTY_TRASH_DAYS ) { |
656 $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>'; |
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 ); |
657 } else { |
728 } else { |
658 $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; |
729 $actions['trash'] = sprintf( |
659 } |
730 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', |
660 |
731 $trash_url, |
661 $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>'; |
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 ); |
|
736 } |
|
737 |
|
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 ); |
662 |
744 |
663 /** |
745 /** |
664 * Filters the action links displayed for each comment in the 'Recent Comments' |
746 * Filters the action links displayed for each comment in the 'Recent Comments' |
665 * dashboard widget. |
747 * dashboard widget. |
666 * |
748 * |
672 * @param WP_Comment $comment The comment object. |
754 * @param WP_Comment $comment The comment object. |
673 */ |
755 */ |
674 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); |
756 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); |
675 |
757 |
676 $i = 0; |
758 $i = 0; |
|
759 |
677 foreach ( $actions as $action => $link ) { |
760 foreach ( $actions as $action => $link ) { |
678 ++$i; |
761 ++$i; |
679 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
762 |
680 |
763 if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) |
681 // Reply and quickedit need a hide-if-no-js span |
764 || 1 === $i |
682 if ( 'reply' == $action || 'quickedit' == $action ) { |
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 ) { |
683 $action .= ' hide-if-no-js'; |
773 $action .= ' hide-if-no-js'; |
684 } |
774 } |
685 |
775 |
686 if ( 'view' === $action && '1' !== $comment->comment_approved ) { |
776 if ( 'view' === $action && '1' !== $comment->comment_approved ) { |
687 $action .= ' hidden'; |
777 $action .= ' hidden'; |
688 } |
778 } |
|
779 |
689 $actions_string .= "<span class='$action'>$sep$link</span>"; |
780 $actions_string .= "<span class='$action'>$sep$link</span>"; |
690 } |
781 } |
691 } |
782 } |
692 ?> |
783 ?> |
693 |
784 |
694 <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>> |
785 <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>> |
695 |
786 |
696 <?php echo get_avatar( $comment, 50, 'mystery' ); ?> |
787 <?php |
697 |
788 $comment_row_class = ''; |
698 <?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?> |
789 |
699 |
790 if ( get_option( 'show_avatars' ) ) { |
700 <div class="dashboard-comment-wrap has-row-actions"> |
791 echo get_avatar( $comment, 50, 'mystery' ); |
|
792 $comment_row_class .= ' has-avatar'; |
|
793 } |
|
794 ?> |
|
795 |
|
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; ?>"> |
701 <p class="comment-meta"> |
799 <p class="comment-meta"> |
702 <?php |
800 <?php |
703 // Comments might not have a post they relate to, e.g. programmatically created ones. |
801 // Comments might not have a post they relate to, e.g. programmatically created ones. |
704 if ( $comment_post_link ) { |
802 if ( $comment_post_link ) { |
705 printf( |
803 printf( |
706 /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */ |
804 /* translators: 1: Comment author, 2: Post link, 3: Notification if the comment is pending. */ |
707 __( 'From %1$s on %2$s %3$s' ), |
805 __( 'From %1$s on %2$s %3$s' ), |
708 '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
806 '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
709 $comment_post_link, |
807 $comment_post_link, |
710 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
808 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
711 ); |
809 ); |
712 } else { |
810 } else { |
713 printf( |
811 printf( |
714 /* translators: 1: comment author, 2: notification if the comment is pending */ |
812 /* translators: 1: Comment author, 2: Notification if the comment is pending. */ |
715 __( 'From %1$s %2$s' ), |
813 __( 'From %1$s %2$s' ), |
716 '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
814 '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
717 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
815 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
718 ); |
816 ); |
719 } |
817 } |
738 <p class="comment-meta"> |
836 <p class="comment-meta"> |
739 <?php |
837 <?php |
740 // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones. |
838 // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones. |
741 if ( $comment_post_link ) { |
839 if ( $comment_post_link ) { |
742 printf( |
840 printf( |
743 /* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */ |
841 /* translators: 1: Type of comment, 2: Post link, 3: Notification if the comment is pending. */ |
744 _x( '%1$s on %2$s %3$s', 'dashboard' ), |
842 _x( '%1$s on %2$s %3$s', 'dashboard' ), |
745 "<strong>$type</strong>", |
843 "<strong>$type</strong>", |
746 $comment_post_link, |
844 $comment_post_link, |
747 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
845 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
748 ); |
846 ); |
749 } else { |
847 } else { |
750 printf( |
848 printf( |
751 /* translators: 1: type of comment, 2: notification if the comment is pending */ |
849 /* translators: 1: Type of comment, 2: Notification if the comment is pending. */ |
752 _x( '%1$s %2$s', 'dashboard' ), |
850 _x( '%1$s %2$s', 'dashboard' ), |
753 "<strong>$type</strong>", |
851 "<strong>$type</strong>", |
754 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
852 '<span class="approve">' . __( '[Pending]' ) . '</span>' |
755 ); |
853 ); |
756 } |
854 } |
854 echo '<h3>' . $args['title'] . '</h3>'; |
951 echo '<h3>' . $args['title'] . '</h3>'; |
855 |
952 |
856 echo '<ul>'; |
953 echo '<ul>'; |
857 |
954 |
858 $today = current_time( 'Y-m-d' ); |
955 $today = current_time( 'Y-m-d' ); |
859 $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); |
956 $tomorrow = current_datetime()->modify( '+1 day' )->format( 'Y-m-d' ); |
860 $year = current_time( 'Y' ); |
957 $year = current_time( 'Y' ); |
861 |
958 |
862 while ( $posts->have_posts() ) { |
959 while ( $posts->have_posts() ) { |
863 $posts->the_post(); |
960 $posts->the_post(); |
864 |
961 |
865 $time = get_the_time( 'U' ); |
962 $time = get_the_time( 'U' ); |
866 if ( date( 'Y-m-d', $time ) == $today ) { |
963 if ( gmdate( 'Y-m-d', $time ) == $today ) { |
867 $relative = __( 'Today' ); |
964 $relative = __( 'Today' ); |
868 } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { |
965 } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) { |
869 $relative = __( 'Tomorrow' ); |
966 $relative = __( 'Tomorrow' ); |
870 } elseif ( date( 'Y', $time ) !== $year ) { |
967 } elseif ( gmdate( 'Y', $time ) !== $year ) { |
871 /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */ |
968 /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/date */ |
872 $relative = date_i18n( __( 'M jS Y' ), $time ); |
969 $relative = date_i18n( __( 'M jS Y' ), $time ); |
873 } else { |
970 } else { |
874 /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */ |
971 /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/date */ |
875 $relative = date_i18n( __( 'M jS' ), $time ); |
972 $relative = date_i18n( __( 'M jS' ), $time ); |
876 } |
973 } |
877 |
974 |
878 // Use the post edit link for those who can edit, the permalink otherwise. |
975 // Use the post edit link for those who can edit, the permalink otherwise. |
879 $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); |
976 $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); |
880 |
977 |
881 $draft_or_post_title = _draft_or_post_title(); |
978 $draft_or_post_title = _draft_or_post_title(); |
882 printf( |
979 printf( |
883 '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>', |
980 '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>', |
884 /* translators: 1: relative date, 2: time */ |
981 /* translators: 1: Relative date, 2: Time. */ |
885 sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), |
982 sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), |
886 $recent_post_link, |
983 $recent_post_link, |
887 /* translators: %s: post title */ |
984 /* translators: %s: Post title. */ |
888 esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), |
985 esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), |
889 $draft_or_post_title |
986 $draft_or_post_title |
890 ); |
987 ); |
891 } |
988 } |
892 |
989 |
985 * widget options of $widget_id. If cached, call $callback, a function that |
1082 * widget options of $widget_id. If cached, call $callback, a function that |
986 * echoes out output for this widget. If not cache, echo a "Loading..." stub |
1083 * echoes out output for this widget. If not cache, echo a "Loading..." stub |
987 * which is later replaced by Ajax call (see top of /wp-admin/index.php) |
1084 * which is later replaced by Ajax call (see top of /wp-admin/index.php) |
988 * |
1085 * |
989 * @since 2.5.0 |
1086 * @since 2.5.0 |
990 * |
1087 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter |
991 * @param string $widget_id |
1088 * by adding it to the function signature. |
992 * @param callable $callback |
1089 * |
993 * @param array $check_urls RSS feeds |
1090 * @param string $widget_id The widget ID. |
994 * @return bool False on failure. True on success. |
1091 * @param callable $callback The callback function used to display each feed. |
995 */ |
1092 * @param array $check_urls RSS feeds. |
996 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { |
1093 * @param mixed ...$args Optional additional parameters to pass to the callback function. |
997 $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>'; |
1094 * @return bool True on success, false on failure. |
|
1095 */ |
|
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>'; |
998 $doing_ajax = wp_doing_ajax(); |
1098 $doing_ajax = wp_doing_ajax(); |
999 |
1099 |
1000 if ( empty( $check_urls ) ) { |
1100 if ( empty( $check_urls ) ) { |
1001 $widgets = get_option( 'dashboard_widget_options' ); |
1101 $widgets = get_option( 'dashboard_widget_options' ); |
1002 if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) { |
1102 if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) { |
1006 $check_urls = array( $widgets[ $widget_id ]['url'] ); |
1106 $check_urls = array( $widgets[ $widget_id ]['url'] ); |
1007 } |
1107 } |
1008 |
1108 |
1009 $locale = get_user_locale(); |
1109 $locale = get_user_locale(); |
1010 $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); |
1110 $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); |
1011 if ( false !== ( $output = get_transient( $cache_key ) ) ) { |
1111 $output = get_transient( $cache_key ); |
|
1112 if ( false !== $output ) { |
1012 echo $output; |
1113 echo $output; |
1013 return true; |
1114 return true; |
1014 } |
1115 } |
1015 |
1116 |
1016 if ( ! $doing_ajax ) { |
1117 if ( ! $doing_ajax ) { |
1017 echo $loading; |
1118 echo $loading; |
1018 return false; |
1119 return false; |
1019 } |
1120 } |
1020 |
1121 |
1021 if ( $callback && is_callable( $callback ) ) { |
1122 if ( $callback && is_callable( $callback ) ) { |
1022 $args = array_slice( func_get_args(), 3 ); |
|
1023 array_unshift( $args, $widget_id, $check_urls ); |
1123 array_unshift( $args, $widget_id, $check_urls ); |
1024 ob_start(); |
1124 ob_start(); |
1025 call_user_func_array( $callback, $args ); |
1125 call_user_func_array( $callback, $args ); |
1026 set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) |
1126 // Default lifetime in cache of 12 hours (same as the feeds). |
|
1127 set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); |
1027 } |
1128 } |
1028 |
1129 |
1029 return true; |
1130 return true; |
1030 } |
1131 } |
1031 |
1132 |
1032 // |
1133 // |
1033 // Dashboard Widgets Controls |
1134 // Dashboard Widgets Controls. |
1034 // |
1135 // |
1035 |
1136 |
1036 /** |
1137 /** |
1037 * Calls widget control callback. |
1138 * Calls widget control callback. |
1038 * |
1139 * |
1064 * from RSS-type widgets. |
1165 * from RSS-type widgets. |
1065 * |
1166 * |
1066 * @since 2.5.0 |
1167 * @since 2.5.0 |
1067 * |
1168 * |
1068 * @param string $widget_id |
1169 * @param string $widget_id |
1069 * @param array $form_inputs |
1170 * @param array $form_inputs |
1070 */ |
1171 */ |
1071 function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
1172 function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
1072 if ( ! $widget_options = get_option( 'dashboard_widget_options' ) ) { |
1173 $widget_options = get_option( 'dashboard_widget_options' ); |
|
1174 if ( ! $widget_options ) { |
1073 $widget_options = array(); |
1175 $widget_options = array(); |
1074 } |
1176 } |
1075 |
1177 |
1076 if ( ! isset( $widget_options[ $widget_id ] ) ) { |
1178 if ( ! isset( $widget_options[ $widget_id ] ) ) { |
1077 $widget_options[ $widget_id ] = array(); |
1179 $widget_options[ $widget_id ] = array(); |
1078 } |
1180 } |
1079 |
1181 |
1080 $number = 1; // Hack to use wp_widget_rss_form() |
1182 $number = 1; // Hack to use wp_widget_rss_form(). |
|
1183 |
1081 $widget_options[ $widget_id ]['number'] = $number; |
1184 $widget_options[ $widget_id ]['number'] = $number; |
1082 |
1185 |
1083 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) { |
1186 if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) { |
1084 $_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] ); |
1187 $_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] ); |
1085 $widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] ); |
1188 $widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] ); |
1086 $widget_options[ $widget_id ]['number'] = $number; |
1189 $widget_options[ $widget_id ]['number'] = $number; |
1087 |
1190 |
1088 // Title is optional. If black, fill it if possible. |
1191 // Title is optional. If black, fill it if possible. |
1288 <script id="tmpl-community-events-no-upcoming-events" type="text/template"> |
1391 <script id="tmpl-community-events-no-upcoming-events" type="text/template"> |
1289 <li class="event-none"> |
1392 <li class="event-none"> |
1290 <# if ( data.location.description ) { #> |
1393 <# if ( data.location.description ) { #> |
1291 <?php |
1394 <?php |
1292 printf( |
1395 printf( |
1293 /* translators: 1: the city the user searched for, 2: meetup organization documentation URL */ |
1396 /* translators: 1: The city the user searched for, 2: Meetup organization documentation URL. */ |
1294 __( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ), |
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>?' ), |
1295 '{{ data.location.description }}', |
1398 '{{ data.location.description }}', |
1296 __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
1399 __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
1297 ); |
1400 ); |
1298 ?> |
1401 ?> |
1299 |
1402 |
1300 <# } else { #> |
1403 <# } else { #> |
1301 <?php |
1404 <?php |
1302 printf( |
1405 printf( |
1303 /* translators: %s: meetup organization documentation URL */ |
1406 /* translators: %s: Meetup organization documentation URL. */ |
1304 __( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ), |
1407 __( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize a WordPress event</a>?' ), |
1305 __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
1408 __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
1306 ); |
1409 ); |
1307 ?> |
1410 ?> |
1308 <# } #> |
1411 <# } #> |
1309 </li> |
1412 </li> |
1479 </ul> |
1582 </ul> |
1480 </div> |
1583 </div> |
1481 <?php |
1584 <?php |
1482 } |
1585 } |
1483 |
1586 |
1484 // Display Browser Nag Meta Box |
1587 /** |
|
1588 * Displays the browser update nag. |
|
1589 * |
|
1590 * @since 3.2.0 |
|
1591 */ |
1485 function wp_dashboard_browser_nag() { |
1592 function wp_dashboard_browser_nag() { |
1486 $notice = ''; |
1593 $notice = ''; |
1487 $response = wp_check_browser_version(); |
1594 $response = wp_check_browser_version(); |
1488 |
1595 |
1489 if ( $response ) { |
1596 if ( $response ) { |
1490 if ( $response['insecure'] ) { |
1597 if ( $response['insecure'] ) { |
1491 /* translators: %s: browser name and link */ |
|
1492 $msg = sprintf( |
1598 $msg = sprintf( |
|
1599 /* translators: %s: Browser name and link. */ |
1493 __( "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." ), |
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." ), |
1494 sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
1601 sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
1495 ); |
1602 ); |
1496 } else { |
1603 } else { |
1497 /* translators: %s: browser name and link */ |
|
1498 $msg = sprintf( |
1604 $msg = sprintf( |
|
1605 /* translators: %s: Browser name and link. */ |
1499 __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ), |
1606 __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ), |
1500 sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
1607 sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
1501 ); |
1608 ); |
1502 } |
1609 } |
1503 |
1610 |
1514 $locale = get_user_locale(); |
1621 $locale = get_user_locale(); |
1515 if ( 'en_US' !== $locale ) { |
1622 if ( 'en_US' !== $locale ) { |
1516 $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
1623 $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
1517 } |
1624 } |
1518 |
1625 |
1519 $notice .= '<p>' . sprintf( __( '<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>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; |
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>'; |
1520 $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; |
1633 $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; |
1521 $notice .= '<div class="clear"></div>'; |
1634 $notice .= '<div class="clear"></div>'; |
1522 } |
1635 } |
1523 |
1636 |
1524 /** |
1637 /** |
1527 * @since 3.2.0 |
1640 * @since 3.2.0 |
1528 * |
1641 * |
1529 * @param string $notice The notice content. |
1642 * @param string $notice The notice content. |
1530 * @param array $response An array containing web browser information. See `wp_check_browser_version()`. |
1643 * @param array $response An array containing web browser information. See `wp_check_browser_version()`. |
1531 */ |
1644 */ |
1532 echo apply_filters( 'browse-happy-notice', $notice, $response ); |
1645 echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1533 } |
1646 } |
1534 |
1647 |
1535 /** |
1648 /** |
|
1649 * Adds an additional class to the browser nag if the current version is insecure. |
|
1650 * |
1536 * @since 3.2.0 |
1651 * @since 3.2.0 |
1537 * |
1652 * |
1538 * @param array $classes |
1653 * @param string[] $classes Array of meta box classes. |
1539 * @return array |
1654 * @return string[] Modified array of meta box classes. |
1540 */ |
1655 */ |
1541 function dashboard_browser_nag_class( $classes ) { |
1656 function dashboard_browser_nag_class( $classes ) { |
1542 $response = wp_check_browser_version(); |
1657 $response = wp_check_browser_version(); |
1543 |
1658 |
1544 if ( $response && $response['insecure'] ) { |
1659 if ( $response && $response['insecure'] ) { |
1547 |
1662 |
1548 return $classes; |
1663 return $classes; |
1549 } |
1664 } |
1550 |
1665 |
1551 /** |
1666 /** |
1552 * Check if the user needs a browser update |
1667 * Checks if the user needs a browser update. |
1553 * |
1668 * |
1554 * @since 3.2.0 |
1669 * @since 3.2.0 |
1555 * |
1670 * |
1556 * @return array|bool False on failure, array of browser data on success. |
1671 * @return array|bool Array of browser data on success, false on failure. |
1557 */ |
1672 */ |
1558 function wp_check_browser_version() { |
1673 function wp_check_browser_version() { |
1559 if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
1674 if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
1560 return false; |
1675 return false; |
1561 } |
1676 } |
1562 |
1677 |
1563 $key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
1678 $key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
1564 |
1679 |
1565 if ( false === ( $response = get_site_transient( 'browser_' . $key ) ) ) { |
1680 $response = get_site_transient( 'browser_' . $key ); |
1566 // include an unmodified $wp_version |
1681 if ( false === $response ) { |
1567 include( ABSPATH . WPINC . '/version.php' ); |
1682 // Include an unmodified $wp_version. |
|
1683 require ABSPATH . WPINC . '/version.php'; |
1568 |
1684 |
1569 $url = 'http://api.wordpress.org/core/browse-happy/1.1/'; |
1685 $url = 'http://api.wordpress.org/core/browse-happy/1.1/'; |
1570 $options = array( |
1686 $options = array( |
1571 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), |
1687 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), |
1572 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
1688 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
1664 |
1780 |
1665 return $classes; |
1781 return $classes; |
1666 } |
1782 } |
1667 |
1783 |
1668 /** |
1784 /** |
|
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 /** |
1669 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). |
1867 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). |
|
1868 * |
|
1869 * @since 2.5.0 |
1670 */ |
1870 */ |
1671 function wp_dashboard_empty() {} |
1871 function wp_dashboard_empty() {} |
1672 |
1872 |
1673 /** |
1873 /** |
1674 * Displays a welcome panel to introduce users to WordPress. |
1874 * Displays a welcome panel to introduce users to WordPress. |
1687 <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> |
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> |
1688 <?php endif; ?> |
1888 <?php endif; ?> |
1689 <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
1889 <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
1690 <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?> |
1890 <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?> |
1691 <?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?> |
1891 <?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?> |
1692 <p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p> |
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> |
1693 <?php endif; ?> |
1898 <?php endif; ?> |
1694 </div> |
1899 </div> |
1695 <div class="welcome-panel-column"> |
1900 <div class="welcome-panel-column"> |
1696 <h3><?php _e( 'Next Steps' ); ?></h3> |
1901 <h3><?php _e( 'Next Steps' ); ?></h3> |
1697 <ul> |
1902 <ul> |
1698 <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> |
1903 <?php if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> |
1699 <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> |
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> |
1700 <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> |
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> |
1701 <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?> |
1906 <?php elseif ( 'page' === get_option( 'show_on_front' ) ) : ?> |
1702 <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> |
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> |
1703 <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> |
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> |
1704 <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></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> |
1705 <?php else : ?> |
1910 <?php else : ?> |
1706 <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
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> |
1711 </ul> |
1916 </ul> |
1712 </div> |
1917 </div> |
1713 <div class="welcome-panel-column welcome-panel-last"> |
1918 <div class="welcome-panel-column welcome-panel-last"> |
1714 <h3><?php _e( 'More Actions' ); ?></h3> |
1919 <h3><?php _e( 'More Actions' ); ?></h3> |
1715 <ul> |
1920 <ul> |
1716 <?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?> |
1921 <?php if ( current_theme_supports( 'widgets' ) ) : ?> |
1717 <li><div class="welcome-icon welcome-widgets-menus"> |
1922 <li><?php printf( '<a href="%s" class="welcome-icon welcome-widgets">' . __( 'Manage widgets' ) . '</a>', admin_url( 'widgets.php' ) ); ?></li> |
1718 <?php |
1923 <?php endif; ?> |
1719 if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) { |
1924 <?php if ( current_theme_supports( 'menus' ) ) : ?> |
1720 printf( |
1925 <li><?php printf( '<a href="%s" class="welcome-icon welcome-menus">' . __( 'Manage menus' ) . '</a>', admin_url( 'nav-menus.php' ) ); ?></li> |
1721 __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ), |
|
1722 admin_url( 'widgets.php' ), |
|
1723 admin_url( 'nav-menus.php' ) |
|
1724 ); |
|
1725 } elseif ( current_theme_supports( 'widgets' ) ) { |
|
1726 echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>'; |
|
1727 } else { |
|
1728 echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>'; |
|
1729 } |
|
1730 ?> |
|
1731 </div></li> |
|
1732 <?php endif; ?> |
1926 <?php endif; ?> |
1733 <?php if ( current_user_can( 'manage_options' ) ) : ?> |
1927 <?php if ( current_user_can( 'manage_options' ) ) : ?> |
1734 <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li> |
1928 <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li> |
1735 <?php endif; ?> |
1929 <?php endif; ?> |
1736 <li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li> |
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> |
1737 </ul> |
1931 </ul> |
1738 </div> |
1932 </div> |
1739 </div> |
1933 </div> |
1740 </div> |
1934 </div> |
1741 <?php |
1935 <?php |