wp_get_auto_update_message

函式
wp_get_auto_update_message ( No parameters )
返回值
  • (string) The update message to be shown.
定義位置
相關方法
wp_maybe_auto_updatewp_get_update_datawp_get_default_update_https_urlwp_get_translation_updateswp_get_default_update_php_url
引入
5.5.0
棄用
-

wp_get_auto_update_message: 這個函式檢索當有新版本的WordPress可用於自動更新時顯示的資訊。它不接受任何引數,並返回一個資訊字串。

確定要顯示的適當的自動更新資訊。

function wp_get_auto_update_message() {
	$next_update_time = wp_next_scheduled( 'wp_version_check' );

	// Check if the event exists.
	if ( false === $next_update_time ) {
		$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
	} else {
		$time_to_next_update = human_time_diff( (int) $next_update_time );

		// See if cron is overdue.
		$overdue = ( time() - $next_update_time ) > 0;

		if ( $overdue ) {
			$message = sprintf(
				/* translators: %s: Duration that WP-Cron has been overdue. */
				__( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ),
				$time_to_next_update
			);
		} else {
			$message = sprintf(
				/* translators: %s: Time until the next update. */
				__( 'Automatic update scheduled in %s.' ),
				$time_to_next_update
			);
		}
	}

	return $message;
}

常見問題

FAQs
檢視更多 >