scarstens
8/8/2012 - 11:16 PM

Footer Widget and Custom Count Widgets Class for WLFW

Footer Widget and Custom Count Widgets Class for WLFW

<?php

register_sidebar(array(
	'name' => __( 'Footer Sidebar' ),
	'id' => 'footer-sidebar',
	'description' => __( 'Widgets in this area will be shown on the footer.' ),
	'before_widget' => '<div id="%1$s" class="grid_4 widget %2$s">',
	'after_widget' => '</div>',
	'before_title' => '<h4 class="widgettitle">',
	'after_title' => '</h4>'
));

add_filter('dynamic_sidebar_params', 'wlfw_number_widgets_by_class');

function wlfw_number_widgets_by_class($instance ='', $this='', $args=''){
	global $sidebars_widgets;
	$sidebars_widgets_flip = array_flip($sidebars_widgets['footer-sidebar']);
	$current_count = $sidebars_widgets_flip[$instance[0]['widget_id']];
	$instance[0]['before_widget'] = preg_replace('~(.*?class\=\")(.*?)(\".*)~',"$1$2 ".'widget_'.($current_count+1)."$3",$instance[0]['before_widget']);
	//var_export($instance);
	return $instance;
}