is_active_widget [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Whether widget is displayed on the front-end.
Either $callback or $id_base can be used $id_base is the first argument when extending WP_Widget class Without the optional $widget_id parameter, returns the ID of the first sidebar in which the first instance of the widget with the given callback or $id_base is found. With the $widget_id parameter, returns the ID of the sidebar where the widget with that callback/$id_base AND that ID is found.
NOTE: $widget_id and $id_base are the same for single widgets. To be effective this function has to run after widgets have initialized, at action 'init' or later.
Source
<?php
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true) {
global $wp_registered_widgets;
$sidebars_widgets = wp_get_sidebars_widgets();
if ( is_array($sidebars_widgets) ) {
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( $skip_inactive && 'wp_inactive_widgets' == $sidebar )
continue;
if ( is_array($widgets) ) {
foreach ( $widgets as $widget ) {
if ( ( $callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback ) || ( $id_base && _get_widget_id_base($widget) == $id_base ) ) {
if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] )
return $sidebar;
}
}
}
}
}
return false;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/is active widget « WordPress Codex
Description. This Conditional Tag checks whether widget is displayed on the front -end. This is a boolean function, meaning it returns either TRUE or FALSE.
codex.wordpress.org - widgets - How do I use is_active_widget? - WordPress
Jul 18, 2011 ... The enqueueing in itself works, it is the is_active_widget that doesn't work. The widget itself works too, and displays correctly. Just the fancybox ...
wordpress.stackexchange.com - how to get is_active_widget on active/runnning page? - Stack Overflow
Oct 12, 2011 ... I'm looking for a solution to check is_active_widget on particular page. ... Seems that this is_active_widget function only check for general ...
stackoverflow.com - Checking if a Widget has Been Activated in WordPress | bavotasan ...
Feb 4, 2009... the following code. is_active_widget('name_of_widget') ... Check this link. http:// codex.wordpress.org/Function_Reference/is_active_widget ...
bavotasan.com