Ticket #6765: 6765-02a+migration+defaults.diff
File 6765-02a+migration+defaults.diff, 9.7 KB (added by , 9 years ago) |
---|
-
src/bp-activity/classes/class-bp-activity-component.php
diff --git src/bp-activity/classes/class-bp-activity-component.php src/bp-activity/classes/class-bp-activity-component.php index 39ae94f..848562d 100644
class BP_Activity_Component extends BP_Component { 116 116 'activity' => $bp->table_prefix . 'bp_activity_meta', 117 117 ); 118 118 119 // Fetch the default directory title. 120 $default_directory_titles = bp_core_get_directory_page_default_titles(); 121 $default_directory_title = $default_directory_titles[$this->id]; 122 119 123 // All globals for activity component. 120 124 // Note that global_tables is included in this array. 121 125 $args = array( 122 126 'slug' => BP_ACTIVITY_SLUG, 123 127 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG, 124 128 'has_directory' => true, 125 'directory_title' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ),129 'directory_title' => isset( $bp->pages->activity->title ) ? $bp->pages->activity->title : $default_directory_title, 126 130 'notification_callback' => 'bp_activity_format_notifications', 127 131 'search_string' => __( 'Search Activity...', 'buddypress' ), 128 132 'global_tables' => $global_tables, -
src/bp-blogs/classes/class-bp-blogs-component.php
diff --git src/bp-blogs/classes/class-bp-blogs-component.php src/bp-blogs/classes/class-bp-blogs-component.php index 69dfe37..bb12f0d 100644
class BP_Blogs_Component extends BP_Component { 65 65 'blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta', 66 66 ); 67 67 68 // Fetch the default directory title. 69 $default_directory_titles = bp_core_get_directory_page_default_titles(); 70 $default_directory_title = $default_directory_titles[$this->id]; 71 68 72 // All globals for blogs component. 69 73 $args = array( 70 74 'slug' => BP_BLOGS_SLUG, 71 75 'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG, 72 76 'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site. 73 'directory_title' => _x( 'Sites', 'component directory title', 'buddypress' ),77 'directory_title' => isset( $bp->pages->blogs->title ) ? $bp->pages->blogs->title : $default_directory_title, 74 78 'notification_callback' => 'bp_blogs_format_notifications', 75 79 'search_string' => __( 'Search sites...', 'buddypress' ), 76 80 'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ), -
src/bp-core/bp-core-functions.php
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php index 7cf28aa..3cbb381 100644
function bp_core_add_page_mappings( $components, $existing = 'keep' ) { 630 630 $pages = array(); 631 631 } 632 632 633 $page_titles = array( 634 'activity' => _x( 'Activity', 'Page title for the Activity directory.', 'buddypress' ), 635 'groups' => _x( 'Groups', 'Page title for the Groups directory.', 'buddypress' ), 636 'sites' => _x( 'Sites', 'Page title for the Sites directory.', 'buddypress' ), 637 'members' => _x( 'Members', 'Page title for the Members directory.', 'buddypress' ), 638 'activate' => _x( 'Activate', 'Page title for the user activation screen.', 'buddypress' ), 639 'register' => _x( 'Register', 'Page title for the user registration screen.', 'buddypress' ), 640 ); 633 $page_titles = bp_core_get_directory_page_default_titles(); 641 634 642 635 $pages_to_create = array(); 643 636 foreach ( array_keys( $components ) as $component_name ) { … … function bp_core_add_page_mappings( $components, $existing = 'keep' ) { 694 687 } 695 688 696 689 /** 690 * Get the default page titles for BP directory pages. 691 * 692 * @since 2.6.0 693 * 694 * @return array 695 */ 696 function bp_core_get_directory_page_default_titles() { 697 return array( 698 'activity' => _x( 'Activity', 'Page title for the Activity directory.', 'buddypress' ), 699 'groups' => _x( 'Groups', 'Page title for the Groups directory.', 'buddypress' ), 700 'sites' => _x( 'Sites', 'Page title for the Sites directory.', 'buddypress' ), 701 'members' => _x( 'Members', 'Page title for the Members directory.', 'buddypress' ), 702 'activate' => _x( 'Activate', 'Page title for the user activation screen.', 'buddypress' ), 703 'register' => _x( 'Register', 'Page title for the user registration screen.', 'buddypress' ), 704 ); 705 } 706 707 /** 697 708 * Remove the entry from bp_pages when the corresponding WP page is deleted. 698 709 * 699 710 * Bails early on multisite installations when not viewing the root site. -
src/bp-core/bp-core-update.php
diff --git src/bp-core/bp-core-update.php src/bp-core/bp-core-update.php index 081b1ff..3d14425 100644
function bp_version_updater() { 263 263 if ( $raw_db_version < 10440 ) { 264 264 bp_update_to_2_5(); 265 265 } 266 267 // 2.6.0 268 if ( $raw_db_version < 10772 ) { 269 bp_update_to_2_6(); 270 } 266 271 } 267 272 268 273 /* All done! *************************************************************/ … … function bp_update_to_2_5() { 502 507 } 503 508 504 509 /** 510 * 2.6.0 update routine. 511 * 512 * - Save legacy directory titles to the corresponding WP pages. 513 * 514 * @since 2.6.0 515 */ 516 function bp_update_to_2_6() { 517 bp_260_migrate_directory_page_titles(); 518 } 519 520 /** 505 521 * Updates the component field for new_members type. 506 522 * 507 523 * @since 2.2.0 … … function bp_cleanup_friendship_activities() { 550 566 } 551 567 552 568 /** 569 * Update WP pages so that their post_title matches the legacy component directory title. 570 * 571 * As of 2.6.0, component directory titles come from the `post_title` attribute of the corresponding WP post object, 572 * instead of being hardcoded. To ensure that directory titles don't change for existing installations, we update these 573 * WP posts with the formerly hardcoded titles. 574 * 575 * @since 2.6.0 576 */ 577 function bp_260_migrate_directory_page_titles() { 578 $bp_pages = bp_core_get_directory_page_ids( 'all' ); 579 580 $default_titles = bp_core_get_directory_page_default_titles(); 581 582 $legacy_titles = array( 583 'activity' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ), 584 'blogs' => _x( 'Sites', 'component directory title', 'buddypress' ), 585 'groups' => _x( 'Groups', 'component directory title', 'buddypress' ), 586 'members' => _x( 'Members', 'component directory title', 'buddypress' ), 587 ); 588 589 foreach ( $bp_pages as $component => $page_id ) { 590 if ( ! isset( $legacy_titles[ $component ] ) ) { 591 continue; 592 } 593 594 $page = get_post( $page_id ); 595 if ( ! $page ) { 596 continue; 597 } 598 599 // If the admin has changed the default title, don't touch it. 600 if ( isset( $default_titles[ $component ] ) && $default_titles[ $component ] !== $page->post_title ) { 601 continue; 602 } 603 604 // If the saved page title is the same as the legacy title, there's nothing to do. 605 if ( $legacy_titles[ $component ] == $page->post_title ) { 606 continue; 607 } 608 609 // Update the page with the legacy title. 610 wp_update_post( array( 611 'ID' => $page_id, 612 'post_title' => $legacy_titles[ $component ], 613 ) ); 614 } 615 } 616 617 /** 553 618 * Redirect user to BP's What's New page on first page load after activation. 554 619 * 555 620 * @since 1.7.0 -
src/bp-groups/classes/class-bp-groups-component.php
diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php index 93bb9b7..d60278c 100644
class BP_Groups_Component extends BP_Component { 168 168 'group' => $bp->table_prefix . 'bp_groups_groupmeta', 169 169 ); 170 170 171 // Fetch the default directory title. 172 $default_directory_titles = bp_core_get_directory_page_default_titles(); 173 $default_directory_title = $default_directory_titles[$this->id]; 174 171 175 // All globals for groups component. 172 176 // Note that global_tables is included in this array. 173 177 $args = array( 174 178 'slug' => BP_GROUPS_SLUG, 175 179 'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG, 176 180 'has_directory' => true, 177 'directory_title' => _x( 'Groups', 'component directory title', 'buddypress' ),181 'directory_title' => isset( $bp->pages->groups->title ) ? $bp->pages->groups->title : $default_directory_title, 178 182 'notification_callback' => 'groups_format_notifications', 179 183 'search_string' => _x( 'Search Groups...', 'Component directory search', 'buddypress' ), 180 184 'global_tables' => $global_tables, -
src/bp-members/classes/class-bp-members-component.php
diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php index 73b45e0..712f80d 100644
class BP_Members_Component extends BP_Component { 108 108 define( 'BP_MEMBERS_SLUG', $this->id ); 109 109 } 110 110 111 // Fetch the default directory title. 112 $default_directory_titles = bp_core_get_directory_page_default_titles(); 113 $default_directory_title = $default_directory_titles[$this->id]; 114 111 115 // Override any passed args. 112 116 $args = array( 113 117 'slug' => BP_MEMBERS_SLUG, 114 118 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 115 119 'has_directory' => true, 116 'directory_title' => _x( 'Members', 'component directory title', 'buddypress' ),120 'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title, 117 121 'search_string' => __( 'Search Members...', 'buddypress' ), 118 122 'global_tables' => array( 119 123 'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',