array(), 'tabs' => array(), ); public function init() { if ( !class_exists('WooCommerce')) return; $this->sub_init('_loyalty_program'); $this->sub_init('_tabs'); } public function sub_init($prefix = '') { if ( !$prefix ) return; if ( !get_option('xstore_sales_booster_settings_'.self::$option_name . $prefix ) ) return; switch ($prefix) { case '_loyalty_program': $this->init_loyalty_program(); break; case '_tabs': if ( get_option( 'woocommerce_enable_myaccount_registration' ) === 'yes' ) $this->init_tabs(); break; } } public function init_loyalty_program() { add_action( 'woocommerce_register_form_end', array($this, 'register_benefits'), 10 ); } public function register_benefits() { $settings = $this->register_benefits_settings(); if ( !count($settings['benefits_ready'])) return; ?>
'.$settings['title'].'' : ''; ?>
settings['loyalty_program'] = array( 'title' => esc_html__('Sign up today and you will be able to:', 'xstore'), 'benefits' => '', 'benefits_ready' => [], ); $local_settings = $this->settings['loyalty_program']; $settings = (array)get_option('xstore_sales_booster_settings', array()); if (count($settings) && isset($settings[self::$option_name . $postfix])) { $local_settings = wp_parse_args( $settings[ self::$option_name . $postfix ], $this->settings['loyalty_program'] ); } $benefits = explode(',', $local_settings['benefits']); if ( count($benefits) < 1) return $this->settings['loyalty_program']; $local_settings['benefits_ready'] = array(); foreach ($benefits as $benefit) { if ( '' == $benefit) continue; $steps_benefits_ready = array( 'icon' => $local_settings[$benefit . '_icon'], 'title' => $local_settings[$benefit . '_title'], 'description' => $local_settings[$benefit . '_description'], ); if ( array_filter($steps_benefits_ready ) ) $local_settings['benefits_ready'][] = $steps_benefits_ready; } // empty all values if ( !array_filter($local_settings['benefits_ready'])) return $this->settings['loyalty_program']; return $local_settings; } public function init_tabs() { $settings = $this->register_tabs_settings(); add_action('wp_enqueue_scripts', array($this, 'load_assets')); add_filter('woocommerce_form_'.($settings['active_tab'] == 'login' ? 'register' : 'login').'_classes', array($this, 'add_classes_hide_form'), 10, 1); add_action('etheme_before_customer_login_form', array($this, 'register_login_form_switcher'), 10); add_action('etheme_before_customer_register_form', array($this, 'register_register_form_switcher'), 10); add_action('woocommerce_login_form_tag', array($this, 'login_form_action')); add_action('woocommerce_register_form_tag', array($this, 'register_form_action')); } public function login_form_action() { echo ' action="'.add_query_arg(array('account-active-tab' => 'login'), get_permalink( get_option( 'woocommerce_myaccount_page_id' ) )).'"'; } public function register_form_action() { echo ' action="'.add_query_arg(array('account-active-tab' => 'register'), get_permalink( get_option( 'woocommerce_myaccount_page_id' ) )).'"'; } public function register_login_form_switcher() { $settings = apply_filters('account_tab_settings', array()); ?>
'.$settings['login_text'].'

'; ?>
'.$settings['register_text'].'

'; ?>
settings['tabs'] = array( 'login_text' => esc_html__('Please log in to your account below in order to continue shopping.', 'xstore'), 'register_text' => esc_html__('Registering for this site will give you access to your order status and history. Please fill in the fields below and we will quickly set up a new account for you. We will only ask you for information that is necessary to make the purchasing process faster and easier.', 'xstore'), 'active_tab' => 'login', ); $local_settings = $this->settings['tabs']; $settings = (array)get_option('xstore_sales_booster_settings', array()); if (count($settings) && isset($settings[self::$option_name . $postfix])) { $local_settings = wp_parse_args( $settings[ self::$option_name . $postfix ], $this->settings['tabs'] ); } if ( isset($_GET['account-active-tab']) ) $local_settings['active_tab'] = $_GET['account-active-tab']; add_filter('account_tab_settings', function ($options) use ($local_settings) { return $local_settings; }); return $local_settings; } /** * Returns the instance. * * @return object * @since 5.1.3 */ public static function get_instance( $shortcodes = array() ) { if ( null == self::$instance ) { self::$instance = new self( $shortcodes ); } return self::$instance; } }