private final function add_ajax_actions()
 {
     if (!$this->wpml_wp_api->is_cron_job()) {
         foreach ($this->ajax_actions as $handle => $callback) {
             if ($this->wpml_wp_api->is_ajax()) {
                 if (stripos($handle, 'wp_ajax_') !== 0) {
                     $handle = 'wp_ajax_' . $handle;
                 }
                 add_action($handle, $callback);
             }
             if ($this->wpml_wp_api->is_back_end() && $this->ajax_actions) {
                 add_action('admin_enqueue_scripts', array($this, 'enqueue_resources'));
             }
         }
     }
 }
예제 #2
0
 function set_up_language_selector()
 {
     $this->get_wp_api();
     if (!$this->wp_api->is_ajax() && !$this->wp_api->is_back_end() && !$this->wp_api->is_cron_job() && !$this->wp_api->is_heartbeat()) {
         // language selector
         // load js and style for js language selector
         if (isset($this->settings['icl_lang_sel_type']) && $this->settings['icl_lang_sel_type'] == 'dropdown' && (!is_admin() || isset($_GET['page']) && $_GET['page'] == ICL_PLUGIN_FOLDER . '/menu/languages.php')) {
             if ($this->settings['icl_lang_sel_stype'] == 'mobile-auto') {
                 include ICL_PLUGIN_PATH . '/lib/mobile-detect.php';
                 $WPML_Mobile_Detect = new WPML_Mobile_Detect();
                 $this->is_mobile = $WPML_Mobile_Detect->isMobile();
                 $this->is_tablet = $WPML_Mobile_Detect->isTablet();
             }
             if ($this->settings['icl_lang_sel_stype'] == 'mobile-auto' && (!empty($this->is_mobile) || !empty($this->is_tablet)) || $this->settings['icl_lang_sel_stype'] == 'mobile') {
                 if (!defined('ICL_DONT_LOAD_LANGUAGES_JS') || !ICL_DONT_LOAD_LANGUAGES_JS) {
                     wp_enqueue_script('language-selector', ICL_PLUGIN_URL . '/res/js/language-selector.js', array(), ICL_SITEPRESS_VERSION, true);
                 }
                 if (!defined('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS') || !ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS) {
                     wp_enqueue_style('language-selector', ICL_PLUGIN_URL . '/res/css/language-selector-click.css', ICL_SITEPRESS_VERSION);
                 }
             }
         }
     }
 }