Skip to content

Commit 6da0e61

Browse files
Add additional control to site-header using customizer
1 parent afd152e commit 6da0e61

File tree

3 files changed

+73
-54
lines changed

3 files changed

+73
-54
lines changed

lib/bootstrap.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,40 @@ function bfg_merge_genesis_attr_classes() {
7272
'footer-widget-area' => 'col-sm-6',
7373
'comment-list' => 'list-unstyled',
7474
'home-featured' => 'jumbotron',
75-
'site-header' => 'navbar navbar-expand-lg navbar-dark bg-dark',
75+
// 'site-header' => 'navbar navbar-expand-lg navbar-dark bg-dark',
7676
'entry-image' => 'img-fluid'
7777
);
78+
79+
$navclasses = array();
80+
81+
$navclasses[] = 'navbar';
82+
83+
$navposition = get_theme_mod( 'navposition', false );
84+
85+
$navclasses[] = $navposition;
86+
87+
$navcontainer = get_theme_mod( 'navcontainer', 'lg' );
88+
$navclasses[] = 'navbar-expand-' . $navcontainer;
89+
90+
$navcolor = get_theme_mod( 'navcolor', 'dark' );
91+
92+
switch( $navcolor ) {
93+
case 'light':
94+
$navclasses[] = 'navbar-light';
95+
$navclasses[] = 'bg-light';
96+
break;
97+
case 'dark':
98+
default:
99+
$navclasses[] = 'navbar-dark';
100+
$navclasses[] = 'bg-dark';
101+
break;
102+
case 'primary':
103+
$navclasses[] = 'navbar-dark';
104+
$navclasses[] = 'bg-primary';
105+
break;
106+
}
107+
108+
$classes['site-header'] = esc_attr( implode( ' ', $navclasses ) );
78109

79110
if ( has_filter( 'bfg_add_classes' ) ) {
80111
$classes = apply_filters( 'bfg_add_classes', $classes );

lib/kirki.php

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,6 @@
1717
'option_type' => 'theme_mod'
1818
) );
1919

20-
// General Section
21-
BFG_Kirki::add_section( 'general', array(
22-
'title' => __( 'General', 'bootstrap-for-genesis' ),
23-
'priority' => '1',
24-
'capability' => 'edit_theme_options'
25-
) );
26-
27-
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
28-
'type' => 'image',
29-
'settings' => 'logo',
30-
'label' => __( 'Logo', 'bootstrap-for-genesis' ),
31-
'description' => __( '', 'bootstrap-for-genesis' ),
32-
'section' => 'general',
33-
'default' => '',
34-
'priority' => 10
35-
) );
36-
37-
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
38-
'type' => 'image',
39-
'settings' => 'favicon',
40-
'label' => __( 'Favicon', 'bootstrap-for-genesis' ),
41-
'description' => __( '', 'bootstrap-for-genesis' ),
42-
'section' => 'general',
43-
'default' => '',
44-
'priority' => 15
45-
) );
46-
47-
// Header Section
48-
BFG_Kirki::add_section( 'header', array(
49-
'title' => __( 'Header', 'bootstrap-for-genesis' ),
50-
'priority' => '2',
51-
'capability' => 'edit_theme_options'
52-
) );
53-
5420
// Navigation Section
5521
BFG_Kirki::add_section( 'navigation', array(
5622
'title' => __( 'Navigation', 'bootstrap-for-genesis' ),
@@ -60,41 +26,58 @@
6026

6127
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
6228
'type' => 'select',
63-
'settings' => 'navtype',
29+
'settings' => 'navposition',
6430
'section' => 'navigation',
6531
'label' => __( 'Navigation Type', 'bootstrap-for-genesis' ),
6632
'description' => __( '', 'bootstrap-for-genesis' ),
6733
'priority' => 5,
6834
'choices' => array(
69-
'navbar-default' => __( 'Default', 'bootstrap-for-genesis' ),
70-
'navbar-static-top' => __( 'Static Top', 'bootstrap-for-genesis' ),
71-
'navbar-fixed-top' => __( 'Fixed Top', 'bootstrap-for-genesis' ),
72-
'navbar-fixed-bottom' => __( 'Fixed Bottom', 'bootstrap-for-genesis' ),
35+
'' => __( 'Default', 'bootstrap-for-genesis' ),
36+
'sticky-top' => __( 'Sticky Top', 'bootstrap-for-genesis' ),
37+
'fixed-top' => __( 'Fixed Top', 'bootstrap-for-genesis' ),
38+
'fixed-bottom' => __( 'Fixed Bottom', 'bootstrap-for-genesis' ),
7339
),
74-
'default' => 'navbar-default'
40+
'default' => ''
7541
) );
7642

7743
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
7844
'type' => 'select',
79-
'settings' => 'navalign',
45+
'settings' => 'navcontainer',
8046
'section' => 'navigation',
81-
'label' => __( 'Navigation Alignment', 'bootstrap-for-genesis' ),
47+
'label' => __( 'Navigation Container', 'bootstrap-for-genesis' ),
8248
'description' => __( '', 'bootstrap-for-genesis' ),
8349
'priority' => 10,
8450
'choices' => array(
85-
'navbar-left' => __( 'Default', 'bootstrap-for-genesis' ),
86-
'navbar-right' => __( 'Right', 'bootstrap-for-genesis' ),
51+
'sm' => __( 'Small', 'bootstrap-for-genesis' ),
52+
'md' => __( 'Medium', 'bootstrap-for-genesis' ),
53+
'lg' => __( 'Large', 'bootstrap-for-genesis' ),
54+
'xl' => __( 'Extra Large', 'bootstrap-for-genesis' )
8755
),
88-
'default' => ''
56+
'default' => 'lg'
57+
) );
58+
59+
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
60+
'type' => 'select',
61+
'settings' => 'navcolor',
62+
'section' => 'navigation',
63+
'label' => __( 'Navigation Color Scheme', 'bootstrap-for-genesis' ),
64+
'description' => __( '', 'bootstrap-for-genesis' ),
65+
'priority' => 15,
66+
'choices' => array(
67+
'light' => __( 'Light', 'bootstrap-for-genesis' ),
68+
'dark' => __( 'Dark', 'bootstrap-for-genesis' ),
69+
'primary' => __( 'Primary', 'bootstrap-for-genesis' )
70+
),
71+
'default' => 'dark'
8972
) );
9073

9174
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
9275
'type' => 'checkbox',
9376
'settings' => 'navextra',
9477
'label' => __( 'Display navigation extras?', 'bootstrap-for-genesis' ),
9578
'section' => 'navigation',
96-
'default' => '0',
97-
'priority' => 10
79+
'default' => 0,
80+
'priority' => 20
9881
) );
9982

10083
BFG_Kirki::add_field( 'bootstrap-for-genesis', array(
@@ -104,7 +87,7 @@
10487
'description' => __( '', 'bootstrap-for-genesis' ),
10588
'section' => 'navigation',
10689
'default' => 'search',
107-
'priority' => 15,
90+
'priority' => 25,
10891
'choices' => array(
10992
'date' => __( 'Date', 'bootstrap-for-genesis' ),
11093
'search' => __( 'Search Form', 'bootstrap-for-genesis' )
@@ -123,6 +106,6 @@
123106
'settings' => 'creds',
124107
'label' => __( 'Footer Credits', 'bootstrap-for-genesis' ),
125108
'section' => 'footer',
126-
'default' => '[footer_copyright] &middot; <a href="http://www.rotsenacob.com">Rotsen Mark Acob</a> &middot; Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>',
109+
'default' => '',
127110
'priority' => 10
128111
) );

lib/nav.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ function bfg_nav_menu_markup_filter( $html, $args ) {
5959
$output .= '<div class="collapse navbar-collapse" id="'.$data_target.'">';
6060
$output .= $html;
6161

62-
if ( get_theme_mod( 'navextra', false ) ) {
62+
$navextra = get_theme_mod( 'navextra', false );
63+
64+
if ( $navextra == true ) {
6365
$output .= apply_filters( 'bfg_navbar_content', bfg_navbar_content_markup() );
6466
}
6567

@@ -77,17 +79,20 @@ function bfg_navbar_brand_markup() {
7779
function bfg_navbar_content_markup() {
7880
$url = get_home_url();
7981

80-
$choices = get_theme_mod( 'select', false );
82+
$choices = get_theme_mod( 'select', 'search' );
83+
84+
$output = '';
85+
8186
switch( $choices ) {
8287
case 'search':
8388
default:
84-
$output = '<form class="form-inline float-lg-right" method="get" action="'.$url.'" role="search">';
89+
$output .= '<form class="form-inline float-lg-right" method="get" action="'.$url.'" role="search">';
8590
$output .= '<input class="form-control mr-sm-2" type="text" placeholder="Search" name="s">';
8691
$output .= '<button class="btn btn-outline-success" type="submit">Search</button>';
8792
$output .= '</form>';
8893
break;
8994
case 'date':
90-
$output = '<p class="navbar-text navbar-right">';
95+
$output .= '<p class="navbar-text navbar-right">';
9196
$output .= date_i18n( get_option( 'date_format' ) );
9297
$output .= '</p>';
9398
break;

0 commit comments

Comments
 (0)