当前位置: 首页>>代码示例>>PHP>>正文


PHP SitePress::check_settings_integrity方法代码示例

本文整理汇总了PHP中SitePress::check_settings_integrity方法的典型用法代码示例。如果您正苦于以下问题:PHP SitePress::check_settings_integrity方法的具体用法?PHP SitePress::check_settings_integrity怎么用?PHP SitePress::check_settings_integrity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SitePress的用法示例。


在下文中一共展示了SitePress::check_settings_integrity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _st_warnings

 static function _st_warnings()
 {
     if (!class_exists('ICL_AdminNotifier')) {
         return;
     }
     global $sitepress, $sitepress_settings;
     if (!isset($sitepress)) {
         return;
     }
     if (method_exists($sitepress, 'check_settings_integrity') && !SitePress::check_settings_integrity()) {
         return;
     }
     if (!isset($sitepress_settings['st']['strings_language'])) {
         $sitepress_settings = $sitepress->get_settings();
     }
     if (isset($sitepress_settings['st']['strings_language'])) {
         if ($sitepress->get_default_language() != $sitepress_settings['st']['strings_language']) {
             self::_st_default_language_warning();
         } elseif ($sitepress_settings['st']['strings_language'] != 'en') {
             self::_st_default_and_st_language_warning();
         } else {
             ICL_AdminNotifier::removeMessage('_st_default_and_st_language_warning');
             ICL_AdminNotifier::removeMessage('_st_default_language_warning');
         }
     }
 }
开发者ID:Calraiser,项目名称:flux,代码行数:26,代码来源:wpml-string-translation.class.php

示例2: admin_language_switcher

 function admin_language_switcher()
 {
     if (!SitePress::check_settings_integrity()) {
         return;
     }
     /** @var $wp_admin_bar WP_Admin_Bar */
     global $wpdb, $wp_admin_bar, $pagenow, $mode;
     $all_languages_enabled = true;
     $current_page = basename($_SERVER['SCRIPT_NAME']);
     $post_type = false;
     $trid = false;
     $translations = false;
     $languages_links = array();
     // individual translations
     $is_post = false;
     $is_tax = false;
     $is_menu = false;
     $current_language = $this->get_current_language();
     switch ($pagenow) {
         case 'post.php':
             $is_post = true;
             $post_id = @intval($_GET['post']);
             $post = get_post($post_id);
             $post_language = $this->get_language_for_element($post_id, 'post_' . get_post_type($post_id));
             if ($post_language && $post_language != $current_language) {
                 $this->switch_lang($post_language);
                 $current_language = $this->get_current_language();
             }
             $trid = $this->get_element_trid($post_id, 'post_' . $post->post_type);
             $translations = $this->get_element_translations($trid, 'post_' . $post->post_type, true);
             break;
         case 'post-new.php':
             $all_languages_enabled = false;
             if (isset($_GET['trid'])) {
                 $trid = intval($_GET['trid']);
                 $post_type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post';
                 $translations = $this->get_element_translations($trid, 'post_' . $post_type, true);
                 $is_post = true;
             }
             break;
         case 'edit-tags.php':
             $is_tax = true;
             if (isset($_GET['action']) && $_GET['action'] == 'edit') {
                 $all_languages_enabled = false;
             }
             $taxonomy = $_GET['taxonomy'];
             $term_tax_id = 0;
             if (isset($_GET['tag_ID'])) {
                 $term_id = @intval($_GET['tag_ID']);
                 $term_tax_id = $wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE taxonomy=%s AND term_id=%d", $taxonomy, $term_id));
             }
             if ($term_tax_id) {
                 $trid = $this->get_element_trid($term_tax_id, 'tax_' . $taxonomy);
             }
             if ($trid) {
                 $translations = $this->get_element_translations($trid, 'tax_' . $taxonomy, true);
             }
             break;
         case 'nav-menus.php':
             $is_menu = true;
             if (isset($_GET['menu']) && $_GET['menu']) {
                 $menu_id = $_GET['menu'];
                 $trid = $trid = $this->get_element_trid($menu_id, 'tax_nav_menu');
                 $translations = $this->get_element_translations($trid, 'tax_nav_menu', true);
             }
             $all_languages_enabled = false;
             break;
         case 'upload.php':
             if ($mode == 'grid') {
                 $all_languages_enabled = false;
             }
             break;
     }
     foreach ($this->get_active_languages() as $lang) {
         $current_page_lang = $current_page;
         if (isset($_SERVER['QUERY_STRING'])) {
             parse_str($_SERVER['QUERY_STRING'], $query_vars);
             unset($query_vars['lang'], $query_vars['admin_bar']);
         } else {
             $query_vars = array();
         }
         // individual translations
         if ($is_post) {
             if (isset($translations[$lang['code']]) && isset($translations[$lang['code']]->element_id)) {
                 $query_vars['post'] = $translations[$lang['code']]->element_id;
                 unset($query_vars['source_lang']);
                 $current_page_lang = 'post.php';
                 $query_vars['action'] = 'edit';
             } else {
                 $current_page_lang = 'post-new.php';
                 if (isset($post)) {
                     $query_vars['post_type'] = $post->post_type;
                     $query_vars['source_lang'] = $current_language;
                 } else {
                     $query_vars['post_type'] = $post_type;
                 }
                 $query_vars['trid'] = $trid;
                 unset($query_vars['post'], $query_vars['action']);
             }
         } elseif ($is_tax) {
//.........这里部分代码省略.........
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:101,代码来源:sitepress.class.php

示例3: admin_language_switcher

    /**
     * echo simple language switcher for WPML, 'sitepress' is used as plugin translation domain
     */
    function admin_language_switcher()
    {
        // do nothing if WPML is not active
        if (!class_exists('SitePress')) {
            return;
        }
        // If check_settings_integrity exists then it should not fail, otherwise ignore.
        if (method_exists('SitePress', 'check_settings_integrity') && !SitePress::check_settings_integrity()) {
            return;
        }
        global $sitepress;
        // We need those methods, so make sure they are available.
        if (!method_exists($sitepress, 'get_current_language') || !method_exists($sitepress, 'get_default_language') || !method_exists($sitepress, 'get_active_languages')) {
            return;
        }
        $languages_links = array();
        $current_language = $sitepress->get_current_language();
        $current_language = $current_language ? $current_language : $sitepress->get_default_language();
        if (isset($_SERVER['QUERY_STRING'])) {
            parse_str($_SERVER['QUERY_STRING'], $query_vars);
            unset($query_vars['lang'], $query_vars['admin_bar']);
        } else {
            $query_vars = array();
        }
        $query_string = http_build_query($query_vars);
        if (empty($query_string)) {
            $query_string = '?';
        } else {
            $query_string = '?' . $query_string . '&';
        }
        foreach ($sitepress->get_active_languages() as $lang) {
            $query = $query_string . 'lang=' . $lang['code'];
            // the default language need to specified explicitly yoo in order to set the lang cookie
            $link_url = admin_url(basename($_SERVER['SCRIPT_NAME']) . $query);
            $languages_links[$lang['code']] = array('url' => $link_url, 'current' => $lang['code'] == $current_language, 'anchor' => $lang['display_name']);
        }
        $query = $query_string . 'lang=all';
        $link_url = admin_url(basename($_SERVER['SCRIPT_NAME']) . $query);
        $languages_links['all'] = array('url' => $link_url, 'current' => 'all' == $current_language, 'anchor' => __('All languages', 'sitepress'));
        // We start with the current language in our select.
        $lang = $languages_links[$current_language];
        if ($languages_links) {
            ?>
<select onchange="window.location=this.value" style="margin: 0 0 0 20px;">
<option value="<?php 
            echo esc_url($lang['url']);
            ?>
"><?php 
            echo $lang['anchor'];
            ?>
</option>
<?php 
            foreach ($languages_links as $code => $lang) {
                if ($code == $current_language) {
                    continue;
                }
                ?>
                <option value="<?php 
                echo esc_url($lang['url']);
                ?>
"><?php 
                echo $lang['anchor'];
                ?>
</option>
                <?php 
            }
            ?>
</select>
<?php 
        }
    }
开发者ID:interfisch,项目名称:lm,代码行数:74,代码来源:swifty-page-manager.php

示例4: administration_menu2

 function administration_menu2()
 {
     if (!SitePress::check_settings_integrity()) {
         return;
     }
     $main_page = apply_filters('icl_menu_main_page', ICL_PLUGIN_FOLDER . '/menu/languages.php');
     if ($this->setup()) {
         add_submenu_page($main_page, __('Taxonomy Translation', 'sitepress'), __('Taxonomy Translation', 'sitepress'), 'wpml_manage_taxonomy_translation', ICL_PLUGIN_FOLDER . '/menu/taxonomy-translation.php');
     }
 }
开发者ID:fdelarosa191,项目名称:iftheme-docs,代码行数:10,代码来源:sitepress.class.php

示例5: get_ls_languages

 function get_ls_languages($template_args = array())
 {
     //Returns false if is admin and settings are corrupted
     if (is_admin() && !SitePress::check_settings_integrity()) {
         return false;
     }
     /** @var $wp_query WP_Query */
     global $wpdb, $wp_query, $w_this_lang, $wpml_post_translations;
     $current_language = $this->get_current_language();
     $default_language = $this->get_default_language();
     $cache_key_args = $template_args ? array_filter($template_args) : array('default');
     $cache_key_args[] = $current_language;
     $cache_key_args[] = $default_language;
     $cache_key_args = array_filter($cache_key_args);
     $cache_key = md5(wp_json_encode($cache_key_args));
     $cache_group = 'ls_languages';
     $found = false;
     $ls_languages = wp_cache_get($cache_key, $cache_group, $found);
     if ($found) {
         return $ls_languages;
     }
     if (is_null($this->wp_query)) {
         $this->set_wp_query();
     }
     // use original wp_query for this
     // backup current $wp_query
     if (!isset($wp_query)) {
         return $this->get_active_languages();
     }
     $_wp_query_back = clone $wp_query;
     unset($wp_query);
     global $wp_query;
     // make it global again after unset
     $wp_query = clone $this->wp_query;
     $w_active_languages = $this->get_active_languages();
     $this_lang = $this->this_lang;
     if ($this_lang == 'all') {
         $w_this_lang = array('code' => 'all', 'english_name' => 'All languages', 'display_name' => __('All languages', 'sitepress'));
     } else {
         $w_this_lang = $this->get_language_details($this_lang);
     }
     if (isset($template_args['skip_missing'])) {
         //override default setting
         $icl_lso_link_empty = !$template_args['skip_missing'];
     } else {
         $icl_lso_link_empty = $this->settings['icl_lso_link_empty'];
     }
     // 1. Determine translations
     if (is_category()) {
         $skip_empty = false;
         $term_taxonomy_id_prepared = $wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id=%d AND taxonomy=%s", array(get_query_var('cat'), 'category'));
         $term_taxonomy_id = $wpdb->get_var($term_taxonomy_id_prepared);
         $trid = $this->get_element_trid($term_taxonomy_id, 'tax_category');
         $translations = $this->get_element_translations($trid, 'tax_category', $skip_empty);
     } elseif (is_tag()) {
         $skip_empty = false;
         $term_taxonomy_id_prepared = $wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id=%d AND taxonomy=%s", array(get_query_var('tag_id'), 'post_tag'));
         $term_taxonomy_id = $wpdb->get_var($term_taxonomy_id_prepared);
         $trid = $this->get_element_trid($term_taxonomy_id, 'tax_post_tag');
         $translations = $this->get_element_translations($trid, 'tax_post_tag', $skip_empty);
     } elseif (is_tax()) {
         $skip_empty = false;
         $term_taxonomy_id_prepared = $wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id=%d AND taxonomy=%s", array($wp_query->get_queried_object_id(), get_query_var('taxonomy')));
         $term_taxonomy_id = $wpdb->get_var($term_taxonomy_id_prepared);
         if ($this->is_translated_taxonomy(get_query_var('taxonomy'))) {
             $trid = $this->get_element_trid($term_taxonomy_id, 'tax_' . get_query_var('taxonomy'));
             $translations = $this->get_element_translations($trid, 'tax_' . get_query_var('taxonomy'), $skip_empty);
         } else {
             $translations[$this->get_current_language()] = (object) array('translation_id' => 0, 'language_code' => $this->get_default_language(), 'original' => 1, 'name' => get_query_var('taxonomy'), 'term_id' => $wp_query->get_queried_object_id());
         }
     } elseif (is_archive() && !empty($wp_query->posts)) {
         $translations = array();
     } elseif (is_attachment()) {
         // Exception for attachments. Not translated.
         $trid = $this->get_element_trid($wp_query->get_queried_object_id(), 'post_attachment');
         $translations = $this->get_element_translations($trid, 'post_attachment');
     } elseif (is_page() || 'page' == get_option('show_on_front') && (isset($this->wp_query->queried_object_id) && $this->wp_query->queried_object_id == get_option('page_on_front') || isset($this->wp_query->queried_object_id) && $this->wp_query->queried_object_id == get_option('page_for_posts'))) {
         $trid = $this->get_element_trid($wp_query->get_queried_object_id(), 'post_page');
         $translations = $this->get_element_translations($trid, 'post_page');
     } elseif (is_singular() && !empty($wp_query->posts) || isset($_wp_query_back->query['name']) && isset($_wp_query_back->query['post_type'])) {
         $trid = $wpml_post_translations->get_element_trid($this->wp_query->post->ID);
         $translations = $this->get_element_translations($trid, 'post_' . $this->wp_query->post->post_type);
     } else {
         $wp_query->is_singular = false;
         $wp_query->is_archive = false;
         $wp_query->is_category = false;
         $wp_query->is_404 = true;
     }
     // 2. determine url
     foreach ($w_active_languages as $k => $lang) {
         $skip_lang = false;
         if (is_singular() || isset($_wp_query_back->query['name']) && isset($_wp_query_back->query['post_type']) || !empty($this->wp_query->queried_object_id) && $this->wp_query->queried_object_id == get_option('page_for_posts')) {
             $this_lang_tmp = $this->this_lang;
             $this->this_lang = $lang['code'];
             $lang_page_on_front = get_option('page_on_front');
             $lang_page_for_posts = get_option('page_for_posts');
             if ($lang_page_on_front) {
                 $lang_page_on_front = icl_object_id($lang_page_on_front, 'page', false, $lang['code']);
             }
             if ($lang_page_for_posts) {
//.........这里部分代码省略.........
开发者ID:sonvq,项目名称:passioninvestment,代码行数:101,代码来源:sitepress.class.php


注:本文中的SitePress::check_settings_integrity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。