Skip to:
Content

BuddyPress.org

Changeset 13436


Ignore:
Timestamp:
03/15/2023 08:16:46 AM (3 years ago)
Author:
imath
Message:

Make more BuddyPress generated links ready for BP Rewrites

  • Improve the Members component adding permastructs and custom rewrite

rules for registration and activation pages.

  • Improve the Blogs component adding custom rewrite rule to handle the

Blogs create page.

  • Make a huge progress about replacing all occurrences of

bp_get_root_domain() (45 replacements were performed).

  • Deprecate bp_groups_directory_permalink(),

bp_get_groups_directory_permalink(), bp_blogs_directory_permalink() &
bp_get_blogs_directory_permalink() and replace them with these new
functions: bp_groups_directory_url(), bp_get_groups_directory_url(),
bp_blogs_directory_url() & bp_get_blogs_directory_url().

  • Although bp_loggedin_user_domain() & bp_displayed_user_domain()

should also be deprecated, we're leaving them as aliases of the right
functions to use. Plugin authors shouldn't use them to build other links
than member's profile home url.

NB: these deprecations are required because these functions were used
to build BuddyPress URLs concatenating URL chunks. Once the BP Classic
plugin will be built we will adapt the code to remove these deprecation
notices.

Props r-a-y, johnjamesjacoby, boonebgorges

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

Location:
trunk
Files:
44 edited

Legend:

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

    r13395 r13436  
    32633263                $link = $activity_obj->primary_link;
    32643264        } else {
    3265                 if ( 'activity_comment' == $activity_obj->type ) {
    3266                         $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/#acomment-' . $activity_obj->id;
     3265                $path_chunks = array(
     3266                        'component_id'                 => 'activity',
     3267                        'single_item_action'           => 'p',
     3268                        'single_item_action_variables' => array( $activity_obj->id ),
     3269                );
     3270
     3271                if ( 'activity_comment' === $activity_obj->type ) {
     3272                        $path_chunks['single_item_action_variables'] = array( $activity_obj->item_id );
     3273
     3274                        $link = bp_rewrites_get_url( $path_chunks ) . '#acomment-' . $activity_obj->id;
    32673275                } else {
    3268                         $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/';
     3276                        $link = bp_rewrites_get_url( $path_chunks );
    32693277                }
    32703278        }
  • trunk/src/bp-activity/bp-activity-template.php

    r13433 r13436  
    8787         */
    8888        function bp_get_activity_directory_permalink() {
     89                $url = bp_rewrites_get_url(
     90                        array(
     91                                'component_id' => 'activity',
     92                        )
     93                );
    8994
    9095                /**
     
    95100                 * @param string $url Permalink url for the activity directory.
    96101                 */
    97                 return apply_filters( 'bp_get_activity_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) );
     102                return apply_filters( 'bp_get_activity_directory_permalink', $url );
    98103        }
    99104
     
    23932398         */
    23942399        function bp_get_activity_comment_delete_link() {
    2395                 $link = wp_nonce_url( trailingslashit( bp_get_activity_directory_permalink() . 'delete/' . bp_get_activity_comment_id() ) . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
     2400                $url  = bp_rewrites_get_url(
     2401                        array(
     2402                                'component_id'                 => 'activity',
     2403                                'single_item_action'           => 'delete',
     2404                                'single_item_action_variables' => array( bp_get_activity_comment_id() ),
     2405                        )
     2406                );
     2407                $link = wp_nonce_url( add_query_arg( 'cid', bp_get_activity_comment_id(), $url ), 'bp_activity_delete_link' );
    23962408
    23972409                /**
     
    29923004                }
    29933005
    2994                 $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activity_id );
     3006                $url = bp_rewrites_get_url(
     3007                        array(
     3008                                'component_id'                 => 'activity',
     3009                                'single_item_action'           => 'delete',
     3010                                'single_item_action_variables' => array( $activity_id ),
     3011                        )
     3012                );
    29953013
    29963014                // Determine if we're on a single activity page, and customize accordingly.
     
    38703888         */
    38713889        function bp_get_sitewide_activity_feed_link() {
     3890                $url  = bp_rewrites_get_url(
     3891                        array(
     3892                                'component_id'       => 'activity',
     3893                                'single_item_action' => 'feed',
     3894                        )
     3895                );
    38723896
    38733897                /**
     
    38763900                 * @since 1.0.0
    38773901                 *
    3878                  * @param string $value The feed link for sitewide activity.
    3879                  */
    3880                 return apply_filters( 'bp_get_sitewide_activity_feed_link', bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed/' );
     3902                 * @param string $url The feed link for sitewide activity.
     3903                 */
     3904                return apply_filters( 'bp_get_sitewide_activity_feed_link', $url );
    38813905        }
    38823906
  • trunk/src/bp-activity/classes/class-bp-activity-oembed-extension.php

    r13433 r13436  
    8686        protected function validate_url_to_item_id( $url ) {
    8787                if ( bp_core_enable_root_profiles() ) {
    88                         $domain = bp_get_root_domain();
     88                        $domain = bp_get_root_url();
    8989                } else {
    9090                        $domain = bp_get_members_directory_permalink();
     
    9696                }
    9797
    98                 // Check for activity slug.
    99                 if ( false === strpos( $url, '/' . bp_get_activity_slug() . '/' ) ) {
    100                         return false;
    101                 }
    102 
    103                 // Do more checks.
    104                 $url = trim( untrailingslashit( $url ) );
    105 
    106                 // Grab the activity ID.
    107                 $activity_id = (int) substr(
    108                         $url,
    109                         strrpos( $url, '/' ) + 1
    110                 );
     98                if ( ! bp_has_pretty_urls() ) {
     99                        $url_query = wp_parse_url( $url, PHP_URL_QUERY );
     100
     101                        if ( $url_query ) {
     102                                $query_vars = bp_parse_args( $url_query, array() );
     103
     104                                if ( isset( $query_vars['bp_member_action'] ) ) {
     105                                        $activity_id = (int) $query_vars['bp_member_action'];
     106                                }
     107                        }
     108
     109                } elseif ( false !== strpos( $url, '/' . bp_get_activity_slug() . '/' ) ) {
     110                        // Do more checks.
     111                        $url = trim( untrailingslashit( $url ) );
     112
     113                        // Grab the activity ID.
     114                        $activity_id = (int) substr(
     115                                $url,
     116                                strrpos( $url, '/' ) + 1
     117                        );
     118                }
    111119
    112120                if ( ! empty( $activity_id ) ) {
  • trunk/src/bp-activity/classes/class-bp-akismet.php

    r12694 r13436  
    192192         */
    193193        public function add_activity_spam_button() {
    194                 if ( !bp_activity_user_can_mark_spam() )
    195                         return;
     194                if ( ! bp_activity_user_can_mark_spam() ) {
     195                        return;
     196                }
    196197
    197198                // By default, only handle activity updates and activity comments.
    198                 if ( !in_array( bp_get_activity_type(), BP_Akismet::get_activity_types() ) )
    199                         return;
     199                if ( ! in_array( bp_get_activity_type(), BP_Akismet::get_activity_types(), true ) ) {
     200                        return;
     201                }
     202
     203                $spam_link = bp_rewrites_get_url(
     204                        array(
     205                                'component_id'                 => 'activity',
     206                                'single_item_action'           => 'spam',
     207                                'single_item_action_variables' => array( bp_get_activity_id() ),
     208                        )
     209                );
    200210
    201211                bp_button(
     
    205215                                'id'         => 'activity_make_spam_' . bp_get_activity_id(),
    206216                                'link_class' => 'bp-secondary-action spam-activity confirm button item-button',
    207                                 'link_href'  => wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/spam/' . bp_get_activity_id() . '/', 'bp_activity_akismet_spam_' . bp_get_activity_id() ),
     217                                'link_href'  => wp_nonce_url( $spam_link, 'bp_activity_akismet_spam_' . bp_get_activity_id() ),
    208218                                'link_text'  => __( 'Spam', 'buddypress' ),
    209219                                'wrapper'    => false,
     
    220230         */
    221231        public function add_activity_comment_spam_button() {
    222                 if ( !bp_activity_user_can_mark_spam() )
    223                         return;
     232                if ( ! bp_activity_user_can_mark_spam() ) {
     233                        return;
     234                }
    224235
    225236                // By default, only handle activity updates and activity comments.
    226237                $current_comment = bp_activity_current_comment();
    227                 if ( empty( $current_comment ) || !in_array( $current_comment->type, BP_Akismet::get_activity_types() ) )
    228                         return;
     238                if ( empty( $current_comment ) || ! in_array( $current_comment->type, BP_Akismet::get_activity_types(), true ) ) {
     239                        return;
     240                }
     241
     242                $spam_link = add_query_arg(
     243                        'cid',
     244                        bp_get_activity_comment_id(),
     245                        bp_rewrites_get_url(
     246                                array(
     247                                        'component_id'                 => 'activity',
     248                                        'single_item_action'           => 'spam',
     249                                        'single_item_action_variables' => array( bp_get_activity_comment_id() ),
     250                                )
     251                        )
     252                );
    229253
    230254                bp_button(
     
    234258                                'id'         => 'activity_make_spam_' . bp_get_activity_comment_id(),
    235259                                'link_class' => 'bp-secondary-action spam-activity-comment confirm',
    236                                 'link_href'  => wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/spam/' . bp_get_activity_comment_id() . '/?cid=' . bp_get_activity_comment_id(), 'bp_activity_akismet_spam_' . bp_get_activity_comment_id() ),
     260                                'link_href'  => wp_nonce_url( $spam_link, 'bp_activity_akismet_spam_' . bp_get_activity_comment_id() ),
    237261                                'link_text'  => __( 'Spam', 'buddypress' ),
    238262                                'wrapper'    => false,
  • trunk/src/bp-activity/screens/permalink.php

    r13433 r13436  
    1717function bp_activity_action_permalink_router() {
    1818        // Not viewing activity.
    19         if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) )
     19        if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) ) {
    2020                return false;
     21        }
    2122
    2223        // No activity to display.
    23         if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) )
     24        if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) ) {
    2425                return false;
     26        }
    2527
    2628        // Get the activity details.
     
    7880         */
    7981        if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) ) {
    80                 bp_core_redirect( bp_get_root_domain() );
     82                bp_core_redirect( bp_get_root_url() );
    8183        }
    8284
  • trunk/src/bp-blogs/bp-blogs-blocks.php

    r13108 r13436  
    3333        $classnames           = 'widget_bp_blogs_widget buddypress widget';
    3434        $wrapper_attributes   = get_block_wrapper_attributes( array( 'class' => $classnames ) );
    35         $blogs_directory_link = bp_get_blogs_directory_permalink();
     35        $blogs_directory_link = bp_get_blogs_directory_url();
    3636        $max_posts            = (int) $block_args['maxPosts'];
    3737        $no_posts             = __( 'Sorry, there were no posts found.', 'buddypress' );
  • trunk/src/bp-blogs/bp-blogs-filters.php

    r13405 r13436  
    3030 */
    3131function bp_blogs_creation_location( $url ) {
     32        $bp_url = bp_get_blogs_directory_url(
     33                array(
     34                        'create_single_item' => 1,
     35                )
     36        );
    3237
    3338        /**
     
    3641         * @since 1.6.0
    3742         *
    38          * @param string $permalink URL for the 'Create a new site' signup page.
    39          * @param string $url       The original URL (points to wp-signup.php by default).
     43         * @param string $bp_url URL for the 'Create a new site' signup page.
     44         * @param string $url    The original URL (points to wp-signup.php by default).
    4045         */
    41         return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_blogs_directory_permalink() . 'create' ), $url );
     46        return apply_filters( 'bp_blogs_creation_location', $bp_url, $url );
    4247}
    4348add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
  • trunk/src/bp-blogs/bp-blogs-template.php

    r13409 r13436  
    6868
    6969/**
    70  * Output blog directory permalink.
    71  *
    72  * @since 1.5.0
    73  *
    74  */
    75 function bp_blogs_directory_permalink() {
    76         echo esc_url( bp_get_blogs_directory_permalink() );
    77 }
    78         /**
    79          * Return blog directory permalink.
    80          *
    81          * @since 1.5.0
    82          *
    83          *
    84          * @return string The URL of the Blogs directory.
    85          */
    86         function bp_get_blogs_directory_permalink() {
    87 
    88                 /**
    89                  * Filters the blog directory permalink.
    90                  *
    91                  * @since 1.5.0
    92                  *
    93                  * @param string $value Permalink URL for the blog directory.
    94                  */
    95                 return apply_filters( 'bp_get_blogs_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) );
    96         }
     70 * Output Blogs directory's URL.
     71 *
     72 * @since 12.0.0
     73 */
     74function bp_blogs_directory_url() {
     75        echo esc_url( bp_get_blogs_directory_url() );
     76}
     77
     78/**
     79 * Returns the Blogs directory's URL.
     80 *
     81 * @since 12.0.0
     82 *
     83 * @param array $path_chunks {
     84 *     An array of arguments. Optional.
     85 *
     86 *     @type int $create_single_item `1` to get the Blogs create link.
     87 * }
     88 * @return string The URL built for the BP Rewrites URL parser.
     89 */
     90function bp_get_blogs_directory_url( $path_chunks = array() ) {
     91        $supported_chunks = array_fill_keys( array( 'create_single_item' ), true );
     92
     93        $path_chunks = bp_parse_args(
     94                array_intersect_key( $path_chunks, $supported_chunks ),
     95                array(
     96                        'component_id' => 'blogs'
     97                )
     98        );
     99
     100        $url = bp_rewrites_get_url( $path_chunks );
     101
     102        /**
     103         * Filters the Blogs directory's URL.
     104         *
     105         * @since 12.0.0
     106         *
     107         * @param string  $url      The Blogs directory's URL.
     108         * @param array   $path_chunks {
     109         *     An array of arguments. Optional.
     110         *
     111         *     @type int $create_single_item `1` to get the Blogs create link.
     112         * }
     113         */
     114        return apply_filters( 'bp_get_blogs_directory_url', $url, $path_chunks );
     115}
    97116
    98117/**
     
    474493                global $blogs_template;
    475494
    476                 if ( empty( $blogs_template->blog->domain ) )
    477                         $permalink = bp_get_root_domain() . $blogs_template->blog->path;
    478                 else {
     495                if ( ! empty( $blogs_template->blog->domain ) ) {
     496                        $permalink = get_site_url( $blogs_template->blog->blog_id );
     497
     498                } else {
    479499                        $protocol = 'http://';
    480                         if ( is_ssl() )
     500                        if ( is_ssl() ) {
    481501                                $protocol = 'https://';
     502                        }
    482503
    483504                        $permalink = $protocol . $blogs_template->blog->domain . $blogs_template->blog->path;
     
    13491370        }
    13501371
     1372        $url = bp_get_blogs_directory_url(
     1373                array(
     1374                        'create_single_item' => 1,
     1375                )
     1376        );
     1377
    13511378        /**
    13521379         * Filters "Create a Site" links for users viewing their own profiles.
     
    13541381         * @since 1.0.0
    13551382         *
    1356          * @param string $value HTML link for creating a site.
    1357          */
    1358         echo apply_filters( 'bp_create_blog_link', '<a href="' . trailingslashit( bp_get_blogs_directory_permalink() . 'create' ) . '">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
     1383         * @param string $url HTML link for creating a site.
     1384         */
     1385        echo apply_filters( 'bp_create_blog_link', '<a href="' . $url . '">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
    13591386}
    13601387
     
    14601487                }
    14611488
     1489                $url = bp_get_blogs_directory_url(
     1490                        array(
     1491                                'create_single_item' => 1,
     1492                        )
     1493                );
     1494
    14621495                $button_args = array(
    14631496                        'id'         => 'create_blog',
     
    14651498                        'link_text'  => __( 'Create a Site', 'buddypress' ),
    14661499                        'link_class' => 'blog-create no-ajax',
    1467                         'link_href'  => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
     1500                        'link_href'  => $url,
    14681501                        'wrapper'    => false,
    14691502                        'block_self' => false,
  • trunk/src/bp-blogs/classes/class-bp-blogs-component.php

    r13432 r13436  
    8282                        'has_directory'         => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site.
    8383                        'rewrite_ids'           => array(
    84                                 'directory'                    => 'blogs',
    85                                 'single_item_action'           => 'blogs_action',
    86                                 'single_item_action_variables' => 'blogs_action_variables',
     84                                'directory'          => 'blogs',
     85                                'create_single_item' => 'blog_create',
    8786                        ),
    8887                        'directory_title'       => isset( $bp->pages->blogs->title ) ? $bp->pages->blogs->title : $default_directory_title,
     
    312311                        // Create a Site.
    313312                        if ( bp_blog_signup_enabled() ) {
     313                                $url = bp_get_blogs_directory_url(
     314                                        array(
     315                                                'create_single_item' => 1,
     316                                        )
     317                                );
     318
    314319                                $wp_admin_nav[] = array(
    315320                                        'parent'   => 'my-account-' . $this->id,
    316321                                        'id'       => 'my-account-' . $this->id . '-create',
    317322                                        'title'    => __( 'Create a Site', 'buddypress' ),
    318                                         'href'     => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
     323                                        'href'     => $url,
    319324                                        'position' => 99
    320325                                );
     
    371376
    372377                parent::setup_cache_groups();
     378        }
     379
     380        /**
     381         * Add the Blog Create rewrite tags.
     382         *
     383         * @since 12.0.0
     384         *
     385         * @param array $rewrite_tags Optional. See BP_Component::add_rewrite_tags() for
     386         *                            description.
     387         */
     388        public function add_rewrite_tags( $rewrite_tags = array() ) {
     389                $rewrite_tags = array(
     390                        'create_single_item' => '([1]{1,})',
     391                );
     392
     393                parent::add_rewrite_tags( $rewrite_tags );
     394        }
     395
     396        /**
     397         * Add the Registration and Activation rewrite rules.
     398         *
     399         * @since 12.0.0
     400         *
     401         * @param array $rewrite_rules Optional. See BP_Component::add_rewrite_rules() for
     402         *                             description.
     403         */
     404        public function add_rewrite_rules( $rewrite_rules = array() ) {
     405                $create_slug = bp_rewrites_get_slug( 'blogs', 'blog_create', 'create' );
     406
     407                $rewrite_rules = array(
     408                        'create_single_item' => array(
     409                                'regex' => $this->root_slug . '/' . $create_slug . '/?$',
     410                                'order' => 50,
     411                                'query' => 'index.php?' . $this->rewrite_ids['directory'] . '=1&' . $this->rewrite_ids['create_single_item'] . '=1',
     412                        ),
     413                );
     414
     415                parent::add_rewrite_rules( $rewrite_rules );
    373416        }
    374417
  • trunk/src/bp-blogs/classes/class-bp-blogs-recent-posts-widget.php

    r13108 r13436  
    5050
    5151                if ( ! empty( $instance['link_title'] ) ) {
    52                         $title = '<a href="' . bp_get_blogs_directory_permalink() . '">' . esc_html( $title ) . '</a>';
     52                        $title = '<a href="' . bp_get_blogs_directory_url() . '">' . esc_html( $title ) . '</a>';
    5353                }
    5454
  • trunk/src/bp-core/bp-core-avatars.php

    r13312 r13436  
    201201 *                                   provided, the function will infer it: for users, by getting the
    202202 *                                   user's email from the database, for groups/blogs, by concatenating
    203  *                                   "{$item_id}-{$object}@{bp_get_root_domain()}". The user query adds
     203 *                                   "{$item_id}-{$object}@{bp_get_domain()}". The user query adds
    204204 *                                   overhead, so it's recommended that wrapper functions provide a
    205205 *                                   value for 'email' when querying user IDs. Default: false.
     
    642642                                $params['email'] = bp_core_get_user_email( $params['item_id'] );
    643643                        } elseif ( 'group' == $params['object'] || 'blog' == $params['object'] ) {
    644                                 $params['email'] = $params['item_id'] . '-' . $params['object'] . '@' . bp_get_root_domain();
     644                                $params['email'] = $params['item_id'] . '-' . $params['object'] . '@' . bp_get_domain();
    645645                        }
    646646                }
  • trunk/src/bp-core/bp-core-blocks.php

    r13144 r13436  
    235235                        $content .= sprintf(
    236236                                '<p class="bp-login-widget-pwd-link"><a href="%1$s">%2$s</a></p>',
    237                                 esc_url( wp_lostpassword_url( bp_get_root_domain() ) ),
     237                                esc_url( wp_lostpassword_url( bp_get_root_url() ) ),
    238238                                esc_html__( 'Lost your password?', 'buddypress' )
    239239                        );
  • trunk/src/bp-core/bp-core-buddybar.php

    r13108 r13436  
    780780                        } else {
    781781                                $message     = __( 'You do not have access to this page.', 'buddypress' );
    782                                 $redirect_to = bp_get_root_domain();
     782                                $redirect_to = bp_get_root_url();
    783783                        }
    784784
  • trunk/src/bp-core/bp-core-catchuri.php

    r13433 r13436  
    632632 *                            logging in. Default: the URL originally requested.
    633633 *     @type string $root     The root URL of the site, used in case of error or mode 1 redirects.
    634  *                            Default: the value of {@link bp_get_root_domain()}.
     634 *                            Default: the value of {@link bp_get_root_url()}.
    635635 *     @type string $message  An error message to display to the user on the log-in page.
    636636 *                            Default: "You must log in to access the page you requested."
     
    647647                'mode'     => 2,                    // 1 = $root, 2 = wp-login.php.
    648648                'redirect' => $redirect_url,        // the URL you get redirected to when a user successfully logs in.
    649                 'root'     => bp_get_root_domain(), // the landing page you get redirected to when a user doesn't have access.
     649                'root'     => bp_get_root_url(),    // the landing page you get redirected to when a user doesn't have access.
    650650                'message'  => __( 'You must log in to access the page you requested.', 'buddypress' )
    651651        );
     
    908908                 */
    909909                if ( false !== $front_page_component && bp_is_current_component( $front_page_component ) && ! bp_current_action() && ! bp_get_current_member_type() ) {
    910                         $bp->canonical_stack['canonical_url'] = trailingslashit( bp_get_root_domain() );
     910                        $bp->canonical_stack['canonical_url'] = bp_get_root_url();
    911911
    912912                // Except when the front page is set to the registration page
  • trunk/src/bp-core/bp-core-filters.php

    r13433 r13436  
    384384         * @param string $value URL to redirect to.
    385385         */
    386         return apply_filters( 'bp_core_login_redirect_to', bp_get_root_domain() );
     386        return apply_filters( 'bp_core_login_redirect_to', bp_get_root_url() );
    387387}
    388388add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
     
    12061206function bp_email_set_default_tokens( $tokens, $property_name, $transform, $email ) {
    12071207        $tokens['site.admin-email'] = bp_get_option( 'admin_email' );
    1208         $tokens['site.url']         = bp_get_root_domain();
     1208        $tokens['site.url']         = bp_get_root_url();
    12091209        $tokens['email.subject']    = $email->get_subject();
    12101210
     
    12361236
    12371237                        if ( bp_is_active( 'settings' ) && empty( $tokens['unsubscribe'] ) ) {
    1238                                 $tokens['unsubscribe'] = esc_url( sprintf(
    1239                                         '%s%s/notifications/',
    1240                                         bp_members_get_user_url( $user_obj->ID ),
    1241                                         bp_get_settings_slug()
    1242                                 ) );
     1238                                $tokens['unsubscribe'] = esc_url(
     1239                                        bp_members_get_user_url(
     1240                                                $user_obj->ID,
     1241                                                array(
     1242                                                        'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     1243                                                        'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_notifications', 'notifications' ),
     1244                                                )
     1245                                        )
     1246                                );
    12431247                        }
    12441248                }
  • trunk/src/bp-core/bp-core-functions.php

    r13433 r13436  
    11161116function bp_core_get_root_domain() {
    11171117        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_rewrites_get_root_url()' );
    1118 
    11191118        $domain = bp_rewrites_get_root_url();
    11201119
     
    11451144        // have a valid URL.
    11461145        if ( empty( $location ) ) {
    1147                 $location = bp_get_root_domain();
     1146                $location = bp_get_root_url();
    11481147        }
    11491148
     
    25302529
    25312530        if ( empty( $_POST['search-terms'] ) ) {
    2532                 bp_core_redirect( bp_get_root_domain() );
     2531                bp_core_redirect( bp_get_root_url() );
    25332532                return;
    25342533        }
     
    25742573
    25752574                if ( empty( $slug ) && 'posts' != $search_which ) {
    2576                         bp_core_redirect( bp_get_root_domain() );
     2575                        bp_core_redirect( bp_get_root_url() );
    25772576                        return;
    25782577                }
     
    43684367        } else {
    43694368                if ( bp_is_active( 'settings' ) ) {
    4370                         $redirect_to = sprintf(
    4371                                 '%s%s/notifications/',
    4372                                 bp_members_get_user_url( $raw_user_id ),
    4373                                 bp_get_settings_slug()
     4369                        $redirect_to = bp_members_get_user_url(
     4370                                $raw_user_id,
     4371                                array(
     4372                                        'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     4373                                        'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_notifications', 'notifications' ),
     4374                                )
    43744375                        );
    43754376                } else {
  • trunk/src/bp-core/bp-core-rewrites.php

    r13433 r13436  
    172172                                $create_slug = 'create';
    173173                                if ( 'groups' === $component->id ) {
    174                                         $create_slug = bp_rewrites_get_slug( 'groups', 'bp_group_create', 'create' );
     174                                        $create_slug = bp_rewrites_get_slug( 'groups', 'group_create', 'create' );
     175                                } elseif ( 'blogs' === $component->id ) {
     176                                        $create_slug = bp_rewrites_get_slug( 'blogs', 'blog_create', 'create' );
    175177                                }
    176178
  • trunk/src/bp-core/bp-core-template.php

    r13432 r13436  
    518518 */
    519519function bp_search_form_action() {
     520        $url = bp_rewrites_get_url(
     521                array(
     522                        'component_id' => bp_get_search_slug(),
     523                )
     524        );
    520525
    521526        /**
     
    524529         * @since 1.0.0
    525530         *
    526          * @param string $value Search form action url.
    527          */
    528         return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
     531         * @param string $url Search form action url.
     532         */
     533        return apply_filters( 'bp_search_form_action', $url );
    529534}
    530535
     
    13971402         */
    13981403        return apply_filters( 'bp_action_variable', $action_variable, $position );
     1404}
     1405
     1406/**
     1407 * Returns the BP root blog's domain name.
     1408 *
     1409 * @since 12.0.0
     1410 *
     1411 * @return string The BP root blog's domain name.
     1412 */
     1413function bp_get_domain() {
     1414        return wp_parse_url( bp_get_root_url(), PHP_URL_HOST );
    13991415}
    14001416
  • trunk/src/bp-core/deprecated/12.0.php

    r13433 r13436  
    242242        return apply_filters_deprecated( 'bp_core_get_user_domain', array( $domain, $user_id, $user_nicename, $user_login), '12.0.0', 'bp_members_get_user_url' );
    243243}
     244
     245/**
     246 * Get the link for the logged-in user's profile.
     247 *
     248 * @since 1.0.0
     249 * @deprecated 12.0.0
     250 *
     251 * @return string
     252 */
     253function bp_get_loggedin_user_link() {
     254        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_loggedin_user_url()' );
     255        $url = bp_loggedin_user_url();
     256
     257        /**
     258         * Filters the link for the logged-in user's profile.
     259         *
     260         * @since 1.2.4
     261         * @deprecated 12.0.0
     262         *
     263         * @param string $url Link for the logged-in user's profile.
     264         */
     265        return apply_filters_deprecated( 'bp_get_loggedin_user_link', array( $url ), '12.0.0', 'bp_loggedin_user_url' );
     266}
     267
     268/**
     269 * Get the link for the displayed user's profile.
     270 *
     271 * @since 1.0.0
     272 * @deprecated 12.0.0
     273 *
     274 * @return string
     275 */
     276function bp_get_displayed_user_link() {
     277        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_displayed_user_url()' );
     278        $url = bp_displayed_user_url();
     279
     280        /**
     281         * Filters the link for the displayed user's profile.
     282         *
     283         * @since 1.2.4
     284         * @deprecated 12.0.0
     285         *
     286         * @param string $url Link for the displayed user's profile.
     287         */
     288        return apply_filters_deprecated( 'bp_get_displayed_user_link', array( $url ), '12.0.0', 'bp_displayed_user_url' );
     289}
     290
     291/**
     292 * Alias of {@link bp_displayed_user_domain()}.
     293 *
     294 * @deprecated 12.0.0
     295 */
     296function bp_user_link() {
     297        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_displayed_user_url()' );
     298        bp_displayed_user_url();
     299}
     300
     301/**
     302 * Output blog directory permalink.
     303 *
     304 * @since 1.5.0
     305 * @deprecated 12.0.0
     306 */
     307function bp_blogs_directory_permalink() {
     308        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_blogs_directory_url()' );
     309        bp_blogs_directory_url();
     310}
     311
     312/**
     313 * Return blog directory permalink.
     314 *
     315 * @since 1.5.0
     316 * @deprecated 12.0.0
     317 *
     318 * @return string The URL of the Blogs directory.
     319 */
     320function bp_get_blogs_directory_permalink() {
     321        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_get_blogs_directory_url()' );
     322        $url = bp_get_blogs_directory_url();
     323
     324        /**
     325         * Filters the blog directory permalink.
     326         *
     327         * @since 1.5.0
     328         * @deprecated 12.0.0
     329         *
     330         * @param string $url Permalink URL for the blog directory.
     331         */
     332        return apply_filters_deprecated( 'bp_get_blogs_directory_permalink', array( $url ), '12.0.0', 'bp_get_blogs_directory_url' );
     333}
  • trunk/src/bp-groups/bp-groups-notifications.php

    r13433 r13436  
    341341                array(
    342342                        'single_item_component' => bp_rewrites_get_slug( 'members', 'member_groups', bp_get_groups_slug() ),
     343                        'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_groups_invites', 'invites' ),
    343344                )
    344345        );
     
    359360        }
    360361
    361         $args         = array(
     362        $args = array(
    362363                'tokens' => array(
    363364                        'group'          => $group,
     
    367368                        'inviter.url'    => bp_members_get_user_url( $inviter_user_id ),
    368369                        'inviter.id'     => $inviter_user_id,
    369                         'invites.url'    => esc_url( $invited_link . '/invites/' ),
     370                        'invites.url'    => esc_url( $invited_link ),
    370371                        'invite.message' => $invite_message,
    371372                        'unsubscribe'    => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
  • trunk/src/bp-groups/bp-groups-template.php

    r13433 r13436  
    9696
    9797/**
     98 * Output Groups directory's URL.
     99 *
     100 * @since 12.0.0
     101 */
     102function bp_groups_directory_url() {
     103        echo esc_url( bp_get_groups_directory_url() );
     104}
     105
     106/**
     107 * Returns the Groups directory's URL.
     108 *
     109 * @since 12.0.0
     110 *
     111 * @param array $path_chunks {
     112 *     An array of arguments. Optional.
     113 *
     114 *     @type int   $create_single_item `1` to get the create a group URL.
     115 *     @type array $directory_type     The group type slug.
     116 * }
     117 * @return string The URL built for the BP Rewrites URL parser.
     118 */
     119function bp_get_groups_directory_url( $path_chunks = array() ) {
     120        $supported_chunks = array_fill_keys( array( 'create_single_item', 'directory_type' ), true );
     121
     122        $path_chunks = bp_parse_args(
     123                array_intersect_key( $path_chunks, $supported_chunks ),
     124                array(
     125                        'component_id' => 'groups'
     126                )
     127        );
     128
     129        $url = bp_rewrites_get_url( $path_chunks );
     130
     131        /**
     132         * Filters the Groups directory's URL.
     133         *
     134         * @since 12.0.0
     135         *
     136         * @param string  $url The Groups directory's URL.
     137         * @param array   $path_chunks {
     138         *     An array of arguments. Optional.
     139         *
     140         *      @type int   $create_single_item `1` to get the create a group URL.
     141         *      @type array $directory_type     The group type slug.
     142         * }
     143         */
     144        return apply_filters( 'bp_get_groups_directory_url', $url, $path_chunks );
     145}
     146
     147/**
    98148 * Output group directory permalink.
    99149 *
    100150 * @since 1.5.0
     151 * @deprecated 12.0.0
    101152 */
    102153function bp_groups_directory_permalink() {
    103         echo esc_url( bp_get_groups_directory_permalink() );
     154        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_groups_directory_url()' );
     155        bp_groups_directory_url();
    104156}
    105157        /**
     
    107159         *
    108160         * @since 1.5.0
     161         * @deprecated 12.0.0
    109162         *
    110163         * @return string
    111164         */
    112165        function bp_get_groups_directory_permalink() {
     166                /*
     167                 * This function is used at many places and we need to review all this
     168                 * places during the 12.0 development cycle. Using BP Rewrites means we
     169                 * cannot concatenate URL chunks to build our URL anymore. We now need
     170                 * to use `bp_get_groups_directory_url( $array )` and make sure to use
     171                 * the right arguments inside this `$array`. Morevover as this function
     172                 * is also used to build a single group URL, we need to create a new
     173                 * function to create single group URLs using BP Rewrites.
     174                 *
     175                 * @todo Once every link reviewed, we'll be able to remove this check
     176                 *       and let PHPUnit tell us the one we forgot, eventually!
     177                 */
     178                if ( ! buddypress()->is_phpunit_running ) {
     179                        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_get_groups_directory_url()' );
     180                }
     181
     182                $url = bp_get_groups_directory_url();
    113183
    114184                /**
     
    116186                 *
    117187                 * @since 1.5.0
    118                  *
    119                  * @param string $value Permalink for the group directory.
    120                  */
    121                 return apply_filters( 'bp_get_groups_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) );
     188                 * @deprecated 12.0.0
     189                 *
     190                 * @param string $url Permalink for the group directory.
     191                 */
     192                return apply_filters_deprecated( 'bp_get_groups_directory_permalink', array( $url ), '12.0.0', 'bp_get_groups_directory_url' );
    122193        }
    123194
  • trunk/src/bp-members/bp-members-filters.php

    r13433 r13436  
    239239                        sprintf(
    240240                                '<a href="%1$s">%2$s</a>',
    241                                 esc_url( wp_login_url( bp_get_root_domain() ) ),
     241                                esc_url( wp_login_url( bp_get_root_url() ) ),
    242242                                esc_html__( 'log in', 'buddypress' )
    243243                        )
     
    311311                                sprintf(
    312312                                        '<a href="%1$s">%2$s</a>',
    313                                         esc_url( wp_login_url( bp_get_root_domain() ) ),
     313                                        esc_url( wp_login_url( bp_get_root_url() ) ),
    314314                                        esc_html__( 'log in', 'buddypress' )
    315315                                ),
    316316                                sprintf(
    317317                                        '<a href="%1$s">%2$s</a>',
    318                                         esc_url( wp_lostpassword_url( bp_get_root_domain() ) ),
     318                                        esc_url( wp_lostpassword_url( bp_get_root_url() ) ),
    319319                                        esc_html__( 'reset it', 'buddypress' )
    320320                                )
  • trunk/src/bp-members/bp-members-functions.php

    r13433 r13436  
    145145 *
    146146 * @param integer $user_id  The user ID.
    147  * @param array   $action {
     147 * @param array   $path_chunks {
    148148 *     An array of arguments. Optional.
    149149 *
     
    178178         * Filters the domain for the passed user.
    179179         *
    180          * @since 1.0.1
    181          * @deprecated 12.0.0
    182          *
    183          * @param string $domain        Domain for the passed user.
    184          * @param int    $user_id       ID of the passed user.
    185          * @param string $user_nicename User nicename of the passed user.
    186          * @param string $user_login    User login of the passed user.
    187          */
    188         $url = apply_filters_deprecated( 'bp_core_get_user_domain', array( $url, $user_id, false, false ), '12.0.0', 'bp_members_get_user_url' );
    189 
    190         /**
    191          * Filters the domain for the passed user.
    192          *
    193180         * @since 12.0.0
    194181         *
     
    327314                }
    328315        }
    329 
    330         /**
    331          * Filters the username based on originally provided user ID.
    332          *
    333          * @since 1.0.1
    334          * @deprecated 12.0.0
    335          *
    336          * @param string $slug Username determined by user ID.
    337          */
    338         $slug = apply_filters_deprecated( 'bp_core_get_username', array( $slug ), '12.0.0', 'bp_members_get_user_slug' );
    339316
    340317        /**
     
    25472524        if ( $is_site_creation ) {
    25482525                if ( bp_is_active( 'blogs' ) ) {
    2549                         $redirect_to = trailingslashit( bp_get_blogs_directory_permalink() . 'create' );
     2526                        $url = bp_get_blogs_directory_url(
     2527                                array(
     2528                                        'create_single_item' => 1,
     2529                                )
     2530                        );
     2531
     2532                        $redirect_to = trailingslashit( $url );
    25502533                } else {
    25512534                        // Perform no redirect in this case.
  • trunk/src/bp-members/bp-members-template.php

    r13433 r13436  
    141141         */
    142142        function bp_get_members_directory_permalink() {
     143                $url = bp_rewrites_get_url(
     144                        array(
     145                                'component_id' => 'members',
     146                        )
     147                );
    143148
    144149                /**
     
    147152                 * @since 1.5.0
    148153                 *
    149                  * @param string $value Members directory permalink.
    150                  */
    151                 return apply_filters( 'bp_get_members_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
     154                 * @param string $url Members directory permalink.
     155                 */
     156                return apply_filters( 'bp_get_members_directory_permalink', $url );
    152157        }
    153158
     
    186191                }
    187192
     193                $url = bp_rewrites_get_url(
     194                        array(
     195                                'component_id'   => 'members',
     196                                'directory_type' => $type->directory_slug,
     197                        )
     198                );
     199
    188200                /**
    189201                 * Filters the member type directory permalink.
     
    191203                 * @since 2.5.0
    192204                 *
    193                  * @param string $value       Member type directory permalink.
     205                 * @param string $url         Member type directory permalink.
    194206                 * @param object $type        Member type object.
    195207                 * @param string $member_type Member type name, as passed to the function.
    196208                 */
    197                 return apply_filters( 'bp_get_member_type_directory_permalink', trailingslashit( bp_get_members_directory_permalink() . bp_get_members_member_type_base() . '/' . $type->directory_slug ), $type, $member_type );
     209                return apply_filters( 'bp_get_member_type_directory_permalink', $url, $type, $member_type );
    198210        }
    199211
     
    14581470
    14591471        // Always add a log out list item to the end of the navigation.
    1460         $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( bp_get_root_domain() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
     1472        $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( bp_get_root_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    14611473
    14621474        echo apply_filters( 'bp_logout_nav_link', $logout_link );
     
    18521864
    18531865/**
    1854  * Output the link for the logged-in user's profile.
    1855  *
    1856  * @since 1.2.4
    1857  */
    1858 function bp_loggedin_user_link() {
    1859         echo esc_url( bp_get_loggedin_user_link() );
    1860 }
    1861         /**
    1862          * Get the link for the logged-in user's profile.
    1863          *
    1864          * @since 1.0.0
    1865          *
    1866          * @return string
    1867          */
    1868         function bp_get_loggedin_user_link() {
    1869 
    1870                 /**
    1871                  * Filters the link for the logged-in user's profile.
    1872                  *
    1873                  * @since 1.2.4
    1874                  *
    1875                  * @param string $value Link for the logged-in user's profile.
    1876                  */
    1877                 return apply_filters( 'bp_get_loggedin_user_link', bp_loggedin_user_domain() );
    1878         }
    1879 
    1880 /**
    1881  * Output the link for the displayed user's profile.
    1882  *
    1883  * @since 1.2.4
    1884  */
    1885 function bp_displayed_user_link() {
    1886         echo esc_url( bp_get_displayed_user_link() );
    1887 }
    1888         /**
    1889          * Get the link for the displayed user's profile.
    1890          *
    1891          * @since 1.0.0
    1892          *
    1893          * @return string
    1894          */
    1895         function bp_get_displayed_user_link() {
    1896 
    1897                 /**
    1898                  * Filters the link for the displayed user's profile.
    1899                  *
    1900                  * @since 1.2.4
    1901                  *
    1902                  * @param string $value Link for the displayed user's profile.
    1903                  */
    1904                 return apply_filters( 'bp_get_displayed_user_link', bp_displayed_user_domain() );
    1905         }
    1906 
    1907         /**
    1908          * Alias of {@link bp_displayed_user_domain()}.
    1909          *
    1910          * @deprecated
    1911          */
    1912         function bp_user_link() {
    1913                 bp_displayed_user_domain();
    1914         }
    1915 
    1916 /**
    19171866 * Alias of {@link bp_displayed_user_id()}.
    19181867 *
     
    19241873
    19251874/**
     1875 * Output the link for the displayed user's profile.
     1876 *
     1877 * @since 1.2.4
     1878 */
     1879function bp_displayed_user_link() {
     1880        echo esc_url( bp_displayed_user_url() );
     1881}
     1882
     1883/**
     1884 * Builds the logged-in user's profile URL.
     1885 *
     1886 * @since 12.0.0
     1887 *
     1888 * @param array $path_chunks {
     1889 *     An array of arguments. Optional.
     1890 *
     1891 *     @type string $single_item_component        The component slug the action is relative to.
     1892 *     @type string $single_item_action           The slug of the action to perform.
     1893 *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     1894 * }
     1895 * @return string The logged-in user's profile URL.
     1896 */
     1897function bp_displayed_user_url( $path_chunks = array() ) {
     1898        $bp  = buddypress();
     1899        $url = '';
     1900
     1901        if ( isset( $bp->displayed_user->domain ) ) {
     1902                $url = $bp->displayed_user->domain;
     1903        }
     1904
     1905        if ( $path_chunks ) {
     1906                $url = bp_members_get_user_url( bp_displayed_user_id(), $path_chunks );
     1907        }
     1908
     1909        /**
     1910         * Filter here to edit the displayed user's profile URL.
     1911         *
     1912         * @since 12.0.0
     1913         *
     1914         * @param string $url         The displayed user's profile URL.
     1915         * @param array  $path_chunks {
     1916         *     An array of arguments. Optional.
     1917         *
     1918         *     @type string $single_item_component        The component slug the action is relative to.
     1919         *     @type string $single_item_action           The slug of the action to perform.
     1920         *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     1921         * }
     1922         */
     1923        return apply_filters( 'bp_displayed_user_url', $url, $path_chunks );
     1924}
     1925
     1926/**
    19261927 * Generate the link for the displayed user's profile.
    19271928 *
    19281929 * @since 1.0.0
    1929  *
     1930 * @since 12.0.0 This function is now an alias of `bp_displayed_user_url()`.
     1931 *               You should only use it to get the "home" URL of the displayed
     1932 *               user's profile page. If you need to build an URL to reach another
     1933 *               page, we strongly advise you to use `bp_displayed_user_url()`.
     1934 *
     1935 * @todo Deprecating this function would be safer.
    19301936 * @return string
    19311937 */
    19321938function bp_displayed_user_domain() {
    1933         $bp = buddypress();
     1939        $url = bp_displayed_user_url();
    19341940
    19351941        /**
     
    19381944         * @since 1.0.0
    19391945         *
    1940          * @param string $value Generated link for the displayed user's profile.
    1941          */
    1942         return apply_filters( 'bp_displayed_user_domain', isset( $bp->displayed_user->domain ) ? $bp->displayed_user->domain : '' );
     1946         * @param string $url Generated link for the displayed user's profile.
     1947         */
     1948        return apply_filters( 'bp_displayed_user_domain',$url );
     1949}
     1950
     1951/**
     1952 * Output the link for the logged-in user's profile.
     1953 *
     1954 * @since 1.2.4
     1955 */
     1956function bp_loggedin_user_link() {
     1957        echo esc_url( bp_loggedin_user_url() );
     1958}
     1959
     1960/**
     1961 * Builds the logged-in user's profile URL.
     1962 *
     1963 * @since 12.0.0
     1964 *
     1965 * @param array $path_chunks {
     1966 *     An array of arguments. Optional.
     1967 *
     1968 *     @type string $single_item_component        The component slug the action is relative to.
     1969 *     @type string $single_item_action           The slug of the action to perform.
     1970 *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     1971 * }
     1972 * @return string The logged-in user's profile URL.
     1973 */
     1974function bp_loggedin_user_url( $path_chunks = array() ) {
     1975        $bp  = buddypress();
     1976        $url = '';
     1977
     1978        if ( isset( $bp->loggedin_user->domain ) ) {
     1979                $url = $bp->loggedin_user->domain;
     1980        }
     1981
     1982        if ( $path_chunks ) {
     1983                $url = bp_members_get_user_url( bp_loggedin_user_id(), $path_chunks );
     1984        }
     1985
     1986        /**
     1987         * Filter here to edit the logged-in user's profile URL.
     1988         *
     1989         * @since 12.0.0
     1990         *
     1991         * @param string $url         The logged-in user's profile URL.
     1992         * @param array  $path_chunks {
     1993         *     An array of arguments. Optional.
     1994         *
     1995         *     @type string $single_item_component        The component slug the action is relative to.
     1996         *     @type string $single_item_action           The slug of the action to perform.
     1997         *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     1998         * }
     1999         */
     2000        return apply_filters( 'bp_loggedin_user_url', $url, $path_chunks );
    19432001}
    19442002
     
    19472005 *
    19482006 * @since 1.0.0
    1949  *
     2007 * @since 12.0.0 This function is now an alias of `bp_loggedin_user_url()`.
     2008 *               You should only use it to get the "home" URL of the logged-in
     2009 *               user's profile page. If you need to build an URL to reach another
     2010 *               page, we strongly advise you to use `bp_loggedin_user_url()`.
     2011 *
     2012 * @todo Deprecating this function would be safer.
    19502013 * @return string
    19512014 */
    19522015function bp_loggedin_user_domain() {
    1953         $bp = buddypress();
     2016        $url = bp_loggedin_user_url();
    19542017
    19552018        /**
     
    19582021         * @since 1.0.0
    19592022         *
    1960          * @param string $value Generated link for the logged-in user's profile.
    1961          */
    1962         return apply_filters( 'bp_loggedin_user_domain', isset( $bp->loggedin_user->domain ) ? $bp->loggedin_user->domain : '' );
     2023         * @param string $url Generated link for the logged-in user's profile.
     2024         */
     2025        return apply_filters( 'bp_loggedin_user_domain', $url );
    19632026}
    19642027
     
    23472410        function bp_get_signup_page() {
    23482411                if ( bp_has_custom_signup_page() ) {
    2349                         $page = trailingslashit( bp_get_root_domain() . '/' . bp_get_signup_slug() );
     2412                        $page = bp_rewrites_get_url(
     2413                                array(
     2414                                        'component_id'    => 'members',
     2415                                        'member_register' => 1,
     2416                                )
     2417                        );
     2418
    23502419                } else {
    2351                         $page = bp_get_root_domain() . '/wp-signup.php';
     2420                        $page = trailingslashit( bp_get_root_url() ) . 'wp-signup.php';
    23522421                }
    23532422
     
    23962465        function bp_get_activation_page() {
    23972466                if ( bp_has_custom_activation_page() ) {
    2398                         $page = trailingslashit( bp_get_root_domain() . '/' . bp_get_activate_slug() );
     2467                        $page = bp_rewrites_get_url(
     2468                                array(
     2469                                        'component_id'    => 'members',
     2470                                        'member_activate' => 1,
     2471                                )
     2472                        );
     2473
    23992474                } else {
    2400                         $page = trailingslashit( bp_get_root_domain() ) . 'wp-activate.php';
     2475                        $page = trailingslashit( bp_get_root_url() ) . 'wp-activate.php';
    24012476                }
    24022477
     
    35663641                if ( 0 === $user_id ) {
    35673642                        $user_id = bp_loggedin_user_id();
    3568                         $domain  = bp_loggedin_user_domain();
    3569                 } else {
    3570                         $domain = bp_members_get_user_url( (int) $user_id );
    3571                 }
    3572 
    3573                 $retval = trailingslashit( $domain . bp_get_members_invitations_slug() . '/list-invites' );
     3643                }
     3644
     3645                $retval = bp_members_get_user_url(
     3646                        (int) $user_id,
     3647                        array(
     3648                                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_invitations', bp_get_members_invitations_slug() ),
     3649                                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_invitations_list_invites', 'list-invites' ),
     3650                        )
     3651                );
    35743652
    35753653                /**
     
    36053683                if ( 0 === $user_id ) {
    36063684                        $user_id = bp_loggedin_user_id();
    3607                         $domain  = bp_loggedin_user_domain();
    3608                 } else {
    3609                         $domain = bp_members_get_user_url( (int) $user_id );
    3610                 }
    3611 
    3612                 $retval = trailingslashit( $domain . bp_get_members_invitations_slug() . '/send-invites' );
     3685                }
     3686
     3687                $retval = bp_members_get_user_url(
     3688                        (int) $user_id,
     3689                        array(
     3690                                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_invitations', bp_get_members_invitations_slug() ),
     3691                                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_invitations_send_invites', 'send-invites' ),
     3692                        )
     3693                );
    36133694
    36143695                /**
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r13433 r13436  
    215215        public function setup_additional_globals() {
    216216                $bp = buddypress();
     217
     218                // Set-up Extra permastructs for the register and activate pages.
     219                $this->register_permastruct = bp_get_signup_slug() . '/%' . $this->rewrite_ids['member_register'] . '%';
     220                $this->activate_permastruct = bp_get_activate_slug() . '/%' . $this->rewrite_ids['member_activate'] . '%';
    217221
    218222                /** Logged in user ***************************************************
     
    784788
    785789        /**
     790         * Add the Registration and Activation rewrite tags.
     791         *
     792         * @since 12.0.0
     793         *
     794         * @param array $rewrite_tags Optional. See BP_Component::add_rewrite_tags() for
     795         *                            description.
     796         */
     797        public function add_rewrite_tags( $rewrite_tags = array() ) {
     798                $rewrite_tags = array(
     799                        'member_register'     => '([1]{1,})',
     800                        'member_activate'     => '([1]{1,})',
     801                        'member_activate_key' => '([^/]+)',
     802                );
     803
     804                parent::add_rewrite_tags( $rewrite_tags );
     805        }
     806
     807        /**
     808         * Add the Registration and Activation rewrite rules.
     809         *
     810         * @since 12.0.0
     811         *
     812         * @param array $rewrite_rules Optional. See BP_Component::add_rewrite_rules() for
     813         *                             description.
     814         */
     815        public function add_rewrite_rules( $rewrite_rules = array() ) {
     816                $rewrite_rules = array(
     817                        'directory_type'      => array(
     818                                'regex' => $this->root_slug . '/' . bp_get_members_member_type_base() . '/([^/]+)/?$',
     819                                'order' => 50,
     820                                'query' => 'index.php?' . $this->rewrite_ids['directory'] . '=1&' . $this->rewrite_ids['directory_type'] . '=$matches[1]',
     821                        ),
     822                        'member_activate'     => array(
     823                                'regex' => bp_get_activate_slug(),
     824                                'order' => 40,
     825                                'query' => 'index.php?' . $this->rewrite_ids['member_activate'] . '=1',
     826                        ),
     827                        'member_activate_key' => array(
     828                                'regex' => bp_get_activate_slug() . '/([^/]+)/?$',
     829                                'order' => 30,
     830                                'query' => 'index.php?' . $this->rewrite_ids['member_activate'] . '=1&' . $this->rewrite_ids['member_activate_key'] . '=$matches[1]',
     831                        ),
     832                        'member_register'     => array(
     833                                'regex' => bp_get_signup_slug(),
     834                                'order' => 20,
     835                                'query' => 'index.php?' . $this->rewrite_ids['member_register'] . '=1',
     836                        ),
     837                );
     838
     839                parent::add_rewrite_rules( $rewrite_rules );
     840        }
     841
     842        /**
     843         * Add the Registration and Activation permastructs.
     844         *
     845         * @since 12.0.0
     846         *
     847         * @param array $permastructs Optional. See BP_Component::add_permastructs() for
     848         *                            description.
     849         */
     850        public function add_permastructs( $permastructs = array() ) {
     851                $permastructs = array(
     852                        // Register permastruct.
     853                        $this->rewrite_ids['member_register'] => array(
     854                                'permastruct' => $this->register_permastruct,
     855                                'args'        => array(),
     856                        ),
     857                        // Activate permastruct.
     858                        $this->rewrite_ids['member_activate'] => array(
     859                                'permastruct' => $this->activate_permastruct,
     860                                'args'        => array(),
     861                        ),
     862                );
     863
     864                parent::add_permastructs( $permastructs );
     865        }
     866
     867        /**
    786868         * Init the BP REST API.
    787869         *
  • trunk/src/bp-members/screens/activate.php

    r13125 r13436  
    2727                $redirect_to = bp_is_component_front_page( 'activate' )
    2828                        ? bp_get_members_directory_permalink()
    29                         : bp_get_root_domain();
     29                        : bp_get_root_url();
    3030
    3131                // Trailing slash it, as we expect these URL's to be.
  • trunk/src/bp-members/screens/register.php

    r13223 r13436  
    2828                $redirect_to = bp_is_component_front_page( 'register' )
    2929                        ? bp_get_members_directory_permalink()
    30                         : bp_get_root_domain();
     30                        : bp_get_root_url();
    3131
    3232                /**
     
    158158                                // This situation doesn't naturally occur so bounce to website root.
    159159                        } else {
    160                                 bp_core_redirect( bp_get_root_domain() );
     160                                bp_core_redirect( bp_get_root_url() );
    161161                        }
    162162                }
  • trunk/src/bp-messages/bp-messages-template.php

    r13433 r13436  
    338338                }
    339339
    340                 $domain = bp_members_get_user_url( $user_id );
     340                $url = bp_members_get_user_url(
     341                        $user_id,
     342                        array(
     343                                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     344                                'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_messages_view', 'view' ),
     345                                'single_item_action_variables' => array( $thread_id ),
     346                        )
     347                );
    341348
    342349                /**
     
    347354                 * @since 2.9.0 Added the `$user_id` parameter.
    348355                 *
    349                  * @param string $value     Permalink of a particular thread.
     356                 * @param string $url       Permalink of a particular thread.
    350357                 * @param int    $thread_id ID of the thread.
    351358                 * @param int    $user_id   ID of the user.
    352359                 */
    353                 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( $domain . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id, $user_id );
     360                return apply_filters( 'bp_get_message_thread_view_link', $url, $thread_id, $user_id );
    354361        }
    355362
     
    383390                }
    384391
    385                 $domain = bp_members_get_user_url( $user_id );
     392                $current_action_slug         = bp_current_action();
     393                $current_action_rewrite_id   = 'member_messages_' . $current_action_slug;
     394                $action_variable_delete_slug = bp_rewrites_get_slug( 'members', $current_action_rewrite_id . '_delete', 'delete' );
     395
     396                $url = bp_members_get_user_url(
     397                        $user_id,
     398                        array(
     399                                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     400                                'single_item_action'           => bp_rewrites_get_slug( 'members', $current_action_rewrite_id, $current_action_slug ),
     401                                'single_item_action_variables' => array( $action_variable_delete_slug, $messages_template->thread->thread_id ),
     402                        )
     403                );
    386404
    387405                /**
     
    390408                 * @since 1.0.0
    391409                 *
    392                  * @param string $value   URL for deleting the current thread.
     410                 * @param string $url   URL for deleting the current thread.
    393411                 * @param int    $user_id ID of the user relative to whom the link should be generated.
    394412                 */
    395                 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ), $user_id );
     413                return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $url, 'messages_delete_thread' ), $user_id );
    396414        }
    397415
     
    435453                }
    436454
    437                 $domain = bp_members_get_user_url( $user_id );
     455                $current_action_slug         = bp_current_action();
     456                $current_action_rewrite_id   = 'member_messages_' . $current_action_slug;
     457                $action_variable_unread_slug = bp_rewrites_get_slug( 'members', $current_action_rewrite_id . '_unread', 'unread' );
    438458
    439459                // Base unread URL.
    440                 $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
     460                $url = bp_members_get_user_url(
     461                        $user_id,
     462                        array(
     463                                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     464                                'single_item_action'           => bp_rewrites_get_slug( 'members', $current_action_rewrite_id, $current_action_slug ),
     465                                'single_item_action_variables' => array( $action_variable_unread_slug ),
     466                        )
     467                );
    441468
    442469                // Add the args to the URL.
     
    497524                }
    498525
    499                 $domain = bp_members_get_user_url( $user_id );
     526                $current_action_slug         = bp_current_action();
     527                $current_action_rewrite_id   = 'member_messages_' . $current_action_slug;
     528                $action_variable_read_slug = bp_rewrites_get_slug( 'members', $current_action_rewrite_id . '_read', 'read' );
    500529
    501530                // Base read URL.
    502                 $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
     531                $url = bp_members_get_user_url(
     532                        $user_id,
     533                        array(
     534                                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     535                                'single_item_action'           => bp_rewrites_get_slug( 'members', $current_action_rewrite_id, $current_action_slug ),
     536                                'single_item_action_variables' => array( $action_variable_read_slug ),
     537                        )
     538                );
    503539
    504540                // Add the args to the URL.
  • trunk/src/bp-notifications/bp-notifications-template.php

    r13433 r13436  
    6161                if ( 0 === $user_id ) {
    6262                        $user_id = bp_loggedin_user_id();
    63                         $domain  = bp_loggedin_user_domain();
    64                 } else {
    65                         $domain = bp_members_get_user_url( (int) $user_id );
    6663                }
    6764
    68                 $retval = trailingslashit( $domain . bp_get_notifications_slug() );
     65                $retval = bp_members_get_user_url(
     66                        $user_id,
     67                        array(
     68                                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_notifications', bp_get_notifications_slug() ),
     69                        )
     70                );
    6971
    7072                /**
     
    102104                if ( 0 === $user_id ) {
    103105                        $user_id = bp_loggedin_user_id();
    104                         $domain  = bp_loggedin_user_domain();
    105                 } else {
    106                         $domain = bp_members_get_user_url( (int) $user_id );
    107106                }
    108107
    109                 $retval = trailingslashit( $domain . bp_get_notifications_slug() . '/unread' );
     108                $retval = bp_members_get_user_url(
     109                        $user_id,
     110                        array(
     111                                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_notifications', bp_get_notifications_slug() ),
     112                                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_notifications_unread', 'unread' ),
     113                        )
     114                );
    110115
    111116                /**
     
    142147                if ( 0 === $user_id ) {
    143148                        $user_id = bp_loggedin_user_id();
    144                         $domain  = bp_loggedin_user_domain();
    145                 } else {
    146                         $domain = bp_members_get_user_url( (int) $user_id );
    147149                }
    148150
    149                 $retval = trailingslashit( $domain . bp_get_notifications_slug() . '/read' );
     151                $retval = bp_members_get_user_url(
     152                        $user_id,
     153                        array(
     154                                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_notifications', bp_get_notifications_slug() ),
     155                                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_notifications_read', 'read' ),
     156                        )
     157                );
    150158
    151159                /**
  • trunk/src/bp-settings/actions/delete-account.php

    r13090 r13436  
    5959
    6060                // Redirect to the root domain.
    61                 bp_core_redirect( bp_get_root_domain() );
     61                bp_core_redirect( bp_get_root_url() );
    6262        }
    6363}
  • trunk/src/bp-templates/bp-legacy/buddypress/members/activate.php

    r12595 r13436  
    4848                                        <?php
    4949                                        /* translators: %s: login url */
    50                                         printf( __( 'Your account was activated successfully! You can now <a href="%s">log in</a> with the username and password you provided when you signed up.', 'buddypress' ), wp_login_url( bp_get_root_domain() ) );
     50                                        printf( __( 'Your account was activated successfully! You can now <a href="%s">log in</a> with the username and password you provided when you signed up.', 'buddypress' ), wp_login_url( bp_get_root_url() ) );
    5151                                        ?>
    5252                                </p>
  • trunk/src/bp-templates/bp-nouveau/buddypress/members/activate.php

    r12220 r13436  
    2727                        printf(
    2828                                '<p><a href="%1$s">%2$s</a></p>',
    29                                 esc_url( wp_login_url( bp_get_root_domain() ) ),
     29                                esc_url( wp_login_url( bp_get_root_url() ) ),
    3030                                esc_html__( 'Log In', 'buddypress' )
    3131                        );
  • trunk/src/bp-templates/bp-nouveau/includes/activity/template-tags.php

    r13213 r13436  
    553553                        }
    554554
     555                        $spam_link = bp_rewrites_get_url(
     556                                array(
     557                                        'component_id'                 => 'activity',
     558                                        'single_item_action'           => 'spam',
     559                                        'single_item_action_variables' => array( bp_get_activity_id() ),
     560                                )
     561                        );
     562
    555563                        $buttons['activity_spam']['button_attr'][ $data_element ] = wp_nonce_url(
    556                                 bp_get_root_domain() . '/' . bp_nouveau_get_component_slug( 'activity' ) . '/spam/' . $activity_id . '/',
     564                                bp_rewrites_get_url(
     565                                        array(
     566                                                'component_id'                 => 'activity',
     567                                                'single_item_action'           => 'spam',
     568                                                'single_item_action_variables' => array( $activity_id ),
     569                                        )
     570                                ),
    557571                                'bp_activity_akismet_spam_' . $activity_id
    558572                        );
     
    882896
    883897                        $buttons['activity_comment_spam']['button_attr'][ $data_element ] = wp_nonce_url(
    884                                 bp_get_root_domain() . '/' . bp_nouveau_get_component_slug( 'activity' ) . '/spam/' . $activity_comment_id . '/?cid=' . $activity_comment_id,
     898                                add_query_arg(
     899                                        'cid',
     900                                        $activity_comment_id,
     901                                        bp_rewrites_get_url(
     902                                                array(
     903                                                        'component_id'                 => 'activity',
     904                                                        'single_item_action'           => 'spam',
     905                                                        'single_item_action_variables' => array( $activity_comment_id ),
     906                                                )
     907                                        )
     908                                ),
    885909                                'bp_activity_akismet_spam_' . $activity_comment_id
    886910                        );
  • trunk/src/bp-templates/bp-nouveau/includes/blogs/functions.php

    r13303 r13436  
    2020                'slug'      => 'all', // slug is used because BP_Core_Nav requires it, but it's the scope
    2121                'li_class'  => array( 'selected' ),
    22                 'link'      => bp_get_root_domain() . '/' . bp_get_blogs_root_slug(),
     22                'link'      => bp_get_blogs_directory_url(),
    2323                'text'      => __( 'All Sites', 'buddypress' ),
    2424                'count'     => bp_get_total_blog_count(),
     
    4444                // If the user can create blogs, add the create nav
    4545                if ( bp_blog_signup_enabled() ) {
     46                        $url = bp_get_blogs_directory_url(
     47                                array(
     48                                        'create_single_item' => 1,
     49                                )
     50                        );
     51
    4652                        $nav_items['create'] = array(
    4753                                'component' => 'blogs',
    4854                                'slug'      => 'create', // slug is used because BP_Core_Nav requires it, but it's the scope
    4955                                'li_class'  => array( 'no-ajax', 'site-create', 'create-button' ),
    50                                 'link'      => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
     56                                'link'      => $url,
    5157                                'text'      => __( 'Create a Site', 'buddypress' ),
    5258                                'count'     => false,
  • trunk/tests/phpunit/includes/testcase.php

    r13433 r13436  
    296296        public function go_to_root() {
    297297                $blog_1_url = get_blog_option( 1, 'home' );
    298                 $this->go_to( str_replace( $blog_1_url, '', trailingslashit( bp_get_root_domain() ) ) );
     298                $this->go_to( str_replace( $blog_1_url, '', trailingslashit( bp_get_root_url() ) ) );
    299299        }
    300300
  • trunk/tests/phpunit/testcases/activity/class.BP_Activity_Activity.php

    r13396 r13436  
    330330                // bp_activity_new_comment() doesn't allow date_recorded
    331331                $a3 = bp_activity_add( array(
    332                         'action'            => sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_get_loggedin_user_link() ) ,
     332                        'action'            => sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_loggedin_user_url() ) ,
    333333                        'content'           => 'Candy is good',
    334334                        'component'         => buddypress()->activity->id,
  • trunk/tests/phpunit/testcases/activity/notifications.php

    r13433 r13436  
    389389         */
    390390        public function test_bp_activity_comment_add_notification() {
     391                $this->set_permalink_structure( '/%postname%/' );
    391392                $a = self::factory()->activity->create( array(
    392393                        'user_id' => $this->u1,
  • trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageId.php

    r12895 r13436  
    77 */
    88class BP_Tests_Core_BpCoreGetDirectoryPageId extends BP_UnitTestCase {
     9        protected $permalink_structure = '';
     10
     11        public function set_up() {
     12                parent::set_up();
     13                $this->permalink_structure = get_option( 'permalink_structure', '' );
     14        }
     15
     16        public function tear_down() {
     17                parent::tear_down();
     18                $this->set_permalink_structure( $this->permalink_structure );
     19        }
     20
    921        public function test_should_fall_back_on_current_component() {
     22                $this->set_permalink_structure( '/%postname%/' );
    1023                $this->go_to( bp_get_activity_directory_permalink() );
    1124
     
    1730
    1831        public function test_should_accept_component_override() {
     32                $this->set_permalink_structure( '/%postname%/' );
    1933                $this->go_to( bp_get_activity_directory_permalink() );
    2034
  • trunk/tests/phpunit/testcases/core/nav/backCompat.php

    r13314 r13436  
    1010        protected $bp_nav;
    1111        protected $bp_options_nav;
     12        protected $permalink_structure = '';
    1213
    1314        public function set_up() {
     
    1516                $this->bp_nav = buddypress()->bp_nav;
    1617                $this->bp_options_nav = buddypress()->bp_options_nav;
     18                $this->permalink_structure = get_option( 'permalink_structure', '' );
    1719        }
    1820
     
    2022                buddypress()->bp_nav = $this->bp_nav;
    2123                buddypress()->bp_options_nav = $this->bp_options_nav;
     24                $this->set_permalink_structure( $this->permalink_structure );
    2225                parent::tear_down();
    2326        }
     
    4649         */
    4750        protected function set_up_group() {
     51                $this->set_permalink_structure( '/%postname%/' );
    4852                $g = self::factory()->group->create( array(
    4953                        'slug' => 'testgroup',
  • trunk/tests/phpunit/testcases/core/nav/bpCoreMaybeHookNewSubnavScreenFunction.php

    r13433 r13436  
    207207                $found = bp_core_maybe_hook_new_subnav_screen_function( $subnav_item );
    208208                $this->assertSame( 'failure', $found['status'] );
    209                 $this->assertSame( bp_get_root_domain(), $found['redirect_args']['root'] );
     209                $this->assertSame( bp_get_root_url(), $found['redirect_args']['root'] );
    210210
    211211                // Clean up
  • trunk/tests/phpunit/testcases/core/nav/bpCoreNewNavItem.php

    r13433 r13436  
    7474                $old_current_user = get_current_user_id();
    7575                $this->set_current_user( $u );
     76                $this->set_permalink_structure( '/%postname%/' );
    7677
    7778                $group = groups_get_group( $g );
  • trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php

    r13195 r13436  
    88 */
    99class BP_Tests_Group_Extension_TestCases extends BP_UnitTestCase {
     10        protected $permalink_structure = '';
     11
     12        public function set_up() {
     13                parent::set_up();
     14                $this->permalink_structure = get_option( 'permalink_structure', '' );
     15        }
     16
     17        public function tear_down() {
     18                parent::tear_down();
     19                $this->set_permalink_structure( $this->permalink_structure );
     20        }
     21
    1022        public function test_parse_legacy_properties() {
    1123                $class_name = 'BPTest_Group_Extension_Parse_Legacy_Properties';
     
    222234        public function test_enable_nav_item_true() {
    223235                $old_options_nav = buddypress()->bp_options_nav;
     236                $this->set_permalink_structure( '/%postname%/' );
    224237
    225238                $g = self::factory()->group->create();
     
    244257         */
    245258        public function test_enable_nav_item_false() {
     259                $this->set_permalink_structure( '/%postname%/' );
    246260                $old_options_nav = buddypress()->bp_options_nav;
    247261
     
    267281         */
    268282        public function test_visibility_private() {
     283                $this->set_permalink_structure( '/%postname%/' );
    269284                $old_options_nav = buddypress()->bp_options_nav;
    270285                $old_current_user = get_current_user_id();
     
    311326         */
    312327        public function test_visibility_public() {
     328                $this->set_permalink_structure( '/%postname%/' );
    313329                $old_options_nav = buddypress()->bp_options_nav;
    314330                $old_current_user = get_current_user_id();
     
    348364         */
    349365        public function test_user_can_visit_inferred_from_enable_nav_item() {
     366                $this->set_permalink_structure( '/%postname%/' );
    350367                $old_current_user = get_current_user_id();
    351368
     
    373390         */
    374391        public function test_user_can_visit_explicit_for_logged_out_user() {
     392                $this->set_permalink_structure( '/%postname%/' );
    375393                $old_current_user = get_current_user_id();
    376394                $this->set_current_user( 0 );
     
    413431         */
    414432        public function test_user_can_visit_explicit_for_logged_in_user() {
     433                $this->set_permalink_structure( '/%postname%/' );
    415434                $g = self::factory()->group->create( array(
    416435                        'status' => 'public',
     
    455474         */
    456475        public function test_user_can_visit_explicit_for_group_member() {
     476                $this->set_permalink_structure( '/%postname%/' );
    457477                $g = self::factory()->group->create( array(
    458478                        'status' => 'public',
     
    499519         */
    500520        public function test_user_can_visit_explicit_for_group_mod() {
     521                $this->set_permalink_structure( '/%postname%/' );
    501522                $g = self::factory()->group->create( array(
    502523                        'status' => 'public',
     
    545566         */
    546567        public function test_user_can_visit_explicit_for_group_admin() {
     568                $this->set_permalink_structure( '/%postname%/' );
    547569                $g = self::factory()->group->create( array(
    548570                        'status' => 'public',
     
    591613         */
    592614        public function test_user_can_see_nav_item_implied() {
     615                $this->set_permalink_structure( '/%postname%/' );
    593616                $g = self::factory()->group->create( array(
    594617                        'status' => 'public',
     
    632655         */
    633656        public function test_user_can_see_nav_item_explicit_for_logged_out_user() {
     657                $this->set_permalink_structure( '/%postname%/' );
    634658                $g = self::factory()->group->create( array(
    635659                        'status' => 'public',
     
    673697         */
    674698        public function test_user_can_see_nav_item_explicit_for_logged_in_user() {
     699                $this->set_permalink_structure( '/%postname%/' );
    675700                $g = self::factory()->group->create( array(
    676701                        'status' => 'public',
     
    715740         */
    716741        public function test_user_can_see_nav_item_explicit_for_group_member() {
     742                $this->set_permalink_structure( '/%postname%/' );
    717743                $g = self::factory()->group->create( array(
    718744                        'status' => 'public',
     
    759785         */
    760786        public function test_user_can_see_nav_item_explicit_for_group_mod() {
     787                $this->set_permalink_structure( '/%postname%/' );
    761788                $g = self::factory()->group->create( array(
    762789                        'status' => 'public',
     
    805832         */
    806833        public function test_user_can_see_nav_item_explicit_for_group_admin() {
     834                $this->set_permalink_structure( '/%postname%/' );
    807835                $g = self::factory()->group->create( array(
    808836                        'status' => 'public',
     
    851879         */
    852880        public function test_widget_on_group_home_page() {
     881                $this->set_permalink_structure( '/%postname%/' );
    853882                $g = self::factory()->group->create( array(
    854883                        'status' => 'public',
     
    872901         */
    873902        public function test_widget_on_group_members_page() {
     903                $this->set_permalink_structure( '/%postname%/' );
    874904                $g = self::factory()->group->create( array(
    875905                        'status' => 'public',
     
    893923         */
    894924        public function test_adding_multiple_extension_classes() {
     925                $this->set_permalink_structure( '/%postname%/' );
    895926                $old_options_nav = buddypress()->bp_options_nav;
    896927
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php

    r13314 r13436  
    77        static public $user_ids;
    88        static public $group_ids;
     9        protected $permalink_structure = '';
     10
     11        public function set_up() {
     12                parent::set_up();
     13                $this->permalink_structure = get_option( 'permalink_structure', '' );
     14        }
     15
     16        public function tear_down() {
     17                parent::tear_down();
     18                $this->set_permalink_structure( $this->permalink_structure );
     19        }
    920
    1021        public static function wpSetUpBeforeClass( $factory ) {
     
    161172         */
    162173        public function test_bp_groups_user_can_send_invites() {
     174                $this->set_permalink_structure( '/%postname%/' );
    163175                $u_nonmembers = self::factory()->user->create();
    164176                $u_members    = self::factory()->user->create();
  • trunk/tests/phpunit/testcases/members/template/bpGetMemberTypeDirectoryPermalink.php

    r13314 r13436  
    66 */
    77class BP_Tests_Members_Template_BpGetMemberTypeDirectoryPermalink extends BP_UnitTestCase {
     8        protected $permalink_structure = '';
     9
    810        public function set_up() {
    911                parent::set_up();
    1012
    1113                buddypress()->members->types = array();
     14                $this->permalink_structure = get_option( 'permalink_structure', '' );
     15        }
     16
     17        public function tear_down() {
     18                parent::tear_down();
     19
     20                $this->set_permalink_structure( $this->permalink_structure );
    1221        }
    1322
     
    1625         */
    1726        public function test_should_default_to_current_member_type() {
     27                $this->set_permalink_structure( '/%postname%/' );
     28
    1829                bp_register_member_type( 'foo', array(
    1930                        'has_directory' => true,
     
    3142         */
    3243        public function test_member_type_param_should_override_current_member_type() {
     44                $this->set_permalink_structure( '/%postname%/' );
     45
    3346                bp_register_member_type( 'foo', array(
    3447                        'has_directory' => true,
     
    7184         */
    7285        public function test_successful_format() {
     86                $this->set_permalink_structure( '/%postname%/' );
     87
    7388                bp_register_member_type( 'foo', array(
    7489                        'has_directory' => true,
Note: See TracChangeset for help on using the changeset viewer.