Ejemplo n.º 1
0
 /**
  * Returns single instance of the class
  *
  * @return \YWRR_Form_Handler
  * @since 1.0.0
  */
 public static function get_instance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self($_REQUEST);
     }
     return self::$instance;
 }
     *
     * @since   1.0.0
     * @return  void
     * @author  Alberto Ruggiero
     */
    public static function unsubscribe_review_request()
    {
        if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
            return;
        }
        if (empty($_POST['action']) || 'unsubscribe_review_request' !== $_POST['action'] || empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'unsubscribe_review_request')) {
            return;
        }
        $customer_email = !empty($_POST['account_email']) ? sanitize_email($_POST['account_email']) : '';
        if (empty($customer_email) || !is_email($customer_email)) {
            wc_add_notice(__('Please provide a valid email address.', 'ywrr'), 'error');
        } elseif ($customer_email !== urldecode(base64_decode($_GET['email']))) {
            wc_add_notice(__('Please retype the email address as provided.', 'ywrr'), 'error');
        }
        if (wc_notice_count('error') === 0) {
            $wc_email = WC_Emails::instance();
            $email = $wc_email->emails['YWRR_Unsubscribe_Mail'];
            $email->trigger($customer_email);
            wc_add_notice(__('An email has been sent with your request', 'ywrr'));
            wp_safe_redirect(get_permalink(get_option('ywrr_unsubscribe_page_id')));
            exit;
        }
    }
}
YWRR_Form_Handler::init();