/** * Handle opt in or out actions based on notice selection * @return void */ public function check_optin_action() { if (!isset($_GET['wc_tracker_optin']) || !isset($_GET['wc_tracker_nonce']) || !wp_verify_nonce($_GET['wc_tracker_nonce'], 'wc_tracker_optin')) { return; } // Enable tracking update_option('woocommerce_allow_tracking', 'yes'); // Remove notice self::remove_notice('tracking'); // Trigger the first track WC_Tracker::send_tracking_data(true); }
/** * Actions on the final step */ private function wc_setup_ready_actions() { WC_Admin_Notices::remove_notice('install'); if (isset($_GET['wc_tracker_optin']) && isset($_GET['wc_tracker_nonce']) && wp_verify_nonce($_GET['wc_tracker_nonce'], 'wc_tracker_optin')) { update_option('woocommerce_allow_tracking', 'yes'); WC_Tracker::send_tracking_data(true); } elseif (isset($_GET['wc_tracker_optout']) && isset($_GET['wc_tracker_nonce']) && wp_verify_nonce($_GET['wc_tracker_nonce'], 'wc_tracker_optout')) { update_option('woocommerce_allow_tracking', 'no'); } }
/** * Handle saving, deleting and refreshing of the master key & info in the admin. * Also handles tracking optin. */ public function handle_master_key() { // If we're not where we want to be (the 'woothemes-helper' page), then get out quick. if (!isset($_GET['page']) || 'woothemes-helper' != $_GET['page']) { return; } // Token $token = isset($_GET['key']) ? sanitize_text_field($_GET['key']) : false; if ($token) { check_admin_referer('wth_connect'); update_option('woothemes_helper_master_key', $token); if (class_exists('WC_Tracker')) { update_option('woocommerce_allow_tracking', 'yes'); WC_Tracker::send_tracking_data(true); } } // Refresh - delete local transients for master key info and helper updates if (isset($_GET['refresh']) && $_GET['refresh'] == true) { check_admin_referer('wth_refresh_token'); delete_transient('wth_master_key_info'); delete_transient('woothemes_helper_updates'); } // Token deleting if (isset($_GET['delete_wth_token']) && $_GET['delete_wth_token'] == true) { // delete remotely $this->api->delete_master_key_request(get_option('woothemes_helper_master_key')); // delete locally delete_option('woothemes_helper_master_key'); delete_transient('wth_master_key_info'); } }