Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_ajax_health_check_get_sizes ›

Desde5.2.0
Obsoleton/a
wp_ajax_health_check_get_sizes ( Sem parâmetros )
Definido em:
Codex:

Ajax handler for site health check to get directories and database sizes.



Fonte

function wp_ajax_health_check_get_sizes() {
	check_ajax_referer( 'health-check-site-status-result' );

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

	if ( ! class_exists( 'WP_Debug_Data' ) ) {
		require_once( ABSPATH . 'wp-admin/includes/class-wp-debug-data.php' );
	}

	$sizes_data = WP_Debug_Data::get_sizes();
	$all_sizes  = array();

	foreach ( $sizes_data as $name => $value ) {
		$name = sanitize_text_field( $name );
		$data = array();

		if ( isset( $value['size'] ) ) {
			if ( is_string( $value['size'] ) ) {
				$data['size'] = sanitize_text_field( $value['size'] );
			} else {
				$data['size'] = (int) $value['size'];
			}
		}

		if ( isset( $value['debug'] ) ) {
			if ( is_string( $value['debug'] ) ) {
				$data['debug'] = sanitize_text_field( $value['debug'] );
			} else {
				$data['debug'] = (int) $value['debug'];
			}
		}

		$all_sizes[ $name ] = $data;
	}

	if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) {
		wp_send_json_error( $all_sizes );
	}

	wp_send_json_success( $all_sizes );
}