Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/01/2023 08:17:11 AM (3 years ago)
Author:
imath
Message:

BP Rewrites: introduce the bp_rewrites_get_url() function

Its role is to build every BuddyPress URL using the BP Rewrites API.

This commit also deprecates softly some key functions like bp_get_root_domain() to let us review (thanks to deprecated notices) all BuddyPress links during 12.0 development cycle and make them use the introduced bp_rewrites_get_url() function or a wrapper of it. Once all replacements achieved, we'll need to fully deprecate:

  • bp_get_root_domain()
  • bp_root_domain()
  • bp_core_get_root_domain()

Slug constants have also been completely deprecated as we will be able to customize every slugs from the future "URL" tab of the BuddyPress settings page.

The $bp->root_domain BuddyPress global has been deprecated in favor of $bp->root_url.

Finally, the Components $rewrite_ids properties are now in place and corresponding rewrite rules are successfully generated.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

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

    r13431 r13432  
    744744            $page_ids_sql     = implode( ',', wp_parse_id_list( $page_ids ) );
    745745            $page_stati_sql   = '\'' . implode( '\', \'', array_map( 'sanitize_key', bp_core_get_directory_pages_stati() ) ) . '\'';
    746             $page_names       = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_title FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status IN ({$page_stati_sql}) " );
     746            $page_names       = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_title, post_status FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status IN ({$page_stati_sql}) " );
    747747
    748748            foreach ( (array) $page_ids as $component_id => $page_id ) {
     
    765765                        }
    766766
    767                         $pages->{$component_id}->slug = implode( '/', array_reverse( (array) $slug ) );
     767                        $pages->{$component_id}->slug         = implode( '/', array_reverse( (array) $slug ) );
     768                        $pages->{$component_id}->custom_slugs = get_post_meta( $page_name->ID, '_bp_component_slugs', true );
     769                        $pages->{$component_id}->visibility   = $page_name->post_status;
    768770                    }
    769771
     
    11081110 *
    11091111 * @since 1.0.0
     1112 * @deprecated 12.0.0
    11101113 *
    11111114 * @return string The domain URL for the blog.
    11121115 */
    11131116function bp_core_get_root_domain() {
    1114 
    1115     $domain = get_home_url( bp_get_root_blog_id() );
     1117    _deprecated_function( __FUNCTION__, '12.0.0', 'bp_rewrites_get_root_url()' );
     1118
     1119    $domain = bp_rewrites_get_root_url();
    11161120
    11171121    /**
     
    11191123     *
    11201124     * @since 1.0.1
     1125     * @deprecated 12.0.0 Use {@see 'bp_rewrites_get_root_url'} instead.
    11211126     *
    11221127     * @param string $domain The domain URL for the blog.
    11231128     */
    1124     return apply_filters( 'bp_core_get_root_domain', $domain );
     1129    return apply_filters_deprecated( 'bp_core_get_root_domain', array( $domain ), '12.0.0', 'bp_rewrites_get_root_url' );
    11251130}
    11261131
Note: See TracChangeset for help on using the changeset viewer.