WC_Admin_Status::status_tools() public WC 1.0
Handles output of tools.
{} Это метод класса: WC_Admin_Status{}
Хуки из метода
Возвращает
Null. Ничего.
Использование
$result = WC_Admin_Status::status_tools();
Код WC_Admin_Status::status_tools() WC Admin Status::status tools WC 5.0.0
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();
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 = array(
'id' => $action,
'name' => $tool['name'],
'action' => $tool['button'],
'description' => $tool['desc'],
);
$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>';
}
include_once __DIR__ . '/views/html-admin-page-status-tools.php';
}