From c0291f04b7ee895b8edabc434d7a93e5ce44c30c Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Fri, 8 Jun 2018 12:31:40 +0200 Subject: [PATCH 1/5] Add handler for version switch button --- .../class-wc-beta-tester-version-picker.php | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-version-picker.php b/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-version-picker.php index f5729fa9856..49cc7056dc7 100644 --- a/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-version-picker.php +++ b/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-version-picker.php @@ -24,6 +24,26 @@ class WC_Beta_Tester_Version_Picker { */ public function __construct() { add_action( 'admin_menu', array( $this, 'add_to_menus' ) ); + add_action( 'admin_init', array( $this, 'handle_version_switch' ) ); + } + + /** + * Handler for the version switch button. + */ + public function handle_version_switch() { + if ( empty( $_GET['wcbt_switch_to_version'] ) ) { + return; + } + + if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'wcbt_switch_version_nonce' ) ) { + wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-beta-tester' ) ); + } + + $switch_to = $_GET['wcbt_switch_to_version']; + + // TODO: Actual switch. + + wp_redirect( admin_url( 'tools.php?page=wc-beta-tester-version-picker&switched=1' ) ); } /** @@ -56,7 +76,13 @@ class WC_Beta_Tester_Version_Picker { usort( $tags, 'version_compare' ); $tags = array_reverse( $tags ); - $versions_html = '