/** * Main WCSO Instance. * * Ensures only one instance of WCSO is loaded or can be loaded. * * @static * @see WCSO() * @return WCSO - Main instance */ public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Checks if the current request is by a user to skip one of their subscription, * and if it is, validate the request and proceed to change to the subscription. * * @since 1.0.0 * @access public * @static * @uses get_current_user_id() */ public static function maybe_change_users_subscription() { if (isset($_GET['skip_subscription']) && isset($_GET['subscription_id']) && isset($_GET['_wpnonce'])) { $user_id = get_current_user_id(); $subscription = wcs_get_subscription($_GET['subscription_id']); if (self::validate_request($user_id, $subscription, $_GET['_wpnonce'])) { $order_id = $_GET['order_id']; // Get order id self::change_users_subscription($subscription, $order_id, $product_id); wp_safe_redirect(WCSO::get_cancel_sub_url()); exit; } } }