Skip to:
Content

BuddyPress.org

Changeset 10755


Ignore:
Timestamp:
05/14/2016 04:59:12 AM (9 years ago)
Author:
boonebgorges
Message:

Introduce bp_core_get_directory_page_id().

This convenience function provides a way for developers to get the ID of a WP
page corresponding to a BuddyPress component.

Props garrett-eclipse.
Fixes #7025.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r10745 r10755  
    491491     */
    492492    return apply_filters( 'bp_core_get_directory_page_ids', $page_ids );
     493}
     494
     495/**
     496 * Get the page ID corresponding to a component directory.
     497 *
     498 * @since 2.6.0
     499 *
     500 * @param string $component The slug representing the component. Defaults to the current component.
     501 * @return int|bool The ID of the directory page associated with the component. False if none is found.
     502 */
     503function bp_core_get_directory_page_id( $component = null ) {
     504        if ( ! $component ) {
     505                $component = bp_current_component();
     506        }
     507
     508    $bp_pages = bp_core_get_directory_page_ids( 'all' );
     509
     510    $page_id = false;
     511    if ( $component && isset( $bp_pages[ $component ] ) ) {
     512        $page_id = (int) $bp_pages[ $component ];
     513        }
     514
     515        return $page_id;
    493516}
    494517
Note: See TracChangeset for help on using the changeset viewer.