bp_core_get_directory_pages ()

获取BuddyPress组件目录页的名称和鼻涕虫。

描述

返回

(对象)页面名称、id和鼻涕虫。

文件:bp-core / bp-core-functions.php

函数bp_core_get_directory_pages() {global $wpdb;//先查看缓存。$pages = wp_cache_get('directory_pages', 'bp_pages');if (false === $pages){//设置页面为标准类。$pages = new stdClass;//获取页面和id。$ page_ids = bp_core_get_directory_page_ids ();if (!empty($page_ids)){//总是从根博客获取页面数据,除非在多博客模式下,当它来自当前博客时。$posts_table_name = bp_is_multiblog_mode() ?$wpdb->post: $wpdb->get_blog_prefix(bp_get_root_blog_id())。 'posts'; $page_ids_sql = implode( ',', wp_parse_id_list( $page_ids ) ); $page_names = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_title FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status = 'publish' " ); foreach ( (array) $page_ids as $component_id => $page_id ) { foreach ( (array) $page_names as $page_name ) { if ( $page_name->ID == $page_id ) { if ( !isset( $pages->{$component_id} ) || !is_object( $pages->{$component_id} ) ) { $pages->{$component_id} = new stdClass; } $pages->{$component_id}->name = $page_name->post_name; $pages->{$component_id}->id = $page_name->ID; $pages->{$component_id}->title = $page_name->post_title; $slug[] = $page_name->post_name; // Get the slug. while ( $page_name->post_parent != 0 ) { $parent = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) ); $slug[] = $parent[0]->post_name; $page_name->post_parent = $parent[0]->post_parent; } $pages->{$component_id}->slug = implode( '/', array_reverse( (array) $slug ) ); } unset( $slug ); } } } wp_cache_set( 'directory_pages', $pages, 'bp_pages' ); } /** * Filters the names and slugs for BuddyPress component directory pages. * * @since BuddyPress 1.5.0 * * @param object $pages Object holding page names and slugs. */ return apply_filters( 'bp_core_get_directory_pages', $pages ); }

更新日志

更新日志
版本 描述
BuddyPress 1.5.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队