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
- Adding iframe Content to Sidebar Widget
- Storing custom dashboard widget options in wordpress
- $post>ID displays wrong post ID
- Video Embed in Sidebar Widget with Links to Others in Category
- Shortcode from a widget is wrapped in unwanted element
- How can I whitelist only specific shortcodes for processing in text widgets?
- Bookshelf plugin and/or widget [closed]
- How to update widget from widget() function?
- Manual display of widget
- Add a banner to the Dashboard
- How to access widget data from outside widget?
- Unable to get Alert function to consistently work with backend widget with latest WP
- How to add a description to Widgets?
- Widget options get
- How to enable / use new video / audio / images widgets in WordPress 4.8?
- Latest/Recent posts widget title link
- Insert Widget option into mark-up with register_sidebar
- Widgets not expanding on wordpress 3.3 widget dashbord
- How do i display the built-in gallery inside a widget?
- Forcing the title of a text widget on to a new line in the admin area
- Removing default theme widgets
- Sidebar not show customizer!
- wp_register_sidebar_widget() disappered my Widgets submenu – what am I doing wrong?
- Display single widget
- Customizing wordpress default widgets?
- different class (css) for sidebar widgets
- Adding widgets with Featured Image via the Customizer run hundreds of queries
- how to put functions inside of widgets
- Adding a Widget : what to put in plugin URL
- How to list all custom post types in a custom widget?
- How can I assign widgets from WP to appear in bbpress?
- get_option returns undesired blank instance of a widget
- escaping and sanitizing input for custom widget form fields
- Dynamic created widget id value of multi-instance in jQuery
- Text widget doesn’t save the content
- Adding Widgets to Draft Pages
- How to select multiple media files for a widget form?
- Create an extra Widget Areas in WordPress TwentyTwelve
- Apply code for all else first block
- How i can widget ID get after drag for wordpress with jquery?
- Turn off “This is the Primary Sidebar Widget Area” message
- dynamic sidebar in front page
- Adding a WordPress Widget to a settings page
- How to change “Call To +1800090098” in TopStore pro theme [closed]
- How to dynamically add the the input text field in widget?
- Header Sidebar Won’t Move Lower – Want to Align with Header Logo [closed]
- display widget checkbox selection on frontend
- Enabled checkbox by default in WordPress widgets
- Is there a way to use get_sidebar() when no widgets are activated?
- Is there any tab widget plugin supporting third party widgets? [closed]
- Add footer widgets
- Widgets in WP 4.3 disappearing – How to fix?
- modifying title (in dashboard) for different widget instances
- How to translate Widget Description in constructor?
- Custom CSS for a particular text/html widget in WordPress
- Removing side bar widgets from GovPress theme
- Adding a single text input field to a custom Dashboard widget
- how to show only particular category post in archive widgets
- How do I customize the positioning of WordPress widgets?
- Limit archive widget results
- How can I detemine the parameters needed by the_widget()?
- widgets in footer?
- Can you hide a widget based on its content?
- Fatal error: Uncaught Error: Class ‘WP_Widget’ not found
- Array showing all values of loop instead of specific value to post
- Widget not appearing in customizer
- How can I have sidebar widgets on Twenty Seventeen theme on all pages?
- Loop through Widgets in sidebar using widget array number?
- Widget settings disappear after refresh
- Make a widget to my footer
- How to change text of a widget depend on condition?
- Always show the widget title in a wordpress widget
- Custom php Widget keeps disappearing from the front end
- Display Posts by Views (Popular Posts Widget)
- Default WordPress widgets always appear
- Add space to the end on a widget
- Show editor widgets only on pages that use a specific template?
- Conditionally enable autoplay when using oEmbed in a custom widget
- Options page for widget
- user definable sidebar per page
- List.js inside WordPress widget
- Show or hide custom menu widget in side bar conditionally
- Post Thumbnails on Sidebar Widgets
- Using Conditional Tags to restrict something to 1 user?
- Problem on register/login widgets
- Classic widgets with 5.9+?
- Can’t edit the widgets sidebar or footer
- Custom dashboard widget – load style only for added widget