Changeset 13449 for trunk/src/bp-groups/bp-groups-template.php
- Timestamp:
- 04/08/2023 06:31:46 AM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r13446 r13449 146 146 147 147 /** 148 * Output group directory permalink. 149 * 150 * @since 1.5.0 151 * @deprecated 12.0.0 152 */ 153 function bp_groups_directory_permalink() { 154 _deprecated_function( __FUNCTION__, '12.0.0', 'bp_groups_directory_url()' ); 155 bp_groups_directory_url(); 156 } 157 /** 158 * Return group directory permalink. 159 * 160 * @since 1.5.0 161 * @deprecated 12.0.0 162 * 163 * @return string 164 */ 165 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(); 183 184 /** 185 * Filters the group directory permalink. 186 * 187 * @since 1.5.0 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' ); 193 } 148 * Returns a group create URL accoding to requested path chunks. 149 * 150 * @since 12.0.0 151 * 152 * @param array $chunks array A list of create action variables. 153 * @return string The group create URL. 154 */ 155 function bp_groups_get_create_url( $action_variables = array() ) { 156 $path_chunks = array(); 157 158 if ( is_array( $action_variables ) && $action_variables ) { 159 $path_chunks = bp_groups_get_path_chunks( $action_variables, 'create' ); 160 } else { 161 $path_chunks = array( 162 'create_single_item' => 1, 163 ); 164 } 165 166 return bp_get_groups_directory_url( $path_chunks ); 167 } 194 168 195 169 /** … … 227 201 } 228 202 203 $url = bp_get_groups_directory_url( 204 array( 205 'directory_type' => $type->directory_slug, 206 ) 207 ); 208 229 209 /** 230 210 * Filters the group type directory permalink. … … 232 212 * @since 2.7.0 233 213 * 234 * @param string $ valueGroup type directory permalink.214 * @param string $url Group type directory permalink. 235 215 * @param object $type Group type object. 236 216 * @param string $member_type Group type name, as passed to the function. 237 217 */ 238 return apply_filters( 'bp_get_group_type_directory_permalink', trailingslashit( bp_get_groups_directory_permalink() . bp_get_groups_group_type_base() . '/' . $type->directory_slug ), $type, $group_type );218 return apply_filters( 'bp_get_group_type_directory_permalink', $url, $type, $group_type ); 239 219 } 240 220 … … 1274 1254 $slug = groups_get_slug( $group ); 1275 1255 1276 if ( $group instanceof BP_Groups_Group ) {1256 if ( $group instanceof BP_Groups_Group || ( is_object( $group ) && isset( $group->id, $group->name, $group->slug ) ) ) { 1277 1257 $group_id = (int) $group->id; 1278 1258 } else { … … 3974 3954 'link_text' => __( 'Create a Group', 'buddypress' ), 3975 3955 'link_class' => 'group-create no-ajax', 3976 'link_href' => bp_get_groups_directory_url( 3977 array( 3978 'create_single_item' => 1, 3979 ) 3980 ), 3956 'link_href' => bp_groups_get_create_url(), 3981 3957 'wrapper' => false, 3982 3958 'block_self' => false, … … 5069 5045 5070 5046 if ( $is_enabled && isset( $create_steps[ $create_step ]['rewrite_id'], $create_steps[ $create_step ]['default_slug'] ) ) { 5071 $create_step_slug = bp_rewrites_get_slug( 'groups', 'bp_group_create_step', 'step' ); 5072 $step_slug = bp_rewrites_get_slug( 'groups', $create_steps[ $create_step ]['rewrite_id'], $create_steps[ $create_step ]['default_slug'] ); 5073 $url = bp_get_groups_directory_url( 5074 array( 5075 'create_single_item' => 1, 5076 'create_single_item_variables' => array( $create_step_slug, $step_slug ), 5077 ) 5078 ); 5047 $url = bp_groups_get_create_url( array( $create_steps[ $create_step ]['default_slug'] ) ); 5079 5048 5080 5049 $step_name = sprintf( '<a href="%1$s">%2$s. %3$s</a>', esc_url( $url ), absint( $counter ), esc_html( $step_name ) ); … … 5137 5106 $create_step = bp_action_variable( 1 ); 5138 5107 if ( $create_step && isset( $create_steps[ $create_step ]['rewrite_id'], $create_steps[ $create_step ]['default_slug'] ) ) { 5139 $create_step_slug = bp_rewrites_get_slug( 'groups', 'bp_group_create_step', 'step' ); 5140 $step_slug = bp_rewrites_get_slug( 'groups', $create_steps[ $create_step ]['rewrite_id'], $create_steps[ $create_step ]['default_slug'] ); 5141 5142 $url = bp_get_groups_directory_url( 5143 array( 5144 'create_single_item' => 1, 5145 'create_single_item_variables' => array( $create_step_slug, $step_slug ), 5146 ) 5147 ); 5108 $url = bp_groups_get_create_url( array( $create_steps[ $create_step ]['default_slug'] ) ); 5148 5109 } 5149 5110 … … 5505 5466 5506 5467 if ( isset( $create_steps[ $previous_step ]['rewrite_id'], $create_steps[ $previous_step ]['default_slug'] ) ) { 5507 $create_step_slug = bp_rewrites_get_slug( 'groups', 'bp_group_create_step', 'step' ); 5508 $previous_step = bp_rewrites_get_slug( 'groups', $create_steps[ $previous_step ]['rewrite_id'], $create_steps[ $previous_step ]['default_slug'] ); 5509 5510 $url = bp_get_groups_directory_url( 5511 array( 5512 'create_single_item' => 1, 5513 'create_single_item_variables' => array( $create_step_slug, $previous_step ), 5514 ) 5515 ); 5468 $url = bp_groups_get_create_url( array( $create_steps[ $previous_step ]['default_slug'] ) ); 5516 5469 } 5517 5470 … … 6488 6441 6489 6442 if ( bp_is_current_action( 'create' ) ) { 6490 $uninvite_url = bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $user_id; 6443 $uninvite_url = add_query_arg( 6444 'user_id', 6445 $user_id, 6446 bp_get_groups_directory_url( bp_groups_get_path_chunks( array( 'group-invites' ), 'create' ) ) 6447 ); 6491 6448 } else { 6492 6449 $uninvite_url = bp_get_group_url(
Note: See TracChangeset
for help on using the changeset viewer.