Left-sidebar-check improvement

Make php logic more fail-proof.
This commit is contained in:
Unknown 2018-03-28 11:50:47 -06:00
parent 5eae85e137
commit a068183c08
1 changed files with 6 additions and 5 deletions

View File

@ -19,16 +19,18 @@ $sidebar_pos = get_theme_mod( 'understrap_sidebar_position' );
$html = ''; $html = '';
if ( 'right' === $sidebar_pos || 'left' === $sidebar_pos ) { if ( 'right' === $sidebar_pos || 'left' === $sidebar_pos ) {
$html = '<div class="'; $html = '<div class="';
if ( is_active_sidebar( 'right-sidebar' ) || is_active_sidebar( 'left-sidebar' ) ) { if ( ( is_active_sidebar( 'right-sidebar' ) && 'right' === $sidebar_pos ) || ( is_active_sidebar( 'left-sidebar' ) && 'left' === $sidebar_pos ) ) {
$html .= 'col-md-8 content-area" id="primary">'; $html .= 'col-md-8 content-area" id="primary">';
} else { } else {
$html .= 'col-md-12 content-area" id="primary">'; $html .= 'col-md-12 content-area" id="primary">';
} }
echo $html; // WPCS: XSS OK. echo $html; // WPCS: XSS OK.
} elseif ( is_active_sidebar( 'right-sidebar' ) && is_active_sidebar( 'left-sidebar' ) ) { } elseif ( 'both' === $sidebar_pos ) {
$html = '<div class="'; $html = '<div class="';
if ( 'both' === $sidebar_pos ) { if ( is_active_sidebar( 'right-sidebar' ) && is_active_sidebar( 'left-sidebar' ) ) {
$html .= 'col-md-6 content-area" id="primary">'; $html .= 'col-md-6 content-area" id="primary">';
} elseif ( is_active_sidebar( 'right-sidebar' ) || is_active_sidebar( 'left-sidebar' ) ) {
$html .= 'col-md-8 content-area" id="primary">';
} else { } else {
$html .= 'col-md-12 content-area" id="primary">'; $html .= 'col-md-12 content-area" id="primary">';
} }
@ -36,4 +38,3 @@ $sidebar_pos = get_theme_mod( 'understrap_sidebar_position' );
} else { } else {
echo '<div class="col-md-12 content-area" id="primary">'; echo '<div class="col-md-12 content-area" id="primary">';
} }