<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50689] trunk/src/wp-admin/includes/dashboard.php: Coding Standards: Use strict comparison in `wp-admin/includes/dashboard.php`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50689">50689</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50689","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-04-07 18:32:01 +0000 (Wed, 07 Apr 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Coding Standards: Use strict comparison in `wp-admin/includes/dashboard.php`.
Includes minor code layout fixes for better readability.
See <a href="https://core.trac.wordpress.org/ticket/52627">#52627</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesdashboardphp">trunk/src/wp-admin/includes/dashboard.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesdashboardphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/dashboard.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/dashboard.php 2021-04-07 17:42:36 UTC (rev 50688)
+++ trunk/src/wp-admin/includes/dashboard.php 2021-04-07 18:32:01 UTC (rev 50689)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -19,6 +19,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_dashboard_setup() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_dashboard_control_callbacks = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $screen = get_current_screen();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,6 +29,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $response && $response['upgrade'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $response['insecure'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -37,8 +39,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // PHP Version.
</span><span class="cx" style="display: block; padding: 0 10px"> $response = wp_check_php_version();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable']
+ && current_user_can( 'update_php' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,9 +180,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Accepts 'high', 'core', 'default', or 'low'. Default 'core'.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null, $context = 'normal', $priority = 'core' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $screen = get_current_screen();
</del><span class="cx" style="display: block; padding: 0 10px"> global $wp_dashboard_control_callbacks;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $screen = get_current_screen();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $private_callback_args = array( '__widget_basename' => $widget_name );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_null( $callback_args ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -185,9 +192,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_args = array_merge( $callback_args, $private_callback_args );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $control_callback && is_callable( $control_callback ) && current_user_can( 'edit_dashboard' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_dashboard_control_callbacks[ $widget_id ] = $control_callback;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( isset( $_GET['edit'] ) && $widget_id === $_GET['edit'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '_wp_dashboard_control_callback';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -212,6 +220,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $context ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $context = 'normal';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $priority ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $priority = 'core';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -246,10 +255,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $screen = get_current_screen();
</span><span class="cx" style="display: block; padding: 0 10px"> $columns = absint( $screen->get_columns() );
</span><span class="cx" style="display: block; padding: 0 10px"> $columns_css = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $columns ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $columns_css = " columns-$columns";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="postbox-container-1" class="postbox-container">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -291,6 +300,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Posts and Pages.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( array( 'post', 'page' ) as $post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $num_posts = wp_count_posts( $post_type );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $num_posts && $num_posts->publish ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'post' === $post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Number of posts. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -299,8 +309,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Number of pages. */
</span><span class="cx" style="display: block; padding: 0 10px"> $text = _n( '%s Page', '%s Pages', $num_posts->publish );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_type_object = get_post_type_object( $post_type );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -308,26 +320,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Comments.
</span><span class="cx" style="display: block; padding: 0 10px"> $num_comm = wp_count_comments();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Number of comments. */
</span><span class="cx" style="display: block; padding: 0 10px"> $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <li class="comment-count">
+ <a href="edit-comments.php"><?php echo $text; ?></a>
+ </li>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Number of comments. */
</span><span class="cx" style="display: block; padding: 0 10px"> $text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <li class="comment-mod-count
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <li class="comment-mod-count<?php echo ! $num_comm->moderated ? ' hidden' : ''; ?>">
+ <a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a>
+ </li>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $num_comm->moderated ) {
- echo ' hidden';
- }
- ?>
- "><a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a></li>
- <?php
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -353,7 +365,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update_right_now_message();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check if search engines are asked not to index this site.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_network_admin() && ! is_user_admin()
+ && current_user_can( 'manage_options' ) && ! get_option( 'blog_public' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the link title attribute for the 'Search engines discouraged'
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -378,7 +392,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $content Default text.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $content = apply_filters( 'privacy_on_link_text', __( 'Search engines discouraged' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content = apply_filters( 'privacy_on_link_text', __( 'Search engines discouraged' ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $title_attr = '' === $title ? '' : " title='$title'";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo "<p class='search-engines-info'><a href='options-reading.php'$title_attr>$content</a></p>";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -426,6 +441,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_network_dashboard_right_now() {
</span><span class="cx" style="display: block; padding: 0 10px"> $actions = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( current_user_can( 'create_sites' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -515,10 +531,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check if a new auto-draft (= no new post_ID) is needed or if the old can be used.
</ins><span class="cx" style="display: block; padding: 0 10px"> $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $last_post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $last_post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore.
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_default_post_to_edit( 'post', true );
</span><span class="cx" style="display: block; padding: 0 10px"> update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -528,6 +546,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_default_post_to_edit( 'post', true );
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = get_current_user_id();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Don't create an option if this is a super admin who does not belong to this site.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -606,6 +625,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<div class="drafts">';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( count( $drafts ) > 3 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> printf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<p class="view-all"><a href="%s">%s</a></p>' . "\n",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -613,8 +633,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> __( 'View all drafts' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n";
+ echo '<ul>';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /* translators: Maximum number of words used in a preview of a draft on the dashboard. */
</span><span class="cx" style="display: block; padding: 0 10px"> $draft_length = (int) _x( '10', 'draft_length' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -622,6 +644,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $drafts as $draft ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = get_edit_post_link( $draft->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $title = _draft_or_post_title( $draft->ID );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> echo "<li>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> printf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="draft-title"><a href="%s" aria-label="%s">%s</a><time datetime="%s">%s</time></div>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -632,13 +655,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> get_the_time( 'c', $draft ),
</span><span class="cx" style="display: block; padding: 0 10px"> get_the_time( __( 'F j, Y' ), $draft )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $the_content = wp_trim_words( $draft->post_content, $draft_length );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $the_content ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<p>' . $the_content . '</p>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> echo "</li>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo "</ul>\n</div>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ echo "</ul>\n";
+ echo '</div>';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -656,7 +683,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['comment'] = clone $comment;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $comment->comment_post_ID > 0 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_post_url = get_the_permalink( $comment->comment_post_ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -952,8 +978,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $posts = new WP_Query( $query_args );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $posts = new WP_Query( $query_args );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $posts->have_posts() ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<div id="' . $args['id'] . '" class="activity-block">';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -970,9 +997,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $posts->the_post();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $time = get_the_time( 'U' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( gmdate( 'Y-m-d', $time ) == $today ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( gmdate( 'Y-m-d', $time ) === $today ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $relative = __( 'Today' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $relative = __( 'Tomorrow' );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( gmdate( 'Y', $time ) !== $year ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1025,6 +1053,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'number' => $total_items * 5,
</span><span class="cx" style="display: block; padding: 0 10px"> 'offset' => 0,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_posts' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $comments_query['status'] = 'approve';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1033,15 +1062,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $possible ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $possible as $comment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $comments[] = $comment;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( count( $comments ) == $total_items ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( count( $comments ) === $total_items ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> break 2;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $comments_query['offset'] += $comments_query['number'];
</span><span class="cx" style="display: block; padding: 0 10px"> $comments_query['number'] = $total_items * 10;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1109,10 +1142,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $check_urls ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $widgets = get_option( 'dashboard_widget_options' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo $loading;
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $check_urls = array( $widgets[ $widget_id ]['url'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1119,6 +1154,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $locale = get_user_locale();
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_transient( $cache_key );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false !== $output ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo $output;
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1156,7 +1192,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_dashboard_control_callbacks;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 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 ] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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 ] )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> call_user_func(
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_dashboard_control_callbacks[ $widget_control_id ],
</span><span class="cx" style="display: block; padding: 0 10px"> '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1181,6 +1220,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $widget_options = get_option( 'dashboard_widget_options' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $widget_options ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $widget_options = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1209,7 +1249,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $rss );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> update_option( 'dashboard_widget_options', $widget_options );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $locale = get_user_locale();
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
</span><span class="cx" style="display: block; padding: 0 10px"> delete_transient( $cache_key );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1554,7 +1596,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return true|void True if not multisite, user can't upload files, or the space check option is disabled.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_dashboard_quota() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_multisite() || ! current_user_can( 'upload_files' )
+ || get_site_option( 'upload_space_check_disabled' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1566,6 +1610,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $percentused = ( $used / $quota ) * 100;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $used_class = ( $percentused >= 70 ) ? ' warning' : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $used = round( $used, 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $percentused = number_format( $percentused );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1703,6 +1748,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $key = md5( $_SERVER['HTTP_USER_AGENT'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = get_site_transient( 'browser_' . $key );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === $response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Include an unmodified $wp_version.
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/version.php';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1719,7 +1765,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = wp_remote_post( $url, $options );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>