/** * woocommerce_status_tools function. * * @access public * @return void */ function woocommerce_status_tools() { global $woocommerce, $wpdb; $tools = apply_filters('woocommerce_debug_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')), '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' => __('<strong class="red">Warning</strong> This tool will delete all customer session data from the database, including any current live carts.', 'woocommerce')))); if (!empty($_GET['action']) && !empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'debug_action')) { switch ($_GET['action']) { case "clear_transients": $woocommerce->clear_product_transients(); echo '<div class="updated"><p>' . __('Product Transients Cleared', 'woocommerce') . '</p></div>'; break; case "clear_expired_transients": // http://w-shadow.com/blog/2012/04/17/delete-stale-transients/ $rows = $wpdb->query("\n\t\t\t\t\tDELETE\n\t\t\t\t\t\ta, b\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ta.option_name LIKE '_transient_%' AND\n\t\t\t\t\t\ta.option_name NOT LIKE '_transient_timeout_%' AND\n\t\t\t\t\t\tb.option_name = CONCAT(\n\t\t\t\t\t\t\t'_transient_timeout_',\n\t\t\t\t\t\t\tSUBSTRING(\n\t\t\t\t\t\t\t\ta.option_name,\n\t\t\t\t\t\t\t\tCHAR_LENGTH('_transient_') + 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND b.option_value < UNIX_TIMESTAMP()\n\t\t\t\t"); $rows2 = $wpdb->query("\n\t\t\t\t\tDELETE\n\t\t\t\t\t\ta, b\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ta.option_name LIKE '_site_transient_%' AND\n\t\t\t\t\t\ta.option_name NOT LIKE '_site_transient_timeout_%' AND\n\t\t\t\t\t\tb.option_name = CONCAT(\n\t\t\t\t\t\t\t'_site_transient_timeout_',\n\t\t\t\t\t\t\tSUBSTRING(\n\t\t\t\t\t\t\t\ta.option_name,\n\t\t\t\t\t\t\t\tCHAR_LENGTH('_site_transient_') + 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND b.option_value < UNIX_TIMESTAMP()\n\t\t\t\t"); echo '<div class="updated"><p>' . sprintf(__('%d Transients Rows Cleared', 'woocommerce'), $rows + $rows2) . '</p></div>'; break; case "reset_roles": // Remove then re-add caps and roles woocommerce_remove_roles(); woocommerce_init_roles(); echo '<div class="updated"><p>' . __('Roles successfully reset', 'woocommerce') . '</p></div>'; break; case "recount_terms": $product_cats = get_terms('product_cat', array('hide_empty' => false, 'fields' => 'id=>parent')); _woocommerce_term_recount($product_cats, get_taxonomy('product_cat'), false, false); $product_tags = get_terms('product_tag', array('hide_empty' => false, 'fields' => 'id=>parent')); _woocommerce_term_recount($product_cats, get_taxonomy('product_tag'), false, false); echo '<div class="updated"><p>' . __('Terms successfully recounted', 'woocommerce') . '</p></div>'; break; case "clear_sessions": $wpdb->query("\n\t\t\t\t\tDELETE FROM {$wpdb->options}\n\t\t\t\t\tWHERE option_name LIKE '_wc_session_%' OR option_name LIKE '_wc_session_expires_%'\n\t\t\t\t"); wp_cache_flush(); break; default: $action = esc_attr($_GET['action']); if (isset($tools[$action]['callback'])) { $callback = $tools[$action]['callback']; $return = call_user_func($callback); if ($return === false) { if (is_array($callback)) { echo '<div class="error"><p>' . sprintf(__('There was an error calling %s::%s', 'woocommerce'), get_class($callback[0]), $callback[1]) . '</p></div>'; } else { echo '<div class="error"><p>' . sprintf(__('There was an error calling %s', 'woocommerce'), $callback) . '</p></div>'; } } } } } ?> <table class="wc_status_table widefat" cellspacing="0"> <thead class="tools"> <tr> <th colspan="2"><?php _e('Tools', 'woocommerce'); ?> </th> </tr> </thead> <tbody class="tools"> <?php foreach ($tools as $action => $tool) { ?> <tr> <td><?php echo esc_html($tool['name']); ?> </td> <td> <p> <a href="<?php echo wp_nonce_url(admin_url('admin.php?page=woocommerce_status&tab=tools&action=' . $action), 'debug_action'); ?> " class="button"><?php echo esc_html($tool['button']); ?> </a> <span class="description"><?php echo wp_kses_post($tool['desc']); ?> </span> </p> </td> </tr> <?php } ?> </tbody> </table> <?php }
* * @author WooThemes * @category Core * @package WooCommerce/Uninstaller * @version 1.6.4 */ if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } global $wpdb, $wp_roles; // Roles + caps if (!function_exists('woocommerce_remove_roles')) { include_once 'woocommerce-core-functions.php'; } if (function_exists('woocommerce_remove_roles')) { woocommerce_remove_roles(); } // Pages wp_delete_post(get_option('woocommerce_shop_page_id'), true); wp_delete_post(get_option('woocommerce_cart_page_id'), true); wp_delete_post(get_option('woocommerce_checkout_page_id'), true); wp_delete_post(get_option('woocommerce_myaccount_page_id'), true); wp_delete_post(get_option('woocommerce_edit_address_page_id'), true); wp_delete_post(get_option('woocommerce_view_order_page_id'), true); wp_delete_post(get_option('woocommerce_change_password_page_id'), true); wp_delete_post(get_option('woocommerce_pay_page_id'), true); wp_delete_post(get_option('woocommerce_thanks_page_id'), true); // mijireh checkout page if ($mijireh_page = get_page_by_path('mijireh-secure-checkout')) { wp_delete_post($mijireh_page->ID, true); }