Skip to:
Content

BuddyPress.org

Changeset 7741


Ignore:
Timestamp:
01/20/2014 08:47:39 PM (11 years ago)
Author:
imath
Message:

Prevents Activate and Register pages from showing in the Pages meta box of the Menu Administration screen.

In the same way these pages are not displayed on the page listings, they will be hidden from the available items of the Pages meta box in the menus administration. This also avoids confusion with the register item of BuddyPress dynamic links.

Fixes #5323

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-filters.php

    r7612 r7741  
    9898}
    9999add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
     100
     101/**
     102 * Prevent specific pages (eg 'Activate') from showing in the Pages meta box of the Menu Administration screen.
     103 *
     104 * @since BuddyPress (2.0)
     105 *
     106 * @uses bp_is_root_blog() checks if current blog is root blog.
     107 * @uses buddypress() gets BuddyPress main instance
     108 *
     109 * @param object $object The post type object used in the meta box
     110 * @return object The $object, with a query argument to remove register and activate pages id.
     111 */
     112function bp_core_exclude_pages_from_nav_menu_admin( $object = null ) {
     113
     114    // Bail if not the root blog
     115    if ( ! bp_is_root_blog() )
     116        return $object;
     117
     118    if ( 'page' != $object->name )
     119        return $object;
     120
     121    $bp = buddypress();
     122    $pages = array();
     123
     124    if ( ! empty( $bp->pages->activate ) )
     125        $pages[] = $bp->pages->activate->id;
     126
     127    if ( ! empty( $bp->pages->register ) )
     128        $pages[] = $bp->pages->register->id;
     129
     130    if ( ! empty( $pages ) )
     131        $object->_default_query['post__not_in'] = $pages;
     132
     133    return $object;
     134}
     135add_filter( 'nav_menu_meta_box_object', 'bp_core_exclude_pages_from_nav_menu_admin', 11, 1 );
    100136
    101137/**
Note: See TracChangeset for help on using the changeset viewer.