-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
8,461 additions
and
2,419 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?php | ||
/** | ||
* Customizer Options | ||
* | ||
* @package Bootstrap for Genesis | ||
* @since 1.0 | ||
* @link http://www.superfastbusiness.com | ||
* @author SuperFastBusiness <www.superfastbusiness.com> | ||
* @copyright Copyright (c) 2015, SuperFastBusiness | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | ||
* | ||
*/ | ||
|
||
add_action( 'init', 'bfg_customizer_options' ); | ||
function bfg_customizer_options() { | ||
// Stores all the controls that will be added | ||
$options = array(); | ||
|
||
// Stores all the sections to be added | ||
$sections = array(); | ||
|
||
// Stores all the panels to be added | ||
$panels = array(); | ||
|
||
// Adds the sections to the $options array | ||
$options['sections'] = $sections; | ||
|
||
// Footer | ||
$section = 'footer'; | ||
|
||
$sections[] = array( | ||
'id' => $section, | ||
'title' => __( 'Footer', 'bfg' ), | ||
'priority' => '35', | ||
'description' => __( '', 'bfg' ) | ||
); | ||
$options['footer'] = array( | ||
'id' => 'creds', | ||
'label' => __( 'Copyright', 'bfg' ), | ||
'section' => $section, | ||
'type' => 'text', | ||
'default' => '' | ||
); | ||
|
||
// Typography | ||
$section = 'typography'; | ||
$font_choices = customizer_library_get_font_choices(); | ||
$sections[] = array( | ||
'id' => $section, | ||
'title' => __( 'Typography', 'bfg' ), | ||
'priority' => '30' | ||
); | ||
$options['heading-font'] = array( | ||
'id' => 'heading-font', | ||
'label' => __( 'Heading Font', 'bfg' ), | ||
'section' => $section, | ||
'type' => 'select', | ||
'choices' => $font_choices, | ||
'default' => 'Raleway' | ||
); | ||
$options['body-font'] = array( | ||
'id' => 'body-font', | ||
'label' => __( 'Body Font', 'bfg' ), | ||
'section' => $section, | ||
'type' => 'select', | ||
'choices' => $font_choices, | ||
'default' => 'Roboto' | ||
); | ||
|
||
|
||
// Adds the sections to the $options array | ||
$options['sections'] = $sections; | ||
|
||
// Adds the panels to the $options array | ||
$options['panels'] = $panels; | ||
$customizer_library = Customizer_Library::Instance(); | ||
$customizer_library->add_options( $options ); | ||
|
||
// To delete custom mods use: customizer_library_remove_theme_mods(); | ||
} | ||
|
||
// Enqueue Google Fonts via Customizer | ||
add_action( 'wp_enqueue_scripts', 'bfg_customizer_fonts' ); | ||
function bfg_customizer_fonts() { | ||
// Font options | ||
$fonts = array( | ||
get_theme_mod( 'heading-font', customizer_library_get_default( 'heading-font' ) ), | ||
get_theme_mod( 'body-font', customizer_library_get_default( 'heading-font' ) ) | ||
); | ||
$font_uri = customizer_library_get_google_font_uri( $fonts ); | ||
|
||
// Load Google Fonts | ||
wp_enqueue_style( 'customizer-fonts', $font_uri, array(), null, 'screen' ); | ||
} | ||
|
||
if ( ! function_exists( 'bfg_customizer_build_styles' ) && class_exists( 'Customizer_Library_Styles' ) ) { | ||
|
||
add_action( 'customizer_library_styles', 'bfg_customizer_build_styles' ); | ||
function bfg_customizer_build_styles() { | ||
// Heading font | ||
$setting = 'heading-font'; | ||
$mod = get_theme_mod( $setting, customizer_library_get_default( $setting ) ); | ||
$stack = customizer_library_get_font_stack( $mod ); | ||
if ( $mod != customizer_library_get_default( $setting ) ) { | ||
Customizer_Library_Styles()->add( array( | ||
'selectors' => array( | ||
'.footer-widgets .widgettitle', | ||
'.widgettitle', | ||
'.h1', | ||
'.h2', | ||
'.h3', | ||
'.h4', | ||
'.h5', | ||
'.h6', | ||
'h1', | ||
'h2', | ||
'h3', | ||
'h4', | ||
'h5', | ||
'h6', | ||
'.widget_recent_entries li a', | ||
), | ||
'declarations' => array( | ||
'font-family' => $stack | ||
) | ||
) ); | ||
} | ||
|
||
// Body Font | ||
$setting = 'body-font'; | ||
$mod = get_theme_mod( $setting, customizer_library_get_default( $setting ) ); | ||
$stack = customizer_library_get_font_stack( $mod ); | ||
if ( $mod != customizer_library_get_default( $setting ) ) { | ||
Customizer_Library_Styles()->add( array( | ||
'selectors' => array( | ||
'body', | ||
'.popover', | ||
'.tooltip', | ||
'.widget_recent_entries li span', | ||
'.site-header .site-description' | ||
), | ||
'declarations' => array( | ||
'font-family' => $stack | ||
) | ||
) ); | ||
} | ||
} | ||
|
||
} | ||
|
||
if ( !function_exists( 'bfg_library_styles' ) ) { | ||
add_action( 'wp_head', 'bfg_library_styles' ); | ||
function bfg_library_styles() { | ||
do_action( 'customizer_library_styles' ); | ||
|
||
$css = Customizer_Library_Styles()->build(); | ||
|
||
if ( !empty( $css ) ) { | ||
echo "\n<!-- Begin Custom CSS -->\n<style type=\"text/css\" id=\"bfg-custom-css\">\n"; | ||
echo $css; | ||
echo "\n</style>\n<!-- End Custom CSS -->\n"; | ||
} | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
lib/modules/customizer-library/custom-controls/content.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Add controls for arbitrary heading, description, line | ||
* | ||
* @package Customizer_Library | ||
* @author Devin Price | ||
*/ | ||
|
||
if ( ! class_exists( 'WP_Customize_Control' ) ) { | ||
return NULL; | ||
} | ||
|
||
class Customizer_Library_Content extends WP_Customize_Control { | ||
|
||
// Whitelist content parameter | ||
public $content = ''; | ||
|
||
/** | ||
* Render the control's content. | ||
* | ||
* Allows the content to be overriden without having to rewrite the wrapper. | ||
* | ||
* @since 1.0.0 | ||
* @return void | ||
*/ | ||
public function render_content() { | ||
|
||
switch ( $this->type ) { | ||
|
||
case 'content' : | ||
|
||
if ( isset( $this->label ) ) { | ||
echo '<span class="customize-control-title">' . $this->label . '</span>'; | ||
} | ||
|
||
if ( isset( $this->content ) ) { | ||
echo $this->content; | ||
} | ||
|
||
if ( isset( $this->description ) ) { | ||
echo '<span class="description customize-control-description">' . $this->description . '</span>'; | ||
} | ||
|
||
break; | ||
|
||
} | ||
|
||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
lib/modules/customizer-library/custom-controls/textarea.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Customize for textarea, extend the WP customizer | ||
* | ||
* @package Customizer_Library | ||
* @author Devin Price, The Theme Foundry | ||
*/ | ||
|
||
if ( ! class_exists( 'WP_Customize_Control' ) ) { | ||
return NULL; | ||
} | ||
|
||
class Customizer_Library_Textarea extends WP_Customize_Control { | ||
|
||
/** | ||
* Render the control's content. | ||
* | ||
* Allows the content to be overriden without having to rewrite the wrapper. | ||
* | ||
* @since 1.0.0 | ||
* @return void | ||
*/ | ||
public function render_content() { | ||
?> | ||
<label> | ||
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> | ||
<textarea class="large-text" cols="20" rows="5" <?php $this->link(); ?>> | ||
<?php echo esc_textarea( $this->value() ); ?> | ||
</textarea> | ||
</label> | ||
<?php | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
/** | ||
* Customizer Library | ||
* | ||
* @package Customizer_Library | ||
* @author Devin Price, The Theme Foundry | ||
* @license GPL-2.0+ | ||
* @version 1.3.0 | ||
*/ | ||
|
||
// If this file is called directly, abort. | ||
if ( ! defined( 'WPINC' ) ) { | ||
die; | ||
} | ||
|
||
// Continue if the Customizer_Library isn't already in use. | ||
if ( ! class_exists( 'Customizer_Library' ) ) : | ||
|
||
// Helper functions to output the customizer controls. | ||
require plugin_dir_path( __FILE__ ) . 'extensions/interface.php'; | ||
|
||
// Helper functions for customizer sanitization. | ||
require plugin_dir_path( __FILE__ ) . 'extensions/sanitization.php'; | ||
|
||
// Helper functions to build the inline CSS. | ||
require plugin_dir_path( __FILE__ ) . 'extensions/style-builder.php'; | ||
|
||
// Helper functions for fonts. | ||
require plugin_dir_path( __FILE__ ) . 'extensions/fonts.php'; | ||
|
||
// Utility functions for the customizer. | ||
require plugin_dir_path( __FILE__ ) . 'extensions/utilities.php'; | ||
|
||
// Customizer preview functions. | ||
require plugin_dir_path( __FILE__ ) . 'extensions/preview.php'; | ||
|
||
// Textarea control | ||
if ( version_compare( $GLOBALS['wp_version'], '4.0', '<' ) ) { | ||
require plugin_dir_path( __FILE__ ) . 'custom-controls/textarea.php'; | ||
} | ||
|
||
// Arbitrary content controls | ||
require plugin_dir_path( __FILE__ ) . 'custom-controls/content.php'; | ||
|
||
/** | ||
* Class wrapper with useful methods for interacting with the theme customizer. | ||
*/ | ||
class Customizer_Library { | ||
|
||
/** | ||
* The one instance of Customizer_Library. | ||
* | ||
* @since 1.0.0. | ||
* | ||
* @var Customizer_Library_Styles The one instance for the singleton. | ||
*/ | ||
private static $instance; | ||
|
||
/** | ||
* The array for storing $options. | ||
* | ||
* @since 1.0.0. | ||
* | ||
* @var array Holds the options array. | ||
*/ | ||
|
||
public $options = array(); | ||
|
||
/** | ||
* Instantiate or return the one Customizer_Library instance. | ||
* | ||
* @since 1.0.0. | ||
* | ||
* @return Customizer_Library | ||
*/ | ||
public static function instance() { | ||
if ( is_null( self::$instance ) ) { | ||
self::$instance = new self(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
|
||
public function add_options( $options = array() ) { | ||
$this->options = array_merge( $options, $this->options ); | ||
} | ||
|
||
public function get_options() { | ||
return $this->options; | ||
} | ||
|
||
} | ||
|
||
endif; |
Oops, something went wrong.