Created
May 15, 2015 22:48
-
-
Save cyberhobo/09d13085ac4534465fc8 to your computer and use it in GitHub Desktop.
Get a WordPress registered widget instance settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_widget_instance( $widget_id ) { | |
global $wp_registered_widgets; | |
if ( empty( $wp_registered_widgets[$widget_id]['callback'] ) ) | |
return array(); | |
/** @var WP_Widget $widget */ | |
$widget = $wp_registered_widgets[$widget_id]['callback'][0]; | |
$settings = $widget->get_settings(); | |
return ! empty( $settings[$widget->number] ) ? $settings[$widget->number] : array(); | |
} |
this just returns the widget defaults not the values of the widget instance, is this correct?
No, returns the current widget settings.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this just return the widget defaults not the values of the widget instance, is this correct?