Skip to:
Content

BuddyPress.org

Ticket #7935: 7935.04.patch

File 7935.04.patch, 3.0 KB (added by r-a-y, 8 years ago)
  • src/bp-core/bp-core-buddybar.php

     
    9090 * Add a link to the main BuddyPress navigation.
    9191 *
    9292 * @since 2.4.0
    93  * @since 2.6.0 Introduced the `$component` parameter. Began returning a BP_Core_Nav_Item object on success.
     93 * @since 2.6.0 Introduced the `$component` parameter. Began returning a BP_Core_Nav_Item
     94 *              object on success.
     95 * @since 3.3.0 Introduced $args['component_id'] parameter so developers can determine what
     96 *              component is registering the nav.
    9497 *
    9598 * @param array|string $args {
    9699 *     Array describing the new nav item.
     100 *     @type string      $component_id            The component ID registering this nav item.
    97101 *     @type string      $name                    Display name for the nav item.
    98102 *     @type string      $slug                    Unique URL slug for the nav item.
    99103 *     @type bool|string $item_css_id             Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
     
    114118        $bp = buddypress();
    115119
    116120        $defaults = array(
     121                'component_id'            => '',    // The component ID registering this nav item.
    117122                'name'                    => false, // Display name for the nav item.
    118123                'slug'                    => false, // URL slug for the nav item.
    119124                'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
     
    141146        }
    142147
    143148        $nav_item = array(
     149                'component_id'            => $r['component_id'],
    144150                'name'                    => $r['name'],
    145151                'slug'                    => $r['slug'],
    146152                'link'                    => trailingslashit( bp_loggedin_user_domain() . $r['slug'] ),
     
    342348                // No subnav item has been requested in the URL, so set a new nav default.
    343349                if ( empty( $unfiltered_action ) ) {
    344350                        if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
     351                                /*
     352                                 * If the screen function isn't available, attempt to find it.
     353                                 *
     354                                 * This is due to our conditional-loading code since v3.0.0.
     355                                 */
     356                                if ( ! is_callable( $r['screen_function'] ) && ! empty( $parent_nav->component_id ) ) {
     357                                        $file = $bp->core->path . 'bp-' . $parent_nav->component_id . '/screens/' . $r['subnav_slug'] . '.php';
     358                                        // Found the file, so require it.
     359                                        if ( file_exists( $file ) ) {
     360                                                require_once $file;
     361                                        }
     362                                }
     363
    345364                                if ( is_callable( $r['screen_function'] ) ) {
    346365                                        add_action( 'bp_screens', $r['screen_function'], 3 );
    347366                                }
  • src/bp-core/classes/class-bp-component.php

     
    498498
    499499                // No sub nav items without a main nav item.
    500500                if ( !empty( $main_nav ) ) {
     501                        // Always set the component ID.
     502                        $main_nav['component_id'] = $this->id;
     503
    501504                        bp_core_new_nav_item( $main_nav, 'members' );
    502505
    503506                        // Sub nav items are not required.