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


PHP icl_get_post_children_recursive函数代码示例

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


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

示例1: icl_get_post_children_recursive

function icl_get_post_children_recursive($post, $type = 'page')
{
    global $wpdb;
    $post = (array) $post;
    $children = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_parent IN (" . join(',', $post) . ")", $type));
    if (!empty($children)) {
        $children = array_merge($children, icl_get_post_children_recursive($children));
    }
    return $children;
}
开发者ID:ViktorLinnasaar,项目名称:hanset,代码行数:10,代码来源:functions.php

示例2: icl_get_post_children_recursive

function icl_get_post_children_recursive($post, $type = 'page')
{
    global $wpdb;
    $post = (array) $post;
    $children = $wpdb->get_col($wpdb->prepare("SELECT ID\r\n                                               FROM {$wpdb->posts}\r\n                                               WHERE post_type=%s\r\n                                                AND post_parent IN (" . wpml_prepare_in($post, '%d') . ")", $type));
    if (!empty($children)) {
        $children = array_merge($children, icl_get_post_children_recursive($children));
    }
    return $children;
}
开发者ID:edgarter,项目名称:wecare,代码行数:10,代码来源:functions.php

示例3: get_documents


//.........这里部分代码省略.........
                 $where .= " AND (iclts.status = " . ICL_TM_COMPLETE . " OR iclts.status = " . ICL_TM_DUPLICATE . ") AND iclts.needs_update = 0\n";
             }
         } elseif ($active_languages && count($active_languages) > 1) {
             if ($tstatus == 'not') {
                 $where .= " AND (";
                 $wheres = array();
                 foreach ($active_languages as $lang) {
                     if ($lang['code'] == $from_lang) {
                         continue;
                     }
                     $tbl_alias_suffix = str_replace('-', '_', $lang['code']);
                     $wheres[] = "iclts_{$tbl_alias_suffix}.status IS NULL OR iclts_{$tbl_alias_suffix}.status = " . ICL_TM_WAITING_FOR_TRANSLATOR . " OR iclts_{$tbl_alias_suffix}.needs_update = 1\n";
                 }
                 $where .= join(' OR ', $wheres) . ")";
             } elseif ($tstatus == 'need-update') {
                 $where .= " AND (";
                 $wheres = array();
                 foreach ($active_languages as $lang) {
                     if ($lang['code'] == $from_lang) {
                         continue;
                     }
                     $tbl_alias_suffix = str_replace('-', '_', $lang['code']);
                     $wheres[] = "iclts_{$tbl_alias_suffix}.needs_update = 1\n";
                 }
                 $where .= join(' OR ', $wheres) . ")";
             } elseif ($tstatus == 'in_progress') {
                 $where .= " AND (";
                 $wheres = array();
                 foreach ($active_languages as $lang) {
                     if ($lang['code'] == $from_lang) {
                         continue;
                     }
                     $tbl_alias_suffix = str_replace('-', '_', $lang['code']);
                     $wheres[] = "iclts_{$tbl_alias_suffix}.status = " . ICL_TM_IN_PROGRESS . "\n";
                 }
                 $where .= join(' OR ', $wheres) . ")";
             } elseif ($tstatus == 'complete') {
                 foreach ($active_languages as $lang) {
                     if ($lang['code'] == $from_lang) {
                         continue;
                     }
                     $tbl_alias_suffix = str_replace('-', '_', $lang['code']);
                     $where .= " AND (iclts_{$tbl_alias_suffix}.status = " . ICL_TM_COMPLETE . " OR iclts_{$tbl_alias_suffix}.status = " . ICL_TM_DUPLICATE . ") AND iclts_{$tbl_alias_suffix}.needs_update = 0\n";
                 }
             }
         }
     }
     if (isset($parent_type) && $parent_type == 'page' && $parent_id > 0) {
         if ($parent_all) {
             $children = icl_get_post_children_recursive($parent_id);
             if (!$children) {
                 $children[] = -1;
             }
             $where .= ' AND p.ID IN (' . join(',', $children) . ')';
         } else {
             $where .= ' AND p.post_parent=' . intval($parent_id);
         }
     }
     if (isset($parent_type) && $parent_type == 'category' && $parent_id > 0) {
         if ($parent_all) {
             $children = icl_get_tax_children_recursive($parent_id);
             $children[] = $parent_id;
             $join .= "  JOIN {$wpdb->term_relationships} tr ON p.ID = tr.object_id\n\t\t\t\t\t\t\tJOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND taxonomy = 'category'\n\t\t\t\t\t\t\tJOIN {$wpdb->terms} tm ON tt.term_id = tm.term_id AND tm.term_id IN(" . join(',', $children) . ")";
         } else {
             $join .= "  JOIN {$wpdb->term_relationships} tr ON p.ID = tr.object_id\n\t\t\t\t\t\t\tJOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND taxonomy = 'category'\n\t\t\t\t\t\t\tJOIN {$wpdb->terms} tm ON tt.term_id = tm.term_id AND tm.term_id = " . intval($parent_id);
         }
     }
     // ORDER
     if ($sort_by) {
         $order = " {$sort_by} ";
     } else {
         $order = " p.post_date DESC";
     }
     if ($sort_order) {
         $order .= $sort_order;
     } else {
         $order .= 'DESC';
     }
     // LIMIT
     if (!isset($_GET['paged'])) {
         $_GET['paged'] = 1;
     }
     $offset = ($_GET['paged'] - 1) * $limit_no;
     $limit = " " . $offset . ',' . $limit_no;
     $sql = "\n\t\t\tSELECT SQL_CALC_FOUND_ROWS {$select}\n\t\t\tFROM {$from}\n\t\t\t{$join}\n\t\t\tWHERE {$where}\n\t\t\tORDER BY {$order}\n\t\t\tLIMIT {$limit}\n\t\t";
     $results = $wpdb->get_results($sql);
     $count = $wpdb->get_var("SELECT FOUND_ROWS()");
     $wp_query->found_posts = $count;
     $wp_query->query_vars['posts_per_page'] = $limit_no;
     $wp_query->max_num_pages = ceil($wp_query->found_posts / $limit_no);
     // post process
     foreach ($results as $k => $v) {
         if ($v->is_translation) {
             $source_language = $wpdb->get_var($wpdb->prepare("SELECT language_code FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND source_language_code IS NULL", $v->trid));
             $_tmp = 'status_' . $source_language;
             $v->{$_tmp} = ICL_TM_COMPLETE;
         }
     }
     return $results;
 }
开发者ID:Calraiser,项目名称:flux,代码行数:101,代码来源:translation-management.class.php


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