wp_dashboard_php_nag() WordPress Function

The wp_dashboard_php_nag() function is used to display a notice to users who are running an outdated version of PHP on their WordPress site. This notice can be dismissed by the user, but will reappear if the user's PHP version falls below the minimum version required by WordPress.

wp_dashboard_php_nag() #

Displays the PHP update nag.


Source

File: wp-admin/includes/dashboard.php

function wp_dashboard_php_nag() {
	$response = wp_check_php_version();

	if ( ! $response ) {
		return;
	}

	if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
		$msg = sprintf(
			/* translators: %s: The server PHP version. */
			__( 'Your site is running an insecure version of PHP (%s), which should be updated.' ),
			PHP_VERSION
		);
	} else {
		$msg = sprintf(
			/* translators: %s: The server PHP version. */
			__( 'Your site is running an outdated version of PHP (%s), which should be updated.' ),
			PHP_VERSION
		);
	}
	?>
	<p><?php echo $msg; ?></p>

	<h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
	<p>
		<?php
		printf(
			/* translators: %s: The minimum recommended PHP version. */
			__( '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.' ),
			$response ? $response['recommended_version'] : ''
		);
		?>
	</p>

	<p class="button-container">
		<?php
		printf(
			'<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>',
			esc_url( wp_get_update_php_url() ),
			__( 'Learn more about updating PHP' ),
			/* translators: Accessibility text. */
			__( '(opens in a new tab)' )
		);
		?>
	</p>
	<?php

	wp_update_php_annotation();
	wp_direct_php_update_button();
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.