Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#8515 closed task (fixed)

Introduce a new function to check if a Widget or a Widget Block is active into a sidebar

Reported by: imath's profile imath Owned by: imath's profile imath
Milestone: 9.0.0 Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

Some of our Legacy Widgets are being displayed only if active into a sidebar. We are using the is_active_widget() WordPress function. I haven't found an equivalent for Widget Blocks and is_active_widget() doesn't fit in this case are all Blocks are inside a specific widget that renders blocks -> WP_Widget_Block.

Attachments (1)

8515.patch (5.1 KB) - added by imath 3 years ago.

Download all attachments as: .zip

Change History (3)

@imath
3 years ago

#1 @imath
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 12997:

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

#2 @imath
3 years ago

In 12998:

Introduce a new BP_Component property for block globals

This new property will help us to manage Widget Block occurrences globals and use a single filter on 'widget_block_dynamic_classname' to make sure Widget Blocks will include Legacy Widget classnames and inherit their styles.

This commit also makes sure WordPress is >= 5.0 before using the has_block function.

See #8515
Fixes #8516

Note: See TracTickets for help on using tickets.