Changeset 6770 for trunk/bp-core/bp-core-functions.php
- Timestamp:
- 02/06/2013 10:10:49 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r6579 r6770 173 173 174 174 return apply_filters( 'bp_core_get_directory_pages', $pages ); 175 } 176 177 /** 178 * Add the pages for the component mapping. These are most often used by components with directories (e.g. groups, members). 179 * 180 * @param array $default_components Optional components to create pages for 181 * @param string $existing 'delete' if you want to delete existing page 182 * mappings and replace with new ones. Otherwise existing page mappings 183 * are kept, and the gaps filled in with new pages 184 * @since BuddyPress (1.7) 185 */ 186 function bp_core_add_page_mappings( $components, $existing = 'keep' ) { 187 188 // Make sure that the pages are created on the root blog no matter which Dashboard the setup is being run on 189 if ( ! bp_is_root_blog() ) 190 switch_to_blog( bp_get_root_blog_id() ); 191 192 $pages = bp_core_get_directory_page_ids(); 193 194 // Delete any existing pages 195 if ( 'delete' == $existing ) { 196 foreach ( (array) $pages as $page_id ) { 197 wp_delete_post( $page_id, true ); 198 } 199 200 $pages = array(); 201 } 202 203 $page_titles = array( 204 'activity' => _x( 'Activity', 'Page title for the Activity directory.', 'buddypress' ), 205 'groups' => _x( 'Groups', 'Page title for the Groups directory.', 'buddypress' ), 206 'sites' => _x( 'Sites', 'Page title for the Sites directory.', 'buddypress' ), 207 'activate' => _x( 'Activate', 'Page title for the user account activation screen.', 'buddypress' ), 208 'members' => _x( 'Members', 'Page title for the Members directory.', 'buddypress' ), 209 'register' => _x( 'Register', 'Page title for the user registration screen.', 'buddypress' ), 210 ); 211 212 $pages_to_create = array(); 213 foreach ( array_keys( $components ) as $component_name ) { 214 if ( ! isset( $pages[ $component_name ] ) && isset( $page_titles[ $component_name ] ) ) { 215 $pages_to_create[ $component_name ] = $page_titles[ $component_name ]; 216 } 217 } 218 219 // Register and Activate are not components, but need pages when 220 // registration is enabled 221 if ( bp_get_signup_allowed() ) { 222 foreach ( array( 'register', 'activate' ) as $slug ) { 223 if ( ! isset( $pages[ $slug ] ) ) { 224 $pages_to_create[ $slug ] = $page_titles[ $slug ]; 225 } 226 } 227 } 228 229 // No need for a Sites directory unless we're on multisite 230 if ( ! is_multisite() && isset( $pages_to_create['sites'] ) ) { 231 unset( $pages_to_create['sites'] ); 232 } 233 234 // Members must always have a page, no matter what 235 if ( ! isset( $pages['members'] ) && ! isset( $pages_to_create['members'] ) ) { 236 $pages_to_create['members'] = $page_titles['members']; 237 } 238 239 // Create the pages 240 foreach ( $pages_to_create as $component_name => $page_name ) { 241 $pages[ $component_name ] = wp_insert_post( array( 242 'comment_status' => 'closed', 243 'ping_status' => 'closed', 244 'post_status' => 'publish', 245 'post_title' => $page_name, 246 'post_type' => 'page', 247 ) ); 248 } 249 250 // Save the page mapping 251 bp_update_option( 'bp-pages', $pages ); 252 253 // If we had to switch_to_blog, go back to the original site. 254 if ( ! bp_is_root_blog() ) 255 restore_current_blog(); 175 256 } 176 257
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)