function widget($args, $instance) { // only show widget on single pages if (!is_singular()) { return; } $content = apply_filters('tinytoc_widget_content', $GLOBALS['posts'][0]->post_content); $min = $instance['min']; $toc = tinyTOC::create($content, $min); if (!$toc) { return; } extract($args); //Our variables from the widget settings. $title = apply_filters('widget_title', $instance['title']); echo $before_widget; // Display the widget title if ($title) { echo $before_title . $title . $after_title; } echo $toc; echo $after_widget; }
private static function update_05($old_options = array()) { $options = array(); foreach ($old_options as $key => $value) { $key = 'general_' . $key; $options[$key] = $value; } switch ($options['general_position']) { case 'above': $options['general_position'] = 'before'; break; case 'below': $options['general_position'] = 'after'; break; case 'neither': $options['general_position'] = 'false'; break; } if (!isset($options['general_widget'])) { $options['general_widget'] = false; } unset($options['general_use_css']); self::$options = wp_parse_args($options, self::$options); update_option('tinytoc_options', self::$options); delete_option('tiny_toc_options'); }