Changeset 13432
- Timestamp:
- 03/01/2023 08:17:11 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/classes/class-bp-activity-component.php
r13414 r13432 179 179 * Set up component global variables. 180 180 * 181 * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for 182 * backwards compatibility. 181 * The BP_ACTIVITY_SLUG constant is deprecated. 183 182 * 184 183 * @since 1.5.0 … … 189 188 */ 190 189 public function setup_globals( $args = array() ) { 191 $bp = buddypress(); 192 193 // Define a slug, if necessary. 194 if ( ! defined( 'BP_ACTIVITY_SLUG' ) ) { 195 define( 'BP_ACTIVITY_SLUG', $this->id ); 190 $bp = buddypress(); 191 $default_slug = $this->id; 192 193 // @deprecated. 194 if ( defined( 'BP_ACTIVITY_SLUG' ) ) { 195 _doing_it_wrong( 'BP_ACTIVITY_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 196 $default_slug = BP_ACTIVITY_SLUG; 196 197 } 197 198 … … 214 215 // Note that global_tables is included in this array. 215 216 $args = array( 216 'slug' => BP_ACTIVITY_SLUG,217 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,217 'slug' => $default_slug, 218 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : $default_slug, 218 219 'has_directory' => true, 220 'rewrite_ids' => array( 221 'directory' => 'activities', 222 'single_item_action' => 'activity_action', 223 'single_item_action_variables' => 'activity_action_variables', 224 ), 219 225 'directory_title' => isset( $bp->pages->activity->title ) ? $bp->pages->activity->title : $default_directory_title, 220 226 'notification_callback' => 'bp_activity_format_notifications', -
trunk/src/bp-blogs/classes/class-bp-blogs-component.php
r13414 r13432 44 44 * Set up global settings for the blogs component. 45 45 * 46 * The BP_BLOGS_SLUG constant is deprecated, and only used here for 47 * backwards compatibility. 46 * The BP_BLOGS_SLUG constant is deprecated. 48 47 * 49 48 * @since 1.5.0 … … 54 53 */ 55 54 public function setup_globals( $args = array() ) { 56 $bp = buddypress(); 57 58 if ( ! defined( 'BP_BLOGS_SLUG' ) ) { 59 define ( 'BP_BLOGS_SLUG', $this->id ); 55 $bp = buddypress(); 56 $default_slug = $this->id; 57 58 // @deprecated. 59 if ( defined( 'BP_BLOGS_SLUG' ) ) { 60 _doing_it_wrong( 'BP_BLOGS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 61 $default_slug = BP_BLOGS_SLUG; 60 62 } 61 63 … … 76 78 // All globals for blogs component. 77 79 $args = array( 78 'slug' => BP_BLOGS_SLUG,79 'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,80 'slug' => $default_slug, 81 'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : $default_slug, 80 82 'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site. 83 'rewrite_ids' => array( 84 'directory' => 'blogs', 85 'single_item_action' => 'blogs_action', 86 'single_item_action_variables' => 'blogs_action_variables', 87 ), 81 88 'directory_title' => isset( $bp->pages->blogs->title ) ? $bp->pages->blogs->title : $default_directory_title, 82 89 'notification_callback' => 'bp_blogs_format_notifications', -
trunk/src/bp-core/bp-core-functions.php
r13431 r13432 744 744 $page_ids_sql = implode( ',', wp_parse_id_list( $page_ids ) ); 745 745 $page_stati_sql = '\'' . implode( '\', \'', array_map( 'sanitize_key', bp_core_get_directory_pages_stati() ) ) . '\''; 746 $page_names = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_title FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status IN ({$page_stati_sql}) " );746 $page_names = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_title, post_status FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status IN ({$page_stati_sql}) " ); 747 747 748 748 foreach ( (array) $page_ids as $component_id => $page_id ) { … … 765 765 } 766 766 767 $pages->{$component_id}->slug = implode( '/', array_reverse( (array) $slug ) ); 767 $pages->{$component_id}->slug = implode( '/', array_reverse( (array) $slug ) ); 768 $pages->{$component_id}->custom_slugs = get_post_meta( $page_name->ID, '_bp_component_slugs', true ); 769 $pages->{$component_id}->visibility = $page_name->post_status; 768 770 } 769 771 … … 1108 1110 * 1109 1111 * @since 1.0.0 1112 * @deprecated 12.0.0 1110 1113 * 1111 1114 * @return string The domain URL for the blog. 1112 1115 */ 1113 1116 function bp_core_get_root_domain() { 1114 1115 $domain = get_home_url( bp_get_root_blog_id() ); 1117 _deprecated_function( __FUNCTION__, '12.0.0', 'bp_rewrites_get_root_url()' ); 1118 1119 $domain = bp_rewrites_get_root_url(); 1116 1120 1117 1121 /** … … 1119 1123 * 1120 1124 * @since 1.0.1 1125 * @deprecated 12.0.0 Use {@see 'bp_rewrites_get_root_url'} instead. 1121 1126 * 1122 1127 * @param string $domain The domain URL for the blog. 1123 1128 */ 1124 return apply_filters ( 'bp_core_get_root_domain', $domain);1129 return apply_filters_deprecated( 'bp_core_get_root_domain', array( $domain ), '12.0.0', 'bp_rewrites_get_root_url' ); 1125 1130 } 1126 1131 -
trunk/src/bp-core/bp-core-rewrites.php
r13422 r13432 44 44 ); 45 45 } 46 47 /** 48 * Delete rewrite rules, so that they are automatically rebuilt on 49 * the subsequent page load. 50 * 51 * @since 12.0.0 52 */ 53 function bp_delete_rewrite_rules() { 54 delete_option( 'rewrite_rules' ); 55 } 56 57 /** 58 * Are Pretty URLs active? 59 * 60 * @since 12.0.0 61 * 62 * @return bool True if Pretty URLs are on. False otherwise. 63 */ 64 function bp_has_pretty_urls() { 65 $has_plain_urls = ! get_option( 'permalink_structure', '' ); 66 return ! $has_plain_urls; 67 } 68 69 /** 70 * Returns the slug to use for the view belonging to the requested component. 71 * 72 * @since 12.0.0 73 * 74 * @param string $component_id The BuddyPress component's ID. 75 * @param string $rewrite_id The view rewrite ID. 76 * @param string $default_slug The view default slug. 77 * @return string The slug to use for the view belonging to the requested component. 78 */ 79 function bp_rewrites_get_slug( $component_id = '', $rewrite_id = '', $default_slug = '' ) { 80 $directory_pages = bp_core_get_directory_pages(); 81 $slug = $default_slug; 82 83 if ( ! isset( $directory_pages->{$component_id}->custom_slugs ) || ! $rewrite_id ) { 84 return $slug; 85 } 86 87 $custom_slugs = (array) $directory_pages->{$component_id}->custom_slugs; 88 if ( isset( $custom_slugs[ $rewrite_id ] ) && $custom_slugs[ $rewrite_id ] ) { 89 $slug = $custom_slugs[ $rewrite_id ]; 90 } 91 92 return $slug; 93 } 94 95 /** 96 * Builds a BuddyPress link using the WP Rewrite API. 97 * 98 * @since 12.0.0 99 * 100 * @param array $args { 101 * Optional. An array of arguments. 102 * 103 * @type string $component_id The BuddyPress component ID. Defaults ''. 104 * @type string $directory_type Whether it's an object type URL. Defaults ''. 105 * Accepts '' (no object type), 'members' or 'groups'. 106 * @type string $single_item The BuddyPress single item's URL chunk. Defaults ''. 107 * Eg: the member's user nicename for Members or the group's slug for Groups. 108 * @type string $single_item_component The BuddyPress single item's component URL chunk. Defaults ''. 109 * Eg: the member's Activity page. 110 * @type string $single_item_action The BuddyPress single item's action URL chunk. Defaults ''. 111 * Eg: the member's Activity mentions page. 112 * @type array $single_item_action_variables The list of BuddyPress single item's action variable URL chunks. Defaults []. 113 * } 114 * @return string The BuddyPress link. 115 */ 116 function bp_rewrites_get_url( $args = array() ) { 117 $bp = buddypress(); 118 $url = get_home_url( bp_get_root_blog_id() ); 119 120 $r = bp_parse_args( 121 $args, 122 array( 123 'component_id' => '', 124 'directory_type' => '', 125 'single_item' => '', 126 'single_item_component' => '', 127 'single_item_action' => '', 128 'single_item_action_variables' => array(), 129 ) 130 ); 131 132 if ( $r['component_id'] && isset( $bp->{$r['component_id']}->rewrite_ids ) ) { 133 $component = $bp->{$r['component_id']}; 134 unset( $r['component_id'] ); 135 136 // Using plain links. 137 if ( ! bp_has_pretty_urls() ) { 138 if ( ! isset( $r['member_register'] ) && ! isset( $r['member_activate'] ) ) { 139 $r['directory'] = 1; 140 } 141 142 $r = array_filter( $r ); 143 $qv = array(); 144 145 foreach ( $component->rewrite_ids as $key => $rewrite_id ) { 146 if ( ! isset( $r[ $key ] ) ) { 147 continue; 148 } 149 150 $qv[ $rewrite_id ] = $r[ $key ]; 151 } 152 153 $url = add_query_arg( $qv, $url ); 154 155 // Using pretty URLs. 156 } else { 157 if ( ! isset( $component->rewrite_ids['directory'] ) || ! isset( $component->directory_permastruct ) ) { 158 return $url; 159 } 160 161 if ( isset( $r['member_register'] ) ) { 162 $url = str_replace( '%' . $component->rewrite_ids['member_register'] . '%', '', $component->register_permastruct ); 163 unset( $r['member_register'] ); 164 } elseif ( isset( $r['member_activate'] ) ) { 165 $url = str_replace( '%' . $component->rewrite_ids['member_activate'] . '%', '', $component->activate_permastruct ); 166 unset( $r['member_activate'] ); 167 } elseif ( isset( $r['create_single_item'] ) ) { 168 $create_slug = 'create'; 169 if ( 'groups' === $component->id ) { 170 $create_slug = bp_rewrites_get_slug( 'groups', 'bp_group_create', 'create' ); 171 } 172 173 $url = str_replace( '%' . $component->rewrite_ids['directory'] . '%', $create_slug, $component->directory_permastruct ); 174 unset( $r['create_single_item'] ); 175 } else { 176 $url = str_replace( '%' . $component->rewrite_ids['directory'] . '%', $r['single_item'], $component->directory_permastruct ); 177 178 // Remove the members directory slug when root profiles are on. 179 if ( bp_core_enable_root_profiles() && 'members' === $component->id && isset( $r['single_item'] ) && $r['single_item'] ) { 180 $url = str_replace( $bp->members->root_slug . '/', '', $url ); 181 } 182 183 unset( $r['single_item'] ); 184 } 185 186 $r = array_filter( $r ); 187 188 if ( isset( $r['directory_type'] ) && $r['directory_type'] ) { 189 if ( 'members' === $component->id ) { 190 array_unshift( $r, bp_get_members_member_type_base() ); 191 } elseif ( 'groups' === $component->id && bp_is_active( 'groups' ) ) { 192 array_unshift( $r, bp_get_groups_group_type_base() ); 193 } else { 194 unset( $r['directory_type'] ); 195 } 196 } 197 198 if ( isset( $r['single_item_action_variables'] ) && $r['single_item_action_variables'] ) { 199 $r['single_item_action_variables'] = join( '/', (array) $r['single_item_action_variables'] ); 200 } 201 202 if ( isset( $r['create_single_item_variables'] ) && $r['create_single_item_variables'] ) { 203 $r['create_single_item_variables'] = join( '/', (array) $r['create_single_item_variables'] ); 204 } 205 206 $url = get_home_url( bp_get_root_blog_id(), user_trailingslashit( '/' . rtrim( $url, '/' ) . '/' . join( '/', $r ) ) ); 207 } 208 } 209 210 /** 211 * Filter here to edit any BudyPress URL. 212 * 213 * @since 12.0.0 214 * 215 * @param string $url The BudyPress URL. 216 * @param array $r { 217 * Optional. An array of arguments. 218 * 219 * @type string $component_id The BuddyPress component ID. Defaults ''. 220 * @type string $directory_type Whether it's an object type URL. Defaults ''. 221 * Accepts '' (no object type), 'members' or 'groups'. 222 * @type string $single_item The BuddyPress single item's URL chunk. Defaults ''. 223 * Eg: the member's user nicename for Members or the group's slug for Groups. 224 * @type string $single_item_component The BuddyPress single item's component URL chunk. Defaults ''. 225 * Eg: the member's Activity page. 226 * @type string $single_item_action The BuddyPress single item's action URL chunk. Defaults ''. 227 * Eg: the member's Activity mentions page. 228 * @type array $single_item_action_variables The list of BuddyPress single item's action variable URL chunks. Defaults []. 229 * } 230 */ 231 return apply_filters( 'bp_rewrites_get_url', $url, $r ); 232 } 233 234 /** 235 * Gets the BP root site URL, using BP Rewrites. 236 * 237 * @since 12.0.0 238 * 239 * @return string The BP root site URL. 240 */ 241 function bp_rewrites_get_root_url() { 242 $url = bp_rewrites_get_url( array() ); 243 244 /** 245 * Filter here to edit the BP root site URL. 246 * 247 * @since 12.0.0 248 * 249 * @param string $url The BP root site URL. 250 */ 251 return apply_filters( 'bp_rewrites_get_root_url', $url ); 252 } -
trunk/src/bp-core/bp-core-template.php
r13417 r13432 1400 1400 1401 1401 /** 1402 * Gets the BP root blog's URL. 1403 * 1404 * @since 12.0.0 1405 * 1406 * @return string The BP root blog's URL. 1407 */ 1408 function bp_get_root_url() { 1409 $bp = buddypress(); 1410 1411 if ( ! empty( $bp->root_url ) ) { 1412 $url = $bp->root_url; 1413 } else { 1414 $url = bp_rewrites_get_root_url(); 1415 $bp->root_url = $url; 1416 } 1417 1418 /** 1419 * Filters the "root url", the URL of the BP root blog. 1420 * 1421 * @since 12.0.0 1422 * 1423 * @param string $url URL of the BP root blog. 1424 */ 1425 return apply_filters( 'bp_get_root_url', $url ); 1426 } 1427 1428 /** 1429 * Output the "root url", the URL of the BP root blog. 1430 * 1431 * @since 12.0.0 1432 */ 1433 function bp_root_url() { 1434 echo esc_url( bp_get_root_url() ); 1435 } 1436 1437 /** 1402 1438 * Output the "root domain", the URL of the BP root blog. 1403 1439 * 1404 1440 * @since 1.1.0 1441 * @deprecated 12.0.0 1405 1442 */ 1406 1443 function bp_root_domain() { 1407 echo bp_get_root_domain(); 1444 _deprecated_function( __FUNCTION__, '12.0.0', 'bp_root_url()' ); 1445 bp_root_url(); 1408 1446 } 1409 1447 /** … … 1411 1449 * 1412 1450 * @since 1.1.0 1451 * @deprecated 12.0.0 1413 1452 * 1414 1453 * @return string URL of the BP root blog. 1415 1454 */ 1416 1455 function bp_get_root_domain() { 1417 $bp = buddypress(); 1418 1419 if ( ! empty( $bp->root_domain ) ) { 1420 $domain = $bp->root_domain; 1421 } else { 1422 $domain = bp_core_get_root_domain(); 1423 $bp->root_domain = $domain; 1424 } 1456 /* 1457 * This function is used at many places and we need to review all this 1458 * places during the 12.0 development cycle. Using BP Rewrites means we 1459 * cannot concatenate URL chunks to build our URL anymore. We now need 1460 * to use `bp_rewrites_get_url( $array )` and make sure to use the right 1461 * arguments inside this `$array`. 1462 * 1463 * @todo Once every link reviewed, we'll be able to remove this check 1464 * and let PHPUnit tell us the one we forgot, eventually! 1465 */ 1466 if ( ! buddypress()->is_phpunit_running ) { 1467 _deprecated_function( __FUNCTION__, '12.0.0', 'bp_get_root_url()' ); 1468 } 1469 1470 $domain = bp_get_root_url(); 1425 1471 1426 1472 /** 1427 * Filters the "root domain", the URL of the BP root blog.1473 * Filters the "root domain", the URL of the BP root blog. 1428 1474 * 1429 1475 * @since 1.2.4 1476 * @deprecated 12.0.0 Use {@see 'bp_get_root_url'} instead. 1430 1477 * 1431 1478 * @param string $domain URL of the BP root blog. 1432 1479 */ 1433 return apply_filters ( 'bp_get_root_domain', $domain);1480 return apply_filters_deprecated( 'bp_core_get_root_domain', array( $domain ), '12.0.0', 'bp_get_root_url' ); 1434 1481 } 1435 1482 -
trunk/src/bp-core/bp-core-update.php
r13431 r13432 862 862 863 863 // Finally make sure to rebuilt permalinks at next page load. 864 delete_option( 'rewrite_rules');864 bp_delete_rewrite_rules(); 865 865 } 866 866 } -
trunk/src/bp-core/classes/class-bp-component.php
r13431 r13432 1124 1124 $queried_object = $query->get_queried_object(); 1125 1125 1126 if ( $queried_object instanceof \WP_Post && 'buddypress' === get_post_type( $queried_object ) ) {1126 if ( $queried_object instanceof WP_Post && 'buddypress' === get_post_type( $queried_object ) ) { 1127 1127 // Only include the queried directory post into returned posts. 1128 1128 $retval = array( $queried_object ); -
trunk/src/bp-core/classes/class-bp-core.php
r13431 r13432 218 218 } 219 219 220 // The domainfor the root of the site where the main blog resides.221 if ( empty( $bp->root_ domain) ) {222 $bp->root_ domain = bp_core_get_root_domain();220 // The URL for the root of the site where the main blog resides. 221 if ( empty( $bp->root_url ) ) { 222 $bp->root_url = bp_rewrites_get_root_url(); 223 223 } 224 224 -
trunk/src/bp-core/deprecated/12.0.php
r13431 r13432 140 140 _deprecated_function( __FUNCTION__, '12.0.0' ); 141 141 } 142 143 /** 144 * Define the slug constants for the Members component. 145 * 146 * Handles the three slug constants used in the Members component - 147 * BP_MEMBERS_SLUG, BP_REGISTER_SLUG, and BP_ACTIVATION_SLUG. If these 148 * constants are not overridden in wp-config.php or bp-custom.php, they are 149 * defined here to match the slug of the corresponding WP pages. 150 * 151 * In general, fallback values are only used during initial BP page creation, 152 * when no slugs have been explicitly defined. 153 * 154 * @since 1.5.0 155 * @deprecated 12.0.0 156 */ 157 function bp_core_define_slugs() { 158 _deprecated_function( __FUNCTION__, '12.0.0' ); 159 } -
trunk/src/bp-friends/classes/class-bp-friends-component.php
r13414 r13432 101 101 * Set up bp-friends global settings. 102 102 * 103 * The BP_FRIENDS_SLUG constant is deprecated, and only used here for 104 * backwards compatibility. 103 * The BP_FRIENDS_SLUG constant is deprecated. 105 104 * 106 105 * @since 1.5.0 … … 111 110 */ 112 111 public function setup_globals( $args = array() ) { 113 $bp = buddypress(); 114 115 // Deprecated. Do not use. 116 // Defined conditionally to support unit tests. 117 if ( ! defined( 'BP_FRIENDS_DB_VERSION' ) ) { 118 define( 'BP_FRIENDS_DB_VERSION', '1800' ); 119 } 120 121 // Define a slug, if necessary. 122 if ( ! defined( 'BP_FRIENDS_SLUG' ) ) { 123 define( 'BP_FRIENDS_SLUG', $this->id ); 112 $bp = buddypress(); 113 $default_slug = $this->id; 114 115 // @deprecated. 116 if ( defined( 'BP_FRIENDS_DB_VERSION' ) ) { 117 _doing_it_wrong( 'BP_FRIENDS_DB_VERSION', esc_html__( 'This constants is not used anymore.', 'buddypress' ), 'BuddyPress 12.0.0' ); 118 } 119 120 // @deprecated. 121 if ( defined( 'BP_FRIENDS_SLUG' ) ) { 122 _doing_it_wrong( 'BP_FRIENDS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 123 $default_slug = BP_FRIENDS_SLUG; 124 124 } 125 125 … … 133 133 // Note that global_tables is included in this array. 134 134 $args = array( 135 'slug' => BP_FRIENDS_SLUG,135 'slug' => $default_slug, 136 136 'has_directory' => false, 137 137 'search_string' => __( 'Search Friends...', 'buddypress' ), -
trunk/src/bp-groups/classes/class-bp-groups-component.php
r13414 r13432 439 439 * Set up component global data. 440 440 * 441 * The BP_GROUPS_SLUG constant is deprecated, and only used here for 442 * backwards compatibility. 441 * The BP_GROUPS_SLUG constant is deprecated. 443 442 * 444 443 * @since 1.5.0 … … 449 448 */ 450 449 public function setup_globals( $args = array() ) { 451 $bp = buddypress(); 452 453 // Define a slug, if necessary. 454 if ( ! defined( 'BP_GROUPS_SLUG' ) ) { 455 define( 'BP_GROUPS_SLUG', $this->id ); 450 $bp = buddypress(); 451 $default_slug = $this->id; 452 453 // @deprecated. 454 if ( defined( 'BP_GROUPS_SLUG' ) ) { 455 _doing_it_wrong( 'BP_GROUPS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 456 $default_slug = BP_GROUPS_SLUG; 456 457 } 457 458 … … 475 476 // Note that global_tables is included in this array. 476 477 $args = array( 477 'slug' => BP_GROUPS_SLUG,478 'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,478 'slug' => $default_slug, 479 'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : $default_slug, 479 480 'has_directory' => true, 481 'rewrite_ids' => array( 482 'directory' => 'groups', 483 'directory_type' => 'groups_type', 484 'create_single_item' => 'group_create', 485 'create_single_item_variables' => 'group_create_variables', 486 'single_item' => 'group', 487 'single_item_action' => 'group_action', 488 'single_item_action_variables' => 'group_action_variables', 489 ), 480 490 'directory_title' => isset( $bp->pages->groups->title ) ? $bp->pages->groups->title : $default_directory_title, 481 491 'notification_callback' => 'groups_format_notifications', -
trunk/src/bp-members/bp-members-functions.php
r13395 r13432 25 25 return (bool) ! empty( $bp->pages->members->id ); 26 26 } 27 28 /**29 * Define the slug constants for the Members component.30 *31 * Handles the three slug constants used in the Members component -32 * BP_MEMBERS_SLUG, BP_REGISTER_SLUG, and BP_ACTIVATION_SLUG. If these33 * constants are not overridden in wp-config.php or bp-custom.php, they are34 * defined here to match the slug of the corresponding WP pages.35 *36 * In general, fallback values are only used during initial BP page creation,37 * when no slugs have been explicitly defined.38 *39 * @since 1.5.040 */41 function bp_core_define_slugs() {42 $bp = buddypress();43 44 // No custom members slug.45 if ( !defined( 'BP_MEMBERS_SLUG' ) ) {46 if ( !empty( $bp->pages->members ) ) {47 define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug );48 } else {49 define( 'BP_MEMBERS_SLUG', 'members' );50 }51 }52 53 // No custom registration slug.54 if ( !defined( 'BP_REGISTER_SLUG' ) ) {55 if ( !empty( $bp->pages->register ) ) {56 define( 'BP_REGISTER_SLUG', $bp->pages->register->slug );57 } else {58 define( 'BP_REGISTER_SLUG', 'register' );59 }60 }61 62 // No custom activation slug.63 if ( !defined( 'BP_ACTIVATION_SLUG' ) ) {64 if ( !empty( $bp->pages->activate ) ) {65 define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug );66 } else {67 define( 'BP_ACTIVATION_SLUG', 'activate' );68 }69 }70 }71 add_action( 'bp_setup_globals', 'bp_core_define_slugs', 11 );72 27 73 28 /** … … 1548 1503 ); 1549 1504 1550 // Core constants.1505 // @todo replace slug constants with custom slugs. 1551 1506 $slug_constants = array( 1552 'BP_GROUPS_SLUG',1553 'BP_MEMBERS_SLUG',1554 1507 'BP_FORUMS_SLUG', 1555 'BP_BLOGS_SLUG',1556 'BP_ACTIVITY_SLUG',1557 'BP_XPROFILE_SLUG',1558 'BP_FRIENDS_SLUG',1559 1508 'BP_SEARCH_SLUG', 1560 'BP_SETTINGS_SLUG',1561 'BP_NOTIFICATIONS_SLUG',1562 'BP_REGISTER_SLUG',1563 'BP_ACTIVATION_SLUG',1564 1509 ); 1565 1510 foreach ( $slug_constants as $constant ) { -
trunk/src/bp-members/bp-members-template.php
r13395 r13432 214 214 */ 215 215 function bp_get_signup_slug() { 216 $bp = buddypress(); 216 $bp = buddypress(); 217 $slug = 'register'; 217 218 218 219 if ( ! empty( $bp->pages->register->slug ) ) { 219 220 $slug = $bp->pages->register->slug; 220 } elseif ( defined( 'BP_REGISTER_SLUG' ) ) {221 $slug = BP_REGISTER_SLUG;222 } else {223 $slug = 'register';224 221 } 225 222 … … 250 247 */ 251 248 function bp_get_activate_slug() { 252 $bp = buddypress(); 249 $bp = buddypress(); 250 $slug = 'activate'; 253 251 254 252 if ( ! empty( $bp->pages->activate->slug ) ) { 255 253 $slug = $bp->pages->activate->slug; 256 } elseif ( defined( 'BP_ACTIVATION_SLUG' ) ) {257 $slug = BP_ACTIVATION_SLUG;258 } else {259 $slug = 'activate';260 254 } 261 255 -
trunk/src/bp-members/classes/class-bp-members-component.php
r13414 r13432 276 276 * Set up bp-members global settings. 277 277 * 278 * The BP_MEMBERS_SLUG constant is deprecated, and only used here for 279 * backwards compatibility. 278 * The BP_MEMBERS_SLUG constant is deprecated. 280 279 * 281 280 * @since 1.5.0 … … 288 287 global $wpdb; 289 288 290 $bp = buddypress(); 289 $bp = buddypress(); 290 $default_slug = $this->id; 291 291 292 292 /** Component Globals ************************************************ 293 293 */ 294 294 295 // Define a slug, as a fallback for backpat. 296 if ( !defined( 'BP_MEMBERS_SLUG' ) ) { 297 define( 'BP_MEMBERS_SLUG', $this->id ); 295 // @deprecated. 296 if ( defined( 'BP_MEMBERS_SLUG' ) ) { 297 _doing_it_wrong( 'BP_MEMBERS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 298 $default_slug = BP_MEMBERS_SLUG; 298 299 } 299 300 … … 304 305 // Override any passed args. 305 306 $args = array( 306 'slug' => BP_MEMBERS_SLUG,307 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,307 'slug' => $default_slug, 308 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $default_slug, 308 309 'has_directory' => true, 310 'rewrite_ids' => array( 311 'directory' => 'members', 312 'directory_type' => 'members_type', 313 'single_item' => 'member', 314 'single_item_component' => 'member_component', 315 'single_item_action' => 'member_action', 316 'single_item_action_variables' => 'member_action_variables', 317 'member_register' => 'register', 318 'member_activate' => 'activate', 319 'member_activate_key' => 'activate_key', 320 ), 309 321 'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title, 310 322 'search_string' => __( 'Search Members...', 'buddypress' ), -
trunk/src/bp-messages/classes/class-bp-messages-component.php
r13414 r13432 146 146 * Set up globals for the Messages component. 147 147 * 148 * The BP_MESSAGES_SLUG constant is deprecated, and only used here for 149 * backwards compatibility. 148 * The BP_MESSAGES_SLUG constant is deprecated. 150 149 * 151 150 * @since 1.5.0 … … 154 153 */ 155 154 public function setup_globals( $args = array() ) { 156 $bp = buddypress(); 157 158 // Define a slug, if necessary. 159 if ( ! defined( 'BP_MESSAGES_SLUG' ) ) { 160 define( 'BP_MESSAGES_SLUG', $this->id ); 155 $bp = buddypress(); 156 $default_slug = $this->id; 157 158 // @deprecated. 159 if ( defined( 'BP_MESSAGES_SLUG' ) ) { 160 _doing_it_wrong( 'BP_MESSAGES_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 161 $default_slug = BP_MESSAGES_SLUG; 161 162 } 162 163 … … 179 180 // Note that global_tables is included in this array. 180 181 parent::setup_globals( array( 181 'slug' => BP_MESSAGES_SLUG,182 'slug' => $default_slug, 182 183 'has_directory' => false, 183 184 'notification_callback' => 'messages_format_notifications', -
trunk/src/bp-notifications/classes/class-bp-notifications-component.php
r13414 r13432 100 100 */ 101 101 public function setup_globals( $args = array() ) { 102 $bp = buddypress(); 103 104 // Define a slug, if necessary. 105 if ( ! defined( 'BP_NOTIFICATIONS_SLUG' ) ) { 106 define( 'BP_NOTIFICATIONS_SLUG', $this->id ); 102 $bp = buddypress(); 103 $default_slug = $this->id; 104 105 // @deprecated. 106 if ( defined( 'BP_NOTIFICATIONS_SLUG' ) ) { 107 _doing_it_wrong( 'BP_NOTIFICATIONS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 108 $default_slug = BP_NOTIFICATIONS_SLUG; 107 109 } 108 110 … … 121 123 // Note that global_tables is included in this array. 122 124 $args = array( 123 'slug' => BP_NOTIFICATIONS_SLUG,125 'slug' => $default_slug, 124 126 'has_directory' => false, 125 127 'search_string' => __( 'Search Notifications...', 'buddypress' ), -
trunk/src/bp-settings/classes/class-bp-settings-component.php
r13414 r13432 95 95 * Setup globals. 96 96 * 97 * The BP_SETTINGS_SLUG constant is deprecated, and only used here for 98 * backwards compatibility. 97 * The BP_SETTINGS_SLUG constant is deprecated. 99 98 * 100 99 * @since 1.5.0 … … 105 104 */ 106 105 public function setup_globals( $args = array() ) { 107 108 // Define a slug, if necessary. 109 if ( ! defined( 'BP_SETTINGS_SLUG' ) ) { 110 define( 'BP_SETTINGS_SLUG', $this->id ); 106 $default_slug = $this->id; 107 108 // @deprecated. 109 if ( defined( 'BP_SETTINGS_SLUG' ) ) { 110 _doing_it_wrong( 'BP_SETTINGS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 111 $default_slug = BP_SETTINGS_SLUG; 111 112 } 112 113 113 114 // All globals for settings component. 114 115 parent::setup_globals( array( 115 'slug' => BP_SETTINGS_SLUG,116 'slug' => $default_slug, 116 117 'has_directory' => false, 117 118 ) ); -
trunk/src/bp-settings/screens/general.php
r13090 r13432 37 37 function bp_settings_remove_email_subnav() { 38 38 if ( ! has_action( 'bp_notification_settings' ) ) { 39 bp_core_remove_subnav_item( BP_SETTINGS_SLUG, 'notifications' );39 bp_core_remove_subnav_item( bp_get_settings_slug(), 'notifications' ); 40 40 } 41 41 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-component.php
r13414 r13432 129 129 * Setup globals. 130 130 * 131 * The BP_XPROFILE_SLUG constant is deprecated, and only used here for 132 * backwards compatibility. 131 * The BP_XPROFILE_SLUG constant is deprecated. 133 132 * 134 133 * @since 1.5.0 … … 137 136 */ 138 137 public function setup_globals( $args = array() ) { 139 $bp = buddypress(); 140 141 // Define a slug, if necessary. 142 if ( ! defined( 'BP_XPROFILE_SLUG' ) ) { 143 define( 'BP_XPROFILE_SLUG', 'profile' ); 138 $bp = buddypress(); 139 $default_slug = 'profile'; 140 141 // @deprecated. 142 if ( defined( 'BP_XPROFILE_SLUG' ) ) { 143 _doing_it_wrong( 'BP_XPROFILE_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' ); 144 $default_slug = BP_XPROFILE_SLUG; 144 145 } 145 146 … … 209 210 210 211 $globals = array( 211 'slug' => BP_XPROFILE_SLUG,212 'slug' => $default_slug, 212 213 'has_directory' => false, 213 214 'notification_callback' => 'xprofile_format_notifications', -
trunk/src/class-buddypress.php
r13431 r13432 307 307 */ 308 308 public function __get( $key ) { 309 return isset( $this->data[ $key ] ) ? $this->data[ $key ] : null; 309 $valid_key = $key; 310 if ( 'root_domain' === $key ) { 311 _doing_it_wrong( 'root_domain', __( 'The root_domain BuddyPress main class property is deprecated since 12.0.0, please use the root_url property instead.', 'buddypress' ), 'BuddyPress 12.0.0' ); 312 $valid_key = 'root_url'; 313 } 314 315 return isset( $this->data[ $valid_key ] ) ? $this->data[ $valid_key ] : null; 310 316 } 311 317 … … 319 325 */ 320 326 public function __set( $key, $value ) { 321 $this->data[ $key ] = $value; 327 $valid_key = $key; 328 if ( 'root_domain' === $key ) { 329 _doing_it_wrong( 'root_domain', __( 'The root_domain BuddyPress main class property is deprecated since 12.0.0, please use the root_url property instead.', 'buddypress' ), 'BuddyPress 12.0.0' ); 330 $valid_key = 'root_url'; 331 } 332 333 $this->data[ $valid_key ] = $value; 322 334 } 323 335
Note: See TracChangeset
for help on using the changeset viewer.