function theme_print_widgets($widgets, $style) { if (!is_array($widgets) || count($widgets) < 1) { return false; } foreach ($widgets as $widget) { echo theme_get_widget_meta_option($widget['name'], 'theme_widget_styling'); if ($widget['name']) { $widget_style = theme_get_widget_style($widget['name'], $style); theme_wrapper($widget_style, $widget); } else { echo $widget['content']; } } return true; }
function theme_print_widgets($widgets, $style) { if (!is_array($widgets) || count($widgets) < 1) { return false; } for ($i = 0; $i < count($widgets); $i++) { $widget = $widgets[$i]; if ($widget['id']) { $widget_style = theme_get_widget_style($widget['id'], $style); theme_wrapper($widget_style, $widget); } else { echo $widget['content']; } } return true; }
function theme_get_dynamic_sidebar_data($sidebar_id) { global $theme_widget_args, $theme_sidebars; $sidebar_style = theme_get_option('theme_sidebars_style_' . $theme_sidebars[$sidebar_id]['group']); theme_ob_start(); $success = dynamic_sidebar($sidebar_id); $content = theme_ob_get_clean(); if (!$success) { return false; } extract($theme_widget_args); $data = explode($after_widget, $content); $widgets = array(); $heading = theme_get_option('theme_' . (is_home() ? 'posts' : 'single') . '_widget_title_tag'); for ($i = 0; $i < count($data); $i++) { $widget = $data[$i]; if (theme_is_empty_html($widget)) { continue; } $id = null; $name = null; $class = null; $style = $sidebar_style; $title = null; if (preg_match('/<widget(.*?)>/', $widget, $matches)) { if (preg_match('/id="(.*?)"/', $matches[1], $ids)) { $id = $ids[1]; } if (preg_match('/name="(.*?)"/', $matches[1], $names)) { $name = $names[1]; } if (preg_match('/class="(.*?)"/', $matches[1], $classes)) { $class = $classes[1]; } if ($name) { $style = theme_get_widget_style($name, $style); } $widget = preg_replace('/<widget[^>]+>/', '', $widget); if (preg_match('/<title>(.*)<\\/title>/', $widget, $matches)) { $title = $matches[1]; $widget = preg_replace('/<title>.*?<\\/title>/', '', $widget); } } $widgets[] = array('id' => $id, 'name' => $name, 'class' => $class, 'style' => $style, 'title' => $title, 'heading' => $heading, 'content' => $widget); } return array_filter($widgets, 'theme_is_displayed_widget'); }
function theme_widget_extra_control() { global $wp_registered_widget_controls, $theme_widgets_style; $params = func_get_args(); $id = $params[count($params) - 1]; $id_disp = 'widget-style'; $val = theme_get_widget_style($id); $widget_controls = theme_get_array_value($wp_registered_widget_controls, $id, array()); if (isset($widget_controls['callback_redirect'])) { $callback = $widget_controls['callback_redirect']; if (is_callable($callback)) { call_user_func_array($callback, $params); } } ?> <h3 style="margin-bottom:3px;"><?php _e('Theme Options', THEME_NS); ?> </h3> <p> <label for="<?php echo $id_disp; ?> "><?php echo __('Appearance', THEME_NS) . ':'; ?> </label><br /> <select class="widefat" id="<?php echo $id_disp; ?> " name="<?php echo $id_disp; ?> "> <?php foreach ($theme_widgets_style as $key => $option) { $selected = $val == $key ? ' selected="selected"' : ''; echo '<option' . $selected . ' value="' . $key . '">' . $option . '</option>'; } ?> </select> </p> <?php }