Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/18/2023 09:42:31 AM (13 months ago)
Author:
imath
Message:

BP Rewrites: start the migration process for the Groups component

  • Add rewrite tags & rules for the Groups directory type and the create URLs.
  • Introduce bp_get_group_url()/bp_group_url() & to retrieve/output a Groups single item URL using BP Rewrites.
  • Introduce bp_get_group_restricted_screens(), bp_get_group_extension_screens() & bp_get_group_screens() to get information about the Groups screens (in particular each screen rewrite ID). These functions will ease slug customizations from the BuddyPress URL settings tab.
  • Improve the Group creation process making sure it's using BP Rewrites to build URLs.
  • Perform easiest replacements for bp_get_group_permalink()/bp_group_permalink() & bp_get_groups_directory_permalink()/bp_groups_directory_permalink() in favor of bp_get_group_url()/bp_group_url() & bp_get_groups_directory_url()/bp_groups_directory_url()`.
  • Improve code formatting & properly escape single group URLs into templates.
  • Update impacted Unit Tests.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

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

    r13177 r13437  
    1818
    1919    // If we're not at domain.org/groups/create/ then return false.
    20     if ( !bp_is_groups_component() || !bp_is_current_action( 'create' ) )
     20    if ( ! bp_is_groups_component() || ! bp_is_current_action( 'create' ) ) {
    2121        return false;
    22 
    23     if ( !is_user_logged_in() )
     22    }
     23
     24    if ( ! is_user_logged_in() ) {
    2425        return false;
    25 
    26     if ( !bp_user_can_create_groups() ) {
     26    }
     27
     28    if ( ! bp_user_can_create_groups() ) {
    2729        bp_core_add_message( __( 'Sorry, you are not allowed to create groups.', 'buddypress' ), 'error' );
    28         bp_core_redirect( bp_get_groups_directory_permalink() );
     30        bp_core_redirect( bp_get_groups_directory_url() );
    2931    }
    3032
     
    199201            do_action( 'groups_group_create_complete', $bp->groups->new_group_id );
    200202
    201             bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     203            bp_core_redirect( bp_get_group_url( $bp->groups->current_group ) );
    202204        } else {
    203205            /**
     
    314316function groups_action_sort_creation_steps() {
    315317
    316     if ( !bp_is_groups_component() || !bp_is_current_action( 'create' ) )
     318    if ( ! bp_is_groups_component() || ! bp_is_current_action( 'create' ) ) {
    317319        return false;
     320    }
    318321
    319322    $bp = buddypress();
    320323
    321     if ( !is_array( $bp->groups->group_creation_steps ) )
     324    if ( ! is_array( $bp->groups->group_creation_steps ) ) {
    322325        return false;
     326    }
    323327
    324328    foreach ( (array) $bp->groups->group_creation_steps as $slug => $step ) {
    325         while ( !empty( $temp[$step['position']] ) )
     329        while ( ! empty( $temp[$step['position']] ) ) {
    326330            $step['position']++;
    327 
    328         $temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
     331        }
     332
     333        $temp[ $step['position'] ] = array(
     334            'rewrite_id' => $step['rewrite_id'],
     335            'name'       => $step['name'],
     336            'slug'       => $slug,
     337        );
    329338    }
    330339
    331340    // Sort the steps by their position key.
    332     ksort($temp);
    333     unset($bp->groups->group_creation_steps);
    334 
    335     foreach( (array) $temp as $position => $step )
    336         $bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
     341    ksort( $temp );
     342    unset( $bp->groups->group_creation_steps );
     343
     344    foreach( (array) $temp as $position => $step ) {
     345        $bp->groups->group_creation_steps[ $step['slug'] ] = array(
     346            'rewrite_id'   => $step['rewrite_id'],
     347            'default_slug' => $step['slug'],
     348            'name'         => $step['name'],
     349            'position'     => $position
     350        );
     351    }
    337352
    338353    /**
Note: See TracChangeset for help on using the changeset viewer.