why i cant use the var $i from my loop to call the function ?
for ($i=1; $i <= 10; $i++){
$widget_id = $i;
$sidebar_id = 'sidebar-ourfocus';
$widget_type = 'ctup-ads-widget';
$widclass = get_sidebar_widget_options($sidebar_id, $widget_type, $widget_id);
}
If i use fixed value for the widget_id it is no problem
$widclass = get_sidebar_widget_options($sidebar_id, $widget_type, '1');
function get_sidebar_widget_options($sidebar_id, $widget_type, $widget_id)
{
// Grab the list of sidebars and their widgets
$sidebars = wp_get_sidebars_widgets();
// Just grab the widgets for our sidebar
$widgets = $sidebars[$sidebar_id];
// If we didn't find the given widget in the given sidebar, throw an error
if ( !$widget_id )
throw new Exception("Widget not found in sidebar");
// Grab the options of each instance of our $widget_type from the DB
$options = get_option('widget_' . $widget_type);
// Ensure there are settings to return
if ( !isset($options[$widget_id]) )
throw new Exception("Widget has no saved options");
// Grab the settings
$widget_options = $options[$widget_id];
return $widget_options;
I tried also to convert the $i to String like
$widget_id = (string) $i;
But it didnt helped :/