mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Make is_active_widget() optionally look in 'wp_inactive_widgets' for use in the admin
git-svn-id: https://develop.svn.wordpress.org/trunk@11164 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -816,15 +816,19 @@ function dynamic_sidebar($index = 1) {
|
||||
* @param callback Optional, Widget callback to check.
|
||||
* @param int $widget_id Optional, but needed for checking. Widget ID.
|
||||
* @param string $id_base Optional, the base ID of a widget created by extending WP_Widget.
|
||||
* @param bool $skip_inactive Optional, whether to check in 'wp_inactive_widgets'.
|
||||
* @return mixed false if widget is not active or id of sidebar in which the widget is active.
|
||||
*/
|
||||
function is_active_widget($callback = false, $widget_id = false, $id_base = false) {
|
||||
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(false);
|
||||
|
||||
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 && preg_replace( '/-[0-9]+$/', '', $widget ) == $id_base ) ) {
|
||||
|
||||
Reference in New Issue
Block a user