WC_Admin_Status::status_tools()
Handles output of tools.
Метод класса: WC_Admin_Status{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$result = WC_Admin_Status::status_tools();
Код WC_Admin_Status::status_tools() WC Admin Status::status tools WC 9.4.2
public static function status_tools() { if ( ! class_exists( 'WC_REST_System_Status_Tools_Controller' ) ) { wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Tools_Controller.' ); } $tools = self::get_tools(); $tool_requires_refresh = false; if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'debug_action' ) ) { // WPCS: input var ok, sanitization ok. $tools_controller = new WC_REST_System_Status_Tools_Controller(); $action = wc_clean( wp_unslash( $_GET['action'] ) ); // WPCS: input var ok. if ( array_key_exists( $action, $tools ) ) { $response = $tools_controller->execute_tool( $action ); $tool = $tools[ $action ]; $tool_requires_refresh = $tool['requires_refresh'] ?? false; $tool = array( 'id' => $action, 'name' => $tool['name'], 'action' => $tool['button'], 'description' => $tool['desc'], 'disabled' => $tool['disabled'] ?? false, ); $tool = array_merge( $tool, $response ); /** * Fires after a WooCommerce system status tool has been executed. * * @param array $tool Details about the tool that has been executed. */ do_action( 'woocommerce_system_status_tool_executed', $tool ); } else { $response = array( 'success' => false, 'message' => __( 'Tool does not exist.', 'woocommerce' ), ); } if ( $response['success'] ) { echo '<div class="updated inline"><p>' . esc_html( $response['message'] ) . '</p></div>'; } else { echo '<div class="error inline"><p>' . esc_html( $response['message'] ) . '</p></div>'; } } // Display message if settings settings have been saved. if ( isset( $_REQUEST['settings-updated'] ) ) { // WPCS: input var ok. echo '<div class="updated inline"><p>' . esc_html__( 'Your changes have been saved.', 'woocommerce' ) . '</p></div>'; } if ( $tool_requires_refresh ) { $tools = self::get_tools(); } include_once __DIR__ . '/views/html-admin-page-status-tools.php'; }