bp_migrate_directory_page_titles()
Update WP pages so that their post_title matches the legacy component directory title.
Description Description
As of 2.7.0, component directory titles come from the post_title
attribute of the corresponding WP post object, instead of being hardcoded. To ensure that directory titles don’t change for existing installations, we update these WP posts with the formerly hardcoded titles.
Source Source
File: bp-core/bp-core-update.php
function bp_migrate_directory_page_titles() { $bp_pages = bp_core_get_directory_page_ids( 'all' ); $default_titles = bp_core_get_directory_page_default_titles(); $legacy_titles = array( 'activity' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ), 'blogs' => _x( 'Sites', 'component directory title', 'buddypress' ), 'groups' => _x( 'Groups', 'component directory title', 'buddypress' ), 'members' => _x( 'Members', 'component directory title', 'buddypress' ), ); foreach ( $bp_pages as $component => $page_id ) { if ( ! isset( $legacy_titles[ $component ] ) ) { continue; } $page = get_post( $page_id ); if ( ! $page ) { continue; } // If the admin has changed the default title, don't touch it. if ( isset( $default_titles[ $component ] ) && $default_titles[ $component ] !== $page->post_title ) { continue; } // If the saved page title is the same as the legacy title, there's nothing to do. if ( $legacy_titles[ $component ] == $page->post_title ) { continue; } // Update the page with the legacy title. wp_update_post( array( 'ID' => $page_id, 'post_title' => $legacy_titles[ $component ], ) ); } }
Changelog Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |