Changeset 11513
- Timestamp:
- 03/16/2017 03:49:08 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-functions.php
r11390 r11513 315 315 // BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found. 316 316 $dupe_names = array(); 317 $page_ids = (array)bp_core_get_directory_page_ids();317 $page_ids = bp_core_get_directory_page_ids(); 318 318 $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) ); 319 319 -
trunk/src/bp-core/bp-core-cache.php
r11447 r11513 74 74 * @param int $post_id ID of the page that was saved. 75 75 */ 76 function bp_core_clear_directory_pages_cache_page_edit( $post_id ) { 77 if ( ! bp_is_root_blog() ) { 78 return; 79 } 76 function bp_core_clear_directory_pages_cache_page_edit( $post_id = 0 ) { 80 77 81 78 // Bail if BP is not defined here. … … 84 81 } 85 82 83 // Bail if not on the root blog 84 if ( ! bp_is_root_blog() ) { 85 return; 86 } 87 86 88 $page_ids = bp_core_get_directory_page_ids( 'all' ); 87 89 88 if ( ! in_array( $post_id, (array) $page_ids ) ) { 90 // Bail if post ID is not a directory page 91 if ( ! in_array( $post_id, $page_ids ) ) { 89 92 return; 90 93 } -
trunk/src/bp-core/bp-core-functions.php
r11447 r11513 489 489 */ 490 490 function bp_core_get_directory_page_ids( $status = 'active' ) { 491 $page_ids = bp_get_option( 'bp-pages' ); 492 493 // Ensure that empty indexes are unset. Should only matter in edge cases. 494 if ( !empty( $page_ids ) && is_array( $page_ids ) ) { 495 foreach( (array) $page_ids as $component_name => $page_id ) { 496 if ( empty( $component_name ) || empty( $page_id ) ) { 497 unset( $page_ids[ $component_name ] ); 498 } 499 500 // 'register' and 'activate' do not have components, but should be whitelisted. 501 if ( 'register' === $component_name || 'activate' === $component_name ) { 502 continue; 503 } 504 505 // Trashed pages should not appear in results. 506 if ( 'trash' == get_post_status( $page_id ) ) { 507 unset( $page_ids[ $component_name ] ); 508 509 } 510 511 // Remove inactive component pages, if required. 512 if ( 'active' === $status && ! bp_is_active( $component_name ) ) { 513 unset( $page_ids[ $component_name ] ); 514 } 491 $page_ids = bp_get_option( 'bp-pages', array() ); 492 493 // Loop through pages 494 foreach ( $page_ids as $component_name => $page_id ) { 495 496 // Ensure that empty indexes are unset. Should only matter in edge cases. 497 if ( empty( $component_name ) || empty( $page_id ) ) { 498 unset( $page_ids[ $component_name ] ); 515 499 } 500 501 // Trashed pages should never appear in results. 502 if ( 'trash' == get_post_status( $page_id ) ) { 503 unset( $page_ids[ $component_name ] ); 504 } 505 506 // 'register' and 'activate' do not have components, but should be whitelisted. 507 if ( in_array( $component_name, array( 'register', 'activate' ), true ) ) { 508 continue; 509 } 510 511 // Remove inactive component pages. 512 if ( ( 'active' === $status ) && ! bp_is_active( $component_name ) ) { 513 unset( $page_ids[ $component_name ] ); 514 } 516 515 } 517 516 … … 520 519 * 521 520 * @since 1.5.0 522 * 523 * @param array $page_ids Array of directory pages. 524 */ 525 return apply_filters( 'bp_core_get_directory_page_ids', $page_ids ); 521 * @since 2.9.0 Add $status parameter 522 * 523 * @param array $page_ids Array of directory pages. 524 * @param string $status Page status to limit results to 525 */ 526 return (array) apply_filters( 'bp_core_get_directory_page_ids', $page_ids, $status ); 526 527 } 527 528 … … 663 664 // Delete any existing pages. 664 665 if ( 'delete' === $existing ) { 665 foreach ( (array)$pages as $page_id ) {666 foreach ( $pages as $page_id ) { 666 667 wp_delete_post( $page_id, true ); 667 668 } … … 889 890 } 890 891 891 $page_ids = array_merge( (array) $new_page_ids, (array)bp_core_get_directory_page_ids( 'all' ) );892 $page_ids = array_merge( $new_page_ids, bp_core_get_directory_page_ids( 'all' ) ); 892 893 bp_core_update_directory_page_ids( $page_ids ); 893 894 } -
trunk/tests/phpunit/testcases/admin/functions.php
r10972 r11513 145 145 ) ) ); 146 146 147 $page_ids = array_merge( $new_page_ids, (array)bp_core_get_directory_page_ids( 'all' ) );147 $page_ids = array_merge( $new_page_ids, bp_core_get_directory_page_ids( 'all' ) ); 148 148 bp_core_update_directory_page_ids( $page_ids ); 149 149
Note: See TracChangeset
for help on using the changeset viewer.