*/ use MailPoet\Models\Segment; use MailPoet\Models\Subscriber; if(!class_exists('MPWA_Frontend_Fields')){ class MPWA_Frontend_Fields { //Helper trait use MPWA_Helper_Function; //Properties public $form_position; public $show_form; public $default_status; public $list_ids; private static $_this_class = NULL; /** * Initialize the class */ public static function init() { if(empty(self::$_this_class)){ self::$_this_class = new self; } return self::$_this_class; }//Edn of init /** * Constructor */ private function __construct() { //Check for if user logged in and already subscribed if(is_user_logged_in()){ $current_user = wp_get_current_user(); $user_subscriber = Subscriber::whereEqual('email', $current_user->user_email)->whereEqual('status', 'subscribed')->findArray(); //If logged in user is not mailpoet subscriber if(empty($user_subscriber)){ $this->run_actions(); } }else{ $this->run_actions(); }//End if }//End of __construct /** * Run necessary hooks * Show subscribe form */ public function run_actions() { //Get the form showing position $this->form_position = get_option('wc_'.$this->tab_slug.'_subscription_position'); //Enable show subscription form $this->show_form = get_option('wc_'.$this->tab_slug.'_enable_subscription'); //Get default checkbox status $this->default_status = get_option('wc_'.$this->tab_slug.'_checkbox_status'); //Get default checkbox status $this->multi_subscription = get_option('wc_'.$this->tab_slug.'_multi_subscription'); // Display GDPR consent $this->show_gdpr_consent = get_option('wc_'.$this->tab_slug.'_show_gdpr_consent'); // Privacy page $this->privacy_page = get_option('wp_page_for_privacy_policy'); if ( !empty($this->privacy_page) ){ $this->privacy_page = get_permalink( $this->privacy_page ); if ( !empty($this->privacy_page) ){ $this->privacy_page = 'Privacy Policy'; } else { $this->privacy_page = '[privacy_policy]'; } } // GDPR Consent Text $this->gdpr_consent_text = get_option('wc_'.$this->tab_slug.'_gdpr_subscription_consent_text'); // Display GDPR unsubscribe option $this->show_gdpr_unsub = get_option('wc_'.$this->tab_slug.'_gdpr_show_unsubscribe'); // GDPR unsubscribe label text $this->gdpr_unsub_label = get_option('wc_'.$this->tab_slug.'_gdpr_unsubscribe_label'); //Subscription Lists selected $this->list_ids = get_option('wc_mailpoet_segment_list', []); //If tick the `Enable subscription` checkbox if('yes' == $this->show_form){ //Hook into the checkout page. Adds the subscription fields. add_action('woocommerce_'.$this->form_position, array($this, 'checkout_page_form')); } }//End of run_actions /** * Checkout page form */ public function checkout_page_form() { ?>
show_gdpr_consent == 'yes' ): ?>
privacy_page, $this->gdpr_consent_text); ?>
show_gdpr_unsub == 'yes'): ?>
show_gdpr_consent == 'yes' ): ?>
privacy_page, $this->gdpr_consent_text); ?>
show_gdpr_unsub == 'yes'): ?>