Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/20/2023 02:30:11 AM (12 months ago)
Author:
imath
Message:

Start implementing parse_query() methods for directory components

First concerned commponents are: Activity, Blogs & Members.

  • Remove the notice used to force pretty permalinks
  • Use plain links to test parse_query() methods are rightly setting BuddyPress URI globals
  • Introduce some helper functions used during the BP Rewrites API parsing process :
    • bp_is_directory_homepage() is checking if a BP Directory is used as the site's homepage
    • bp_rewrites_get_custom_slug_rewrite_id() finds a Rewrite ID out of a custom slug.
    • bp_rewrites_get_member_data() returns the field to use to get the user by.
    • bp_reset_query() makes it possible to parse again a request in specific cases (eg: root profiles)

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/87
See #4954

File:
1 edited

Legend:

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

    r13449 r13455  
    956956}
    957957add_filter( 'wp_unique_post_slug', 'bp_core_set_unique_directory_page_slug', 10, 6 );
     958
     959/**
     960 * Checks if a component's directory is set as the site's homepage.
     961 *
     962 * @since 12.0.0
     963 *
     964 * @param string   $component The component ID.
     965 * @return boolean            True if a component's directory is set as the site's homepage.
     966 *                            False otherwise.
     967 */
     968function bp_is_directory_homepage( $component = '' ) {
     969    $is_directory_homepage = false;
     970    $is_page_on_front      = 'page' === get_option( 'show_on_front', 'posts' );
     971    $page_id_on_front      = get_option( 'page_on_front', 0 );
     972    $directory_pages       = bp_core_get_directory_pages();
     973
     974    if ( $is_page_on_front && isset( $directory_pages->{$component} ) && (int) $page_id_on_front === (int) $directory_pages->{$component}->id ) {
     975        $is_directory_homepage = true;
     976    }
     977
     978    return $is_directory_homepage;
     979}
    958980
    959981/**
Note: See TracChangeset for help on using the changeset viewer.