Ticket #8625: 8625.01.patch
File 8625.01.patch, 2.0 KB (added by , 3 years ago) |
---|
-
src/bp-core/bp-core-widgets.php
14 14 * Should BuddyPress load Legacy Widgets? 15 15 * 16 16 * @since 10.0.0 17 * @deprecated 17 18 * 18 19 * @return bool False if BuddyPress shouldn't load Legacy Widgets. True otherwise. 19 20 */ … … 64 65 * @since 10.0.0 65 66 */ 66 67 function bp_core_maybe_unhook_legacy_widgets() { 67 if ( bp_core_retain_legacy_widgets() ) {68 return;69 }70 71 68 $callbacks = array( 72 ' bp_core_register_login_widget',73 ' bp_members_register_members_widget',74 ' bp_members_register_whos_online_widget',75 ' bp_members_register_recently_active_widget',69 'BP_Core_Login_Widget', 70 'BP_Core_Members_Widget', 71 'BP_Core_Whos_Online_Widget', 72 'BP_Core_Recently_Active_Widget', 76 73 ); 77 74 78 75 if ( bp_is_active( 'friends' ) ) { 79 $callbacks[] = ' bp_friends_register_friends_widget';76 $callbacks[] = 'BP_Core_Friends_Widget'; 80 77 } 81 78 82 79 if ( bp_is_active( 'groups' ) ) { 83 $callbacks[] = ' bp_groups_register_groups_widget';80 $callbacks[] = 'BP_Groups_Widget'; 84 81 } 85 82 86 83 if ( bp_is_active( 'messages' ) ) { 87 $callbacks[] = ' bp_messages_register_sitewide_notices_widget';84 $callbacks[] = 'BP_Messages_Sitewide_Notices_Widget'; 88 85 } 89 86 90 87 if ( bp_is_active( 'blogs' ) && bp_is_active( 'activity' ) && bp_is_root_blog() ) { 91 $callbacks[] = ' bp_blogs_register_recent_posts_widget';88 $callbacks[] = 'BP_Blogs_Recent_Posts_Widget'; 92 89 } 93 90 94 foreach ( $callbacks as $callback ) { 95 remove_action( 'widgets_init', $callback ); 91 // Widget base is the callback in lowercase letters. Sigh. 92 $legacy_widgets_base = array_map( 'strtolower', $callbacks ); 93 94 foreach ( $legacy_widgets_base as $key => $widget_base ) { 95 if ( ! is_active_widget( false, false, $widget_base ) ) { 96 unregister_widget( $callbacks[ $key ] ); 97 } 96 98 } 97 99 } 98 add_action( 'widgets_init', 'bp_core_maybe_unhook_legacy_widgets', 0 );100 add_action( 'widgets_init', 'bp_core_maybe_unhook_legacy_widgets', 20 );