Ticket #5810: 5810.patch
| File 5810.patch, 3.6 KB (added by , 12 years ago) |
|---|
-
src/bp-core/bp-core-template.php
diff --git src/bp-core/bp-core-template.php src/bp-core/bp-core-template.php index 3d71621..5280297 100644
function bp_is_directory() { 1294 1294 } 1295 1295 1296 1296 /** 1297 * Is the directory, the parent of the page being viewed. 1298 * 1299 * @since BuddyPress (2.1.0). 1300 * 1301 * @param integer $object_id the id to check 1302 * @return bool True if the directory is the parent of the page, otherwise 1303 * false. 1304 */ 1305 function bp_is_directory_current_parent( $object_id = 0 ) { 1306 $retval = false; 1307 1308 if ( ! is_buddypress() || empty( $object_id ) ) { 1309 return $retval; 1310 } 1311 1312 foreach ( buddypress()->pages as $page ) { 1313 if ( ! empty( $page->key ) && $object_id == $page->id ) { 1314 $retval = true; 1315 break; 1316 } 1317 } 1318 1319 return (bool) apply_filters( 'bp_is_directory_current_parent', $retval ); 1320 } 1321 1322 /** 1297 1323 * Check to see if a component's URL should be in the root, not under a member page. 1298 1324 * 1299 1325 * - Yes ('groups' is root) : http://domain.com/groups/the-group -
src/bp-templates/bp-legacy/buddypress-functions.php
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php index 1e8686c..5eec96a 100644
class BP_Legacy extends BP_Theme_Compat { 90 90 /** Body no-js Class ********************************************************/ 91 91 add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 ); 92 92 93 /** WP Nav Menu & WP List Pages current parent page parent css fix ************/ 94 add_filter( 'nav_menu_css_class', array( $this, 'directory_current_parent_page' ), 10, 2 ); 95 add_filter( 'page_css_class', array( $this, 'directory_current_parent_page' ), 10, 2 ); 96 93 97 /** Buttons ***********************************************************/ 94 98 95 99 if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { … … class BP_Legacy extends BP_Theme_Compat { 381 385 } 382 386 383 387 /** 388 * Adds the current_page_parent class to menu item, if needed. 389 * 390 * When viewing a single member/group, this function make sure a current_page_parent class 391 * is added to the parent directory item/page listed in the WP Nav Menu /WP List Pages 392 * 393 * @since BuddyPress (2.1.0) 394 * @param array $classes the list of nav item/page classes 395 * @param WP_Post $item the nav item or page object 396 * @return array $classes 397 */ 398 public function directory_current_parent_page( $classes = array(), $item = null ) { 399 // Bail if not displaying a single user or group 400 if ( ! bp_is_user() && ! bp_is_group() ) { 401 return $classes; 402 } 403 404 // Page and nav menu item are post types 405 if ( ! is_a( $item, 'WP_Post' ) ) { 406 return $classes; 407 } 408 409 $object_id = 'ID'; 410 411 if ( 'page' != $item->post_type ) { 412 $object_id = 'object_id'; 413 } 414 415 // Bail if the object id is not set 416 if ( empty( $item->{$object_id} ) ) { 417 return $classes; 418 } 419 420 // Set the current page parent class 421 $current_page_parent = array( 'current_page_parent' ); 422 423 /** 424 * If a page is set to list blog posts, it will always be the 425 * default parent. So we need to remove the current page parent 426 * class. 427 */ 428 if ( ! bp_is_directory_current_parent( $item->{$object_id} ) ) { 429 $classes = array_diff( $classes, $current_page_parent ); 430 431 // Make sure the parent directory is the current page parent 432 } else { 433 $classes = array_merge( $classes, $current_page_parent ); 434 } 435 436 return $classes; 437 } 438 439 /** 384 440 * Load localizations for topic script 385 441 * 386 442 * These localizations require information that may not be loaded even by init.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)