This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cornerstone/inc/reg-sidebars.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
87 lines (78 sloc)
2.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register widget area. | |
* | |
* @link http://codex.wordpress.org/Function_Reference/register_sidebar | |
*/ | |
if ( function_exists('register_sidebar') ) { | |
register_sidebar(array( | |
'name' => __( 'Sidebar', 'theme_text_domain' ), | |
'id' => 'sidebar', | |
'description' => 'Appears with Archives, Search Results, the Blog page template, and when viewing single posts.', | |
'class' => 'sidebar', | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<div class="widget-head"><h2 class="widget-title">', | |
'after_title' => '</h2></div>' | |
)); | |
register_sidebar( array( | |
'name' => __( 'Mega Footer' ), | |
'id' => 'mega-footer', | |
'description' => 'Limited to 6 widgets. Will appear at the bottom of every page in the site.', | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<div class="widget-head"><h2 class="widget-title">', | |
'after_title' => '</h2></div>' | |
) ); | |
for($i=0; $i<60; $i++){ | |
register_sidebar(array( | |
'name' => __( 'Home '.$i, 'theme_text_domain' ), | |
'id' => 'home'.$i, | |
'class' => 'sidebar', | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<div class="widget-head"><h2 class="widget-title">', | |
'after_title' => '</h2></div>' | |
)); | |
} | |
} | |
// if no title then add widget content wrapper to before widget | |
add_filter( 'dynamic_sidebar_params', 'check_sidebar_params' ); | |
function check_sidebar_params( $params ) { | |
global $wp_registered_widgets; | |
$settings_getter = $wp_registered_widgets[ $params[0]['widget_id'] ]['callback'][0]; | |
$settings = $settings_getter->get_settings(); | |
$settings = $settings[ $params[1]['number'] ]; | |
if ( $params[0][ 'after_widget' ] == '</div></aside>' && isset( $settings[ 'title' ] ) && empty( $settings[ 'title' ] ) ){ | |
$params[0][ 'before_widget' ] .= '<div class="widget-content ccc">'; | |
} | |
#Counts widgets in mega footer and adds column class accordingly | |
if( $params[0]['id'] == 'mega-footer' ){ | |
if( is_multisite() ){ | |
$widgets = get_site_option('sidebars_widgets')['mega-footer']; | |
} else { | |
$widgets = get_option('sidebars_widgets')['mega-footer']; | |
} | |
$count = count($widgets); | |
if( $count > 6 ){ | |
$cols = 2; | |
} else { | |
$cols = floor(12 / $count); | |
} | |
$params[0]['before_widget'] = str_replace('class="', 'class="col-xs-' . $cols . ' ', $params[0]['before_widget']); | |
} | |
return $params; | |
} | |
function mf_remove_extra( $sidebars_widgets ){ | |
$widgets = $sidebars_widgets['mega-footer']; | |
if( is_array($sidebars_widgets['mega-footer']) ){ | |
foreach ($sidebars_widgets['mega-footer'] as $i => $widget) { | |
if( $i > 6 ){ | |
unset($sidebars_widgets['mega-footer'][$i]); | |
} | |
} | |
} | |
return $sidebars_widgets; | |
} | |
add_filter( 'sidebars_widgets', 'mf_remove_extra' ); | |
?> |