[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Core Component Widgets. 4 * 5 * @package BuddyPress 6 * @subpackage Core 7 * @since 1.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Should BuddyPress load Legacy Widgets? 15 * 16 * @since 10.0.0 17 * 18 * @return bool False if BuddyPress shouldn't load Legacy Widgets. True otherwise. 19 */ 20 function bp_core_retain_legacy_widgets() { 21 $theme_supports = current_theme_supports( 'widgets-block-editor' ); 22 $wp_supports = bp_is_running_wp( '5.8.0' ); 23 24 /** This filter is documented in wp-includes/widgets.php */ 25 $block_widgets_enabled = $theme_supports && apply_filters( 'use_widgets_block_editor', $wp_supports ); 26 27 $retain_legacy_widgets = true; 28 if ( $block_widgets_enabled ) { 29 $retain_legacy_widgets = false; 30 } 31 32 /** 33 * Filter here to force Legacy Widgets to be retained or not. 34 * 35 * @since 10.0.0 36 * 37 * @param bool $retain_legacy_widgets False if BuddyPress shouldn't load Legacy Widgets. True otherwise. 38 */ 39 return apply_filters( 'bp_core_retain_legacy_widgets', $retain_legacy_widgets ); 40 } 41 42 /** 43 * Registers the Login widget. 44 * 45 * @since 10.0.0 46 */ 47 function bp_core_register_login_widget() { 48 register_widget( 'BP_Core_Login_Widget' ); 49 } 50 51 /** 52 * Register bp-core widgets. 53 * 54 * @since 1.0.0 55 */ 56 function bp_core_register_widgets() { 57 add_action( 'widgets_init', 'bp_core_register_login_widget' ); 58 } 59 add_action( 'bp_register_widgets', 'bp_core_register_widgets' ); 60 61 /** 62 * Checks whether BuddyPress should unhook Legacy Widget registrations. 63 * 64 * @since 10.0.0 65 */ 66 function bp_core_maybe_unhook_legacy_widgets() { 67 if ( bp_core_retain_legacy_widgets() ) { 68 return; 69 } 70 71 $callbacks = array( 72 'BP_Core_Login_Widget' => 'bp_core_register_login_widget', 73 'BP_Core_Members_Widget' => 'bp_members_register_members_widget', 74 'BP_Core_Whos_Online_Widget' => 'bp_members_register_whos_online_widget', 75 'BP_Core_Recently_Active_Widget' => 'bp_members_register_recently_active_widget', 76 ); 77 78 if ( bp_is_active( 'friends' ) ) { 79 $callbacks['BP_Core_Friends_Widget'] = 'bp_friends_register_friends_widget'; 80 } 81 82 if ( bp_is_active( 'groups' ) ) { 83 $callbacks['BP_Groups_Widget'] = 'bp_groups_register_groups_widget'; 84 } 85 86 if ( bp_is_active( 'messages' ) ) { 87 $callbacks['BP_Messages_Sitewide_Notices_Widget'] = 'bp_messages_register_sitewide_notices_widget'; 88 } 89 90 if ( bp_is_active( 'blogs' ) && bp_is_active( 'activity' ) && bp_is_root_blog() ) { 91 $callbacks['BP_Blogs_Recent_Posts_Widget'] = 'bp_blogs_register_recent_posts_widget'; 92 } 93 94 foreach ( $callbacks as $widget_id => $callback ) { 95 $widget_base = strtolower( $widget_id ); 96 97 // If there's an active widget, we need to carry on loading it. 98 if ( is_active_widget( false, false, $widget_base ) ) { 99 continue; 100 } 101 102 remove_action( 'widgets_init', $callback ); 103 } 104 } 105 add_action( 'widgets_init', 'bp_core_maybe_unhook_legacy_widgets', 0 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |