Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2015 07:57:03 PM (9 years ago)
Author:
tw2113
Message:

[Samus Aran]
I first battled the documentation inconsistencies on planet Zebes. It was there that I foiled the plans of the
Space Pirate leader Mother Brain to use the issues to attack galactic civilization...

I next fought the inconsistencies on their homeworld SR388. I completely eradicated them except for an @since tag,
which after hatching followed me like a confused child...

I personally delivered it to the Galactic Research Station at Ceres so scientists could study its energy production qualities...

The scientists' findings were astounding! They discovered that the powers of the docs inconsistencies
might be harnessed for the good of galactic civilization!

Satisfied that all was well, I left the station to seek a new bounty to hunt. But, I had hardly gone beyond the asteroid
belt when I picked up a distress signal!

Ceres station was under attack!

More documentation cleanup for part of BP-Core component.

See #6398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-buddybar.php

    r10326 r10356  
    3434
    3535    $defaults = array(
    36         'name'                    => false, // Display name for the nav item
    37         'slug'                    => false, // URL slug for the nav item
    38         'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
     36        'name'                    => false, // Display name for the nav item.
     37        'slug'                    => false, // URL slug for the nav item.
     38        'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
    3939        'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
    4040        'site_admin_only'         => false, // Can only site admins see this nav item?
    41         'position'                => 99,    // Index of where this nav item should be positioned
    42         'screen_function'         => false, // The name of the function to run when clicked
    43         'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
     41        'position'                => 99,    // Index of where this nav item should be positioned.
     42        'screen_function'         => false, // The name of the function to run when clicked.
     43        'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
    4444    );
    4545
     
    103103
    104104    $defaults = array(
    105         'name'                    => false, // Display name for the nav item
    106         'slug'                    => false, // URL slug for the nav item
    107         'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
     105        'name'                    => false, // Display name for the nav item.
     106        'slug'                    => false, // URL slug for the nav item.
     107        'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
    108108        'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
    109109        'site_admin_only'         => false, // Can only site admins see this nav item?
    110         'position'                => 99,    // Index of where this nav item should be positioned
    111         'screen_function'         => false, // The name of the function to run when clicked
    112         'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
     110        'position'                => 99,    // Index of where this nav item should be positioned.
     111        'screen_function'         => false, // The name of the function to run when clicked.
     112        'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
    113113    );
    114114
     
    178178
    179179    $defaults = array(
    180         'name'                    => false, // Display name for the nav item
    181         'slug'                    => false, // URL slug for the nav item
    182         'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
     180        'name'                    => false, // Display name for the nav item.
     181        'slug'                    => false, // URL slug for the nav item.
     182        'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
    183183        'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
    184184        'site_admin_only'         => false, // Can only site admins see this nav item?
    185         'position'                => 99,    // Index of where this nav item should be positioned
    186         'screen_function'         => false, // The name of the function to run when clicked
    187         'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
     185        'position'                => 99,    // Index of where this nav item should be positioned.
     186        'screen_function'         => false, // The name of the function to run when clicked.
     187        'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
    188188    );
    189189
     
    221221    }
    222222
    223     // Look for current component
     223    // Look for current component.
    224224    if ( bp_is_current_component( $r['slug'] ) || bp_is_current_item( $r['slug'] ) ) {
    225225
     
    231231        } elseif ( ! bp_current_action() ) {
    232232
    233             // Add our screen hook if screen function is callable
     233            // Add our screen hook if screen function is callable.
    234234            if ( is_callable( $r['screen_function'] ) ) {
    235235                add_action( 'bp_screens', $r['screen_function'], 3 );
     
    278278
    279279    $defaults = array(
    280         'parent_slug'     => false, // Slug of the parent
    281         'screen_function' => false, // The name of the function to run when clicked
    282         'subnav_slug'     => false  // The slug of the subnav item to select when clicked
     280        'parent_slug'     => false, // Slug of the parent.
     281        'screen_function' => false, // The name of the function to run when clicked.
     282        'subnav_slug'     => false  // The slug of the subnav item to select when clicked.
    283283    );
    284284
     
    286286
    287287    if ( $function = $bp->bp_nav[$r['parent_slug']]['screen_function'] ) {
    288         // Remove our screen hook if screen function is callable
     288        // Remove our screen hook if screen function is callable.
    289289        if ( is_callable( $function ) ) {
    290290            remove_action( 'bp_screens', $function, 3 );
     
    297297
    298298        // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
    299         // Find the component
     299        // Find the component.
    300300        $component_uri_key = array_search( $r['parent_slug'], $bp->unfiltered_uri );
    301301
     
    306306        }
    307307
    308         // No subnav item has been requested in the URL, so set a new nav default
     308        // No subnav item has been requested in the URL, so set a new nav default.
    309309        if ( empty( $unfiltered_action ) ) {
    310310            if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
     
    318318
    319319        // The URL is explicitly requesting the new subnav item, but should be
    320         // directed to the canonical URL
     320        // directed to the canonical URL.
    321321        } elseif ( $unfiltered_action == $r['subnav_slug'] ) {
    322322            unset( $bp->canonical_stack['action'] );
     
    324324        // In all other cases (including the case where the original subnav item
    325325        // is explicitly called in the URL), the canonical URL will contain the
    326         // subnav slug
     326        // subnav slug.
    327327        } else {
    328328            $bp->canonical_stack['action'] = bp_current_action();
     
    354354            $temp[$nav_item['position']] = $nav_item;
    355355        } else {
    356             // increase numbers here to fit new items in.
     356            // Increase numbers here to fit new items in.
    357357            do {
    358358                $nav_item['position']++;
     
    444444 *                                          Default: false.
    445445 * }
    446  *
    447446 * @return bool|null Returns false on failure.
    448447 */
     
    451450
    452451    $r = wp_parse_args( $args, array(
    453         'name'              => false, // Display name for the nav item
    454         'slug'              => false, // URL slug for the nav item
    455         'parent_slug'       => false, // URL slug of the parent nav item
    456         'parent_url'        => false, // URL of the parent item
    457         'item_css_id'       => false, // The CSS ID to apply to the HTML of the nav item
     452        'name'              => false, // Display name for the nav item.
     453        'slug'              => false, // URL slug for the nav item.
     454        'parent_slug'       => false, // URL slug of the parent nav item.
     455        'parent_url'        => false, // URL of the parent item.
     456        'item_css_id'       => false, // The CSS ID to apply to the HTML of the nav item.
    458457        'user_has_access'   => true,  // Can the logged in user see this nav item?
    459458        'no_access_url'     => '',
    460459        'site_admin_only'   => false, // Can only site admins see this nav item?
    461         'position'          => 90,    // Index of where this nav item should be positioned
    462         'screen_function'   => false, // The name of the function to run when clicked
     460        'position'          => 90,    // Index of where this nav item should be positioned.
     461        'screen_function'   => false, // The name of the function to run when clicked.
    463462        'link'              => '',    // The link for the subnav item; optional, not usually required.
    464         'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu
     463        'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu.
    465464    ) );
    466465
    467     // If we don't have the required info we need, don't create this subnav item
     466    // If we don't have the required info we need, don't create this subnav item.
    468467    if ( empty( $r['name'] ) || empty( $r['slug'] ) || empty( $r['parent_slug'] ) || empty( $r['parent_url'] ) || empty( $r['screen_function'] ) )
    469468        return false;
    470469
    471     // Link was not forced, so create one
     470    // Link was not forced, so create one.
    472471    if ( empty( $r['link'] ) ) {
    473472        $r['link'] = trailingslashit( $r['parent_url'] . $r['slug'] );
    474473
    475         // If this sub item is the default for its parent, skip the slug
     474        // If this sub item is the default for its parent, skip the slug.
    476475        if ( ! empty( $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) && $r['slug'] == $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) {
    477476            $r['link'] = trailingslashit( $r['parent_url'] );
     
    479478    }
    480479
    481     // If this is for site admins only and the user is not one, don't create the subnav item
     480    // If this is for site admins only and the user is not one, don't create the subnav item.
    482481    if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
    483482        return false;
     
    529528 *                                       Default: false.
    530529 * }
    531  *
    532530 * @return bool|null Returns false on failure.
    533531 */
     
    536534
    537535    $r = wp_parse_args( $args, array(
    538         'slug'              => false, // URL slug for the screen
    539         'parent_slug'       => false, // URL slug of the parent screen
     536        'slug'              => false, // URL slug for the screen.
     537        'parent_slug'       => false, // URL slug of the parent screen.
    540538        'user_has_access'   => true,  // Can the user visit this screen?
    541539        'no_access_url'     => '',
    542540        'site_admin_only'   => false, // Can only site admins visit this screen?
    543         'screen_function'   => false, // The name of the function to run when clicked
     541        'screen_function'   => false, // The name of the function to run when clicked.
    544542    ) );
    545543
     
    550548     * checking the following two conditions:
    551549     *   (1) Either:
    552      *       (a) the parent slug matches the current_component, or
    553      *       (b) the parent slug matches the current_item
     550     *       (a) the parent slug matches the current_component, or
     551     *       (b) the parent slug matches the current_item
    554552     *   (2) And either:
    555      *       (a) the current_action matches $slug, or
     553     *       (a) the current_action matches $slug, or
    556554     *       (b) there is no current_action (ie, this is the default subnav for the parent nav)
    557      *       and this subnav item is the default for the parent item (which we check by
    558      *       comparing this subnav item's screen function with the screen function of the
    559      *       parent nav item in $bp->bp_nav). This condition only arises when viewing a
    560      *       user, since groups should always have an action set.
     555     *       and this subnav item is the default for the parent item (which we check by
     556     *       comparing this subnav item's screen function with the screen function of the
     557     *       parent nav item in $bp->bp_nav). This condition only arises when viewing a
     558     *       user, since groups should always have an action set.
    561559     */
    562560
    563     // If we *don't* meet condition (1), return
     561    // If we *don't* meet condition (1), return.
    564562    if ( ! bp_is_current_component( $r['parent_slug'] ) && ! bp_is_current_item( $r['parent_slug'] ) ) {
    565563        return;
    566564    }
    567565
    568     // If we *do* meet condition (2), then the added subnav item is currently being requested
     566    // If we *do* meet condition (2), then the added subnav item is currently being requested.
    569567    if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ( $r['screen_function'] == $bp->bp_nav[$r['parent_slug']]['screen_function'] ) ) ) {
    570568
    571         // If this is for site admins only and the user is not one, don't create the subnav item
     569        // If this is for site admins only and the user is not one, don't create the subnav item.
    572570        if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
    573571            return false;
     
    576574        $hooked = bp_core_maybe_hook_new_subnav_screen_function( $r );
    577575
    578         // If redirect args have been returned, perform the redirect now
     576        // If redirect args have been returned, perform the redirect now.
    579577        if ( ! empty( $hooked['status'] ) && 'failure' === $hooked['status'] && isset( $hooked['redirect_args'] ) ) {
    580578            bp_core_no_access( $hooked['redirect_args'] );
     
    589587 *
    590588 * @param array $subnav_item The subnav array added to bp_options_nav in `bp_core_new_subnav_item()`.
    591  *
    592589 * @return array
    593590 */
     
    603600    }
    604601
    605     // User has access, so let's try to hook the display callback
     602    // User has access, so let's try to hook the display callback.
    606603    if ( ! empty( $subnav_item['user_has_access'] ) && ! $site_admin_restricted ) {
    607604
    608         // Screen function is invalid
     605        // Screen function is invalid.
    609606        if ( ! is_callable( $subnav_item['screen_function'] ) ) {
    610607            $retval['status'] = 'failure';
    611608
    612         // Success - hook to bp_screens
     609        // Success - hook to bp_screens.
    613610        } else {
    614611            add_action( 'bp_screens', $subnav_item['screen_function'], 3 );
     
    617614
    618615    // User doesn't have access. Determine redirect arguments based on
    619     // user status
     616    // user status.
    620617    } else {
    621618        $retval['status'] = 'failure';
     
    626623
    627624            // If a redirect URL has been passed to the subnav
    628             // item, respect it
     625            // item, respect it.
    629626            if ( ! empty( $subnav_item['no_access_url'] ) ) {
    630627                $message     = __( 'You do not have access to this page.', 'buddypress' );
     
    632629
    633630            // In the case of a user page, we try to assume a
    634             // redirect URL
     631            // redirect URL.
    635632            } elseif ( bp_is_user() ) {
    636633
     
    646643                // know will be accessible.
    647644                } else {
    648                     // Try 'activity' first
     645                    // Try 'activity' first.
    649646                    if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
    650647                        $redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
    651                     // Then try 'profile'
     648                    // Then try 'profile'.
    652649                    } else {
    653650                        $redirect_to = trailingslashit( bp_displayed_user_domain() . ( 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id ) );
     
    657654                }
    658655
    659             // Fall back to the home page
     656            // Fall back to the home page.
    660657            } else {
    661658                $message     = __( 'You do not have access to this page.', 'buddypress' );
     
    672669            // When the user is logged out, pass an empty array
    673670            // This indicates that the default arguments should be
    674             // used in bp_core_no_access()
     671            // used in bp_core_no_access().
    675672            $retval['redirect_args'] = array();
    676673        }
     
    699696                $temp[$subnav_item['position']] = $subnav_item;
    700697            else {
    701                 // increase numbers here to fit new items in.
     698                // Increase numbers here to fit new items in.
    702699                do {
    703700                    $subnav_item['position']++;
     
    722719 * @param string $nav_item The slug of the top-level nav item whose subnav items you're checking.
    723720 *                         Default: the current component slug.
    724  *
    725721 * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise.
    726722 */
     
    748744 *
    749745 * @param int $parent_id The slug of the parent navigation item.
    750  *
    751746 * @return bool Returns false on failure, ie if the nav item can't be found.
    752747 */
     
    754749    $bp = buddypress();
    755750
    756     // Unset subnav items for this nav item
     751    // Unset subnav items for this nav item.
    757752    if ( isset( $bp->bp_options_nav[$parent_id] ) && is_array( $bp->bp_options_nav[$parent_id] ) ) {
    758753        foreach( (array) $bp->bp_options_nav[$parent_id] as $subnav_item ) {
     
    765760
    766761    if ( $function = $bp->bp_nav[$parent_id]['screen_function'] ) {
    767         // Remove our screen hook if screen function is callable
     762        // Remove our screen hook if screen function is callable.
    768763        if ( is_callable( $function ) ) {
    769764            remove_action( 'bp_screens', $function, 3 );
     
    788783
    789784    if ( ! empty( $screen_function ) ) {
    790         // Remove our screen hook if screen function is callable
     785        // Remove our screen hook if screen function is callable.
    791786        if ( is_callable( $screen_function ) ) {
    792787            remove_action( 'bp_screens', $screen_function, 3 );
     
    823818 * @param string $context Context of this preference check. 'admin' or 'front'.
    824819 * @param int    $user    Optional. ID of the user to check. Default: 0 (which falls back to the logged-in user's ID).
    825  *
    826820 * @return bool True if the toolbar should be showing for this user.
    827821 */
Note: See TracChangeset for help on using the changeset viewer.