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


PHP wpml_prepare_in函数代码示例

本文整理汇总了PHP中wpml_prepare_in函数的典型用法代码示例。如果您正苦于以下问题:PHP wpml_prepare_in函数的具体用法?PHP wpml_prepare_in怎么用?PHP wpml_prepare_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: archive_query_has_posts

 /**
  * Returns the number of posts for a given post_type, date and language combination that is published.
  *
  * @param string       $lang language code to check
  * @param null|int     $year
  * @param null|int     $month
  * @param null|int     $day
  * @param string|array $post_type
  *
  * @return bool
  *
  * @used-by \WPML_Languages::add_date_or_cpt_url_to_ls_lang to determine what languages to show in the Language Switcher
  */
 public function archive_query_has_posts($lang, $year = null, $month = null, $day = null, $post_type = 'post')
 {
     $cache_args = array();
     $cache_args['lang'] = $lang;
     $cache_args['year'] = $year;
     $cache_args['month'] = $month;
     $cache_args['day'] = $day;
     $cache_args['post_type'] = $post_type;
     $cache_key = md5(json_encode($cache_args));
     $cache_group = 'archive_query_has_posts';
     $cache = new WPML_WP_Cache($cache_group);
     $found = false;
     $result = $cache->get($cache_key, $found);
     if (!$found) {
         $post_status_snippet = $this->wp_api->current_user_can('read') ? "p.post_status IN (" . wpml_prepare_in(array('publish', 'private')) . ") " : "p.post_status = 'publish'";
         $post_type_snippet = is_array($post_type) ? " AND post_type IN (" . wpml_prepare_in($post_type) . ") " : $this->wpdb->prepare(' AND p.post_type = %s ', $post_type);
         $year_snippet = (bool) $year === true ? $this->wpdb->prepare(' AND year(p.post_date) = %d ', $year) : '';
         $month_snippet = (bool) $month === true ? $this->wpdb->prepare(' AND month(p.post_date) = %d ', $month) : '';
         $day_snippet = (bool) $day === true ? $this->wpdb->prepare(' AND day(p.post_date) = %d ', $day) : '';
         $lang_snippet = $this->wpdb->prepare(' AND t.language_code = %s ', $lang);
         $result = $this->wpdb->get_var("\n                        SELECT p.ID FROM {$this->wpdb->posts} p\n\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_translations t\n\t\t\t\t\t\t\tON p.ID = t.element_id AND t.element_type = CONCAT('post_', p.post_type)\n\t\t\t\t\t\tWHERE " . $post_status_snippet . $year_snippet . $month_snippet . $day_snippet . $post_type_snippet . $lang_snippet . "\n\t\t\t\t\t\tLIMIT 1");
         $cache->set($cache_key, $result);
     }
     return (bool) $result;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:38,代码来源:wpml-query-utils.class.php

示例2: icl_reset_language_data

/**
 * @package wpml-core
 */
function icl_reset_language_data()
{
    global $wpdb, $sitepress;
    $active = $wpdb->get_col("SELECT code FROM {$wpdb->prefix}icl_languages WHERE active = 1");
    $wpdb->query("TRUNCATE TABLE `{$wpdb->prefix}icl_languages`");
    SitePress_Setup::fill_languages();
    $wpdb->query("TRUNCATE TABLE `{$wpdb->prefix}icl_languages_translations`");
    SitePress_Setup::fill_languages_translations();
    $wpdb->query("TRUNCATE TABLE `{$wpdb->prefix}icl_flags`");
    SitePress_Setup::fill_flags();
    //restore active
    $wpdb->query("UPDATE {$wpdb->prefix}icl_languages SET active=1 WHERE code IN(" . wpml_prepare_in($active) . ")");
    $wpdb->update($wpdb->prefix . 'icl_flags', array('from_template' => 0), null);
    $codes = $wpdb->get_col("SELECT code FROM {$wpdb->prefix}icl_languages");
    foreach ($codes as $code) {
        if (!$code || $wpdb->get_var($wpdb->prepare("SELECT lang_code FROM {$wpdb->prefix}icl_flags WHERE lang_code = %s", $code))) {
            continue;
        }
        if (!file_exists(ICL_PLUGIN_PATH . '/res/flags/' . $code . '.png')) {
            $file = 'nil.png';
        } else {
            $file = $code . '.png';
        }
        $wpdb->insert($wpdb->prefix . 'icl_flags', array('lang_code' => $code, 'flag' => $file, 'from_template' => 0));
    }
    $last_default_language = $sitepress !== null ? $sitepress->get_default_language() : 'en';
    if (!in_array($last_default_language, $codes)) {
        $allowed_langs = array_intersect(array_keys($sitepress->get_active_languages()), $codes);
        $sitepress->set_default_language(array_pop($allowed_langs));
    }
    icl_cache_clear();
}
开发者ID:edgarter,项目名称:wecare,代码行数:35,代码来源:sitepress-schema.php

示例3: author_query_has_posts

 /**
  * @param array|string $post_type
  * @param WP_User      $author_data
  * @param array        $lang
  *
  * @return int
  */
 public function author_query_has_posts($post_type, $author_data, $lang)
 {
     global $wpdb;
     $post_types = (array) $post_type;
     $post_type_snippet = (bool) $post_types ? " AND post_type IN (" . wpml_prepare_in($post_types) . ") " : "";
     return $wpdb->get_var($wpdb->prepare("\n                        SELECT COUNT(p.ID) FROM {$wpdb->posts} p\n\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_translations t\n\t\t\t\t\t\t\tON p.ID=t.element_id AND t.element_type = CONCAT('post_', p.post_type)\n\t\t\t\t\t\tWHERE p.post_author=%d\n\t\t\t\t\t\t  " . $post_type_snippet . "\n\t\t\t\t\t\t  AND post_status='publish'\n\t\t\t\t\t\t  AND language_code=%s", $author_data->ID, $lang['code']));
 }
开发者ID:pcuervo,项目名称:odc,代码行数:14,代码来源:wpml-query-utils.class.php

示例4: archive_query_has_posts

 /**
  * Returns the number of posts for a given post_type, date and language combination that is published.
  *
  * @param string   $lang language code to check
  * @param  int     $year
  * @param null|int $month
  * @param null|int $day
  * @param string   $post_type
  *
  * @return null|string
  *
  * @used-by \WPML_Languages::add_date_or_cpt_url_to_ls_lang to determine what languages to show in the Language Switcher
  */
 public function archive_query_has_posts($lang, $year = null, $month = null, $day = null, $post_type = 'post')
 {
     $post_types = (array) $post_type;
     $post_type_snippet = (bool) $post_types ? " AND post_type IN (" . wpml_prepare_in($post_types) . ") " : "";
     $year_snippet = (bool) $year === true ? $this->wpdb->prepare(' AND year(p.post_date) = %d ', $year) : '';
     $month_snippet = (bool) $month === true ? $this->wpdb->prepare(' AND month(p.post_date) = %d ', $month) : '';
     $day_snippet = (bool) $day === true ? $this->wpdb->prepare(' AND day(p.post_date) = %d ', $day) : '';
     return $this->wpdb->get_var($this->wpdb->prepare("\n                        SELECT COUNT(p.ID) FROM {$this->wpdb->posts} p\n\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_translations t\n\t\t\t\t\t\t\tON p.ID = t.element_id AND t.element_type = CONCAT('post_', p.post_type)\n\t\t\t\t\t\tWHERE post_status='publish'\n\t\t\t\t\t\t\t" . $year_snippet . $month_snippet . $day_snippet . $post_type_snippet . "\n\t\t\t\t\t\t  AND language_code = %s", $lang));
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:22,代码来源:wpml-query-utils.class.php

示例5: get_new_terms_just_duplicated

 private function get_new_terms_just_duplicated($duplicate_ids, $taxonomies)
 {
     if ((bool) $duplicate_ids === false || (bool) $taxonomies === false) {
         return array();
     }
     $duplicate_ids_in = wpml_prepare_in($duplicate_ids, '%d');
     $taxonomies_in = wpml_prepare_in($taxonomies);
     $terms = $this->wpdb->get_results("SELECT tt.term_taxonomy_id, tt.taxonomy\n\t\t\t FROM {$this->wpdb->term_taxonomy} tt\n\t\t\t JOIN {$this->wpdb->term_relationships} tr\n\t\t\t\tON tt.term_taxonomy_id = tr.term_taxonomy_id\n\t\t\t JOIN {$this->wpdb->postmeta} pm\n\t\t\t    ON pm.post_id = tr.object_id\n\t\t\t JOIN {$this->wpdb->terms} t_duplicate\n\t\t\t    ON t_duplicate.term_id = tt.term_id\n\t\t\t JOIN  {$this->wpdb->terms} t_original\n\t\t\t    ON t_original.name = t_duplicate.name\n\t\t\t JOIN {$this->wpdb->term_taxonomy} tt_master\n\t\t\t    ON tt_master.term_id = t_original.term_id\n\t\t\t JOIN {$this->wpdb->term_relationships} tr_master\n\t\t\t    ON tt_master.term_taxonomy_id = tr_master.term_taxonomy_id\n\t\t\t LEFT JOIN {$this->wpdb->term_relationships} tr_other\n\t\t\t    ON tt.term_taxonomy_id = tr_other.term_taxonomy_id\n\t\t\t      AND tr_other.object_id != tr.object_id\n\t\t\t      AND tr_other.object_id NOT IN ({$duplicate_ids_in})\n\t\t      LEFT JOIN {$this->wpdb->postmeta} pm_other\n\t\t        ON pm_other.post_id = tr_other.object_id\n\t\t          AND NOT (pm_other.meta_key = '_icl_lang_duplicate_of'\n\t\t                    AND  pm_other.meta_value IN ({$duplicate_ids_in}))\n\t\t     WHERE pm.meta_key = '_icl_lang_duplicate_of'\n\t\t        AND tr_other.object_id IS NULL\n\t\t        AND pm_other.post_id IS NULL\n\t\t        AND pm.meta_value IN ({$duplicate_ids_in})\n\t\t        AND tr_master.object_id IN ({$duplicate_ids_in})\n\t\t        AND tt.taxonomy IN ({$taxonomies_in})");
     return $terms;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:10,代码来源:wpml-term-hierarchy-duplication.class.php

示例6: filter_tm_source_langs

 /**
  * Filters the active languages to include all languages in which strings exist.
  *
  * @param array[] $source_langs
  *
  * @return array[]
  */
 public function filter_tm_source_langs($source_langs)
 {
     $string_lang_codes = $this->wpdb->get_col("\tSELECT DISTINCT(s.language)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE s.language\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNOT IN (" . wpml_prepare_in(array_keys($source_langs)) . ")");
     foreach ($string_lang_codes as $lang_code) {
         $language = $this->sitepress->get_language_details($lang_code);
         if ((bool) $language === true) {
             $source_langs[$lang_code] = $language;
         }
     }
     return $source_langs;
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:18,代码来源:class-wpml-tm-filters.php

示例7: extra_conditions_snippet

 protected function extra_conditions_snippet()
 {
     $extra_conditions = "";
     if (!empty($this->post_status)) {
         $status_snippet = " AND post_status IN (" . wpml_prepare_in($this->post_status) . ") ";
         $extra_conditions .= apply_filters('_icl_posts_language_count_status', $status_snippet);
     }
     $extra_conditions .= $this->post_status != array('trash') ? " AND post_status <> 'trash'" : '';
     $extra_conditions .= " AND post_status <> 'auto-draft' ";
     $extra_conditions .= parent::extra_conditions_snippet();
     return $extra_conditions;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:12,代码来源:wpml-post-language-filter.class.php

示例8: migrate_old_translated_values

 private function migrate_old_translated_values($form_id)
 {
     global $wpdb;
     $st_context = $this->tm_api->get_st_context($form_id);
     $form_strings = array_keys($this->tm_api->get_form_strings($form_id));
     foreach ($form_strings as &$string_name) {
         $string_name = "{$form_id}_" . $string_name;
     }
     $s_name_in = wpml_prepare_in($form_strings);
     $id_s_needing_update = $wpdb->get_results($wpdb->prepare("SELECT st.id AS id, cs.id AS right_id\n                 FROM {$wpdb->prefix}icl_strings s\n                 JOIN {$wpdb->prefix}icl_strings cs\n                  ON CONCAT(%s,cs.title) = s.name\n                 JOIN {$wpdb->prefix}icl_string_translations st\n                  ON s.id = st.string_id\n                 LEFT JOIN {$wpdb->prefix}icl_string_translations cst\n                  ON cs.id = cst.string_id AND st.language = cst.language\n                 WHERE s.context = 'gravity_form'\n                  AND cs.context = %s\n                  AND cst.language IS NULL\n                  AND s.name IN ({$s_name_in})", $form_id . '_', $st_context));
     foreach ($id_s_needing_update as $id_data) {
         $wpdb->update($wpdb->prefix . 'icl_string_translations', array('string_id' => $id_data->right_id), array('id' => $id_data->id));
     }
 }
开发者ID:Nguyenkain,项目名称:strida.vn,代码行数:14,代码来源:gfml-migration.class.php

示例9: get_multiple_slug_adjusted_IDs

 private function get_multiple_slug_adjusted_IDs($slugs)
 {
     global $wpdb;
     $pages_with_name = $wpdb->get_results("\n\t\t\t\tSELECT ID, post_name, post_parent\n\t\t\t\tFROM {$wpdb->posts} p\n\t\t\t\tJOIN {$wpdb->prefix}icl_translations t\n\t\t\t\tON p.ID = t.element_id AND element_type='post_page'\n\t\t\t\tWHERE p.post_name IN (" . wpml_prepare_in($slugs) . ")\n\t\t\t\t");
     $page_names = array();
     $page_objects = array();
     foreach ($pages_with_name as $page) {
         $page_names[$page->ID] = $page->post_name;
         $page_objects[$page->ID] =& $page;
     }
     array_pop($slugs);
     foreach ($pages_with_name as &$page) {
         $page = $this->remove_by_wrong_parent($page, $page->post_parent, $page_names, $page_objects, $slugs);
     }
     return array_filter($pages_with_name);
 }
开发者ID:pcuervo,项目名称:odc,代码行数:16,代码来源:wpml-pagename-query-filter.class.php

示例10: cms_navigation_meta_box

    function cms_navigation_meta_box($post)
    {
        global $wpdb, $sitepress;
        if (!$sitepress->get_setting('setup_complete')) {
            return;
        }
        //if it's a new post copy some custom fields from the original post
        $cms_nav_section = false;
        if ($post->ID == 0 && isset($_GET['trid']) && $_GET['trid']) {
            $copied_custom_fields = array('_top_nav_excluded', '_cms_nav_minihome');
            foreach ($copied_custom_fields as $k => $v) {
                $copied_custom_fields[$k] = "'" . $v . "'";
            }
            $res_prepared = $wpdb->prepare("\r\r\n                SELECT meta_key, meta_value FROM {$wpdb->prefix}icl_translations tr\r\r\n                JOIN {$wpdb->postmeta} pm ON tr.element_id = pm.post_id\r\r\n                WHERE tr.trid=%d AND (source_language_code IS NULL OR source_language_code='')\r\r\n                    AND meta_key IN (" . wpml_prepare_in($copied_custom_fields) . ")\r\r\n            ", $_GET['trid']);
            $res = $wpdb->get_results($res_prepared);
            foreach ($res as $r) {
                $post_custom[$r->meta_key][0] = $r->meta_value;
            }
        } else {
            // get sections
            global $sitepress;
            $current_language = $sitepress->get_current_language();
            $sql = $wpdb->prepare("\r\r\n\t\t\t\t\tSELECT\r\r\n\t\t\t\t\t  DISTINCT meta_value\r\r\n\t\t\t\t\tFROM {$wpdb->postmeta} pm\r\r\n\t\t\t\t\tINNER JOIN {$wpdb->prefix}icl_translations t\r\r\n\t\t\t\t\tON t.element_id = pm.post_id\r\r\n\t\t\t\t\tWHERE meta_key='_cms_nav_section'\r\r\n\t\t\t\t\tAND t.element_type = 'post_page'\r\r\n\t\t\t\t\tAND t.language_code = %s\r\r\n\t\t\t\t\t", $current_language);
            $sections = $wpdb->get_col($sql);
            $post_custom = get_post_custom($post->ID);
            $cms_nav_section = isset($post_custom['_cms_nav_section'][0]) ? $post_custom['_cms_nav_section'][0] : '';
        }
        $top_nav_excluded = isset($post_custom['_top_nav_excluded'][0]) ? $post_custom['_top_nav_excluded'][0] : '';
        $cms_nav_minihome = isset($post_custom['_cms_nav_minihome'][0]) ? $post_custom['_cms_nav_minihome'][0] : '';
        $cms_nav_offsite_url = isset($post_custom['_cms_nav_offsite_url'][0]) ? $post_custom['_cms_nav_offsite_url'][0] : '';
        if ($top_nav_excluded) {
            $top_nav_excluded = 'checked="checked"';
        }
        if ($cms_nav_minihome) {
            $cms_nav_minihome = 'checked="checked"';
        }
        ?>

        <p>
        <label><input type="checkbox" value="1" name="exclude_from_top_nav" <?php 
        echo $top_nav_excluded;
        ?>
 />&nbsp; <?php 
        echo __('Exclude from the top navigation', 'wpml-cms-nav');
        ?>
</label> &nbsp;
        <label><input type="checkbox" value="1" name="cms_nav_minihome" <?php 
        echo $cms_nav_minihome;
        ?>
 />&nbsp; <?php 
        echo __('Mini home (don\'t list child pages for this page)', 'wpml-cms-nav');
        ?>
</label>
        </p>
        <p>
        <?php 
        echo __('Section', 'wpml-cms-nav');
        ?>

        <?php 
        if (!empty($sections)) {
            ?>

            <select name="cms_nav_section">    
            <option value=''><?php 
            echo __('--none--', 'wpml-cms-nav');
            ?>
</option>
            <?php 
            foreach ($sections as $s) {
                ?>

            <option <?php 
                if ($s == $cms_nav_section) {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                echo $s;
                ?>
</option>
            <?php 
            }
            ?>
        
            </select>
        <?php 
        }
        ?>
    
        <input type="text" name="cms_nav_section_new" value="" <?php 
        if (!empty($sections)) {
            ?>
style="display:none"<?php 
        }
        ?>
 />
        <?php 
        if (!empty($sections)) {
            ?>
//.........这里部分代码省略.........
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:101,代码来源:cms-navigation.class.php

示例11: adjust_taxonomies_terms_ids

 /**
  * @param string|array $terms_ids
  *
  * @return array
  */
 private function adjust_taxonomies_terms_ids($terms_ids)
 {
     /** @var  wpdb $wpdb */
     global $wpdb;
     $terms_ids = array_unique($this->explode_and_trim($terms_ids));
     if (empty($terms_ids)) {
         return $terms_ids;
     }
     // in_statement added two times to limit size of inner query
     $in_statement = wpml_prepare_in($terms_ids, '%d');
     $sql = $wpdb->prepare("SELECT a.term_id AS original, b.translated AS translated, a.taxonomy AS taxonomy\r\n                                     FROM {$wpdb->term_taxonomy} a LEFT OUTER JOIN\r\n                                                (SELECT t.term_id translated, o.term_id\r\n                                                 FROM {$wpdb->term_taxonomy} o, {$wpdb->term_taxonomy} t\r\n                                                 WHERE o.term_id IN ({$in_statement})\r\n                                                 AND t.term_id = (\tSELECT tt.term_id\r\n                                                                        FROM {$wpdb->term_taxonomy} tt\r\n                                                                        WHERE tt.term_taxonomy_id\r\n                                                                            = (\tSELECT element_id\r\n                                                                                FROM {$wpdb->prefix}icl_translations el\r\n                                                                                WHERE el.trid = (\tSELECT tr.trid\r\n                                                                                                FROM {$wpdb->prefix}icl_translations tr\r\n                                                                                                WHERE tr.element_id = o.term_taxonomy_id\r\n                                                                                                    AND tr.element_type LIKE 'tax%%' LIMIT 1)\r\n                                                                                    AND el.language_code = %s\r\n                                                                        LIMIT 1)\r\n                                                 LIMIT 1)) b on a.term_id=b.term_id\r\n                                     WHERE a.term_id IN ({$in_statement})\r\n                                                 ", $this->get_current_language());
     $adjusted_ids = $wpdb->get_results($sql);
     $translated_ids = array();
     foreach ($adjusted_ids as $adjusted_term) {
         if (!$this->is_translated_taxonomy($adjusted_term->taxonomy)) {
             $translated_ids[] = $adjusted_term->original;
             continue;
         }
         if (!is_null($adjusted_term->translated)) {
             $translated_ids[] = $adjusted_term->translated;
         }
     }
     return $translated_ids;
 }
开发者ID:tlandn,项目名称:akvo-sites-zz-template,代码行数:29,代码来源:sitepress.class.php

示例12: sync_with_translations

 public function sync_with_translations($post_id, $post_vars = false)
 {
     global $wpdb;
     $term_count_update = new WPML_Update_Term_Count();
     $post = get_post($post_id);
     $translated_ids = $this->post_translation->get_element_translations($post_id, false, true);
     $post_format = $this->sync_post_format ? get_post_format($post_id) : null;
     $ping_status = $this->sync_ping_status ? pings_open($post_id) ? 'open' : 'closed' : null;
     $comment_status = $this->sync_comment_status ? comments_open($post_id) ? 'open' : 'closed' : null;
     $post_password = $this->sync_password ? $post->post_password : null;
     $post_status = $this->sync_private_flag && get_post_status($post_id) === 'private' ? 'private' : null;
     $menu_order = $this->sync_menu_order && !empty($post->menu_order) ? $post->menu_order : null;
     $page_template = $this->sync_page_template && get_post_type($post_id) === 'page' ? get_page_template_slug($post_id) : null;
     $post_date = $this->sync_post_date ? $wpdb->get_var($wpdb->prepare("SELECT post_date FROM {$wpdb->posts} WHERE ID=%d LIMIT 1", $post_id)) : null;
     if ((bool) $post_vars === true) {
         $this->sync_sticky_flag($this->post_translation->get_element_trid($post_id), $post_vars);
     }
     foreach ($translated_ids as $lang_code => $translated_pid) {
         $this->sync_custom_fields($post_id, $translated_pid);
         if ($post_format !== null) {
             set_post_format($translated_pid, $post_format);
         }
         if ($post_date !== null) {
             $post_date_gmt = get_gmt_from_date($post_date);
             $data = array('post_date' => $post_date, 'post_date_gmt' => $post_date_gmt);
             $now = gmdate('Y-m-d H:i:59');
             if (mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false)) {
                 $post_status = 'future';
             } else {
                 $post_status = 'publish';
             }
             $data['post_status'] = $post_status;
             $wpdb->update($wpdb->posts, $data, array('ID' => $translated_pid));
         }
         if ($post_password !== null) {
             $wpdb->update($wpdb->posts, array('post_password' => $post_password), array('ID' => $translated_pid));
         }
         if ($post_status !== null && !in_array(get_post_status($translated_pid), array('auto-draft', 'draft', 'inherit', 'trash'))) {
             $wpdb->update($wpdb->posts, array('post_status' => $post_status), array('ID' => $translated_pid));
             $term_count_update->update_for_post($translated_pid);
         }
         if ($post_status == null && $this->sync_private_flag && get_post_status($translated_pid) == 'private') {
             $wpdb->update($wpdb->posts, array('post_status' => get_post_status($post_id)), array('ID' => $translated_pid));
             $term_count_update->update_for_post($translated_pid);
         }
         if ($ping_status !== null) {
             $wpdb->update($wpdb->posts, array('ping_status' => $ping_status), array('ID' => $translated_pid));
         }
         if ($comment_status !== null) {
             $wpdb->update($wpdb->posts, array('comment_status' => $comment_status), array('ID' => $translated_pid));
         }
         if ($page_template !== null) {
             update_post_meta($translated_pid, '_wp_page_template', $page_template);
         }
         $this->sync_with_translations($translated_pid);
     }
     if ($this->sync_parent) {
         $this->maybe_fix_translated_parent(get_post_type($post_id));
     }
     if ($menu_order !== null && (bool) $translated_ids !== false) {
         $wpdb->query("UPDATE {$wpdb->posts}\n\t\t\t\t   SET menu_order={$menu_order}\n\t\t\t\t   WHERE ID IN (" . wpml_prepare_in($translated_ids, '%d') . ")");
     }
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:63,代码来源:wpml-post-synchronization.class.php

示例13: icl_st_get_pending_string_translations_stats

function icl_st_get_pending_string_translations_stats()
{
    global $wpdb, $sitepress, $sitepress_settings;
    $current_user = $sitepress->get_current_user();
    $user_lang_pairs = get_user_meta($current_user->ID, $wpdb->prefix . 'language_pairs', true);
    $stats = array();
    if (!empty($user_lang_pairs[$sitepress_settings['st']['strings_language']])) {
        $results = $wpdb->get_results($wpdb->prepare("\r\n            SELECT COUNT(id) AS c, language \r\n            FROM {$wpdb->prefix}icl_string_translations \r\n            WHERE status=%d AND language IN (" . wpml_prepare_in(array_keys($user_lang_pairs[$sitepress_settings['st']['strings_language']])) . ")\r\n                    AND (translator_id IS NULL or translator_id > 0)\r\n            GROUP BY language\r\n            ORDER BY c DESC\r\n            ", ICL_TM_WAITING_FOR_TRANSLATOR));
        foreach ($results as $r) {
            $_stats[$r->language] = $r->c;
        }
        foreach ($user_lang_pairs[$sitepress_settings['st']['strings_language']] as $lang => $one) {
            $stats[$lang] = isset($_stats[$lang]) ? $_stats[$lang] : 0;
        }
    }
    return $stats;
}
开发者ID:edgarter,项目名称:wecare,代码行数:17,代码来源:functions.php

示例14: icl_upgrade_2_0_0_steps

function icl_upgrade_2_0_0_steps($step, $stepper)
{
    global $wpdb, $sitepress, $wp_post_types, $sitepress_settings;
    if (!isset($sitepress)) {
        $sitepress = new SitePress();
    }
    $TranslationManagement = new TranslationManagement();
    $default_language = $sitepress->get_default_language();
    define('ICL_TM_DISABLE_ALL_NOTIFICATIONS', true);
    // make sure no notifications are being sent
    //if(defined('icl_upgrade_2_0_0_runonce')){
    //  return;
    //}
    //define('icl_upgrade_2_0_0_runonce', true);
    // fix source_language_code
    // assume that the lowest element_id is the source language
    ini_set('max_execution_time', 300);
    $post_types = array_keys($wp_post_types);
    foreach ($post_types as $pt) {
        $types[] = 'post_' . $pt;
    }
    $temp_upgrade_data = get_option('icl_temp_upgrade_data', array('step' => 0, 'offset' => 0));
    switch ($step) {
        case 1:
            // if the tables are missing, call the plugin activation routine
            $table_name = $wpdb->prefix . 'icl_translation_status';
            if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
                icl_sitepress_activate();
            }
            $wpdb->query("ALTER TABLE `{$wpdb->prefix}icl_translations` CHANGE `element_type` `element_type` VARCHAR( 32 ) NOT NULL DEFAULT 'post_post'");
            $wpdb->query("ALTER TABLE `{$wpdb->prefix}icl_translations` CHANGE `element_id` `element_id` BIGINT( 20 ) NULL DEFAULT NULL ");
            // fix source_language_code
            // all source documents must have null
            if (isset($types)) {
                $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = NULL\n\t\t\t\t\tWHERE element_type IN('" . join("','", $types) . "') AND source_language_code = '' AND language_code=%s", $default_language));
                // get translated documents with missing source language
                $res = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\tSELECT translation_id, trid, language_code\n\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\n\t\t\t\t\tWHERE (source_language_code = '' OR source_language_code IS NULL)\n\t\t\t\t\t\tAND element_type IN('" . join("','", $types) . "')\n\t\t\t\t\t\tAND language_code <> %s\n\t\t\t\t\t\t", $default_language));
                foreach ($res as $row) {
                    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = %s WHERE translation_id=%d", $default_language, $row->translation_id));
                }
            }
            $temp_upgrade_data['step'] = 2;
            update_option('icl_temp_upgrade_data', $temp_upgrade_data);
            return array('message' => __('Processing translations...', 'sitepress'));
            break;
        case 2:
            $limit = 100;
            $offset = $temp_upgrade_data['offset'];
            $processing = FALSE;
            //loop existing translations
            if (isset($types)) {
                $res = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_translations\n                                 WHERE element_type IN(" . wpml_prepare_in($types) . " )\n                                    AND source_language_code IS NULL LIMIT %d  OFFSET %d", array($limit, $offset)));
                foreach ($res as $row) {
                    $processing = TRUE;
                    // grab translations
                    $translations = $sitepress->get_element_translations($row->trid, $row->element_type);
                    $md5 = 0;
                    $table_name = $wpdb->prefix . 'icl_node';
                    if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name) {
                        list($md5, $links_fixed) = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT md5, links_fixed FROM {$wpdb->prefix}icl_node\n\t\t\t\t\t\t\tWHERE nid = %d\n\t\t\t\t\t\t", $row->element_id), ARRAY_N);
                    }
                    if (!$md5) {
                        $md5 = $TranslationManagement->post_md5($row->element_id);
                    }
                    $translation_package = $TranslationManagement->create_translation_package($row->element_id);
                    foreach ($translations as $lang => $t) {
                        if (!$t->original) {
                            // determine service and status
                            $service = 'local';
                            $needs_update = 0;
                            list($rid, $status, $current_md5) = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\t\t\t\tSELECT c.rid, n.status , c.md5\n\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_content_status c\n\t\t\t\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_core_status n ON c.rid = n.rid\n\t\t\t\t\t\t\t\tWHERE c.nid = %d AND target = %s\n\t\t\t\t\t\t\t\tORDER BY rid DESC\n\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t", $row->element_id, $lang), ARRAY_N);
                            $translator_id = false;
                            if ($rid) {
                                if ($current_md5 != $md5) {
                                    $needs_update = 1;
                                }
                                if ($status == 3) {
                                    $status = 10;
                                } else {
                                    $status = 2;
                                }
                                $service = 'icanlocalize';
                                foreach ($sitepress_settings['icl_lang_status'] as $lpair) {
                                    if ($lpair['from'] == $row->language_code && $lpair['to'] == $lang && isset($lpair['translators'][0]['id'])) {
                                        $translator_id = $lpair['translators'][0]['id'];
                                        break;
                                    }
                                }
                            } else {
                                $status = 10;
                                $translator_id = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID=%d", $t->element_id));
                                $tlp = get_user_meta($translator_id, $wpdb->prefix . 'language_pairs', true);
                                $tlp[$row->language_code][$lang] = 1;
                                $TranslationManagement->edit_translator($translator_id, $tlp);
                            }
                            // add translation_status record
                            list($newrid) = $TranslationManagement->update_translation_status(array('translation_id' => $t->translation_id, 'status' => $status, 'translator_id' => $translator_id, 'needs_update' => $needs_update, 'md5' => $md5, 'translation_service' => $service, 'translation_package' => serialize($translation_package), 'links_fixed' => intval(isset($links_fixed) ? $links_fixed : 0)));
                            $job_id = $TranslationManagement->add_translation_job($newrid, $translator_id, $translation_package);
                            if ($job_id && $status == 10) {
                                $post = get_post($t->element_id);
//.........这里部分代码省略.........
开发者ID:pcuervo,项目名称:odc,代码行数:101,代码来源:upgrade-2.0.0.php

示例15: add_posts_management_column

 function add_posts_management_column($columns)
 {
     global $posts, $wpdb, $__management_columns_posts_translations;
     $element_type = isset($_REQUEST['post_type']) ? 'post_' . $_REQUEST['post_type'] : 'post_post';
     if (count($this->get_active_languages()) <= 1 || get_query_var('post_status') == 'trash') {
         return $columns;
     }
     if (isset($_POST['action']) && $_POST['action'] == 'inline-save' && $_POST['post_ID']) {
         $p = new stdClass();
         $p->ID = $_POST['post_ID'];
         $posts = array($p);
     } elseif (empty($posts)) {
         return $columns;
     }
     if (is_null($__management_columns_posts_translations)) {
         $post_ids = array();
         foreach ($posts as $p) {
             $post_ids[] = $p->ID;
         }
         // get posts translations
         // get trids
         $trid_array = $wpdb->get_col($wpdb->prepare("\n\t\t\t\tSELECT trid FROM {$wpdb->prefix}icl_translations\n\t\t\t\tWHERE element_type = %s AND element_id IN (" . wpml_prepare_in($post_ids, '%d') . ")\n\t\t\t", $element_type));
         $elements_translations = $wpdb->get_results("\n\t\t\t\tSELECT trid, element_id, language_code, source_language_code\n\t\t\t\tFROM {$wpdb->prefix}icl_translations\n\t\t\t\tWHERE trid IN (" . wpml_prepare_in($trid_array, '%d') . ")\n\t\t\t");
         foreach ($elements_translations as $v) {
             $by_trid[$v->trid][] = $v;
         }
         foreach ($elements_translations as $v) {
             if (in_array($v->element_id, $post_ids)) {
                 $el_trid = $v->trid;
                 foreach ($elements_translations as $val) {
                     if ($val->trid == $el_trid) {
                         $__management_columns_posts_translations[$v->element_id][$val->language_code] = $val;
                     }
                 }
             }
         }
     }
     $active_languages = $this->get_active_languages();
     $languages = array();
     foreach ($active_languages as $v) {
         if ($v['code'] == $this->get_current_language()) {
             continue;
         }
         $languages[] = $v['code'];
     }
     $res = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT f.lang_code, f.flag, f.from_template, l.name\n\t\t\tFROM {$wpdb->prefix}icl_flags f\n\t\t\t\tJOIN {$wpdb->prefix}icl_languages_translations l ON f.lang_code = l.language_code\n\t\t\tWHERE l.display_language_code = %s AND f.lang_code IN(" . wpml_prepare_in($languages) . ")\n\t\t", $this->admin_language));
     foreach ($res as $r) {
         if ($r->from_template) {
             $wp_upload_dir = wp_upload_dir();
             $flag_path = $wp_upload_dir['baseurl'] . '/flags/';
         } else {
             $flag_path = ICL_PLUGIN_URL . '/res/flags/';
         }
         $flags[$r->lang_code] = '<img src="' . $flag_path . $r->flag . '" width="18" height="12" alt="' . $r->name . '" title="' . $r->name . '" />';
     }
     $flags_column = '';
     foreach ($active_languages as $v) {
         if (isset($flags[$v['code']])) {
             $flags_column .= $flags[$v['code']];
         }
     }
     $new_columns = array();
     foreach ($columns as $k => $v) {
         $new_columns[$k] = $v;
         if ($k == 'title') {
             $new_columns['icl_translations'] = $flags_column;
         }
     }
     return $new_columns;
 }
开发者ID:Artur-Qaramyan,项目名称:wordpress,代码行数:70,代码来源:sitepress.class.php


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