wp/wp-admin/includes/dashboard.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    18  * @global callable[] $wp_dashboard_control_callbacks
    18  * @global callable[] $wp_dashboard_control_callbacks
    19  */
    19  */
    20 function wp_dashboard_setup() {
    20 function wp_dashboard_setup() {
    21 	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
    21 	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
    22 
    22 
       
    23 	$screen = get_current_screen();
       
    24 
       
    25 	/* Register Widgets and Controls */
    23 	$wp_dashboard_control_callbacks = array();
    26 	$wp_dashboard_control_callbacks = array();
    24 	$screen                         = get_current_screen();
    27 
    25 
    28 	// Browser version
    26 	/* Register Widgets and Controls */
    29 	$check_browser = wp_check_browser_version();
    27 
    30 
    28 	$response = wp_check_browser_version();
    31 	if ( $check_browser && $check_browser['upgrade'] ) {
    29 
       
    30 	if ( $response && $response['upgrade'] ) {
       
    31 		add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
    32 		add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
    32 
    33 
    33 		if ( $response['insecure'] ) {
    34 		if ( $check_browser['insecure'] ) {
    34 			wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
    35 			wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
    35 		} else {
    36 		} else {
    36 			wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
    37 			wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
    37 		}
    38 		}
    38 	}
    39 	}
    39 
    40 
    40 	// PHP Version.
    41 	// PHP Version.
    41 	$response = wp_check_php_version();
    42 	$check_php = wp_check_php_version();
    42 
    43 
    43 	if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable']
    44 	if ( $check_php && current_user_can( 'update_php' ) ) {
    44 		&& current_user_can( 'update_php' )
    45 		// If "not acceptable" the widget will be shown.
    45 	) {
    46 		if ( isset( $check_php['is_acceptable'] ) && ! $check_php['is_acceptable'] ) {
    46 		add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
    47 			add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
    47 
    48 
    48 		wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
    49 			if ( $check_php['is_lower_than_future_minimum'] ) {
       
    50 				wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
       
    51 			} else {
       
    52 				wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
       
    53 			}
       
    54 		}
    49 	}
    55 	}
    50 
    56 
    51 	// Site Health.
    57 	// Site Health.
    52 	if ( current_user_can( 'view_site_health_checks' ) && ! is_network_admin() ) {
    58 	if ( current_user_can( 'view_site_health_checks' ) && ! is_network_admin() ) {
    53 		if ( ! class_exists( 'WP_Site_Health' ) ) {
    59 		if ( ! class_exists( 'WP_Site_Health' ) ) {
   276 </div>
   282 </div>
   277 
   283 
   278 	<?php
   284 	<?php
   279 	wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
   285 	wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
   280 	wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
   286 	wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
   281 
       
   282 }
   287 }
   283 
   288 
   284 //
   289 //
   285 // Dashboard Widgets.
   290 // Dashboard Widgets.
   286 //
   291 //
   484 		do_action( 'wpmuadminresult' );
   489 		do_action( 'wpmuadminresult' );
   485 	?>
   490 	?>
   486 
   491 
   487 	<form action="<?php echo esc_url( network_admin_url( 'users.php' ) ); ?>" method="get">
   492 	<form action="<?php echo esc_url( network_admin_url( 'users.php' ) ); ?>" method="get">
   488 		<p>
   493 		<p>
   489 			<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
   494 			<label class="screen-reader-text" for="search-users">
       
   495 				<?php
       
   496 				/* translators: Hidden accessibility text. */
       
   497 				_e( 'Search Users' );
       
   498 				?>
       
   499 			</label>
   490 			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users" />
   500 			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users" />
   491 			<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
   501 			<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
   492 		</p>
   502 		</p>
   493 	</form>
   503 	</form>
   494 
   504 
   495 	<form action="<?php echo esc_url( network_admin_url( 'sites.php' ) ); ?>" method="get">
   505 	<form action="<?php echo esc_url( network_admin_url( 'sites.php' ) ); ?>" method="get">
   496 		<p>
   506 		<p>
   497 			<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
   507 			<label class="screen-reader-text" for="search-sites">
       
   508 				<?php
       
   509 				/* translators: Hidden accessibility text. */
       
   510 				_e( 'Search Sites' );
       
   511 				?>
       
   512 			</label>
   498 			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites" />
   513 			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites" />
   499 			<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
   514 			<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
   500 		</p>
   515 		</p>
   501 	</form>
   516 	</form>
   502 	<?php
   517 	<?php
   514 	 */
   529 	 */
   515 	do_action( 'mu_activity_box_end' );
   530 	do_action( 'mu_activity_box_end' );
   516 }
   531 }
   517 
   532 
   518 /**
   533 /**
   519  * The Quick Draft widget display and creation of drafts.
   534  * Displays the Quick Draft widget.
   520  *
   535  *
   521  * @since 3.8.0
   536  * @since 3.8.0
   522  *
   537  *
   523  * @global int $post_ID
   538  * @global int $post_ID
   524  *
   539  *
   556 	$post_ID = (int) $post->ID;
   571 	$post_ID = (int) $post->ID;
   557 	?>
   572 	?>
   558 
   573 
   559 	<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
   574 	<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
   560 
   575 
   561 		<?php if ( $error_msg ) : ?>
   576 		<?php
   562 		<div class="error"><?php echo $error_msg; ?></div>
   577 		if ( $error_msg ) {
   563 		<?php endif; ?>
   578 			wp_admin_notice(
       
   579 				$error_msg,
       
   580 				array(
       
   581 					'additional_classes' => array( 'error' ),
       
   582 				)
       
   583 			);
       
   584 		}
       
   585 		?>
   564 
   586 
   565 		<div class="input-text-wrap" id="title-wrap">
   587 		<div class="input-text-wrap" id="title-wrap">
   566 			<label for="title">
   588 			<label for="title">
   567 				<?php
   589 				<?php
   568 				/** This filter is documented in wp-admin/edit-form-advanced.php */
   590 				/** This filter is documented in wp-admin/edit-form-advanced.php */
   797 			++$i;
   819 			++$i;
   798 
   820 
   799 			if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
   821 			if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
   800 				|| 1 === $i
   822 				|| 1 === $i
   801 			) {
   823 			) {
   802 				$sep = '';
   824 				$separator = '';
   803 			} else {
   825 			} else {
   804 				$sep = ' | ';
   826 				$separator = ' | ';
   805 			}
   827 			}
   806 
   828 
   807 			// Reply and quickedit need a hide-if-no-js span.
   829 			// Reply and quickedit need a hide-if-no-js span.
   808 			if ( 'reply' === $action || 'quickedit' === $action ) {
   830 			if ( 'reply' === $action || 'quickedit' === $action ) {
   809 				$action .= ' hide-if-no-js';
   831 				$action .= ' hide-if-no-js';
   811 
   833 
   812 			if ( 'view' === $action && '1' !== $comment->comment_approved ) {
   834 			if ( 'view' === $action && '1' !== $comment->comment_approved ) {
   813 				$action .= ' hidden';
   835 				$action .= ' hidden';
   814 			}
   836 			}
   815 
   837 
   816 			$actions_string .= "<span class='$action'>$sep$link</span>";
   838 			$actions_string .= "<span class='$action'>{$separator}{$link}</span>";
   817 		}
   839 		}
   818 	}
   840 	}
   819 	?>
   841 	?>
   820 
   842 
   821 		<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
   843 		<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
   902 	<?php
   924 	<?php
   903 	$GLOBALS['comment'] = null;
   925 	$GLOBALS['comment'] = null;
   904 }
   926 }
   905 
   927 
   906 /**
   928 /**
   907  * Callback function for Activity widget.
   929  * Outputs the Activity widget.
       
   930  *
       
   931  * Callback function for {@see 'dashboard_activity'}.
   908  *
   932  *
   909  * @since 3.8.0
   933  * @since 3.8.0
   910  */
   934  */
   911 function wp_dashboard_site_activity() {
   935 function wp_dashboard_site_activity() {
   912 
   936 
   964 		'post_status'    => $args['status'],
   988 		'post_status'    => $args['status'],
   965 		'orderby'        => 'date',
   989 		'orderby'        => 'date',
   966 		'order'          => $args['order'],
   990 		'order'          => $args['order'],
   967 		'posts_per_page' => (int) $args['max'],
   991 		'posts_per_page' => (int) $args['max'],
   968 		'no_found_rows'  => true,
   992 		'no_found_rows'  => true,
   969 		'cache_results'  => false,
   993 		'cache_results'  => true,
   970 		'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
   994 		'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
   971 	);
   995 	);
   972 
   996 
   973 	/**
   997 	/**
   974 	 * Filters the query arguments used for the Recent Posts widget.
   998 	 * Filters the query arguments used for the Recent Posts widget.
  1062 		if ( ! is_array( $possible ) ) {
  1086 		if ( ! is_array( $possible ) ) {
  1063 			break;
  1087 			break;
  1064 		}
  1088 		}
  1065 
  1089 
  1066 		foreach ( $possible as $comment ) {
  1090 		foreach ( $possible as $comment ) {
  1067 			if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
  1091 			if ( ! current_user_can( 'edit_post', $comment->comment_post_ID )
       
  1092 				&& ( post_password_required( $comment->comment_post_ID )
       
  1093 					|| ! current_user_can( 'read_post', $comment->comment_post_ID ) )
       
  1094 			) {
       
  1095 				// The user has no access to the post and thus cannot see the comments.
  1068 				continue;
  1096 				continue;
  1069 			}
  1097 			}
  1070 
  1098 
  1071 			$comments[] = $comment;
  1099 			$comments[] = $comment;
  1072 
  1100 
  1088 			_wp_dashboard_recent_comments_row( $comment );
  1116 			_wp_dashboard_recent_comments_row( $comment );
  1089 		}
  1117 		}
  1090 		echo '</ul>';
  1118 		echo '</ul>';
  1091 
  1119 
  1092 		if ( current_user_can( 'edit_posts' ) ) {
  1120 		if ( current_user_can( 'edit_posts' ) ) {
  1093 			echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
  1121 			echo '<h3 class="screen-reader-text">' .
       
  1122 				/* translators: Hidden accessibility text. */
       
  1123 				__( 'View more comments' ) .
       
  1124 			'</h3>';
  1094 			_get_list_table( 'WP_Comments_List_Table' )->views();
  1125 			_get_list_table( 'WP_Comments_List_Table' )->views();
  1095 		}
  1126 		}
  1096 
  1127 
  1097 		wp_comment_reply( -1, false, 'dashboard', false );
  1128 		wp_comment_reply( -1, false, 'dashboard', false );
  1098 		wp_comment_trashnotice();
  1129 		wp_comment_trashnotice();
  1135  * @param array    $check_urls RSS feeds.
  1166  * @param array    $check_urls RSS feeds.
  1136  * @param mixed    ...$args    Optional additional parameters to pass to the callback function.
  1167  * @param mixed    ...$args    Optional additional parameters to pass to the callback function.
  1137  * @return bool True on success, false on failure.
  1168  * @return bool True on success, false on failure.
  1138  */
  1169  */
  1139 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) {
  1170 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) {
  1140 	$loading    = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&hellip;' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
       
  1141 	$doing_ajax = wp_doing_ajax();
  1171 	$doing_ajax = wp_doing_ajax();
       
  1172 	$loading    = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&hellip;' ) . '</p>';
       
  1173 	$loading   .= wp_get_admin_notice(
       
  1174 		__( 'This widget requires JavaScript.' ),
       
  1175 		array(
       
  1176 			'type'               => 'error',
       
  1177 			'additional_classes' => array( 'inline', 'hide-if-js' ),
       
  1178 		)
       
  1179 	);
  1142 
  1180 
  1143 	if ( empty( $check_urls ) ) {
  1181 	if ( empty( $check_urls ) ) {
  1144 		$widgets = get_option( 'dashboard_widget_options' );
  1182 		$widgets = get_option( 'dashboard_widget_options' );
  1145 
  1183 
  1146 		if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
  1184 		if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
  1206 		);
  1244 		);
  1207 	}
  1245 	}
  1208 }
  1246 }
  1209 
  1247 
  1210 /**
  1248 /**
  1211  * The RSS dashboard widget control.
  1249  * Sets up the RSS dashboard widget control and $args to be used as input to wp_widget_rss_form().
  1212  *
  1250  *
  1213  * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
  1251  * Handles POST data from RSS-type widgets.
  1214  * from RSS-type widgets.
       
  1215  *
  1252  *
  1216  * @since 2.5.0
  1253  * @since 2.5.0
  1217  *
  1254  *
  1218  * @param string $widget_id
  1255  * @param string $widget_id
  1219  * @param array  $form_inputs
  1256  * @param array  $form_inputs
  1276 	</div>
  1313 	</div>
  1277 
  1314 
  1278 	<p class="community-events-footer">
  1315 	<p class="community-events-footer">
  1279 		<?php
  1316 		<?php
  1280 			printf(
  1317 			printf(
  1281 				'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1318 				'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1282 				'https://make.wordpress.org/community/meetups-landing-page',
  1319 				'https://make.wordpress.org/community/meetups-landing-page',
  1283 				__( 'Meetups' ),
  1320 				__( 'Meetups' ),
  1284 				/* translators: Accessibility text. */
  1321 				/* translators: Hidden accessibility text. */
  1285 				__( '(opens in a new tab)' )
  1322 				__( '(opens in a new tab)' )
  1286 			);
  1323 			);
  1287 		?>
  1324 		?>
  1288 
  1325 
  1289 		|
  1326 		|
  1290 
  1327 
  1291 		<?php
  1328 		<?php
  1292 			printf(
  1329 			printf(
  1293 				'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1330 				'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1294 				'https://central.wordcamp.org/schedule/',
  1331 				'https://central.wordcamp.org/schedule/',
  1295 				__( 'WordCamps' ),
  1332 				__( 'WordCamps' ),
  1296 				/* translators: Accessibility text. */
  1333 				/* translators: Hidden accessibility text. */
  1297 				__( '(opens in a new tab)' )
  1334 				__( '(opens in a new tab)' )
  1298 			);
  1335 			);
  1299 		?>
  1336 		?>
  1300 
  1337 
  1301 		|
  1338 		|
  1302 
  1339 
  1303 		<?php
  1340 		<?php
  1304 			printf(
  1341 			printf(
  1305 				'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1342 				'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1306 				/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
  1343 				/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
  1307 				esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
  1344 				esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
  1308 				__( 'News' ),
  1345 				__( 'News' ),
  1309 				/* translators: Accessibility text. */
  1346 				/* translators: Hidden accessibility text. */
  1310 				__( '(opens in a new tab)' )
  1347 				__( '(opens in a new tab)' )
  1311 			);
  1348 			);
  1312 		?>
  1349 		?>
  1313 	</p>
  1350 	</p>
  1314 
  1351 
  1319  * Prints the markup for the Community Events section of the Events and News Dashboard widget.
  1356  * Prints the markup for the Community Events section of the Events and News Dashboard widget.
  1320  *
  1357  *
  1321  * @since 4.8.0
  1358  * @since 4.8.0
  1322  */
  1359  */
  1323 function wp_print_community_events_markup() {
  1360 function wp_print_community_events_markup() {
  1324 	?>
  1361 	$community_events_notice  = '<p class="hide-if-js">' . ( 'This widget requires JavaScript.' ) . '</p>';
  1325 
  1362 	$community_events_notice .= '<p class="community-events-error-occurred" aria-hidden="true">' . __( 'An error occurred. Please try again.' ) . '</p>';
  1326 	<div class="community-events-errors notice notice-error inline hide-if-js">
  1363 	$community_events_notice .= '<p class="community-events-could-not-locate" aria-hidden="true"></p>';
  1327 		<p class="hide-if-js">
  1364 
  1328 			<?php _e( 'This widget requires JavaScript.' ); ?>
  1365 	wp_admin_notice(
  1329 		</p>
  1366 		$community_events_notice,
  1330 
  1367 		array(
  1331 		<p class="community-events-error-occurred" aria-hidden="true">
  1368 			'type'               => 'error',
  1332 			<?php _e( 'An error occurred. Please try again.' ); ?>
  1369 			'additional_classes' => array( 'community-events-errors', 'inline', 'hide-if-js' ),
  1333 		</p>
  1370 			'paragraph_wrap'     => false,
  1334 
  1371 		)
  1335 		<p class="community-events-could-not-locate" aria-hidden="true"></p>
  1372 	);
  1336 	</div>
  1373 
  1337 
       
  1338 	<div class="community-events-loading hide-if-no-js">
       
  1339 		<?php _e( 'Loading&hellip;' ); ?>
       
  1340 	</div>
       
  1341 
       
  1342 	<?php
       
  1343 	/*
  1374 	/*
  1344 	 * Hide the main element when the page first loads, because the content
  1375 	 * Hide the main element when the page first loads, because the content
  1345 	 * won't be ready until wp.communityEvents.renderEventsTemplate() has run.
  1376 	 * won't be ready until wp.communityEvents.renderEventsTemplate() has run.
  1346 	 */
  1377 	 */
  1347 	?>
  1378 	?>
  1425 			<li class="event event-{{ event.type }} wp-clearfix">
  1456 			<li class="event event-{{ event.type }} wp-clearfix">
  1426 				<div class="event-info">
  1457 				<div class="event-info">
  1427 					<div class="dashicons event-icon" aria-hidden="true"></div>
  1458 					<div class="dashicons event-icon" aria-hidden="true"></div>
  1428 					<div class="event-info-inner">
  1459 					<div class="event-info-inner">
  1429 						<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
  1460 						<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
       
  1461 						<# if ( event.type ) {
       
  1462 							const titleCaseEventType = event.type.replace(
       
  1463 								/\w\S*/g,
       
  1464 								function ( type ) { return type.charAt(0).toUpperCase() + type.substr(1).toLowerCase(); }
       
  1465 							);
       
  1466 						#>
       
  1467 							{{ 'wordcamp' === event.type ? 'WordCamp' : titleCaseEventType }}
       
  1468 							<span class="ce-separator"></span>
       
  1469 						<# } #>
  1430 						<span class="event-city">{{ event.location.location }}</span>
  1470 						<span class="event-city">{{ event.location.location }}</span>
  1431 					</div>
  1471 					</div>
  1432 				</div>
  1472 				</div>
  1433 
  1473 
  1434 				<div class="event-date-time">
  1474 				<div class="event-date-time">
  1530 			 *
  1570 			 *
  1531 			 * @since 2.3.0
  1571 			 * @since 2.3.0
  1532 			 *
  1572 			 *
  1533 			 * @param string $link The widget's secondary link URL.
  1573 			 * @param string $link The widget's secondary link URL.
  1534 			 */
  1574 			 */
  1535 			'link'         => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
  1575 			'link'         => apply_filters(
       
  1576 				'dashboard_secondary_link',
       
  1577 				/* translators: Link to the Planet website of the locale. */
       
  1578 				__( 'https://planet.wordpress.org/' )
       
  1579 			),
  1536 
  1580 
  1537 			/**
  1581 			/**
  1538 			 * Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
  1582 			 * Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
  1539 			 *
  1583 			 *
  1540 			 * @since 2.3.0
  1584 			 * @since 2.3.0
  1541 			 *
  1585 			 *
  1542 			 * @param string $url The widget's secondary feed URL.
  1586 			 * @param string $url The widget's secondary feed URL.
  1543 			 */
  1587 			 */
  1544 			'url'          => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
  1588 			'url'          => apply_filters(
       
  1589 				'dashboard_secondary_feed',
       
  1590 				/* translators: Link to the Planet feed of the locale. */
       
  1591 				__( 'https://planet.wordpress.org/feed/' )
       
  1592 			),
  1545 
  1593 
  1546 			/**
  1594 			/**
  1547 			 * Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
  1595 			 * Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
  1548 			 *
  1596 			 *
  1549 			 * @since 2.3.0
  1597 			 * @since 2.3.0
  1626 				/* translators: %s: Number of megabytes. */
  1674 				/* translators: %s: Number of megabytes. */
  1627 				__( '%s MB Space Allowed' ),
  1675 				__( '%s MB Space Allowed' ),
  1628 				number_format_i18n( $quota )
  1676 				number_format_i18n( $quota )
  1629 			);
  1677 			);
  1630 			printf(
  1678 			printf(
  1631 				'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
  1679 				'<a href="%1$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
  1632 				esc_url( admin_url( 'upload.php' ) ),
  1680 				esc_url( admin_url( 'upload.php' ) ),
  1633 				$text,
  1681 				$text,
       
  1682 				/* translators: Hidden accessibility text. */
  1634 				__( 'Manage Uploads' )
  1683 				__( 'Manage Uploads' )
  1635 			);
  1684 			);
  1636 			?>
  1685 			?>
  1637 		</li><li class="storage-count <?php echo $used_class; ?>">
  1686 		</li><li class="storage-count <?php echo $used_class; ?>">
  1638 			<?php
  1687 			<?php
  1641 				__( '%1$s MB (%2$s%%) Space Used' ),
  1690 				__( '%1$s MB (%2$s%%) Space Used' ),
  1642 				number_format_i18n( $used, 2 ),
  1691 				number_format_i18n( $used, 2 ),
  1643 				$percentused
  1692 				$percentused
  1644 			);
  1693 			);
  1645 			printf(
  1694 			printf(
  1646 				'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
  1695 				'<a href="%1$s" class="musublink">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
  1647 				esc_url( admin_url( 'upload.php' ) ),
  1696 				esc_url( admin_url( 'upload.php' ) ),
  1648 				$text,
  1697 				$text,
       
  1698 				/* translators: Hidden accessibility text. */
  1649 				__( 'Manage Uploads' )
  1699 				__( 'Manage Uploads' )
  1650 			);
  1700 			);
  1651 			?>
  1701 			?>
  1652 		</li>
  1702 		</li>
  1653 	</ul>
  1703 	</ul>
  1727 	 *
  1777 	 *
  1728 	 * @since 3.2.0
  1778 	 * @since 3.2.0
  1729 	 *
  1779 	 *
  1730 	 * @param string      $notice   The notice content.
  1780 	 * @param string      $notice   The notice content.
  1731 	 * @param array|false $response An array containing web browser information, or
  1781 	 * @param array|false $response An array containing web browser information, or
  1732 	 *                              false on failure. See `wp_check_browser_version()`.
  1782 	 *                              false on failure. See wp_check_browser_version().
  1733 	 */
  1783 	 */
  1734 	echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  1784 	echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  1735 }
  1785 }
  1736 
  1786 
  1737 /**
  1787 /**
  1823 	if ( ! $response ) {
  1873 	if ( ! $response ) {
  1824 		return;
  1874 		return;
  1825 	}
  1875 	}
  1826 
  1876 
  1827 	if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
  1877 	if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
  1828 		$msg = sprintf(
  1878 		// The `is_secure` array key name doesn't actually imply this is a secure version of PHP. It only means it receives security updates.
       
  1879 
       
  1880 		if ( $response['is_lower_than_future_minimum'] ) {
       
  1881 			$message = sprintf(
       
  1882 				/* translators: %s: The server PHP version. */
       
  1883 				__( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates and soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ),
       
  1884 				PHP_VERSION
       
  1885 			);
       
  1886 		} else {
       
  1887 			$message = sprintf(
       
  1888 				/* translators: %s: The server PHP version. */
       
  1889 				__( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates. It should be updated.' ),
       
  1890 				PHP_VERSION
       
  1891 			);
       
  1892 		}
       
  1893 	} elseif ( $response['is_lower_than_future_minimum'] ) {
       
  1894 		$message = sprintf(
  1829 			/* translators: %s: The server PHP version. */
  1895 			/* translators: %s: The server PHP version. */
  1830 			__( 'Your site is running an insecure version of PHP (%s), which should be updated.' ),
  1896 			__( 'Your site is running on an outdated version of PHP (%s), which soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ),
  1831 			PHP_VERSION
  1897 			PHP_VERSION
  1832 		);
  1898 		);
  1833 	} else {
  1899 	} else {
  1834 		$msg = sprintf(
  1900 		$message = sprintf(
  1835 			/* translators: %s: The server PHP version. */
  1901 			/* translators: %s: The server PHP version. */
  1836 			__( 'Your site is running an outdated version of PHP (%s), which should be updated.' ),
  1902 			__( 'Your site is running on an outdated version of PHP (%s), which should be updated.' ),
  1837 			PHP_VERSION
  1903 			PHP_VERSION
  1838 		);
  1904 		);
  1839 	}
  1905 	}
  1840 	?>
  1906 	?>
  1841 	<p><?php echo $msg; ?></p>
  1907 	<p class="bigger-bolder-text"><?php echo $message; ?></p>
  1842 
  1908 
  1843 	<h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
  1909 	<p><?php _e( 'What is PHP and how does it affect my site?' ); ?></p>
  1844 	<p>
  1910 	<p>
       
  1911 		<?php _e( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site&#8217;s performance.' ); ?>
  1845 		<?php
  1912 		<?php
  1846 		printf(
  1913 		if ( ! empty( $response['recommended_version'] ) ) {
  1847 			/* translators: %s: The minimum recommended PHP version. */
  1914 			printf(
  1848 			__( 'PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are created with increased performance in mind, so you may see a positive effect on your site&#8217;s performance. The minimum recommended version of PHP is %s.' ),
  1915 				/* translators: %s: The minimum recommended PHP version. */
  1849 			$response ? $response['recommended_version'] : ''
  1916 				__( 'The minimum recommended version of PHP is %s.' ),
  1850 		);
  1917 				$response['recommended_version']
       
  1918 			);
       
  1919 		}
  1851 		?>
  1920 		?>
  1852 	</p>
  1921 	</p>
  1853 
  1922 
  1854 	<p class="button-container">
  1923 	<p class="button-container">
  1855 		<?php
  1924 		<?php
  1856 		printf(
  1925 		printf(
  1857 			'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1926 			'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1858 			esc_url( wp_get_update_php_url() ),
  1927 			esc_url( wp_get_update_php_url() ),
  1859 			__( 'Learn more about updating PHP' ),
  1928 			__( 'Learn more about updating PHP' ),
  1860 			/* translators: Accessibility text. */
  1929 			/* translators: Hidden accessibility text. */
  1861 			__( '(opens in a new tab)' )
  1930 			__( '(opens in a new tab)' )
  1862 		);
  1931 		);
  1863 		?>
  1932 		?>
  1864 	</p>
  1933 	</p>
  1865 	<?php
  1934 	<?php
  1877  * @return string[] Modified array of meta box classes.
  1946  * @return string[] Modified array of meta box classes.
  1878  */
  1947  */
  1879 function dashboard_php_nag_class( $classes ) {
  1948 function dashboard_php_nag_class( $classes ) {
  1880 	$response = wp_check_php_version();
  1949 	$response = wp_check_php_version();
  1881 
  1950 
  1882 	if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
  1951 	if ( ! $response ) {
  1883 		$classes[] = 'php-insecure';
  1952 		return $classes;
       
  1953 	}
       
  1954 
       
  1955 	if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
       
  1956 		$classes[] = 'php-no-security-updates';
       
  1957 	} elseif ( $response['is_lower_than_future_minimum'] ) {
       
  1958 		$classes[] = 'php-version-lower-than-future-minimum';
  1884 	}
  1959 	}
  1885 
  1960 
  1886 	return $classes;
  1961 	return $classes;
  1887 }
  1962 }
  1888 
  1963 
  1911 	$issues_total = $issue_counts['recommended'] + $issue_counts['critical'];
  1986 	$issues_total = $issue_counts['recommended'] + $issue_counts['critical'];
  1912 	?>
  1987 	?>
  1913 	<div class="health-check-widget">
  1988 	<div class="health-check-widget">
  1914 		<div class="health-check-widget-title-section site-health-progress-wrapper loading hide-if-no-js">
  1989 		<div class="health-check-widget-title-section site-health-progress-wrapper loading hide-if-no-js">
  1915 			<div class="site-health-progress">
  1990 			<div class="site-health-progress">
  1916 				<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">
  1991 				<svg aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
  1917 					<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
  1992 					<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
  1918 					<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
  1993 					<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
  1919 				</svg>
  1994 				</svg>
  1920 			</div>
  1995 			</div>
  1921 			<div class="site-health-progress-label">
  1996 			<div class="site-health-progress-label">
  1975 
  2050 
  1976 	<?php
  2051 	<?php
  1977 }
  2052 }
  1978 
  2053 
  1979 /**
  2054 /**
  1980  * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
  2055  * Outputs empty dashboard widget to be populated by JS later.
       
  2056  *
       
  2057  * Usable by plugins.
  1981  *
  2058  *
  1982  * @since 2.5.0
  2059  * @since 2.5.0
  1983  */
  2060  */
  1984 function wp_dashboard_empty() {}
  2061 function wp_dashboard_empty() {}
  1985 
  2062 
  1995 	$is_block_theme          = wp_is_block_theme();
  2072 	$is_block_theme          = wp_is_block_theme();
  1996 	?>
  2073 	?>
  1997 	<div class="welcome-panel-content">
  2074 	<div class="welcome-panel-content">
  1998 	<div class="welcome-panel-header">
  2075 	<div class="welcome-panel-header">
  1999 		<div class="welcome-panel-header-image">
  2076 		<div class="welcome-panel-header-image">
  2000 			<?php echo file_get_contents( dirname( __DIR__ ) . '/images/about-header-about.svg' ); ?>
  2077 			<?php echo file_get_contents( dirname( __DIR__ ) . '/images/dashboard-background.svg' ); ?>
  2001 		</div>
  2078 		</div>
  2002 		<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
  2079 		<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
  2003 		<p>
  2080 		<p>
  2004 			<a href="<?php echo esc_url( admin_url( 'about.php' ) ); ?>">
  2081 			<a href="<?php echo esc_url( admin_url( 'about.php' ) ); ?>">
  2005 			<?php
  2082 			<?php
  2009 			</a>
  2086 			</a>
  2010 		</p>
  2087 		</p>
  2011 	</div>
  2088 	</div>
  2012 	<div class="welcome-panel-column-container">
  2089 	<div class="welcome-panel-column-container">
  2013 		<div class="welcome-panel-column">
  2090 		<div class="welcome-panel-column">
  2014 			<div class="welcome-panel-icon-pages"></div>
  2091 			<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
       
  2092 				<rect width="48" height="48" rx="4" fill="#1E1E1E"/>
       
  2093 				<path fill-rule="evenodd" clip-rule="evenodd" d="M32.0668 17.0854L28.8221 13.9454L18.2008 24.671L16.8983 29.0827L21.4257 27.8309L32.0668 17.0854ZM16 32.75H24V31.25H16V32.75Z" fill="white"/>
       
  2094 			</svg>
  2015 			<div class="welcome-panel-column-content">
  2095 			<div class="welcome-panel-column-content">
  2016 				<h3><?php _e( 'Author rich content with blocks and patterns' ); ?></h3>
  2096 				<h3><?php _e( 'Author rich content with blocks and patterns' ); ?></h3>
  2017 				<p><?php _e( 'Block patterns are pre-configured block layouts. Use them to get inspired or create new pages in a flash.' ); ?></p>
  2097 				<p><?php _e( 'Block patterns are pre-configured block layouts. Use them to get inspired or create new pages in a flash.' ); ?></p>
  2018 				<a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=page' ) ); ?>"><?php _e( 'Add a new page' ); ?></a>
  2098 				<a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=page' ) ); ?>"><?php _e( 'Add a new page' ); ?></a>
  2019 			</div>
  2099 			</div>
  2020 		</div>
  2100 		</div>
  2021 		<div class="welcome-panel-column">
  2101 		<div class="welcome-panel-column">
  2022 			<div class="welcome-panel-icon-layout"></div>
  2102 			<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
       
  2103 				<rect width="48" height="48" rx="4" fill="#1E1E1E"/>
       
  2104 				<path fill-rule="evenodd" clip-rule="evenodd" d="M18 16h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H18a2 2 0 0 1-2-2V18a2 2 0 0 1 2-2zm12 1.5H18a.5.5 0 0 0-.5.5v3h13v-3a.5.5 0 0 0-.5-.5zm.5 5H22v8h8a.5.5 0 0 0 .5-.5v-7.5zm-10 0h-3V30a.5.5 0 0 0 .5.5h2.5v-8z" fill="#fff"/>
       
  2105 			</svg>
  2023 			<div class="welcome-panel-column-content">
  2106 			<div class="welcome-panel-column-content">
  2024 			<?php if ( $is_block_theme ) : ?>
  2107 			<?php if ( $is_block_theme ) : ?>
  2025 				<h3><?php _e( 'Customize your entire site with block themes' ); ?></h3>
  2108 				<h3><?php _e( 'Customize your entire site with block themes' ); ?></h3>
  2026 				<p><?php _e( 'Design everything on your site &#8212; from the header down to the footer, all using blocks and patterns.' ); ?></p>
  2109 				<p><?php _e( 'Design everything on your site &#8212; from the header down to the footer, all using blocks and patterns.' ); ?></p>
  2027 				<a href="<?php echo esc_url( admin_url( 'site-editor.php' ) ); ?>"><?php _e( 'Open site editor' ); ?></a>
  2110 				<a href="<?php echo esc_url( admin_url( 'site-editor.php' ) ); ?>"><?php _e( 'Open site editor' ); ?></a>
  2033 				<?php endif; ?>
  2116 				<?php endif; ?>
  2034 			<?php endif; ?>
  2117 			<?php endif; ?>
  2035 			</div>
  2118 			</div>
  2036 		</div>
  2119 		</div>
  2037 		<div class="welcome-panel-column">
  2120 		<div class="welcome-panel-column">
  2038 			<div class="welcome-panel-icon-styles"></div>
  2121 			<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
       
  2122 				<rect width="48" height="48" rx="4" fill="#1E1E1E"/>
       
  2123 				<path fill-rule="evenodd" clip-rule="evenodd" d="M31 24a7 7 0 0 1-7 7V17a7 7 0 0 1 7 7zm-7-8a8 8 0 1 1 0 16 8 8 0 0 1 0-16z" fill="#fff"/>
       
  2124 			</svg>
  2039 			<div class="welcome-panel-column-content">
  2125 			<div class="welcome-panel-column-content">
  2040 			<?php if ( $is_block_theme ) : ?>
  2126 			<?php if ( $is_block_theme ) : ?>
  2041 				<h3><?php _e( 'Switch up your site&#8217;s look & feel with Styles' ); ?></h3>
  2127 				<h3><?php _e( 'Switch up your site&#8217;s look & feel with Styles' ); ?></h3>
  2042 				<p><?php _e( 'Tweak your site, or give it a whole new look! Get creative &#8212; how about a new color palette or font?' ); ?></p>
  2128 				<p><?php _e( 'Tweak your site, or give it a whole new look! Get creative &#8212; how about a new color palette or font?' ); ?></p>
  2043 				<a href="<?php echo esc_url( admin_url( 'site-editor.php?styles=open' ) ); ?>"><?php _e( 'Edit styles' ); ?></a>
  2129 				<a href="<?php echo esc_url( admin_url( '/site-editor.php?path=%2Fwp_global_styles' ) ); ?>"><?php _e( 'Edit styles' ); ?></a>
  2044 			<?php else : ?>
  2130 			<?php else : ?>
  2045 				<h3><?php _e( 'Discover a new way to build your site.' ); ?></h3>
  2131 				<h3><?php _e( 'Discover a new way to build your site.' ); ?></h3>
  2046 				<p><?php _e( 'There is a new kind of WordPress theme, called a block theme, that lets you build the site you&#8217;ve always wanted &#8212; with blocks and styles.' ); ?></p>
  2132 				<p><?php _e( 'There is a new kind of WordPress theme, called a block theme, that lets you build the site you&#8217;ve always wanted &#8212; with blocks and styles.' ); ?></p>
  2047 				<a href="<?php echo esc_url( __( 'https://wordpress.org/support/article/block-themes/' ) ); ?>"><?php _e( 'Learn about block themes' ); ?></a>
  2133 				<a href="<?php echo esc_url( __( 'https://wordpress.org/documentation/article/block-themes/' ) ); ?>"><?php _e( 'Learn about block themes' ); ?></a>
  2048 			<?php endif; ?>
  2134 			<?php endif; ?>
  2049 			</div>
  2135 			</div>
  2050 		</div>
  2136 		</div>
  2051 	</div>
  2137 	</div>
  2052 	</div>
  2138 	</div>