Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevsuperfast committed Aug 30, 2015
2 parents 848194c + 2a11f52 commit a147b1d
Show file tree
Hide file tree
Showing 18 changed files with 8,461 additions and 2,419 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Bootstrap for Genesis is a genesis child theme which integrates [Twitter Bootstr
* Tab Widget
* Modal Widget
11. Github Updater Support
12. Customizer Library Support

## Credits

Expand All @@ -62,3 +63,5 @@ Without these projects, this theme wouldn't be where it is today.
* [Bones for Genesis 2.0 with Bootstrap integration](https://github.com/jer0dh/bones-for-genesis-2-0-bootstrap)
* [SiteOrigin Widgets Bundle](https://wordpress.org/plugins/so-widgets-bundle/)
* [AQ Resizer](https://github.com/syamilmj/Aqua-Resizer)
* [Customizer Library](https://github.com/devinsays/customizer-library)
* [GitHub Updater](https://github.com/afragen/github-updater)
4 changes: 2 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ function bfg_google_fonts() {
// Add TGM Plugin Activation Support
add_theme_support( 'bfg-module-tgm' );

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

// Include php files from lib folder
// @link https://gist.github.com/theandystratton/5924570
Expand Down
164 changes: 164 additions & 0 deletions lib/customizer.php
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";
}
}
}
10 changes: 7 additions & 3 deletions lib/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
add_action( 'genesis_footer', 'bfg_do_footer' );

function bfg_do_footer() {
$creds = '<a href="http://www.superfastbusiness.com">Bootstrap for Genesis</a> by <a href="http://www.superfastbusiness.com">SuperFastBusiness</a>';

if ( get_theme_mod( 'creds', false ) ) {
$creds = get_theme_mod( 'creds' );
} else {
$creds = '<a href="http://www.superfastbusiness.com">Bootstrap for Genesis</a> by <a href="http://www.superfastbusiness.com">SuperFastBusiness</a>';
}

genesis_markup(array(
'html5' => '<div %s>',
'xhtml' => '<div class="copyright">',
'context' => 'copyright'
));
echo apply_filters( 'bfg_footer_creds', $creds );
echo apply_filters( 'bfg_footer_creds', do_shortcode( $creds ) );
echo '</div>';

if ( is_active_sidebar( 'footer-right' ) ) {
Expand Down
50 changes: 50 additions & 0 deletions lib/modules/customizer-library/custom-controls/content.php
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 lib/modules/customizer-library/custom-controls/textarea.php
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
}

}
94 changes: 94 additions & 0 deletions lib/modules/customizer-library/customizer-library.php
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;
Loading

0 comments on commit a147b1d

Please sign in to comment.