• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP walk_page_tree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: wp_list_pages2

function wp_list_pages2($args)
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || $wp_query->is_posts_page) {
            $current_page = $wp_query->get_queried_object_id();
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    $output = apply_filters('wp_list_pages', $output);
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:andychang88,项目名称:jianzhanseo.com,代码行数:34,代码来源:functions2.php


示例2: wp_list_pages

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int    $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                Default is the value of 'date_format' option.
 *     @type int    $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                the given n depth). Default 0.
 *     @type bool   $echo         Whether or not to echo the list of pages. Default true.
 *     @type string $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array  $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string $post_type    Post type to query for. Default 'page'.
 *     @type string $post_status  Comma-separated list of post statuses to include. Default 'publish'.
 *     @type string $show_date	  Whether to display the page publish or modified date for each page. Accepts
 *                                'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'preserve'.
 *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    if (!in_array($r['item_spacing'], array('preserve', 'discard'), true)) {
        // invalid value, fall back to default.
        $r['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
//.........这里部分代码省略.........
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:101,代码来源:post-template.php


示例3: wp_list_pages

function wp_list_pages($args = '') {
	if ( is_array($args) )
		$r = &$args;
	else
		parse_str($args, $r);

	$defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'),
		'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '');
	$r = array_merge($defaults, $r);

	$output = '';

	// sanitize, mostly to keep spaces out
	$r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);

	// Allow plugins to filter an array of excluded pages
	$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));

	// Query pages.
	$pages = get_pages($r);

	if ( !empty($pages) ) {
		if ( $r['title_li'] )
			$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';

		global $wp_query;
		$current_page = $wp_query->get_queried_object_id();
		$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);

		if ( $r['title_li'] )
			$output .= '</ul></li>';
	}

	$output = apply_filters('wp_list_pages', $output);

	if ( $r['echo'] )
		echo $output;
	else
		return $output;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:40,代码来源:post-template.php


示例4: list_grandchild_pages

 /**
  * list_grandchild_pages
  *
  * List as many levels as exist within the grandchild-sidebar-menu ul
  *
  * @param int $parent_page_id
  *
  * @return string
  */
 private function list_grandchild_pages($parent_page_id)
 {
     if (!$this->current_page_ancestor($parent_page_id)) {
         return '';
     }
     if (!($pages = $this->get_child_pages($parent_page_id))) {
         return '';
     }
     if ($this->level == $this->args['levels']) {
         return '';
     }
     $this->level++;
     $content = sprintf('<ul class="grandchild-sidebar-menu level-%s children">', $this->level);
     $inside = '';
     foreach ($pages as $page) {
         $inside .= walk_page_tree(array($page), 1, $this->current_page_id, $this->args);
         $inside .= $this->list_grandchild_pages($page->ID);
         $inside .= "</li>\n";
     }
     if ('' == $inside) {
         return '';
     }
     return $content . $inside . "</ul>\n";
 }
开发者ID:narendra-addweb,项目名称:MyImmoPix,代码行数:33,代码来源:Advanced_Sidebar_Menu_List_Pages.php


示例5: wpss_list_pages

function wpss_list_pages($arr, $query_args)
{
    $map_args = array('title' => 'post_title', 'date' => 'post_date', 'author' => 'post_author', 'modified' => 'post_modified');
    // modify the query args for get_pages() if necessary
    $orderby = array_key_exists($query_args['orderby'], $map_args) ? $map_args[$query_args['orderby']] : $query_args['orderby'];
    $r = array('depth' => $arr['page_depth'], 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => $arr['exclude'], 'echo' => 1, 'authors' => '', 'sort_column' => $orderby, 'sort_order' => $query_args['order'], 'link_before' => '', 'link_after' => '', 'walker' => '');
    $output = '';
    $current_page = 0;
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // sanitize, mostly to keep spaces out
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
    }
    // remove links
    if ($arr['links'] != 'true') {
        $output = preg_replace('/<a href=\\"(.*?)\\">(.*?)<\\/a>/', "\\2", $output);
    }
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:WestBayResidential,项目名称:wbrsorg,代码行数:35,代码来源:simple-sitemap.php


示例6: cmspo_list_pages

function cmspo_list_pages($args = null, $count = false)
{
    // no array in post_status until 3.2
    $post_type = esc_attr($_GET['post_type']);
    $defaults = array('post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => implode(',', cmspo_post_statuses()));
    $r = wp_parse_args($args, $defaults);
    $pages = new WP_Query($r);
    wp_reset_query();
    $pages = $pages->posts;
    if (count($pages) == 0) {
        return false;
    } else {
        if ($count) {
            return count($pages);
        }
    }
    $walker = new PO_Walker();
    $args = array('depth' => 0, 'link_before' => '', 'link_after' => '', 'walker' => $walker);
    $output = walk_page_tree($pages, 0, $args['depth'], $args);
    return $output;
}
开发者ID:timk85,项目名称:DIT,代码行数:21,代码来源:cms-page-order.php


示例7: printf

<div id="posttype-page" class="posttypediv">
	<p>
		<?php 
printf(__('The above sidebar will replace the "<strong>%s</strong>" sidebar for all pages selected below.', 'simple-page-sidebars'), $default_sidebar);
echo ' ';
_e('Any currently assigned custom sidebars will also be overridden for the selected pages.', 'simple-page-sidebars');
?>
	</p>

	<div id="page-all" class="tabs-panel tabs-panel-view-all tabs-panel-active">
		<ul id="pagechecklist" class="list:page categorychecklist form-no-clear">
			<?php 
$posts = get_posts(array('post_type' => 'page', 'order' => 'ASC', 'orderby' => 'title', 'posts_per_page' => -1, 'suppress_filters' => true, 'cache_results' => false));
$args['sidebar'] = self::sanitize_sidebar_name(stripslashes($_GET['sidebar']));
$args['selected'] = self::get_page_ids_using_sidebar($args['sidebar']);
$args['walker'] = new Simple_Page_Siders_Walker_Page_Checklist();
$items = walk_page_tree($posts, 0, 0, $args);
echo $items;
?>
		</ul>
	</div><!-- end div.tabs-panel -->

	<p style="margin: 5px 0 0 0">
		<span class="description"><?php 
_e('To delete this sidebar, simply uncheck all pages and click the "Update Sidebar" button.', 'simple-page-sidebars');
?>
</span>
	</p>
</div><!-- end div.posttypediv -->
开发者ID:omaharry,项目名称:stmaryomaha,代码行数:29,代码来源:meta-box-sidebar-pages.php


示例8: lectures_screen

 /**
  * lectures_screen( $vars )
  *
  * Hooks into screen_handler
  * Adds a UI to list lectures.
  *
  * @param Array $vars a set of variables received for this screen template
  * @return Array $vars a set of variable passed to this screen template
  */
 function lectures_screen($vars)
 {
     global $bp;
     $args = array('numberposts' => '-1', 'post_type' => 'lecture', 'group_id' => $bp->groups->current_group->id, 'orderby' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '');
     $lectures = get_posts($args);
     $vars['lectures_hanlder_uri'] = $vars['current_uri'] . '/lectures/';
     $vars['lectures'] = walk_page_tree($lectures, 0, 0, $args);
     return $vars;
 }
开发者ID:warinermedia,项目名称:buddypress-courseware,代码行数:18,代码来源:lectures.class.php


示例9: wp_list_pages

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return string HTML content, if not displaying.
 */
function wp_list_pages($args = '') {
	$defaults = array(
		'depth' => 0, 'show_date' => '',
		'date_format' => get_option('date_format'),
		'child_of' => 0, 'exclude' => '',
		'title_li' => __('Pages'), 'echo' => 1,
		'authors' => '', 'sort_column' => 'menu_order, post_title',
		'link_before' => '', 'link_after' => '', 'walker' => '',
	);

	$r = wp_parse_args( $args, $defaults );
	extract( $r, EXTR_SKIP );

	$output = '';
	$current_page = 0;

	// sanitize, mostly to keep spaces out
	$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);

	// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
	$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();

	/**
	 * Filter the array of pages to exclude from the pages list.
	 *
	 * @since 2.1.0
	 *
	 * @param array $exclude_array An array of page IDs to exclude.
	 */
	$r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );

	// Query pages.
	$r['hierarchical'] = 0;
	$pages = get_pages($r);

	if ( !empty($pages) ) {
		if ( $r['title_li'] )
			$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';

		global $wp_query;
		if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
			$current_page = get_queried_object_id();
		} elseif ( is_singular() ) {
			$queried_object = get_queried_object();
			if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
				$current_page = $queried_object->ID;
			}
		}

		$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);

		if ( $r['title_li'] )
			$output .= '</ul></li>';
	}

	/**
	 * Filter the HTML output of the pages to list.
	 *
	 * @since 1.5.1
	 *
	 * @see wp_list_pages()
	 *
	 * @param string $output HTML output of the pages list.
	 * @param array  $r      An array of page-listing arguments.
	 */
	$output = apply_filters( 'wp_list_pages', $output, $r );

	if ( $r['echo'] )
		echo $output;
	else
		return $output;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:80,代码来源:post-template.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wampIniSet函数代码示例发布时间:2022-05-23
下一篇:
PHP walk_page_dropdown_tree函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap