@@ -409,12 +426,12 @@
$c_users = get_user_count();
$c_blogs = get_blog_count();
- /* translators: %s: number of users on the network */
+ /* translators: %s: Number of users on the network. */
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
- /* translators: %s: number of sites on the network */
+ /* translators: %s: Number of sites on the network. */
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
- /* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
+ /* translators: 1: Text indicating the number of sites on the network, 2: Text indicating the number of users on the network. */
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
@@ -489,21 +506,21 @@
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
- $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
+ $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID.
if ( $last_post_id ) {
$post = get_post( $last_post_id );
- if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
+ if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore.
$post = get_default_post_to_edit( 'post', true );
- update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+ update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
} else {
- $post->post_title = ''; // Remove the auto draft title
+ $post->post_title = ''; // Remove the auto draft title.
}
} else {
$post = get_default_post_to_edit( 'post', true );
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
- if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
- update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+ if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) {
+ update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
}
}
@@ -580,19 +597,33 @@
echo '
";
+ /* translators: Maximum number of words used in a preview of a draft on the dashboard. */
+ $draft_length = intval( _x( '10', 'draft_length' ) );
+
$drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
echo "
' . get_comment_author_link( $comment ) . '', $comment_post_link, @@ -711,7 +809,7 @@ ); } else { printf( - /* translators: 1: comment author, 2: notification if the comment is pending */ + /* translators: 1: Comment author, 2: Notification if the comment is pending. */ __( 'From %1$s %2$s' ), '' . get_comment_author_link( $comment ) . '', '' . __( '[Pending]' ) . '' @@ -740,7 +838,7 @@ // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones. if ( $comment_post_link ) { printf( - /* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */ + /* translators: 1: Type of comment, 2: Post link, 3: Notification if the comment is pending. */ _x( '%1$s on %2$s %3$s', 'dashboard' ), "$type", $comment_post_link, @@ -748,7 +846,7 @@ ); } else { printf( - /* translators: 1: type of comment, 2: notification if the comment is pending */ + /* translators: 1: Type of comment, 2: Notification if the comment is pending. */ _x( '%1$s %2$s', 'dashboard' ), "$type", '' . __( '[Pending]' ) . '' @@ -801,7 +899,6 @@ if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) { echo '
' . __( 'No activity yet!' ) . '
'; echo ''; $today = current_time( 'Y-m-d' ); - $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); + $tomorrow = current_datetime()->modify( '+1 day' )->format( 'Y-m-d' ); $year = current_time( 'Y' ); while ( $posts->have_posts() ) { $posts->the_post(); $time = get_the_time( 'U' ); - if ( date( 'Y-m-d', $time ) == $today ) { + if ( gmdate( 'Y-m-d', $time ) == $today ) { $relative = __( 'Today' ); - } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { + } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) { $relative = __( 'Tomorrow' ); - } elseif ( date( 'Y', $time ) !== $year ) { - /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */ + } elseif ( gmdate( 'Y', $time ) !== $year ) { + /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/date */ $relative = date_i18n( __( 'M jS Y' ), $time ); } else { - /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */ + /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/date */ $relative = date_i18n( __( 'M jS' ), $time ); } @@ -881,10 +978,10 @@ $draft_or_post_title = _draft_or_post_title(); printf( '- %1$s %4$s
',
- /* translators: 1: relative date, 2: time */
+ /* translators: 1: Relative date, 2: Time. */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
$recent_post_link,
- /* translators: %s: post title */
+ /* translators: %s: Post title. */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
$draft_or_post_title
);
@@ -987,14 +1084,17 @@
* which is later replaced by Ajax call (see top of /wp-admin/index.php)
*
* @since 2.5.0
+ * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
+ * by adding it to the function signature.
*
- * @param string $widget_id
- * @param callable $callback
- * @param array $check_urls RSS feeds
- * @return bool False on failure. True on success.
+ * @param string $widget_id The widget ID.
+ * @param callable $callback The callback function used to display each feed.
+ * @param array $check_urls RSS feeds.
+ * @param mixed ...$args Optional additional parameters to pass to the callback function.
+ * @return bool True on success, false on failure.
*/
-function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
- $loading = ' ';
+function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) {
+ $loading = ' ';
$doing_ajax = wp_doing_ajax();
if ( empty( $check_urls ) ) {
@@ -1008,7 +1108,8 @@
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
- if ( false !== ( $output = get_transient( $cache_key ) ) ) {
+ $output = get_transient( $cache_key );
+ if ( false !== $output ) {
echo $output;
return true;
}
@@ -1019,18 +1120,18 @@
}
if ( $callback && is_callable( $callback ) ) {
- $args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
- set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
+ // Default lifetime in cache of 12 hours (same as the feeds).
+ set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS );
}
return true;
}
//
-// Dashboard Widgets Controls
+// Dashboard Widgets Controls.
//
/**
@@ -1066,10 +1167,11 @@
* @since 2.5.0
*
* @param string $widget_id
- * @param array $form_inputs
+ * @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
- if ( ! $widget_options = get_option( 'dashboard_widget_options' ) ) {
+ $widget_options = get_option( 'dashboard_widget_options' );
+ if ( ! $widget_options ) {
$widget_options = array();
}
@@ -1077,10 +1179,11 @@
$widget_options[ $widget_id ] = array();
}
- $number = 1; // Hack to use wp_widget_rss_form()
+ $number = 1; // Hack to use wp_widget_rss_form().
+
$widget_options[ $widget_id ]['number'] = $number;
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
+ if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
$_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] );
$widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
$widget_options[ $widget_id ]['number'] = $number;
@@ -1126,7 +1229,7 @@
'%2$s %3$s',
'https://make.wordpress.org/community/meetups-landing-page',
__( 'Meetups' ),
- /* translators: accessibility text */
+ /* translators: Accessibility text. */
__( '(opens in a new tab)' )
);
?>
@@ -1138,7 +1241,7 @@
'%2$s %3$s',
'https://central.wordcamp.org/schedule/',
__( 'WordCamps' ),
- /* translators: accessibility text */
+ /* translators: Accessibility text. */
__( '(opens in a new tab)' )
);
?>
@@ -1151,7 +1254,7 @@
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
__( 'News' ),
- /* translators: accessibility text */
+ /* translators: Accessibility text. */
__( '(opens in a new tab)' )
);
?>
@@ -1243,7 +1346,7 @@
' . __( 'Loading…' ) . '
' . __( 'This widget requires JavaScript.' ) . '
' . __( 'Loading…' ) . '
' . __( 'This widget requires JavaScript.' ) . '