WC_REST_System_Status_Tools_Controller::get_tools PHP Method

get_tools() public method

'button' becomes 'action' in the API.
public get_tools ( ) : array
return array
    public function get_tools()
    {
        $tools = array('clear_transients' => array('name' => __('WC transients', 'woocommerce'), 'button' => __('Clear transients', 'woocommerce'), 'desc' => __('This tool will clear the product/shop transients cache.', 'woocommerce')), 'clear_expired_transients' => array('name' => __('Expired transients', 'woocommerce'), 'button' => __('Clear expired transients', 'woocommerce'), 'desc' => __('This tool will clear ALL expired transients from WordPress.', 'woocommerce')), 'delete_orphaned_variations' => array('name' => __('Orphaned variations', 'woocommerce'), 'button' => __('Delete orphaned variations', 'woocommerce'), 'desc' => __('This tool will delete all variations which have no parent.', 'woocommerce')), 'recount_terms' => array('name' => __('Term counts', 'woocommerce'), 'button' => __('Recount terms', 'woocommerce'), 'desc' => __('This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce')), 'reset_roles' => array('name' => __('Capabilities', 'woocommerce'), 'button' => __('Reset capabilities', 'woocommerce'), 'desc' => __('This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce')), 'clear_sessions' => array('name' => __('Customer sessions', 'woocommerce'), 'button' => __('Clear all sessions', 'woocommerce'), 'desc' => sprintf('<strong class="red">%1$s</strong> %2$s', __('Note:', 'woocommerce'), __('This tool will delete all customer session data from the database, including any current live carts.', 'woocommerce'))), 'install_pages' => array('name' => __('Install WooCommerce pages', 'woocommerce'), 'button' => __('Install pages', 'woocommerce'), 'desc' => sprintf('<strong class="red">%1$s</strong> %2$s', __('Note:', 'woocommerce'), __('This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce'))), 'delete_taxes' => array('name' => __('Delete all WooCommerce tax rates', 'woocommerce'), 'button' => __('Delete ALL tax rates', 'woocommerce'), 'desc' => sprintf('<strong class="red">%1$s</strong> %2$s', __('Note:', 'woocommerce'), __('This option will delete ALL of your tax rates, use with caution.', 'woocommerce'))), 'reset_tracking' => array('name' => __('Reset usage tracking settings', 'woocommerce'), 'button' => __('Reset usage tracking settings', 'woocommerce'), 'desc' => __('This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', 'woocommerce')));
        return apply_filters('woocommerce_debug_tools', $tools);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Test to make sure we can RUN a tool correctly.
  *
  * @since 2.7.0
  */
 public function test_execute_system_tool()
 {
     wp_set_current_user($this->user);
     $tools_controller = new WC_REST_System_Status_Tools_Controller();
     $raw_tools = $tools_controller->get_tools();
     $raw_tool = $raw_tools['recount_terms'];
     $response = $this->server->dispatch(new WP_REST_Request('POST', '/wc/v1/system_status/tools/recount_terms'));
     $data = $response->get_data();
     $this->assertEquals('recount_terms', $data['id']);
     $this->assertEquals('Term counts', $data['name']);
     $this->assertEquals('Recount terms', $data['action']);
     $this->assertEquals('This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description']);
     $this->assertTrue($data['success']);
     $response = $this->server->dispatch(new WP_REST_Request('POST', '/wc/v1/system_status/tools/not_a_real_tool'));
     $this->assertEquals(404, $response->get_status());
 }
All Usage Examples Of WC_REST_System_Status_Tools_Controller::get_tools