Changeset 13377
- Timestamp:
- 12/01/2022 05:02:24 AM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r13363 r13377 665 665 666 666 /** 667 * Get the BP Directory pages allowed stati. 668 * 669 * @since 11.0.0 670 * 671 * @return array The BP Directory pages allowed stati. 672 */ 673 function bp_core_get_directory_pages_stati() { 674 $default_page_status = array( 'publish' ); 675 676 /** 677 * Filter here to edit the allowed BP Directory pages stati. 678 * 679 * @since 11.0.0 680 * 681 * @param array $default_page_status The default allowed BP Directory pages stati. 682 */ 683 $page_stati = (array) apply_filters( 'bp_core_get_directory_pages_stati', $default_page_status ); 684 685 // Validate the post stati, making sure each status is registered. 686 foreach ( $page_stati as $page_status_key => $page_status ) { 687 if ( ! get_post_status_object( $page_status ) ) { 688 unset( $page_stati[ $page_status_key ] ); 689 } 690 } 691 692 if ( ! $page_stati ) { 693 $page_stati = $default_page_status; 694 } 695 696 return $page_stati; 697 } 698 699 /** 667 700 * Get names and slugs for BuddyPress component directory pages. 668 701 * … … 684 717 // Get pages and IDs. 685 718 $page_ids = bp_core_get_directory_page_ids(); 686 if ( ! empty( $page_ids ) ) {719 if ( ! empty( $page_ids ) ) { 687 720 688 721 // Always get page data from the root blog, except on multiblog mode, when it comes … … 690 723 $posts_table_name = bp_is_multiblog_mode() ? $wpdb->posts : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts'; 691 724 $page_ids_sql = implode( ',', wp_parse_id_list( $page_ids ) ); 692 $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' " ); 725 $page_stati_sql = '\'' . implode( '\', \'', array_map( 'sanitize_key', bp_core_get_directory_pages_stati() ) ) . '\''; 726 $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 IN ({$page_stati_sql}) " ); 693 727 694 728 foreach ( (array) $page_ids as $component_id => $page_id ) {
Note: See TracChangeset
for help on using the changeset viewer.