Skip to:
Content

BuddyPress.org

Ticket #5323: 5323.01.diff

File 5323.01.diff, 1.5 KB (added by imath, 10 years ago)
  • bp-core/bp-core-filters.php

     
    9999add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
    100100
    101101/**
     102 * Prevent specific pages (eg 'Activate') from showing in the Pages meta box of Administration Menu 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 );
     136
     137/**
    102138 * Set "From" name in outgoing email to the site name.
    103139 *
    104140 * @uses bp_get_option() fetches the value for a meta_key in the wp_X_options table.