wp_ajax_health_check_background_updates

函式
wp_ajax_health_check_background_updates ( No parameters )

wp_ajax_health_check_background_updates: 這個函式是一個WordPress的AJAX處理程式,檢查後臺更新是否在網站上正常工作。它不需要任何引數,並返回一個JSON響應,表明後臺更新的狀態。

Ajax處理程式用於後臺更新的網站健康檢查。

function wp_ajax_health_check_background_updates() {
	_doing_it_wrong(
		'wp_ajax_health_check_background_updates',
		sprintf(
		// translators: 1: The Site Health action that is no longer used by core. 2: The new function that replaces it.
			__( 'The Site Health check for %1$s has been replaced with %2$s.' ),
			'wp_ajax_health_check_background_updates',
			'WP_REST_Site_Health_Controller::test_background_updates'
		),
		'5.6.0'
	);

	check_ajax_referer( 'health-check-site-status' );

	if ( ! current_user_can( 'view_site_health_checks' ) ) {
		wp_send_json_error();
	}

	if ( ! class_exists( 'WP_Site_Health' ) ) {
		require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
	}

	$site_health = WP_Site_Health::get_instance();
	wp_send_json_success( $site_health->get_test_background_updates() );
}

常見問題

FAQs
檢視更多 >