Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmyc/2d4d362de2241442c5792f6b87a1bf2e to your computer and use it in GitHub Desktop.
Save timmyc/2d4d362de2241442c5792f6b87a1bf2e to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: WooCommerce Remove Admin Version Option
* Plugin URI: https://woocommerce.com
* Description: Adds a tool to the WooCommerce > Status > Tools page to remove the woocommerce_admin_version option
* Author: WooCommerce
* Domain Path: /languages
* Version: 0.1
*/
/**
* Register the cache clearing tool on the WooCommerce > Status > Tools page.
*
* @param array $debug_tools Available debug tool registrations.
* @return array Filtered debug tool registrations.
*/
function woocommerce_remove_woocommerce_admin_version_option_add_tool( $debug_tools ) {
$debug_tools[ 'remove_woocommerce_admin_version_option' ] = array(
'name' => __( 'Remove WooCommerce Admin Version Option', 'woocommerce' ),
'button' => __( 'Remove', 'woocommerce' ),
'desc' => 'This tool removes the woocommerce_admin_version option to trigger database migrations to run again',
'callback' => 'woocommerce_remove_woocommerce_admin_version_option_delete',
);
return $debug_tools;
}
function woocommerce_remove_woocommerce_admin_version_option_delete() {
delete_option( 'woocommerce_admin_version' );
}
function woocommerce_remove_woocommerce_admin_version_option_filter() {
add_filter( 'woocommerce_debug_tools', 'woocommerce_remove_woocommerce_admin_version_option_add_tool' );
}
add_action( 'woocommerce_init', 'woocommerce_remove_woocommerce_admin_version_option_filter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment