WC_REST_System_Status_V2_Controller::get_environment_info_per_fields() │ public │ WC 1.0
Get array of environment information. Includes thing like software versions, and various server settings.
Метод класса: WC_REST_System_Status_V2_Controller{}
Хуков нет.
Возвращает
Массив
.
Использование
$WC_REST_System_Status_V2_Controller = new WC_REST_System_Status_V2_Controller(); $WC_REST_System_Status_V2_Controller->get_environment_info_per_fields( $fields );
- $fields(массив) (обязательный)
- List of fields to be included on the response.
Код WC_REST_System_Status_V2_Controller::get_environment_info_per_fields() WC REST System Status V2 Controller::get environment info per fields WC 9.2.3
public function get_environment_info_per_fields( $fields ) { global $wpdb; $enable_remote_post = $this->check_if_field_item_exists( 'environment', array( 'remote_post_successful', 'remote_post_response' ), $fields ); $enable_remote_get = $this->check_if_field_item_exists( 'environment', array( 'remote_get_successful', 'remote_get_response' ), $fields ); // Figure out cURL version, if installed. $curl_version = ''; if ( function_exists( 'curl_version' ) ) { $curl_version = curl_version(); $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; } elseif ( extension_loaded( 'curl' ) ) { $curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce' ); } // WP memory limit. $wp_memory_limit = wc_let_to_num( WP_MEMORY_LIMIT ); if ( function_exists( 'memory_get_usage' ) ) { $wp_memory_limit = max( $wp_memory_limit, wc_let_to_num( @ini_get( 'memory_limit' ) ) ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } // Test POST requests. $post_response_successful = null; $post_response_code = null; if ( $enable_remote_post ) { $post_response_code = get_transient( 'woocommerce_test_remote_post' ); if ( false === $post_response_code || is_wp_error( $post_response_code ) ) { $response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array( 'timeout' => 10, 'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ), 'httpversion' => '1.1', 'body' => array( 'cmd' => '_notify-validate', ), ) ); if ( ! is_wp_error( $response ) ) { $post_response_code = $response['response']['code']; } set_transient( 'woocommerce_test_remote_post', $post_response_code, HOUR_IN_SECONDS ); } $post_response_successful = ! is_wp_error( $post_response_code ) && $post_response_code >= 200 && $post_response_code < 300; } // Test GET requests. $get_response_successful = null; $get_response_code = null; if ( $enable_remote_get ) { $get_response_code = get_transient( 'woocommerce_test_remote_get' ); if ( false === $get_response_code || is_wp_error( $get_response_code ) ) { $response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ), array( 'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ), ) ); if ( ! is_wp_error( $response ) ) { $get_response_code = $response['response']['code']; } set_transient( 'woocommerce_test_remote_get', $get_response_code, HOUR_IN_SECONDS ); } $get_response_successful = ! is_wp_error( $get_response_code ) && $get_response_code >= 200 && $get_response_code < 300; } $database_version = wc_get_server_database_version(); $log_directory = LoggingUtil::get_log_directory(); // Return all environment info. Described by JSON Schema. return array( 'home_url' => get_option( 'home' ), 'site_url' => get_option( 'siteurl' ), 'store_id' => get_option( \WC_Install::STORE_ID_OPTION, null ), 'version' => WC()->version, 'log_directory' => $log_directory, 'log_directory_writable' => wp_is_writable( $log_directory ), 'wp_version' => get_bloginfo( 'version' ), 'wp_multisite' => is_multisite(), 'wp_memory_limit' => $wp_memory_limit, 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), 'language' => get_locale(), 'external_object_cache' => wp_using_ext_object_cache(), 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wc_clean( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '', 'php_version' => phpversion(), 'php_post_max_size' => wc_let_to_num( ini_get( 'post_max_size' ) ), 'php_max_execution_time' => (int) ini_get( 'max_execution_time' ), 'php_max_input_vars' => (int) ini_get( 'max_input_vars' ), 'curl_version' => $curl_version, 'suhosin_installed' => extension_loaded( 'suhosin' ), 'max_upload_size' => wp_max_upload_size(), 'mysql_version' => $database_version['number'], 'mysql_version_string' => $database_version['string'], 'default_timezone' => date_default_timezone_get(), 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), 'soapclient_enabled' => class_exists( 'SoapClient' ), 'domdocument_enabled' => class_exists( 'DOMDocument' ), 'gzip_enabled' => is_callable( 'gzopen' ), 'mbstring_enabled' => extension_loaded( 'mbstring' ), 'remote_post_successful' => $post_response_successful, 'remote_post_response' => is_wp_error( $post_response_code ) ? $post_response_code->get_error_message() : $post_response_code, 'remote_get_successful' => $get_response_successful, 'remote_get_response' => is_wp_error( $get_response_code ) ? $get_response_code->get_error_message() : $get_response_code, ); }