One could e.g. get the widget blocks data with:
$widget_blocks = get_option( 'widget_block' );
and then loop through the array and run has_block() on the contant part, e.g. like (untested):
function is_active_block_widget_wpse( $blockname )
$widget_blocks = get_option( 'widget_block' );
foreach( (array) $widget_blocks as $widget_block ) {
if ( ! empty( $widget_block['content'] )
&& has_block( $blockname, $widget_block['content'] )
) {
return true;
}
}
return false;
}
to find if a given blockname is an active widget:
is_active_block_widget_wpse( 'my-plugin/my-block' )
We note that this simple implementation assumes none inactive block widgets.
Other helpful functions: wp_get_sidebars_widgets() and is_active_widget()
Related Posts:
- How to disable Widget Gutenberg Blocks?
- Converting a WordPress widget to a block
- Is there an official email form widget or block?
- How to allow your custom widget as block in gutemberg editor
- isSavingPost() for widgets
- Is there any way to parse blocks inside widget area?
- How Migrate a Legacy Widget to block?
- WordPress 5.8 : display new widget
- Determine if a specific Gutenberg block is used on pages/posts
- When editing in block editor, the post/article gets under the floating widgets
- Widget block editor: Unable to collect checkbox values inside widget update() method
- getBlockVariations(…) is undefined in Widget and Template Part editors but not Post Editor
- How to insert a block in a widget which links to a entry/page
- WordPress 3.8 – Dashboard 1 Column Screen Options
- Executing Javascript When a Widget is Added in the Backend
- Give Editor Access To Sidebar
- Get number of widgets in sidebar
- How to edit widgets in WordPress
- Extend WordPress 3.8 Site Activity Dashboard Widget to include more comments
- Enabling jquery when dragging available widget to sidebar area
- How to display custom widget anywhere
- Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?
- Complex widget form UI – examples and best practices
- PHP Coding Standards, Widgets and Sanitization
- Different widgets on different page templates?
- Widgets not displaying in theme customizer
- Register multiple sidebars
- How to add a filter to all widget output
- Where to get the unsaved list of widgets in customizer?
- Widget Update Code Not Working
- Reorder dashboard widgets
- Is It Possible to Restore Accidentally Deleted Widgets?
- How Can I Duplicate a Widget?
- How do I create a widget that only allows a single instance?
- Using tabs in admin widgets [closed]
- Widget “Save” resetting jQuery hidden fields
- How to add class on Widget Title
- Create variable from widget instance
- Save/update widget outside admin panel [closed]
- Why use widgets?
- Completely disabling widgets
- How do I pass arguments to dashboard widget callback functions?
- Creating your own widgets: using cache?
- Bolding specific word(s)/parts of widget title
- Adding a widget to a string of HTML
- How to add a class to a link in text editor
- WordPress widget new instance creates content duplicates
- Pass variables from one widget to another widget
- Remove the widgets tab from theme customizer
- Remove/Add widgets from/to the Available Widgets pool
- Remove/Unregister or hide a widget added by a plugin
- Check if widget is active
- Radio buttons in widget not saving
- How can I apply css styling to the current day in the calendar widget
- How to check if a widget has no title
- AJAX Contact Form Issue
- Including PHP files doesn’t work outside of Localhost
- Widget html code error
- Display sidebar only if it has content
- Post-specific widgets in WordPress ‘Twenty Fourteen’ theme
- Excluding specific widgets from default sidebar class
- How to truncate titles in Recent Posts widget?
- Can WordPress Read Its Own RSS Feed?
- Can’t see widget areas in my customizer
- Display custom widget, added as a shortcode in the correct place
- Debug errors on sidebar
- Dynamic sidebar based on category
- Show posts from one category with thumbnail and description on latest
- Widget textarea input gets formatted
- Show widget differently depending on if it’s in the sidebar or footer
- Get posts after today (upcoming events)
- How to pass data from page to widget functions?
- Adding a rich text editor to a widget – specifically CKEditor
- Enqueue script/style if certain widget has certain value
- How to display/register widget only on post pages in custom plugin
- Is it possible to display tag cloud widget by category?
- Widgets not saving values
- Widget page is missing from menu and default widgets are not showing
- wp_editor in widget breaks after save (no buttons and visual tab broken)
- How to use a dropdown to populate a list of post from CPT
- Fire on widgets_init only on dashboard
- Access Customizer widget instance form
- Allow shortcode for custom widget
- Registering a stylesheet inside my WordPress widget
- Insert widgets into loop/custom query at every nth position
- How to insert widgets into a post?
- Widget’s Content Mssing in Child Theme
- wrapper div for widgets not showing with all widgets
- call widget from within shortcode
- How to get class from widget area
- In widget, the value of select field doesn’t get updated, changes after saving
- Editing Help Section
- Searching for a one page overview widget
- How do I add after the tag in WordPress widget?
- Creating a simple button inside of a widget
- How to check widget-cpt meta and display its custom css in the head?
- How to place a widget beside a div/text so that they display as a continuous line
- How to Activate WordPress Widgets
- How to output built-in widgets with number in range as class?
- How can I create my own widgets in WordPress? [closed]