core_upgrade_preamble

函式
core_upgrade_preamble ( No parameters )

WordPress中的core_upgrade_preamble鉤子是用來修改顯示在WordPress升級頁面頂部的文字。這個鉤子可以用來在升級頁面的前言中新增自定義文字或其他內容。

顯示升級WordPress以下載最新或自動升級的表格。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function core_upgrade_preamble() {
global $required_php_version, $required_mysql_version;
$updates = get_core_updates();
// Include an unmodified $wp_version.
require ABSPATH . WPINC . '/version.php';
$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
echo '<h2 class="response">';
_e( 'An updated version of WordPress is available.' );
echo '</h2>';
echo '<div class="notice notice-warning inline"><p>';
printf(
/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
__( 'https://wordpress.org/support/article/wordpress-backups/' ),
__( 'https://wordpress.org/support/article/updating-wordpress/' )
);
echo '</p></div>';
} elseif ( $is_development_version ) {
echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
} else {
echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';
}
echo '<ul class="core-updates">';
foreach ( (array) $updates as $update ) {
echo '<li>';
list_core_update( $update );
echo '</li>';
}
echo '</ul>';
// Don't show the maintenance mode notice when we are only showing a single re-install option.
if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) {
echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>';
} elseif ( ! $updates ) {
list( $normalized_version ) = explode( '-', $wp_version );
echo '<p>' . sprintf(
/* translators: 1: URL to About screen, 2: WordPress version. */
__( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ),
esc_url( self_admin_url( 'about.php' ) ),
$normalized_version
) . '</p>';
}
dismissed_updates();
}
function core_upgrade_preamble() { global $required_php_version, $required_mysql_version; $updates = get_core_updates(); // Include an unmodified $wp_version. require ABSPATH . WPINC . '/version.php'; $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version ); if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { echo '<h2 class="response">'; _e( 'An updated version of WordPress is available.' ); echo '</h2>'; echo '<div class="notice notice-warning inline"><p>'; printf( /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */ __( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ), __( 'https://wordpress.org/support/article/wordpress-backups/' ), __( 'https://wordpress.org/support/article/updating-wordpress/' ) ); echo '</p></div>'; } elseif ( $is_development_version ) { echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>'; } else { echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>'; } echo '<ul class="core-updates">'; foreach ( (array) $updates as $update ) { echo '<li>'; list_core_update( $update ); echo '</li>'; } echo '</ul>'; // Don't show the maintenance mode notice when we are only showing a single re-install option. if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) { echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>'; } elseif ( ! $updates ) { list( $normalized_version ) = explode( '-', $wp_version ); echo '<p>' . sprintf( /* translators: 1: URL to About screen, 2: WordPress version. */ __( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>'; } dismissed_updates(); }
function core_upgrade_preamble() {
	global $required_php_version, $required_mysql_version;

	$updates = get_core_updates();

	// Include an unmodified $wp_version.
	require ABSPATH . WPINC . '/version.php';

	$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );

	if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
		echo '<h2 class="response">';
		_e( 'An updated version of WordPress is available.' );
		echo '</h2>';

		echo '<div class="notice notice-warning inline"><p>';
		printf(
			/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
			__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
			__( 'https://wordpress.org/support/article/wordpress-backups/' ),
			__( 'https://wordpress.org/support/article/updating-wordpress/' )
		);
		echo '</p></div>';
	} elseif ( $is_development_version ) {
		echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
	} else {
		echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';
	}

	echo '<ul class="core-updates">';
	foreach ( (array) $updates as $update ) {
		echo '<li>';
		list_core_update( $update );
		echo '</li>';
	}
	echo '</ul>';

	// Don't show the maintenance mode notice when we are only showing a single re-install option.
	if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) {
		echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>';
	} elseif ( ! $updates ) {
		list( $normalized_version ) = explode( '-', $wp_version );
		echo '<p>' . sprintf(
			/* translators: 1: URL to About screen, 2: WordPress version. */
			__( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ),
			esc_url( self_admin_url( 'about.php' ) ),
			$normalized_version
		) . '</p>';
	}

	dismissed_updates();
}

常見問題

FAQs
檢視更多 >