Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (13 months ago)
Author:
imath
Message:

Make BP_Core_Nav generate "BP Rewrites ready" navigation links

  • Remove all components $parent_url attributes when setting sub nav items.
  • Only use the bp_core_create_nav_link() $link attribute argument & the bp_core_create_subnav_link() $parent_url attribute argument if specified to preserve backward compatibility.
  • Migrates the Community search feature so that it uses BP Rewrites.
  • Perform some bp_loggedin_user_domain() in favor of bp_loggedin_user_url().
  • Update some PHPUnit tests.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-template.php

    r13437 r13441  
    12741274
    12751275    if ( $slug ) {
    1276         $supported_chunks = array_fill_keys( array( 'single_item_component', 'single_item_action', 'single_item_action_variables' ), true );
     1276        $supported_chunks = array_fill_keys( array( 'single_item_action', 'single_item_action_variables' ), true );
    12771277        $path_chunks      = bp_parse_args(
    12781278            array_intersect_key( $path_chunks, $supported_chunks ),
     
    33413341        }
    33423342
     3343        $views = bp_get_group_screens( 'manage' );
     3344        if ( isset( $views[ $page ]['rewrite_id'] ) ) {
     3345            $page = bp_rewrites_get_slug( 'groups', $views[ $page ]['rewrite_id'], $page );
     3346        }
     3347
     3348        $url = bp_get_group_url(
     3349            $group,
     3350            array(
     3351                'single_item_action'           => bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ),
     3352                'single_item_action_variables' => $page,
     3353            )
     3354        );
     3355
    33433356        /**
    33443357         * Filters the 'action' attribute for a group admin form.
     
    33483361         * @since 10.0.0 Added the `$page` parameter.
    33493362         *
    3350          * @param string          $value Action attribute for a group admin form.
     3363         * @param string          $url  Action attribute for a group admin form.
    33513364         * @param BP_Groups_Group $group The group object.
    33523365         * @param int|string|bool $page  Page slug.
    33533366         */
    3354         return apply_filters( 'bp_group_admin_form_action', trailingslashit( bp_get_group_permalink( $group ) . 'admin/' . $page ), $group, $page );
     3367        return apply_filters( 'bp_group_admin_form_action', $url, $group, $page );
    33553368    }
    33563369
     
    35263539        }
    35273540
    3528         $user_domain = bp_loggedin_user_domain();
     3541        $groups_slug = bp_get_groups_slug();
     3542        $path_chunks = array(
     3543            'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug ),
     3544            'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites', 'invites' ),
     3545            'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites_accept', 'accept' ), $group->id ),
     3546        );
     3547
    35293548        if ( bp_is_user() ) {
    3530             $user_domain = bp_displayed_user_domain();
    3531         }
     3549            $user_domain = bp_displayed_user_url( $path_chunks );
     3550        } else {
     3551            $user_domain = bp_loggedin_user_url( $path_chunks );
     3552        }
     3553
     3554        $url = wp_nonce_url( $user_domain, 'groups_accept_invite' );
    35323555
    35333556        /**
     
    35373560         * @since 2.5.0 Added the `$group` parameter.
    35383561         *
    3539          * @param string $value URL for accepting an invitation to a group.
     3562         * @param string $url  URL for accepting an invitation to a group.
    35403563         * @param object $group Group object.
    35413564         */
    3542         return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( trailingslashit( $user_domain . bp_get_groups_slug() . '/invites/accept/' . $group->id ), 'groups_accept_invite' ), $group );
     3565        return apply_filters( 'bp_get_group_accept_invite_link', $url, $group );
    35433566    }
    35443567
     
    35673590        }
    35683591
    3569         $user_domain = bp_loggedin_user_domain();
     3592        $groups_slug = bp_get_groups_slug();
     3593        $path_chunks = array(
     3594            'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug ),
     3595            'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites', 'invites' ),
     3596            'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites_reject', 'reject' ), $group->id ),
     3597        );
     3598
    35703599        if ( bp_is_user() ) {
    3571             $user_domain = bp_displayed_user_domain();
    3572         }
     3600            $user_domain = bp_displayed_user_url( $path_chunks );
     3601        } else {
     3602            $user_domain = bp_loggedin_user_url( $path_chunks );
     3603        }
     3604
     3605        $url = wp_nonce_url( $user_domain, 'groups_reject_invite' );
    35733606
    35743607        /**
     
    35783611         * @since 2.5.0 Added the `$group` parameter.
    35793612         *
    3580          * @param string $value URL for rejecting an invitation to a group.
     3613         * @param string $url  URL for rejecting an invitation to a group.
    35813614         * @param object $group Group object.
    35823615         */
    3583         return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( trailingslashit( $user_domain . bp_get_groups_slug() . '/invites/reject/' . $group->id ), 'groups_reject_invite' ), $group );
     3616        return apply_filters( 'bp_get_group_reject_invite_link', $url, $group );
    35843617    }
    35853618
Note: See TracChangeset for help on using the changeset viewer.