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


PHP _icl_tax_has_objects_recursive函数代码示例

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


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

示例1: _icl_tax_has_objects_recursive

function _icl_tax_has_objects_recursive($id, $term_id = -1, $rec = 0)
{
    // based on the case where two categories were one the parent of another
    // eliminating the chance of infinite loops by letting this function calling itself too many times
    // 100 is the default limit in most of teh php configuration
    //
    // this limit this function to work only with categories nested up to 60 levels
    // should enough for most cases
    if ($rec > 60) {
        return false;
    }
    global $wpdb;
    if ($term_id === -1) {
        $term_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id=%d", $id));
    }
    $children = $wpdb->get_results($wpdb->prepare("\n        SELECT term_taxonomy_id, term_id, count FROM {$wpdb->term_taxonomy} WHERE parent = %d\n    ", $term_id));
    $count = 0;
    foreach ($children as $ch) {
        $count += $ch->count;
    }
    if ($count) {
        return true;
    } else {
        foreach ($children as $ch) {
            if (_icl_tax_has_objects_recursive($ch->term_taxonomy_id, $ch->term_id, $rec + 1)) {
                return true;
            }
        }
    }
    return false;
}
开发者ID:ViktorLinnasaar,项目名称:hanset,代码行数:31,代码来源:functions.php

示例2: get_element_translations

 /**
  * @param int    $trid
  * @param string $el_type Use comment, post, page, {custom post time name}, nav_menu, nav_menu_item, category, post_tag, etc. (prefixed with 'post_', 'tax_', or nothing for 'comment')
  * @param bool   $skip_empty
  * @param bool   $all_statuses
  * @param bool   $skip_cache
  *
  * @return array|bool|mixed
  */
 function get_element_translations($trid, $el_type = 'post_post', $skip_empty = false, $all_statuses = false, $skip_cache = false)
 {
     $cache_key_args = array_filter(array($trid, $el_type, $skip_empty, $all_statuses));
     $cache_key = md5(json_encode($cache_key_args));
     $cache_group = 'element_translations';
     $temp_elements = $skip_cache ? false : wp_cache_get($cache_key, $cache_group);
     if ($temp_elements) {
         return $temp_elements;
     }
     global $wpdb;
     $translations = array();
     $sel_add = '';
     $where_add = '';
     if ($trid) {
         if (0 === strpos($el_type, 'post_')) {
             $sel_add = ', p.post_title, p.post_status';
             $join_add = " LEFT JOIN {$wpdb->posts} p ON t.element_id=p.ID";
             $groupby_add = "";
             if (!is_admin() && empty($all_statuses) && $el_type != 'post_attachment') {
                 // the current user may not be the admin but may have read private post/page caps!
                 if (current_user_can('read_private_pages') || current_user_can('read_private_posts')) {
                     $where_add .= " AND (p.post_status = 'publish' OR p.post_status = 'private' OR p.post_status = 'pending')";
                 } else {
                     $where_add .= " AND (";
                     $where_add .= "p.post_status = 'publish' OR p.post_status = 'pending' ";
                     if ($uid = $this->get_current_user()->ID) {
                         $where_add .= " OR (post_status in ('draft', 'private', 'pending') AND  post_author = {$uid})";
                     }
                     $where_add .= ") ";
                 }
             }
         } elseif (preg_match('#^tax_(.+)$#', $el_type)) {
             $sel_add = ', tm.name, tm.term_id, COUNT(tr.object_id) AS instances';
             $join_add = " LEFT JOIN {$wpdb->term_taxonomy} tt ON t.element_id=tt.term_taxonomy_id\r\n\t\t\t\t\t\t\t  LEFT JOIN {$wpdb->terms} tm ON tt.term_id = tm.term_id\r\n\t\t\t\t\t\t\t  LEFT JOIN {$wpdb->term_relationships} tr ON tr.term_taxonomy_id=tt.term_taxonomy_id\r\n\t\t\t\t\t\t\t  ";
             $groupby_add = "GROUP BY tm.term_id";
         }
         $where_add .= " AND t.trid='{$trid}'";
         if (!isset($join_add)) {
             $join_add = "";
         }
         if (!isset($groupby_add)) {
             $groupby_add = "";
         }
         $query = "\r\n\t\t\t\tSELECT t.translation_id, t.language_code, t.element_id, t.source_language_code, NULLIF(t.source_language_code, '') IS NULL AS original {$sel_add}\r\n\t\t\t\tFROM {$wpdb->prefix}icl_translations t\r\n\t\t\t\t\t {$join_add}\r\n\t\t\t\tWHERE 1 {$where_add}\r\n\t\t\t\t{$groupby_add}\r\n\t\t\t";
         $ret = $wpdb->get_results($query);
         foreach ($ret as $t) {
             if (preg_match('#^tax_(.+)$#', $el_type) && $t->instances == 0 && !_icl_tax_has_objects_recursive($t->element_id) && $skip_empty) {
                 continue;
             }
             $cached_object_key = $t->element_id . '#' . $el_type . '#0#' . $t->language_code;
             wp_cache_set($cached_object_key, $cached_object_key, 'icl_object_id');
             $translations[$t->language_code] = $t;
         }
     }
     if ($translations) {
         wp_cache_set($cache_key, $translations, $cache_group);
     }
     return $translations;
 }
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:68,代码来源:sitepress.class.php

示例3: get_element_translations

 function get_element_translations($trid, $el_type = 'post_post', $skip_empty = false)
 {
     global $wpdb;
     $translations = array();
     $sel_add = '';
     $where_add = '';
     if ($trid) {
         if (0 === strpos($el_type, 'post_')) {
             $sel_add = ', p.post_title, p.post_status';
             $join_add = " LEFT JOIN {$wpdb->posts} p ON t.element_id=p.ID";
             $groupby_add = "";
             if (!is_admin()) {
                 $where_add .= " AND (";
                 $where_add .= "p.post_status = 'publish'";
                 if ($uid = get_current_user_id()) {
                     $where_add .= " OR (post_status in ('draft', 'private') AND  post_author = {$uid})";
                 }
                 $where_add .= ") ";
             }
         } elseif (preg_match('#^tax_(.+)$#', $el_type)) {
             $sel_add = ', tm.name, tm.term_id, COUNT(tr.object_id) AS instances';
             $join_add = " LEFT JOIN {$wpdb->term_taxonomy} tt ON t.element_id=tt.term_taxonomy_id\n                              LEFT JOIN {$wpdb->terms} tm ON tt.term_id = tm.term_id\n                              LEFT JOIN {$wpdb->term_relationships} tr ON tr.term_taxonomy_id=tt.term_taxonomy_id\n                              ";
             $groupby_add = "GROUP BY tm.term_id";
         }
         $where_add .= " AND t.trid='{$trid}'";
         $query = "\n                SELECT t.translation_id, t.language_code, t.element_id, t.source_language_code IS NULL AS original {$sel_add}\n                FROM {$wpdb->prefix}icl_translations t\n                     {$join_add}\n                WHERE 1 {$where_add}\n                {$groupby_add} \n            ";
         $ret = $wpdb->get_results($query);
         foreach ($ret as $t) {
             if (preg_match('#^tax_(.+)$#', $el_type) && $t->instances == 0 && !_icl_tax_has_objects_recursive($t->element_id) && $skip_empty) {
                 continue;
             }
             $translations[$t->language_code] = $t;
         }
     }
     return $translations;
 }
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:36,代码来源:sitepress.class.php

示例4: must_ignore_translation

 /**
  * @param stdClass $translation
  *
  * @return bool
  */
 private function must_ignore_translation($translation)
 {
     return $this->wpml_element_type_is_taxonomy($translation->element_type) && $this->skip_empty && $translation->instances === 0 && (!$this->skip_recursions && !_icl_tax_has_objects_recursive($translation->element_id));
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:9,代码来源:class-wpml-translations.php


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