require_class($_REQUEST['helper']); } add_action( 'wp_ajax_et_panel_ajax', array($this, 'et_panel_ajax') ); add_action('wp_ajax_et_close_installation_video', array($this, 'et_close_installation_video')); $current_theme = wp_get_theme(); $this->theme_name = strtolower( preg_replace( '#[^a-zA-Z]#', '', $current_theme->get( 'Name' ) ) ); add_action( 'admin_init', array( $this, 'admin_redirects' ), 30 ); add_action('admin_init',array($this,'add_page_admin_script'), 1140); add_filter('admin_body_class', array($this, 'admin_body_class')); if(!is_child_theme()){ add_action( 'after_switch_theme', array( $this, 'switch_theme' ) ); } if ( ! $this->set_page_data() ){ return; } if (isset($this->page['class']) && ! empty($this->page['class'])){ $this->require_class($this->page['class']); } // Stas $this->init_vars(); } public static function add_svg_support( $mimes ) { $mimes['svg'] = 'image/svg+xml'; $mimes['json'] = 'application/json'; return $mimes; } /** * Correct SVG file uploads to make them pass the WP check. * * WP upload validation relies on the fileinfo PHP extension, which causes inconsistencies. * E.g. json file type is application/json but is reported as text/plain. * ref: https://core.trac.wordpress.org/ticket/45633 * * @access public * @since 4.3.4 * @param array $data Values for the extension, mime type, and corrected filename. * @param string $file Full path to the file. * @param string $filename The name of the file (may differ from $file due to * $file being in a tmp directory). * @param string[] $mimes Array of mime types keyed by their file extension regex. * @param string|bool $real_mime The actual mime type or false if the type cannot be determined. * * @return array */ public function correct_svg_filetype( $data, $file, $filename, $mimes, $real_mime = false ) { // If both ext and type are. if ( ! empty( $data['ext'] ) && ! empty( $data['type'] ) ) { return $data; } $wp_file_type = wp_check_filetype( $filename, $mimes ); if ( 'svg' === $wp_file_type['ext'] ) { $data['ext'] = 'svg'; $data['type'] = 'image/svg+xml'; } return $data; } public function init_vars() { $this->settingJsConfig = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'resetOptions' => __( 'All your settings will be reset to default values. Are you sure you want to do this ?', 'xstore' ), 'pasteYourOptions' => __( 'Please, paste your options there.', 'xstore' ), 'loadingOptions' => __( 'Loading options', 'xstore' ) . '...', 'ajaxError' => __( 'Ajax error', 'xstore' ), 'nonce' => wp_create_nonce( 'xstore_panel_saving_nonce' ), 'audioPlaceholder' => ETHEME_BASE_URI.'framework/panel/images/audio.png', ); return $this->settingJsConfig; } public static function get_instance() { if ( ! self::$instance ) { self::$instance = new self(); } return self::$instance; } public function admin_body_class($class) { global $pagenow; $screen = get_current_screen(); $screen_id = $screen ? $screen->id : ''; if ( strpos($screen_id, 'et-panel') ) { $class .= ' et-'.get_option('et_panel_dark_light_default', 'light').'-mode'; } return $class; } /** * enqueue scripts for current panel page * * @version 1.0.2 * @since 7.0.0 */ public function add_page_admin_script(){ wp_register_script('etheme_panel_global',ETHEME_BASE_URI.'framework/panel/js/global.min.js', array('jquery','etheme_admin_js'), false,true); wp_localize_script( 'etheme_panel_global', 'XStorePanelConfig', array( 'messages' => array( 'register_licence' => esc_html__('Oops... There was an issue updating your theme. We could not validate your purchase code. Please register the theme and try again, or contact our support forum for more information.', 'xstore'), ) )); if ( isset($this->page['script']) && ! empty($this->page['script']) ){ wp_register_script('etheme_panel_'.$this->page['script'],ETHEME_BASE_URI.'framework/panel/js/'.$this->page['script'].'.js', array('jquery','etheme_admin_js'), false,true); // prevent loading this JS file and load it only in case it requires from the other files if ( !in_array($this->page['script'], array('system_requirements.min'))) wp_enqueue_script('etheme_panel_'.$this->page['script']); switch ($this->page['script']) { case 'patcher.min': wp_localize_script( 'etheme_panel_'.$this->page['script'], 'XStorePanelPatcherConfig', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'success' => esc_html__('Successfully applied', 'xstore'), 'applied_btn' => ''. '' . esc_html__('Applied', 'xstore').'', 'error_btn' => ''. '' . esc_html__('Error', 'xstore').'', 'apply_all' => esc_html__('Before proceeding, please confirm that you wish to apply all patches.', 'xstore'), 'backup_info' => esc_html__('We recommend that you make backups of your website before making any changes.', 'xstore'), 'question' => esc_html__('Before proceeding, please confirm that you wish to apply this patch.', 'xstore'), 'test_mode' => isset($_GET['xstore-patches-test-mode']), 'nonce' => wp_create_nonce( 'xstore_patches_apply_nonce' ), 'file_will_modify' => esc_html__('Please, note that the following file will be modified: {{file}}', 'xstore'), 'files_will_modify' => esc_html__('Please, note that the following files will be modified: {{files}}', 'xstore') ) ); break; case 'welcome.min': wp_register_script( 'slick_carousel', get_template_directory_uri() . '/js/libs/slick.min.js', array('jquery') ); wp_register_style( 'slick-carousel', get_template_directory_uri() . '/css/libs/slick.css' ); break; case 'demos.min': case 'plugins.min': case 'sales_booster.min': wp_enqueue_script( 'jquery_lazyload'); break; } } if ( isset($this->page['template']) && ! empty($this->page['template']) ){ if ( etheme_is_activated() && get_option('et_documentation_beacon', false) !== 'off') wp_enqueue_script('etheme_panel_documentation',ETHEME_BASE_URI.'framework/panel/js/documentation.min.js', array('jquery','etheme_admin_js'), false,true); if ( in_array($this->page['template'], array('changelog', 'theme-builders')) ) wp_enqueue_script('etheme_panel_global'); } if (did_action('etheme_panel_page_has_options') ) { wp_enqueue_script('etheme_panel_global'); wp_enqueue_script( 'xstore_panel_settings_admin_js', ETHEME_BASE_URI.'framework/panel/js/settings/save_action.min.js' ); wp_localize_script( 'xstore_panel_settings_admin_js', 'XStorePanelSettingsConfig', $this->settingJsConfig ); } } // deprecated since v9.4 but need to be to prevent fatal errors in XStore AMO/White label branding public function add_page_admin_settings_scripts() { // wp_enqueue_script( 'xstore_panel_settings_admin_js', ETHEME_BASE_URI.'framework/panel/js/settings/save_action.min.js', array('wp-color-picker') ); // // wp_localize_script( 'xstore_panel_settings_admin_js', 'XStorePanelSettingsConfig', $this->settingJsConfig ); } // deprecated since v9.4 but need to be to prevent fatal errors in XStore AMO/White label branding public function add_page_admin_settings_xstore_icons() { } public function xstore_panel_icons_fonts_enqueue() { $dir_uri = get_template_directory_uri(); $icons_type = ( etheme_get_option('bold_icons', 0) ) ? 'bold' : 'light'; wp_register_style( 'xstore-icons-font', false ); wp_enqueue_style( 'xstore-icons-font' ); wp_add_inline_style( 'xstore-icons-font', "@font-face { font-family: 'xstore-icons'; src: url('".$dir_uri."/fonts/xstore-icons-".$icons_type.".ttf') format('truetype'), url('".$dir_uri."/fonts/xstore-icons-".$icons_type.".woff2') format('woff2'), url('".$dir_uri."/fonts/xstore-icons-".$icons_type.".woff') format('woff'), url('".$dir_uri."/fonts/xstore-icons-".$icons_type.".svg#xstore-icons') format('svg'); font-weight: normal; font-style: normal; font-display: swap; }" ); wp_enqueue_style( 'xstore-icons-font-style', $dir_uri . '/css/xstore-icons.css' ); } /** * Set panel page data * * @version 1.0.2 * @since 7.0.0 * @log added sales_booster actions */ public function set_page_data(){ if (! isset($_REQUEST['page'])){ return false; } switch ( $_REQUEST['page'] ) { case 'et-panel-system-requirements': $this->page['template'] = 'system-requirements'; $this->page['script'] = 'system_requirements.min'; break; case 'et-panel-changelog': $this->page['template'] = 'changelog'; break; case 'et-panel-support': $this->page['template'] = 'support'; $this->page['class'] = 'youtube'; $this->page['script'] = 'support.min'; break; case 'et-panel-demos': $this->page['template'] = 'demos'; $this->page['script'] = 'demos.min'; break; case 'et-panel-patcher': $this->page['template'] = 'patcher'; $this->page['script'] = 'patcher.min'; break; case 'et-panel-custom-fonts': $this->page['template'] = 'custom-fonts'; break; case 'et-panel-sales-booster': $this->page['script'] = 'sales_booster.min'; $this->page['template'] = 'sales-booster'; $this->page['class'] = 'sales-booster'; do_action('etheme_panel_page_has_options'); break; case 'et-panel-maintenance-mode': $this->page['script'] = 'maintenance_mode.min'; $this->page['template'] = 'maintenance-mode'; $this->page['class'] = 'maintenance-mode'; break; case 'et-panel-social-authentication': $this->page['script'] = 'instagram.min'; $this->page['template'] = 'social-authentication'; $this->page['class'] = 'instagram'; break; case 'et-panel-social': $this->page['script'] = 'instagram.min'; $this->page['template'] = 'instagram'; $this->page['class'] = 'instagram'; break; case 'et-panel-open-ai': $this->page['script'] = 'ai.min'; $this->page['template'] = 'ai'; // $this->page['class'] = 'ai'; break; case 'et-panel-plugins': $this->page['script'] = 'plugins.min'; $this->page['template'] = 'plugins'; $this->page['class'] = 'plugins'; break; case 'et-panel-email-builder': $this->page['script'] = 'email_builder.min'; $this->page['template'] = 'email-builder'; $this->page['class'] = 'email-builder'; break; case 'et-panel-theme-builders': $this->page['script'] = 'theme-builder.min'; $this->page['template'] = 'theme-builders'; $this->page['class'] = 'plugins'; break; case 'et-panel-white-label-branding': case 'et-panel-xstore-amp': do_action('etheme_panel_page_has_options'); break; case 'et-panel-search-stats': // do_action('etheme_panel_page_has_options'); break; default: if ( strpos($_REQUEST['page'], 'et-panel') !== false ) { if ( $_REQUEST['page'] == 'et-panel-email-builder-templates' ) { wp_safe_redirect( admin_url('edit.php?post_type=viwec_template') ); } else { $this->page['template'] = 'welcome'; $this->page['script'] = 'welcome.min'; } } break; } return true; } /** * Require page classes * * require page classes when ajax process and return the callbacks for ajax requests * * @version 1.0.0 * @since 7.0.0 * @param string $class class filename */ public function require_class($class=''){ if (! $class){ return; } require_once( apply_filters('etheme_file_url', ETHEME_CODE . 'panel/classes/'.sanitize_file_name($class).'.php') ); } /** * Global panel ajax * * require page classes when ajax process and return the callbacks for ajax requests * * @version 1.0.2 * @since 7.0.0 * @todo remove this * @log added sales_booster actions */ public function et_panel_ajax(){ if ( isset($_POST['action_type']) ){ switch ( $_POST['action_type'] ) { case 'et_instagram_user_add': $this->require_class('instagram'); $class = new Instagram(); $class->et_instagram_user_add(); break; case 'et_instagram_user_remove': $this->require_class('instagram'); $class = new Instagram(); $class->et_instagram_user_remove(); break; case 'et_instagram_save_settings': $this->require_class('instagram'); $class = new Instagram(); $class->et_instagram_save_settings(); break; case 'et_email_builder_switch_default': $this->require_class('email-builder'); $class = new EmailBuilder(); $class->et_email_builder_switch_default(); break; case 'et_documentation_beacon': $this->require_class('youtube'); $class = new YouTube(); $class->et_documentation_beacon(); break; case 'et_email_builder_switch_dev_mode_default': $this->require_class('email-builder'); $class = new EmailBuilder(); $class->et_email_builder_switch_dev_mode_default(); break; case 'et_maintenance_mode_switch_default': $this->require_class('maintenance-mode'); $class = new MaintenanceMode(); $class->et_maintenance_mode_switch_default(); break; case 'et_panel_dark_light_switch_default': $this->et_panel_dark_light_switch_default(); break; default: break; } } } public function et_panel_dark_light_switch_default(){ update_option( 'et_panel_dark_light_default', $_POST['value']); die(); } /** * Add admin panel dashboard pages to admin menu. * * @since 5.0.0 * @version 1.0.3 */ public function et_add_menu_page(){ $system = class_exists('Etheme_System_Requirements') ? Etheme_System_Requirements::get_instance() : new Etheme_System_Requirements(); $system->system_test(); $result = $system->result(); $allow_full_access = !etheme_activation_required(); $allow_force_access_woocommerce_features = true; $is_et_core = class_exists('ETC\App\Controllers\Admin\Import'); $is_activated = etheme_is_activated(); $is_wc = class_exists('WooCommerce'); $is_elementor = class_exists('\Elementor\Plugin'); $info_base = ''; $info = str_replace('{{info_color}}', 'var(--et_admin_orange-color)', $info_base); $info = ''; $update_info = str_replace('{{info_color}}', 'var(--et_admin_green-color)', $info_base); $update_info = ''; $icon = ETHEME_CODE_IMAGES . 'wp-icon.svg'; $label = 'XStore'; $plugin_label = 'XStore'; $show_pages = array( 'welcome', 'system_requirements', 'demos', 'plugins', 'patcher', 'open_ai', 'customize', 'email_builder', 'sales_booster', 'custom_fonts', 'maintenance_mode', 'social_authentication', 'social', 'support', 'changelog', 'sponsors' ); $hide_theme_builders = false; $xstore_branding_settings = get_option( 'xstore_white_label_branding_settings', array() ); if ( count($xstore_branding_settings) ) { if (isset($xstore_branding_settings['control_panel'])) { if ($xstore_branding_settings['control_panel']['icon']) $icon = $xstore_branding_settings['control_panel']['icon']; if ($xstore_branding_settings['control_panel']['label']) $label = $xstore_branding_settings['control_panel']['label']; if (isset($xstore_branding_settings['control_panel']['hide_theme_builders']) && $xstore_branding_settings['control_panel']['hide_theme_builders'] == 'on') $hide_theme_builders = true; $show_pages_parsed = array(); foreach ($show_pages as $show_page) { if (isset($xstore_branding_settings['control_panel']['page_' . $show_page])) $show_pages_parsed[] = $show_page; }; $show_pages = $show_pages_parsed; } if ( isset($xstore_branding_settings['plugins_data'] ) ) { if (isset($xstore_branding_settings['plugins_data']['label']) && !empty($xstore_branding_settings['plugins_data']['label'])) $plugin_label = $xstore_branding_settings['plugins_data']['label']; } } $priorities = array( 'welcome' => 52, 'theme-builders' => 52.2, 'staticblocks' => 53.2, // in another file 'etheme_portfolio' => 54, // in another file 'sales-booster' => 52.3, 'widgets' => 52.35, 'email-builder' => 52.4, 'theme-options' => 52.1, 'etheme_slides' => 53.1, 'etheme_mega_menus' => 53 ); $icons = array( 'welcome' => $icon, 'theme-builders' => 'dashicons-schedule', 'staticblocks' => 'dashicons-welcome-widgets-menus', // in another file 'etheme_portfolio' => 'dashicons-images-alt', 'sales-booster' => 'dashicons-chart-bar', 'widgets' => 'dashicons-align-right', 'email-builder' => 'dashicons-email-alt', 'theme-options' => 'dashicons-admin-settings', 'etheme_slides' => 'dashicons-images-alt2', 'etheme_mega_menus' => 'dashicons-welcome-widgets-menus' ); $is_update_support = 'active'; $is_subscription = false; if ( $is_activated ){ if (apply_filters('etheme_hide_updates', false)){ $is_update_support = 'active'; $is_update_available = false; } else { $check_update = new ETheme_Version_Check(); $is_update_available = $check_update->is_update_available(); $is_update_support = 'active'; //$check_update->get_support_status(); $is_subscription = $check_update->is_subscription; } } else { $is_update_available = false; } if ($is_activated && $is_update_support !='active' && $result){ if ($is_update_support == 'expire-soon'){ $info = str_replace('{{info_color}}', 'var(--et_admin_orange-color)', $info_base); } else { $info = str_replace('{{info_color}}', 'var(--et_admin_red-color)', $info_base); } } else if ($is_activated && $is_update_available && $result ){ $info = $update_info; } elseif(!$is_activated){ $info = str_replace('{{info_color}}', 'var(--et_admin_orange-color)', $info_base); } // temporary disable setter for notices // @todo remove when alerts will be fully redesigned $info = ''; $server_label = esc_html__( 'System Status', 'xstore' ); if (!$result && ($is_activated || $allow_full_access)){ $server_label = esc_html__( 'Server Reqs.', 'xstore' ); $server_label .= ' ' . $info; } add_menu_page( $label . ' ' . ( ( (!$is_activated && !$allow_full_access) || !$result || $is_update_available || $is_update_support !='active' ) ? $info : '' ), $label . ' ' . ( ( (!$is_activated && !$allow_full_access) || !$result || $is_update_available || $is_update_support !='active' ) ? $info : '' ), 'manage_options', 'et-panel-welcome', array( $this, 'etheme_panel_page' ), $icons['welcome'], $priorities['welcome'] ); if ( in_array('welcome', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__( 'Dashboard', 'xstore' ) .' '. ( (!$is_activated && !$allow_full_access) || ($is_update_support !='active' && $result) ? $info : ''), esc_html__( 'Dashboard', 'xstore' ) .' '. ( (!$is_activated && !$allow_full_access) || ($is_update_support !='active' && $result) ? $info : ''), 'manage_options', 'et-panel-welcome', array( $this, 'etheme_panel_page' ) ); } if ( (!$is_activated || !$is_et_core) || $allow_full_access ) { if ( in_array('system_requirements', $show_pages) ) { add_submenu_page( 'et-panel-welcome', $server_label, $server_label, 'manage_options', 'et-panel-system-requirements', array( $this, 'etheme_panel_page' ) ); } } if ( $is_activated || $allow_full_access ) { // make active link if theme is active if ( in_array('demos', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__( 'Import Demos 130+', 'xstore' ), esc_html__( 'Import Demos 130+', 'xstore' ), 'manage_options', 'et-panel-demos', array( $this, 'etheme_panel_page' ) ); } if ( in_array('plugins', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__( 'Plugins Installer', 'xstore' ), esc_html__( 'Plugins Installer', 'xstore' ), 'manage_options', 'et-panel-plugins', array( $this, 'etheme_panel_page' ) ); } // tweak this page link to make link available always // but is hidden with css if is disabled from XStore White Label Branding plugin $available_patches_affix = ''; // if ( class_exists('Etheme_Patcher') ) { // $patcher = Etheme_Patcher::get_instance(); // $available_patches = count($patcher->get_available_patches(ETHEME_THEME_VERSION)); // if ( $available_patches ) { // $available_patches_affix = ' '. // $available_patches. // ''; // } // } add_submenu_page( 'et-panel-welcome', (in_array('patcher', $show_pages) ? esc_html__( 'Patcher', 'xstore' ) : ''), (in_array('patcher', $show_pages) ? esc_html__( 'Patcher', 'xstore' ) : '') . $available_patches_affix, 'manage_options', 'et-panel-patcher', array( $this, 'etheme_panel_page' ) ); } if ( ($is_activated || $allow_full_access) && in_array('custom_fonts', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__( 'Custom Fonts', 'xstore' ), esc_html__( 'Custom Fonts', 'xstore' ), 'manage_options', 'et-panel-custom-fonts', array( $this, 'etheme_panel_page' ) ); } if ( ($is_activated && $is_et_core) || $allow_full_access ) { $is_amp = class_exists('XStore_AMP'); if ( !$is_amp ) { add_submenu_page( 'et-panel-welcome', esc_html__('AMP XStore', 'xstore'), esc_html__('AMP XStore', 'xstore'), 'manage_options', (!$is_amp || !$is_activated ? 'et-panel-plugins&plugin=xstore-amp' : 'et-panel-xstore-amp'), (!$is_amp || !$is_activated ? array($this, 'etheme_panel_page') : '') ); } if (in_array('open_ai', $show_pages)) { add_submenu_page( 'et-panel-welcome', esc_html__('ChatGPT', 'xstore'), esc_html__('ChatGPT', 'xstore'), 'manage_options', 'et-panel-open-ai', array($this, 'etheme_panel_page') ); } if (in_array('social_authentication', $show_pages)) { add_submenu_page( 'et-panel-welcome', esc_html__('Social Authentication', 'xstore'), esc_html__('Social Authentication', 'xstore'), 'manage_options', 'et-panel-social-authentication', array($this, 'etheme_panel_page') ); } if (in_array('social', $show_pages)) { add_submenu_page( 'et-panel-welcome', esc_html__('API Integrations', 'xstore'), esc_html__('API Integrations', 'xstore'), 'manage_options', 'et-panel-social', array($this, 'etheme_panel_page') ); } if (in_array('maintenance_mode', $show_pages)) { add_submenu_page( 'et-panel-welcome', esc_html__('Maintenance Mode', 'xstore'), esc_html__('Maintenance Mode', 'xstore'), 'manage_options', 'et-panel-maintenance-mode', array($this, 'etheme_panel_page') ); } if ( in_array('support', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__( 'Tutorials & Support', 'xstore' ), esc_html__( 'Tutorials & Support', 'xstore' ), 'manage_options', 'et-panel-support', array( $this, 'etheme_panel_page' ) ); } if (in_array('system_requirements', $show_pages)) { add_submenu_page( 'et-panel-welcome', $server_label, $server_label, 'manage_options', 'et-panel-system-requirements', array($this, 'etheme_panel_page') ); } if ( in_array('changelog', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__( 'Changelog', 'xstore' ), esc_html__( 'Changelog', 'xstore' ), 'manage_options', 'et-panel-changelog', array( $this, 'etheme_panel_page' ) ); } } if ( ($is_activated || $allow_full_access) && in_array('sponsors', $show_pages) ) { add_submenu_page( 'et-panel-welcome', esc_html__('SEO Experts', 'xstore'), esc_html__('SEO Experts', 'xstore'), 'manage_options', 'https://overflowcafe.com/am/aff/go/8theme', '' ); } //add_submenu_page( // 'et-panel-welcome', // esc_html__( 'Customization Services', 'xstore' ), // esc_html__( 'Customization Services', 'xstore' ), // 'manage_options', // 'https://wpkraken.io/?ref=8theme', // '' //); // add_submenu_page( // 'et-panel-welcome', // esc_html__( 'Woocommerce Hosting', 'xstore' ), // esc_html__( 'Woocommerce Hosting', 'xstore' ), // 'manage_options', // 'http://www.bluehost.com/track/8theme', // '' // ); add_submenu_page( 'et-panel-welcome', esc_html__( 'Get WPML Plugin', 'xstore' ), esc_html__( 'Get WPML Plugin', 'xstore' ), 'manage_options', 'https://wpml.org/?aid=46060&affiliate_key=YI8njhBqLYnp&dr', '' ); // add_submenu_page( // 'et-panel-welcome', // esc_html__( 'Hosting Service', 'xstore' ), // esc_html__( 'Hosting Service', 'xstore' ), // 'manage_options', // 'https://www.siteground.com/index.htm?afcode=37f764ca72ceea208481db0311041c62', // '' // ); // if (!$is_subscription){ // add_submenu_page( // 'et-panel-welcome', // esc_html__( 'Go Unlimited', 'xstore' ), // esc_html__( 'Go Unlimited', 'xstore' ), // 'manage_options', // 'https://www.8theme.com/#price-section-anchor', // '' // ); // } // add_submenu_page( // 'et-panel-welcome', // esc_html__( 'WooCommerce Plugins', 'xstore' ), // esc_html__( 'WooCommerce Plugins', 'xstore' ), // 'manage_options', // 'https://yithemes.com/product-category/plugins/?refer_id=1028760', // '' // ); // if ( $is_et_core ) { // add_submenu_page( // 'et-panel-welcome', // esc_html__( 'Rate Theme', 'xstore' ), // esc_html__( 'Rate Theme', 'xstore' ), // 'manage_options', // 'https://themeforest.net/item/xstore-responsive-woocommerce-theme/reviews/15780546', // '' // ); // } if ( ($allow_force_access_woocommerce_features || $is_wc) && in_array( 'email_builder', $show_pages ) ) { add_menu_page( esc_html__( 'Email Builder', 'xstore' ), esc_html__( 'Email Builder', 'xstore' ), 'manage_options', 'et-panel-email-builder', array( $this, 'etheme_panel_page' ), $icons['email-builder'], $priorities['email-builder'] ); if ( get_option('etheme_built_in_email_builder', false) ) { add_submenu_page( 'et-panel-email-builder', esc_html__( 'Email Builder', 'xstore' ), esc_html__( 'General Settings', 'xstore'), 'manage_options', 'et-panel-email-builder', array($this, 'etheme_panel_page') ); add_submenu_page( 'et-panel-email-builder', esc_html__('View Templates', 'xstore'), esc_html__('View Templates', 'xstore'), 'manage_options', 'et-panel-email-builder-templates', array($this, 'etheme_panel_page') ); } } if ( ($is_et_core && $is_activated) || $allow_full_access ) { add_menu_page( esc_html__('Widgets', 'xstore'), esc_html__('Widgets', 'xstore'), 'edit_theme_options', admin_url('widgets.php'), '', $icons['widgets'], $priorities['widgets'] ); } if ( ($is_activated || $allow_full_access) && ($allow_force_access_woocommerce_features || $is_wc) && in_array( 'sales_booster', $show_pages ) ) { add_menu_page( esc_html__( 'Sales Booster', 'xstore' ), esc_html__( 'Sales Booster', 'xstore' ), 'manage_options', 'et-panel-sales-booster', array( $this, 'etheme_panel_page' ), $icons['sales-booster'], $priorities['sales-booster'] ); add_submenu_page( 'et-panel-sales-booster', esc_html__( 'Sales Booster', 'xstore' ), esc_html__( 'All Features', 'xstore' ), 'manage_options', 'et-panel-sales-booster', array($this, 'etheme_panel_page') ); $sales_booster_main_features = array( 'fake_sale_popup' => esc_html__('Fake Sale Popup', 'xstore'), 'cart_checkout_countdown' => esc_html__( 'Cart Countdown', 'xstore' ), 'cart_checkout_progress_bar' => esc_html__( 'Progress Bar', 'xstore' ), 'fake_live_viewing' => esc_html__('Fake Live Viewing', 'xstore'), 'fake_product_sales' => esc_html__('Item Sold Indicator', 'xstore'), 'customer_reviews_advanced' => esc_html__('Advanced Reviews', 'xstore'), 'quantity_discounts' => esc_html__('Quantity Discounts', 'xstore'), 'safe_checkout' => esc_html__('Safe Checkout', 'xstore'), ); foreach ($sales_booster_main_features as $sales_booster_main_feature_key => $sales_booster_main_feature_title) { add_submenu_page( 'et-panel-sales-booster', esc_html__( 'Sales Booster', 'xstore' ), $sales_booster_main_feature_title, 'manage_options', 'et-panel-sales-boosterðeme-sales-booster-tab='.$sales_booster_main_feature_key, array($this, 'etheme_panel_page') ); } add_submenu_page( 'et-panel-sales-booster', esc_html__( 'Sales Booster', 'xstore' ), esc_html__( 'More Features', 'xstore' ) . ' →', 'manage_options', 'et-panel-sales-booster', array($this, 'etheme_panel_page') ); } if ( $allow_full_access && !$is_et_core ) { add_menu_page( esc_html__( 'Static Blocks', 'xstore' ), esc_html__( 'Static Blocks', 'xstore' ), 'manage_options', 'et-panel-staticblocks_post_type', array( $this, 'etheme_panel_page' ), $icons['staticblocks'], $priorities['staticblocks'] ); } if ( $allow_full_access && (!$is_et_core || !$is_elementor) ) { add_menu_page( esc_html__( 'Mega Menus', 'xstore' ), esc_html__( 'Mega Menus', 'xstore' ), 'manage_options', 'et-panel-etheme_mega_menus_post_type', array( $this, 'etheme_panel_page' ), $icons['etheme_mega_menus'], $priorities['etheme_mega_menus'] ); add_menu_page( esc_html__( 'Slides', 'xstore' ), esc_html__( 'Slides', 'xstore' ), 'manage_options', 'et-panel-etheme_slides_post_type', array( $this, 'etheme_panel_page' ), $icons['etheme_slides'], $priorities['etheme_slides'] ); } if ( $allow_full_access && !$is_et_core ) { add_menu_page( esc_html__( 'Portfolio', 'xstore' ), esc_html__( 'Portfolio', 'xstore' ), 'manage_options', 'et-panel-etheme_portfolio_post_type', array( $this, 'etheme_panel_page' ), $icons['etheme_portfolio'], $priorities['etheme_portfolio'] ); } if ( ($is_activated || $allow_full_access) && !$hide_theme_builders ) { // && class_exists('\Elementor\Plugin') // $theme_builder_key = 'et-elementor'. ($has_pro ? '-pro' : '') . '-theme-builder'; $theme_builder_key = 'et-panel-theme-builders'; add_menu_page( sprintf(esc_html__('%s Builders', 'xstore'), $label), sprintf(esc_html__('%s Builders', 'xstore'), $label), 'manage_options', $theme_builder_key, array( $this, 'etheme_panel_page_theme_builders' ), $icons['theme-builders'], $priorities['theme-builders'] ); // if ( $has_pro ) { add_submenu_page( $theme_builder_key, esc_html__('Builders Panel', 'xstore'), esc_html__('Builders Panel', 'xstore'), 'manage_options', $theme_builder_key, array( $this, 'etheme_panel_page_theme_builders' ) ); $theme_builders = array( 'header' => array( 'title' => esc_html__('Header', 'xstore'), 'multiple_builders' => [ 'customizer' => admin_url('/customize.php?autofocus[panel]=header-builder'), 'elementor' => true ], ), 'footer' => array( 'title' => esc_html__('Footer', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ) ); // if ( $allow_force_access_woocommerce_features || $is_wc ) { $theme_builders = array_merge($theme_builders, array( 'product' => array( 'title' => esc_html__('Single Product', 'xstore'), 'multiple_builders' => [ 'customizer' => admin_url('/customize.php?autofocus['.(get_option( 'etheme_single_product_builder', false ) ? 'panel' : 'section').']=single_product_builder'), 'elementor' => true ], ), 'product-archive' => array( 'title' => esc_html__('Products Archive', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), 'myaccount' => array( 'title' => esc_html__('My Account Page', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), 'cart' => array( 'title' => esc_html__('Cart Page', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), 'checkout' => array( 'title' => esc_html__('Checkout Page', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), 'archive' => array( 'title' => esc_html__('Archive', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), )); // } $theme_builders = array_merge($theme_builders, array( 'search-results' => array( 'title' => esc_html__('Search Results', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), 'error-404' => array( 'title' => esc_html__('Error-404', 'xstore'), 'multiple_builders' => [ 'elementor' => true ], ), )); $has_pro = $is_elementor && defined( 'ELEMENTOR_PRO_VERSION' ); $elementor_pro_theme_builder_link = $has_pro ? \Elementor\Plugin::$instance->app->get_settings('menu_url') : ''; foreach ($theme_builders as $theme_builder_unique_key => $theme_builder_unique_info) { $allow_customizer_builder = isset($theme_builder_unique_info['multiple_builders']['customizer']); $allow_elementor_builder = isset($theme_builder_unique_info['multiple_builders']['elementor']); if ( !$is_wc && in_array($theme_builder_unique_key, array('product','product-old', 'product-archive', 'myaccount', 'cart', 'checkout') ) ) $allow_customizer_builder = $allow_elementor_builder = false; $builder_url = admin_url( 'admin.php?page=et-panel-theme-builders' ); $builders_panel_url = admin_url( 'admin.php?page=et-panel-theme-builders' ); // takeover the priority for Customizer builder over other theme builders if ( $allow_customizer_builder ) $builder_url = $theme_builder_unique_info['multiple_builders']['customizer']; // takeover the priority for Elementor builder over other theme builders if ( $allow_elementor_builder ) { if ( in_array($theme_builder_unique_key, array('myaccount', 'cart', 'checkout')) ) { if ($has_pro) { if ( !get_option('et_theme_builder_wc_install_done', false) && method_exists('\WC_Install', 'create_pages') && get_option('etheme_current_version') ) { remove_filter('woocommerce_create_pages', 'etheme_do_not_setup_demo_pages', 10); \WC_Install::create_pages(); // to start this once only on first load update_option('et_theme_builder_wc_install_done', 'yes'); } $cart_checkout_page_id = get_option('woocommerce_' . $theme_builder_unique_key . '_page_id'); // wc_get_page_id($theme_builder_unique_key) not working correct; if ($cart_checkout_page_id > 0) { $builder_url = add_query_arg(array('post' => $cart_checkout_page_id, 'action' => 'elementor', 'et_page' => $theme_builder_unique_key), admin_url('post.php')); } else { // $builder_url = $elementor_pro_theme_builder_link . '/templates/single-page'; $builder_url = add_query_arg(array('post_type' => 'page', 'action' => 'elementor', 'et_page' => $theme_builder_unique_key), admin_url('post-new.php')); } } } else $builder_url = !$has_pro ? $builders_panel_url : $elementor_pro_theme_builder_link . '/templates/' . $theme_builder_unique_key; } add_submenu_page( $theme_builder_key, $theme_builder_unique_info['title'], $theme_builder_unique_info['title'], 'manage_options', $builder_url, '' ); } // } } if ( ($allow_full_access || $is_et_core) && in_array('customize', $show_pages) ) { if ( ($is_activated || $allow_full_access) && $is_et_core ) { add_menu_page( esc_html__('Theme Options', 'xstore'), esc_html__('Theme Options', 'xstore'), 'manage_options', 'et-panel-theme-options', '', $icons['theme-options'], $priorities['theme-options'] ); add_submenu_page( 'et-panel-theme-options', 'Header Builder', 'Header Builder', 'manage_options', admin_url('/customize.php?autofocus[panel]=header-builder'), '' ); } else { add_menu_page( esc_html__('Theme Options', 'xstore'), esc_html__('Theme Options', 'xstore'), 'manage_options', 'et-panel-theme-options', admin_url( 'themes.php?page=install-required-plugins&plugin_status=all' ), $icons['theme-options'], $priorities['theme-options'] ); } } } /** * Add target blank to some dashboard pages. * * @since 6.2 * @version 1.0.0 */ public function et_add_menu_page_target() { ob_start(); ?> page['template']) && ! empty($this->page['template']); ob_start(); get_template_part( 'framework/panel/templates/page', 'header' ); get_template_part( 'framework/panel/templates/page', 'navigation' ); echo '
You can add any HTML here (admin -> Theme Options -> E-Commerce -> Promo Popup).
We suggest you create a static block and use it by turning on the settings below<\/p>","newsletter_sections_et-desktop":false,"newsletter_section_et-desktop":"","newsletter_content_alignment_et-desktop":"start","newsletter_background_et-desktop":{"background-color":"#ffffff","background-image":"","background-repeat":"no-repeat","background-position":"center center","background-size":"","background-attachment":""},"newsletter_background_et-desktop[background-color]":null,"newsletter_box_model_et-desktop":{"margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","border-top-width":"0px","border-right-width":"0px","border-bottom-width":"0px","border-left-width":"0px","padding-top":"15px","padding-right":"15px","padding-bottom":"15px","padding-left":"15px"},"newsletter_border_et-desktop":"solid","newsletter_border_color_custom_et-desktop":"","contacts_icon_et-desktop":"left","contacts_direction_et-desktop":"hor","contacts_package_et-desktop":[{"contact_title":"Phone","contact_subtitle":"Call us any time","contact_icon":"et_icon-phone"},{"contact_title":"Hours","contact_subtitle":"Call us any time 24\/7","contact_icon":"et_icon-calendar"},{"contact_title":"Email","contact_subtitle":"Write us any time","contact_icon":"et_icon-chat"}],"contacts_alignment_et-desktop":"start","contact_box_model_et-desktop":{"margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","border-top-width":"0px","border-right-width":"0px","border-bottom-width":"0px","border-left-width":"0px","padding-top":"0px","padding-right":"10px","padding-bottom":"10px","padding-left":"10px"},"contact_border_et-desktop":"solid","contact_border_color_custom_et-desktop":"#e1e1e1","header_socials_type_et-desktop":"type1","header_socials_package_et-desktop":[{"social_name":"Facebook","social_url":"#","social_icon":"et_icon-facebook"},{"social_name":"Twitter","social_url":"#","social_icon":"et_icon-twitter"},{"social_name":"Instagram","social_url":"#","social_icon":"et_icon-instagram"},{"social_name":"Google plus","social_url":"#","social_icon":"et_icon-google_plus"},{"social_name":"Youtube","social_url":"#","social_icon":"et_icon-youtube"},{"social_name":"Linkedin","social_url":"#","social_icon":"et_icon-linkedin"}],"header_socials_content_alignment_et-desktop":"start","header_socials_elements_zoom_et-desktop":"100","header_socials_elements_spacing_et-desktop":"10","header_socials_target_et-desktop":false,"header_socials_no_follow_et-desktop":false,"search_type_et-desktop":"input","search_ajax_et-desktop":true,"search_by_sku_et-desktop":true,"search_category_et-desktop":true,"search_all_categories_text_et-desktop":"All categories","search_placeholder_et-desktop":"Search for...","search_limit_results_et-desktop":"3","search_icon_zoom_et-desktop":1,"search_content_alignment_et-desktop":"center","search_width_et-desktop":"100","search_height_et-desktop":"40","search_border_radius_et-desktop":"0","search_color_et-desktop":"#888888","search_button_background_custom_et-desktop":"#000000","search_button_color_et-desktop":"#ffffff","search_input_box_model_et-desktop":{"margin-top":"0px","margin-right":"","margin-bottom":"0px","margin-left":"","border-top-width":"1px","border-right-width":"1px","border-bottom-width":"1px","border-left-width":"1px","padding-top":"0px","padding-right":"0px","padding-bottom":"0px","padding-left":"10px"},"search_input_border_et-desktop":"solid","search_input_border_color_custom_et-desktop":"#e1e1e1","search_icon_box_model_et-desktop":{"margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","border-top-width":"0px","border-right-width":"0px","border-bottom-width":"0px","border-left-width":"0px","padding-top":"10px","padding-right":"0px","padding-bottom":"10px","padding-left":"0px"},"search_icon_border_et-desktop":"solid","search_icon_border_color_custom_et-desktop":"#e1e1e1","search_zoom_et-desktop":"100","search_content_position_et-desktop":"right","search_content_position_custom_et-desktop":"0","search_content_box_model_et-desktop":{"margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","border-top-width":"1px","border-right-width":"1px","border-bottom-width":"1px","border-left-width":"1px","padding-top":"20px","padding-right":"30px","padding-bottom":"30px","padding-left":"30px"},"search_content_border_et-desktop":"solid","search_content_border_color_custom_et-desktop":"#e1e1e1","wishlist_style_et-desktop":"type1","wishlist_icon_et-desktop":"type1","wishlist_icon_zoom_et-desktop":1.3,"wishlist_label_et-desktop":true,"wishlist_label_custom_et-desktop":"Wishlist","wishlist_content_type_et-desktop":"dropdown","wishlist_link_to":"wishlist_url","wishlist_custom_url":"#","mini-wishlist-items-count":null,"wishlist_quantity_et-desktop":true,"wishlist_quantity_size_et-desktop":1,"wishlist_quantity_active_background_custom_et-desktop":"#ffffff","wishlist_quantity_active_color_et-desktop":"#000000","wishlist_content_alignment_et-desktop":"start","wishlist_background_et-desktop":"current","wishlist_background_custom_et-desktop":"#ffffff","wishlist_color_et-desktop":"#000000","wishlist_border_radius_et-desktop":"0","wishlist_box_model_et-desktop":{"margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","border-top-width":"0px","border-right-width":"0px","border-bottom-width":"0px","border-left-width":"0px","padding-top":"0px","padding-right":"0px","padding-bottom":"0px","padding-left":"0px"},"wishlist_border_et-desktop":"solid","wishlist_border_color_custom_et-desktop":"#e1e1e1","wishlist_zoom_et-desktop":"100","wishlist_dropdown_position_et-desktop":"right","wishlist_dropdown_position_custom_et-desktop":"0","wishlist_dropdown_background_custom_et-desktop":"#ffffff","wishlist_content_position_et-desktop":"right","wishlist_content_box_model_et-desktop":{"margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","border-top-width":"1px","border-right-width":"1px","border-bottom-width":"1px","border-left-width":"1px","padding-top":"20px","padding-right":"20px","padding-bottom":"20px","padding-left":"20px"},"wishlist_content_border_et-desktop":"solid","wishlist_content_border_color_custom_et-desktop":"#e1e1e1"}}';
// $ooo = json_decode($ooo, true);
// foreach ( $ooo as $key => $val ) {
// set_theme_mod( $key, $val );
// }
// }
}
// Stas fields
public $xstore_panel_section_settings, $settings_name;
public function enqueue_settings_scripts($script) {
if ( $script == 'icons_select' ) {
$this->xstore_panel_icons_fonts_enqueue();
}
wp_register_script('etheme_panel_'.$script, ETHEME_BASE_URI.'framework/panel/js/settings/'.$script.'.js', array('jquery','etheme_admin_js'), false,true);
wp_enqueue_script('etheme_panel_'.$script);
wp_localize_script( 'xstore_panel_settings_'.$script, 'XStorePanelSettings'.ucfirst($script).'Config', $this->settingJsConfig );
}
public function xstore_panel_icons_list($type = 'simple') {
$icons = array(
'simple' => array(
'none' => esc_html__( 'None', 'xstore' ),
'et_icon-delivery' => esc_html__( 'Delivery', 'xstore' ),
'et_icon-coupon' => esc_html__( 'Coupon', 'xstore' ),
'et_icon-calendar' => esc_html__( 'Calendar', 'xstore' ),
'et_icon-compare' => esc_html__( 'Compare', 'xstore' ),
'et_icon-checked' => esc_html__( 'Checked', 'xstore' ),
'et_icon-tick' => esc_html__( 'Tick', 'xstore' ),
'et_icon-chat' => esc_html__( 'Chat', 'xstore' ),
'et_icon-phone-call' => esc_html__( 'Phone', 'xstore' ),
'et_icon-whatsapp' => esc_html__( 'Whatsapp', 'xstore' ),
'et_icon-viber' => esc_html__( 'Viber', 'xstore' ),
'et_icon-exclamation' => esc_html__( 'Exclamation', 'xstore' ),
'et_icon-gift' => esc_html__( 'Gift', 'xstore' ),
'et_icon-heart' => esc_html__( 'Heart', 'xstore' ),
'et_icon-heart-2' => esc_html__( 'Heart 2', 'xstore' ),
'et_icon-message' => esc_html__( 'Message', 'xstore' ),
'et_icon-internet' => esc_html__( 'Internet', 'xstore' ),
'et_icon-user' => esc_html__( 'Account', 'xstore' ),
'et_icon-sent' => esc_html__( 'Sent', 'xstore' ),
'et_icon-home' => esc_html__( 'Home', 'xstore' ),
'et_icon-shop' => esc_html__( 'Shop', 'xstore' ),
'et_icon-shopping-bag' => esc_html__( 'Bag', 'xstore' ),
'et_icon-shopping-bag-2' => esc_html__( 'Bag 2', 'xstore' ),
'et_icon-shopping-bag-3' => esc_html__( 'Bag 3', 'xstore' ),
'et_icon-shopping-cart' => esc_html__( 'Cart', 'xstore' ),
'et_icon-shopping-cart-2' => esc_html__( 'Cart 2', 'xstore' ),
'et_icon-shopping-basket' => esc_html__( 'Basket', 'xstore' ),
'et_icon-burger' => esc_html__( 'Burger', 'xstore' ),
'et_icon-star' => esc_html__( 'Star', 'xstore' ),
'et_icon-time' => esc_html__( 'Time', 'xstore' ),
'et_icon-location' => esc_html__( 'Location', 'xstore' ),
'et_icon-dev-menu' => esc_html__( 'Dev menu', 'xstore' ),
'et_icon-clock' => esc_html__( 'clock', 'xstore' ),
'et_icon-size' => esc_html__( 'Size', 'xstore' ),
'et_icon-more' => esc_html__( 'More', 'xstore' ),
),
);
return $icons[$type];
}
// don't name setting with key of elements it will break saving for this field
public function xstore_panel_settings_repeater_field( $section = '', $setting = '', $setting_title = '', $setting_descr = '', $default = '', $template = array(), $active_callbacks = array(), $custom_item_title = false ) {
wp_enqueue_script('jquery-ui-sortable');
wp_enqueue_script('jquery-ui-draggable');
$this->enqueue_settings_scripts( 'sortable' );
$this->enqueue_settings_scripts( 'repeater' );
$settings = $this->xstore_panel_section_settings;
if ( isset( $settings[ $section ][ $setting ] ) ) {
$selected_value = $settings[ $section ][ $setting ];
} else {
$selected_value = $default;
}
$values_2_save = $selected_value;
if ( is_array( $selected_value ) ) {
$values_2_save = array();
foreach ( $selected_value as $item_value => $item_name ) {
$values_2_save[] = $item_value;
}
$values_2_save = implode( ',', $values_2_save );
}
$sorted_list_parsed = array();
if ( ! empty( $values_2_save ) ) {
$sorted_list_values = explode( ',', $values_2_save );
foreach ( $sorted_list_values as $item ) {
$sorted_list_parsed[ $item ] = array(
'callbacks' => $template
);
// foreach ( $template as $template_item => $template_item_value) {
// $current_template = $template;
// $current_template[$template_item]['args'][1] = $item.'_'.$template_item_value['args'][1];
// $sorted_list_parsed[$item] = array(
// 'callbacks' => $template
// );
// }
}
}
// foreach ($sorted_list_values as $item) {
// $sorted_list_parsed[$item] = $default[$item];
// }
if ( count($sorted_list_parsed))
$sorted_list_parsed = array_merge($sorted_list_parsed, $default);
$class = '';
$to_hide = false;
$attr = array();
if ( count($active_callbacks) ) {
$this->enqueue_settings_scripts('callbacks');
$attr['data-callbacks'] = array();
foreach ( $active_callbacks as $key) {
if ( isset($settings[ $key['section'] ]) ) {
if ( isset( $settings[ $key['section'] ][ $key['name'] ] ) && $settings[ $key['section'] ][ $key['name'] ] == $key['value'] ) {
}
else {
$to_hide = true;
}
}
elseif ( $key['value'] != $key['default'] ) {
$to_hide = true;
}
$attr['data-callbacks'][] = $key['name'].':'.$key['value'];
}
$attr[] = 'data-callbacks="'. implode(',', $attr['data-callbacks']) . '"';
unset($attr['data-callbacks']);
}
if ( $to_hide ) {
$class .= ' hidden';
}
ob_start();
?>
; ?>)