本文整理汇总了PHP中get_page_hierarchy函数的典型用法代码示例。如果您正苦于以下问题:PHP get_page_hierarchy函数的具体用法?PHP get_page_hierarchy怎么用?PHP get_page_hierarchy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_page_hierarchy函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: jeml_page_management_dropdown
function jeml_page_management_dropdown()
{
global $submenu, $wpdb;
$pages = $wpdb->get_results("SELECT ID, post_title, post_name, post_parent FROM {$wpdb->posts} WHERE post_type = 'page' AND post_status = 'publish' ORDER BY menu_order ASC, post_title ASC");
$indexed_pages = get_page_hierarchy($pages);
foreach ($pages as $page) {
$indexed_pages[$page->ID] = $page;
}
foreach ($indexed_pages as $page) {
$indent = '';
$parent = $page->post_parent;
while ($parent != 0) {
$indent .= ' ';
$parent = $indexed_pages[$parent]->post_parent;
}
$submenu['edit.php?post_type=page'][] = array($indent . $page->post_title, 'edit_pages', 'post.php?action=edit&post=' . $page->ID);
}
}
开发者ID:GaryJones,项目名称:m2xdemo,代码行数:18,代码来源:page-management-dropdown.php
示例2: generate_page_rewrite_rules
function generate_page_rewrite_rules() {
global $wpdb;
//get pages in order of hierarchy, i.e. children after parents
$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'static'"));
//now reverse it, because we need parents after children for rewrite rules to work properly
$posts = array_reverse($posts, true);
$page_rewrite_rules = array();
$page_attachment_rewrite_rules = array();
if ($posts) {
foreach ($posts as $id => $post) {
// URI => page name
$uri = get_page_uri($id);
$attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'attachment' AND post_parent = '$id'");
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$attach_uri = get_page_uri($attachment->ID);
$page_attachment_rewrite_rules[$attach_uri] = $attachment->post_name;
}
}
$page_rewrite_rules[$uri] = $post;
}
update_option('page_uris', $page_rewrite_rules);
if ( $page_attachment_rewrite_rules )
update_option('page_attachment_uris', $page_attachment_rewrite_rules);
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:34,代码来源:functions-post.php
示例3: page_uri_index
/**
* Retrieve all page and attachments for pages URIs.
*
* The attachments are for those that have pages as parents and will be
* retrieved.
*
* @since 2.5.0
* @access public
*
* @return array Array of page URIs as first element and attachment URIs as second element.
*/
function page_uri_index()
{
global $wpdb;
//get pages in order of hierarchy, i.e. children after parents
$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM {$wpdb->posts} WHERE post_type = 'page' AND post_status != 'auto-draft'"));
// If we have no pages get out quick
if (!$posts) {
return array(array(), array());
}
//now reverse it, because we need parents after children for rewrite rules to work properly
$posts = array_reverse($posts, true);
$page_uris = array();
$page_attachment_uris = array();
foreach ($posts as $id => $post) {
// URL => page name
$uri = get_page_uri($id);
$attachments = $wpdb->get_results($wpdb->prepare("SELECT ID, post_name, post_parent FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_parent = %d", $id));
if (!empty($attachments)) {
foreach ($attachments as $attachment) {
$attach_uri = get_page_uri($attachment->ID);
$page_attachment_uris[$attach_uri] = $attachment->ID;
}
}
$page_uris[$uri] = $id;
}
return array($page_uris, $page_attachment_uris);
}
开发者ID:snagga,项目名称:urbantac,代码行数:38,代码来源:rewrite.php
示例4: get_page_hierarchy
/**
* get_page_hierarchy() - {@internal Missing Short Description}}
*
* Fetches the pages returned as a FLAT list, but arranged in order of their hierarchy,
* i.e., child parents immediately follow their parents.
*
* @package WordPress
* @subpackage Post
* @since 2.0
*
* @param array $posts posts array
* @param int $parent parent page ID
* @return array {@internal Missing Description}}
*/
function get_page_hierarchy($posts, $parent = 0)
{
$result = array();
if ($posts) {
foreach ($posts as $post) {
if ($post->post_parent == $parent) {
$result[$post->ID] = $post->post_name;
$children = get_page_hierarchy($posts, $post->ID);
$result += $children;
//append $children to $result
}
}
}
return $result;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:29,代码来源:post.php
示例5: generate_page_uri_index
function generate_page_uri_index()
{
global $wpdb;
//get pages in order of hierarchy, i.e. children after parents
$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM {$wpdb->posts} WHERE post_type = 'page'"));
//now reverse it, because we need parents after children for rewrite rules to work properly
$posts = array_reverse($posts, true);
$page_uris = array();
$page_attachment_uris = array();
if ($posts) {
foreach ($posts as $id => $post) {
// URL => page name
$uri = get_page_uri($id);
$attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_parent = '{$id}'");
if ($attachments) {
foreach ($attachments as $attachment) {
$attach_uri = get_page_uri($attachment->ID);
$page_attachment_uris[$attach_uri] = $attachment->ID;
}
}
$page_uris[$uri] = $id;
}
delete_option('page_uris');
update_option('page_uris', $page_uris);
if ($page_attachment_uris) {
delete_option('page_attachment_uris');
update_option('page_attachment_uris', $page_attachment_uris);
}
}
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:30,代码来源:post.php
示例6: prev_lecture
/**
* prev_lecture( $lecture )
* Get the previous lecture
*
* @param Mixed $lecture object, current lecture
* @return Mixed the previous $lecture object
*/
function prev_lecture($lecture)
{
global $bp;
// Get lectures
$lectures = BPSP_Lectures::has_lectures($bp->groups->current_group->id);
if (empty($lectures)) {
return null;
}
// Try to sort them by menu_order
usort($lectures, array('BPSP_Lectures', 'cmp_menu_order'));
// Use WordPress's hierarchical algorithm
$hierarchy = get_page_hierarchy($lectures, 0);
// Find current position in hierarchy
while (next($hierarchy)) {
if (current($hierarchy) == $lecture->post_name) {
break;
}
}
$prev = prev($hierarchy);
if ($prev) {
return BPSP_Lectures::is_lecture($prev);
} else {
return null;
}
}
开发者ID:warinermedia,项目名称:buddypress-courseware,代码行数:32,代码来源:lectures.class.php
注:本文中的get_page_hierarchy函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论