Skip to content

Commit

Permalink
Merge pull request weblab#103 from jmr06005/master
Browse files Browse the repository at this point in the history
Update to fix home 8-30 bug
  • Loading branch information
amb00010 committed Feb 17, 2015
2 parents 416a847 + 0ce94ef commit 624bdcc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
51 changes: 30 additions & 21 deletions css/widgets-area.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
<?php
$absolute_path = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
$wp_load = $absolute_path[0] . 'wp-load.php';
require_once($wp_load);

header("Content-type: text/css; charset: UTF-8");
header('Cache-control: must-revalidate');

$sidebars = wp_get_sidebars_widgets();
$index = 0;
for ($i=1; $i < 31 ; $i++) {
if( !empty($sidebars['home'.$i]) ){
if( $i > $index ){
$index = $i; //$index is the biggest home widget area that has widgets, the next widget area doesn't have widgets
}
}
}
$start = ++$index;
for ($i=$start; $i < 31; $i++) {
echo '#home'.$i.'{ display:none; } ';
}
<?php
$absolute_path = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
$wp_load = $absolute_path[0] . 'wp-load.php';
require_once($wp_load);

header("Content-type: text/css; charset: UTF-8");
header('Cache-control: must-revalidate');

$rows = get_theme_mod('homepagerows', '2');
$count = 1;
for($i=0; $i<$rows; $i++){
$widths = get_theme_mod('homepage_'.$i, '12');
$widths = explode(',',$widths);
if(count($widths) == 1) $widths[0] = 12;
foreach($widths as $width){
if($width == 0) break;
$count++;
}
}
$hidehomes = array();
$showhomes = array();
for ($i=$count; $i < 61; $i++) {
$hidehomes[] = '#home'.$i;
}
for ($i=1; $i < $count; $i++) {
$showhomes[] = '#home'.$i;
}
echo implode(', ',$hidehomes).' { display:none; } ';
echo implode(', ',$showhomes).' { display:block; } ';

?>
19 changes: 14 additions & 5 deletions page-home.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/
$rows = get_theme_mod('homepagerows', '2');
$count = 1;
get_header(); ?>
get_header();
?>

<div id="page-home">
<?php while ( have_posts() ) : the_post(); ?>
Expand All @@ -23,10 +24,18 @@
?>
<div class="col-sm-<?php echo $width; ?>">
<div class="home-section" id="home-section-<?php echo $count; ?>">
<?php if ( is_active_sidebar( 'home'.$count ) ) { ?>
<?php dynamic_sidebar( 'home'.$count ); ?>
<?php } else { ?>
<?php }; ?>
<?php if ( is_active_sidebar( 'home'.$count ) ) {
dynamic_sidebar( 'home'.$count );
} elseif(isset( $wp_customize )) {
?>
<div class="widget">
<h3>Home <?php echo $count; ?></h3>
We're in the customizer, this widget area is empty.
</div>
<?php
} else {

}?>
</div>
</div>
<?php $count ++; } ?>
Expand Down

0 comments on commit 624bdcc

Please sign in to comment.