"; var $end_tag = ""; var $start_html = "
  • \n
    \n\n
    \n
  • "; function atom_widget_splitter(){ $widget_ops = array('classname' => 'splitter', 'description' => _a('Splits area into 2 columns')); $this->WP_Widget('atom-splitter', _a('Column Splitter'), $widget_ops); atom_add('area_check', array(&$this, 'area_check'), 10, 2); atom_add('widget_area', array(&$this, 'widget_area'), 10, 2); } function area_check($sidebar_content, $area_id){ // no point in going further if no splitters are active if(!defined('SPLITTER_ACTIVE')) return $sidebar_content; // ignore splitters when checking for active widgets return str_replace(array($this->start_tag, $this->end_tag), '', $sidebar_content); } function widget_area($sidebar_content, $area_id){ // no point in going further if no splitters are active if(!defined('SPLITTER_ACTIVE')) return $sidebar_content; // replace splitter string with html and show splitters if we have any other active widgets in the sidebar $sidebar_content = str_replace($this->start_tag, $this->start_html, $sidebar_content); $sidebar_content = str_replace($this->end_tag, $this->end_html, $sidebar_content); if(strpos($area_id, 'sidebar') !== false): // check splitters $all_widgets = wp_get_sidebars_widgets(); $splitters = 0; foreach($all_widgets as $sidebar => $sidebar_widgets) if($sidebar == $area_id) foreach($sidebar_widgets as $widget) if(strpos($widget, 'atom-splitter') !== false) $splitters++; if($splitters % 2): $sidebar_content .= $this->end_html; // odd splitter count => missing a splitter. atom_add_debug_message("Fixed a missing closing column splitter in {$area_id}. "); endif; endif; return $sidebar_content; } function widget($args, $instance){ global $__atom_widget_splitter; extract($args); defined("SPLITTER_ACTIVE") or define("SPLITTER_ACTIVE", true); if(!isset($__atom_widget_splitter)): $__atom_widget_splitter = true; echo $this->start_tag; // this will get replace with html when the sidebars are processed for the first time atom_add_debug_message("Column splitter opened in {$args['widget_id']} ({$args['widget_name']})."); else: unset($GLOBALS['__atom_widget_splitter']); echo $this->end_tag; atom_add_debug_message("Column splitter closed in {$args['widget_id']} ({$args['widget_name']})."); endif; } function form($instance){ ?>