Skip to content

Commit a147b1d

Browse files
Merge branch 'dev'
2 parents 848194c + 2a11f52 commit a147b1d

File tree

18 files changed

+8461
-2419
lines changed

18 files changed

+8461
-2419
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Bootstrap for Genesis is a genesis child theme which integrates [Twitter Bootstr
4343
* Tab Widget
4444
* Modal Widget
4545
11. Github Updater Support
46+
12. Customizer Library Support
4647

4748
## Credits
4849

@@ -62,3 +63,5 @@ Without these projects, this theme wouldn't be where it is today.
6263
* [Bones for Genesis 2.0 with Bootstrap integration](https://github.com/jer0dh/bones-for-genesis-2-0-bootstrap)
6364
* [SiteOrigin Widgets Bundle](https://wordpress.org/plugins/so-widgets-bundle/)
6465
* [AQ Resizer](https://github.com/syamilmj/Aqua-Resizer)
66+
* [Customizer Library](https://github.com/devinsays/customizer-library)
67+
* [GitHub Updater](https://github.com/afragen/github-updater)

functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ function bfg_google_fonts() {
7979
// Add TGM Plugin Activation Support
8080
add_theme_support( 'bfg-module-tgm' );
8181

82-
// Custom SiteOrigin Widgets
83-
require_once( BFG_THEME_MODULES . 'siteorigin/siteorigin.php' );
82+
// Customizer Helper
83+
require_once( BFG_THEME_MODULES . 'customizer-library/customizer-library.php' );
8484

8585
// Include php files from lib folder
8686
// @link https://gist.github.com/theandystratton/5924570

lib/customizer.php

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?php
2+
/**
3+
* Customizer Options
4+
*
5+
* @package Bootstrap for Genesis
6+
* @since 1.0
7+
* @link http://www.superfastbusiness.com
8+
* @author SuperFastBusiness <www.superfastbusiness.com>
9+
* @copyright Copyright (c) 2015, SuperFastBusiness
10+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11+
*
12+
*/
13+
14+
add_action( 'init', 'bfg_customizer_options' );
15+
function bfg_customizer_options() {
16+
// Stores all the controls that will be added
17+
$options = array();
18+
19+
// Stores all the sections to be added
20+
$sections = array();
21+
22+
// Stores all the panels to be added
23+
$panels = array();
24+
25+
// Adds the sections to the $options array
26+
$options['sections'] = $sections;
27+
28+
// Footer
29+
$section = 'footer';
30+
31+
$sections[] = array(
32+
'id' => $section,
33+
'title' => __( 'Footer', 'bfg' ),
34+
'priority' => '35',
35+
'description' => __( '', 'bfg' )
36+
);
37+
$options['footer'] = array(
38+
'id' => 'creds',
39+
'label' => __( 'Copyright', 'bfg' ),
40+
'section' => $section,
41+
'type' => 'text',
42+
'default' => ''
43+
);
44+
45+
// Typography
46+
$section = 'typography';
47+
$font_choices = customizer_library_get_font_choices();
48+
$sections[] = array(
49+
'id' => $section,
50+
'title' => __( 'Typography', 'bfg' ),
51+
'priority' => '30'
52+
);
53+
$options['heading-font'] = array(
54+
'id' => 'heading-font',
55+
'label' => __( 'Heading Font', 'bfg' ),
56+
'section' => $section,
57+
'type' => 'select',
58+
'choices' => $font_choices,
59+
'default' => 'Raleway'
60+
);
61+
$options['body-font'] = array(
62+
'id' => 'body-font',
63+
'label' => __( 'Body Font', 'bfg' ),
64+
'section' => $section,
65+
'type' => 'select',
66+
'choices' => $font_choices,
67+
'default' => 'Roboto'
68+
);
69+
70+
71+
// Adds the sections to the $options array
72+
$options['sections'] = $sections;
73+
74+
// Adds the panels to the $options array
75+
$options['panels'] = $panels;
76+
$customizer_library = Customizer_Library::Instance();
77+
$customizer_library->add_options( $options );
78+
79+
// To delete custom mods use: customizer_library_remove_theme_mods();
80+
}
81+
82+
// Enqueue Google Fonts via Customizer
83+
add_action( 'wp_enqueue_scripts', 'bfg_customizer_fonts' );
84+
function bfg_customizer_fonts() {
85+
// Font options
86+
$fonts = array(
87+
get_theme_mod( 'heading-font', customizer_library_get_default( 'heading-font' ) ),
88+
get_theme_mod( 'body-font', customizer_library_get_default( 'heading-font' ) )
89+
);
90+
$font_uri = customizer_library_get_google_font_uri( $fonts );
91+
92+
// Load Google Fonts
93+
wp_enqueue_style( 'customizer-fonts', $font_uri, array(), null, 'screen' );
94+
}
95+
96+
if ( ! function_exists( 'bfg_customizer_build_styles' ) && class_exists( 'Customizer_Library_Styles' ) ) {
97+
98+
add_action( 'customizer_library_styles', 'bfg_customizer_build_styles' );
99+
function bfg_customizer_build_styles() {
100+
// Heading font
101+
$setting = 'heading-font';
102+
$mod = get_theme_mod( $setting, customizer_library_get_default( $setting ) );
103+
$stack = customizer_library_get_font_stack( $mod );
104+
if ( $mod != customizer_library_get_default( $setting ) ) {
105+
Customizer_Library_Styles()->add( array(
106+
'selectors' => array(
107+
'.footer-widgets .widgettitle',
108+
'.widgettitle',
109+
'.h1',
110+
'.h2',
111+
'.h3',
112+
'.h4',
113+
'.h5',
114+
'.h6',
115+
'h1',
116+
'h2',
117+
'h3',
118+
'h4',
119+
'h5',
120+
'h6',
121+
'.widget_recent_entries li a',
122+
),
123+
'declarations' => array(
124+
'font-family' => $stack
125+
)
126+
) );
127+
}
128+
129+
// Body Font
130+
$setting = 'body-font';
131+
$mod = get_theme_mod( $setting, customizer_library_get_default( $setting ) );
132+
$stack = customizer_library_get_font_stack( $mod );
133+
if ( $mod != customizer_library_get_default( $setting ) ) {
134+
Customizer_Library_Styles()->add( array(
135+
'selectors' => array(
136+
'body',
137+
'.popover',
138+
'.tooltip',
139+
'.widget_recent_entries li span',
140+
'.site-header .site-description'
141+
),
142+
'declarations' => array(
143+
'font-family' => $stack
144+
)
145+
) );
146+
}
147+
}
148+
149+
}
150+
151+
if ( !function_exists( 'bfg_library_styles' ) ) {
152+
add_action( 'wp_head', 'bfg_library_styles' );
153+
function bfg_library_styles() {
154+
do_action( 'customizer_library_styles' );
155+
156+
$css = Customizer_Library_Styles()->build();
157+
158+
if ( !empty( $css ) ) {
159+
echo "\n<!-- Begin Custom CSS -->\n<style type=\"text/css\" id=\"bfg-custom-css\">\n";
160+
echo $css;
161+
echo "\n</style>\n<!-- End Custom CSS -->\n";
162+
}
163+
}
164+
}

lib/footer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
add_action( 'genesis_footer', 'bfg_do_footer' );
1717

1818
function bfg_do_footer() {
19-
$creds = '<a href="http://www.superfastbusiness.com">Bootstrap for Genesis</a> by <a href="http://www.superfastbusiness.com">SuperFastBusiness</a>';
20-
19+
if ( get_theme_mod( 'creds', false ) ) {
20+
$creds = get_theme_mod( 'creds' );
21+
} else {
22+
$creds = '<a href="http://www.superfastbusiness.com">Bootstrap for Genesis</a> by <a href="http://www.superfastbusiness.com">SuperFastBusiness</a>';
23+
}
24+
2125
genesis_markup(array(
2226
'html5' => '<div %s>',
2327
'xhtml' => '<div class="copyright">',
2428
'context' => 'copyright'
2529
));
26-
echo apply_filters( 'bfg_footer_creds', $creds );
30+
echo apply_filters( 'bfg_footer_creds', do_shortcode( $creds ) );
2731
echo '</div>';
2832

2933
if ( is_active_sidebar( 'footer-right' ) ) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Add controls for arbitrary heading, description, line
4+
*
5+
* @package Customizer_Library
6+
* @author Devin Price
7+
*/
8+
9+
if ( ! class_exists( 'WP_Customize_Control' ) ) {
10+
return NULL;
11+
}
12+
13+
class Customizer_Library_Content extends WP_Customize_Control {
14+
15+
// Whitelist content parameter
16+
public $content = '';
17+
18+
/**
19+
* Render the control's content.
20+
*
21+
* Allows the content to be overriden without having to rewrite the wrapper.
22+
*
23+
* @since 1.0.0
24+
* @return void
25+
*/
26+
public function render_content() {
27+
28+
switch ( $this->type ) {
29+
30+
case 'content' :
31+
32+
if ( isset( $this->label ) ) {
33+
echo '<span class="customize-control-title">' . $this->label . '</span>';
34+
}
35+
36+
if ( isset( $this->content ) ) {
37+
echo $this->content;
38+
}
39+
40+
if ( isset( $this->description ) ) {
41+
echo '<span class="description customize-control-description">' . $this->description . '</span>';
42+
}
43+
44+
break;
45+
46+
}
47+
48+
}
49+
50+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Customize for textarea, extend the WP customizer
4+
*
5+
* @package Customizer_Library
6+
* @author Devin Price, The Theme Foundry
7+
*/
8+
9+
if ( ! class_exists( 'WP_Customize_Control' ) ) {
10+
return NULL;
11+
}
12+
13+
class Customizer_Library_Textarea extends WP_Customize_Control {
14+
15+
/**
16+
* Render the control's content.
17+
*
18+
* Allows the content to be overriden without having to rewrite the wrapper.
19+
*
20+
* @since 1.0.0
21+
* @return void
22+
*/
23+
public function render_content() {
24+
?>
25+
<label>
26+
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
27+
<textarea class="large-text" cols="20" rows="5" <?php $this->link(); ?>>
28+
<?php echo esc_textarea( $this->value() ); ?>
29+
</textarea>
30+
</label>
31+
<?php
32+
}
33+
34+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Customizer Library
4+
*
5+
* @package Customizer_Library
6+
* @author Devin Price, The Theme Foundry
7+
* @license GPL-2.0+
8+
* @version 1.3.0
9+
*/
10+
11+
// If this file is called directly, abort.
12+
if ( ! defined( 'WPINC' ) ) {
13+
die;
14+
}
15+
16+
// Continue if the Customizer_Library isn't already in use.
17+
if ( ! class_exists( 'Customizer_Library' ) ) :
18+
19+
// Helper functions to output the customizer controls.
20+
require plugin_dir_path( __FILE__ ) . 'extensions/interface.php';
21+
22+
// Helper functions for customizer sanitization.
23+
require plugin_dir_path( __FILE__ ) . 'extensions/sanitization.php';
24+
25+
// Helper functions to build the inline CSS.
26+
require plugin_dir_path( __FILE__ ) . 'extensions/style-builder.php';
27+
28+
// Helper functions for fonts.
29+
require plugin_dir_path( __FILE__ ) . 'extensions/fonts.php';
30+
31+
// Utility functions for the customizer.
32+
require plugin_dir_path( __FILE__ ) . 'extensions/utilities.php';
33+
34+
// Customizer preview functions.
35+
require plugin_dir_path( __FILE__ ) . 'extensions/preview.php';
36+
37+
// Textarea control
38+
if ( version_compare( $GLOBALS['wp_version'], '4.0', '<' ) ) {
39+
require plugin_dir_path( __FILE__ ) . 'custom-controls/textarea.php';
40+
}
41+
42+
// Arbitrary content controls
43+
require plugin_dir_path( __FILE__ ) . 'custom-controls/content.php';
44+
45+
/**
46+
* Class wrapper with useful methods for interacting with the theme customizer.
47+
*/
48+
class Customizer_Library {
49+
50+
/**
51+
* The one instance of Customizer_Library.
52+
*
53+
* @since 1.0.0.
54+
*
55+
* @var Customizer_Library_Styles The one instance for the singleton.
56+
*/
57+
private static $instance;
58+
59+
/**
60+
* The array for storing $options.
61+
*
62+
* @since 1.0.0.
63+
*
64+
* @var array Holds the options array.
65+
*/
66+
67+
public $options = array();
68+
69+
/**
70+
* Instantiate or return the one Customizer_Library instance.
71+
*
72+
* @since 1.0.0.
73+
*
74+
* @return Customizer_Library
75+
*/
76+
public static function instance() {
77+
if ( is_null( self::$instance ) ) {
78+
self::$instance = new self();
79+
}
80+
81+
return self::$instance;
82+
}
83+
84+
public function add_options( $options = array() ) {
85+
$this->options = array_merge( $options, $this->options );
86+
}
87+
88+
public function get_options() {
89+
return $this->options;
90+
}
91+
92+
}
93+
94+
endif;

0 commit comments

Comments
 (0)