Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/14/2021 01:50:38 AM (4 years ago)
Author:
imath
Message:

Add a new function to check if a Widget/Block is active into a sidebar

Some of our Legacy Widgets are being displayed only if active they have been included into a Sidebar Widget. We are using the is_active_widget() WordPress function to check whether it is the case or not. This function doesn't fit in the Widget Blocks case as all Blocks are being inserted into the specific WP_Widget_Block widget.

As WordPress 5.8 doesn't provide any equivalent (so far?), we are introducing a new function to do this check: bp_is_widget_block_active(). It takes 2 optional arguments.

  • $block_name: the name of the block you need to check (eg: 'bp/members').
  • $widget_id_base: the Base ID of the widget (eg: 'bp_messages_sitewide_notices_widget').

You can use it to check a block, a widget or both.

Fixes #8515

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r12947 r12997  
    376376 */
    377377function bp_nouveau_is_object_nav_in_sidebar() {
    378     return is_active_widget( false, false, 'bp_nouveau_sidebar_object_nav_widget', true );
     378    return bp_is_widget_block_active( 'bp/primary-nav', 'bp_nouveau_sidebar_object_nav_widget' );
    379379}
    380380
Note: See TracChangeset for help on using the changeset viewer.