Permalink
Browse files

Make Theme options only available for outdated WordPress Versions.

Go Customizer all the way!
  • Loading branch information...
1 parent 39d9e32 commit 6b1095ba145484b43e3bbe68c2243b5d02f8dc31 @obenland committed Aug 24, 2012
Showing with 87 additions and 80 deletions.
  1. +61 −10 functions.php
  2. +22 −10 inc/theme-customizer.php
  3. +4 −60 inc/theme-options.php
View
@@ -41,11 +41,13 @@ function the_bootstrap_setup() {
) );
add_theme_support( 'tha_hooks', array( 'all' ) );
-
- /**
- * Custom Theme Options
- */
- require_once( get_template_directory() . '/inc/theme-options.php' );
+
+ if ( version_compare( get_bloginfo( 'version' ), '3.4', '<' ) )
+ // Custom Theme Options
+ require_once( get_template_directory() . '/inc/theme-options.php' );
+ else
+ // Implement the Theme Customizer script
+ require_once( get_template_directory() . '/inc/theme-customizer.php' );
/**
* Custom template tags for this theme.
@@ -58,11 +60,6 @@ function the_bootstrap_setup() {
require_once( get_template_directory() . '/inc/custom-header.php' );
/**
- * Implement the Theme Customizer script
- */
- require_once( get_template_directory() . '/inc/theme-customizer.php' );
-
- /**
* Custom Nav Menu handler for the Navbar.
*/
require_once( get_template_directory() . '/inc/nav-menu-walker.php' );
@@ -92,6 +89,60 @@ function the_bootstrap_setup() {
/**
+ * Returns the options object for The Bootstrap.
+ *
+ * @author Automattic
+ * @since 1.3.0 - 06.04.2012
+ *
+ * @return stdClass Theme Options
+ */
+function the_bootstrap_options() {
+ return (object) wp_parse_args(
+ get_option( 'the_bootstrap_theme_options', array() ),
+ the_bootstrap_get_default_theme_options()
+ );
+}
+
+
+/**
+ * Returns the default options for The Bootstrap.
+ *
+ * @author Automattic
+ * @since 1.3.0 - 06.04.2012
+ *
+ * @return void
+ */
+function the_bootstrap_get_default_theme_options() {
+ $default_theme_options = array(
+ 'theme_layout' => 'content-sidebar',
+ 'navbar_site_name' => false,
+ 'navbar_searchform' => true,
+ 'navbar_inverse' => true,
+ 'navbar_position' => 'static',
+ );
+
+ return apply_filters( 'the_bootstrap_default_theme_options', $default_theme_options );
+}
+
+
+/**
+ * Adds The Bootstrap layout classes to the array of body classes.
+ *
+ * @author WordPress.org
+ * @since 1.3.0 - 06.04.2012
+ *
+ * @return void
+ */
+function the_bootstrap_layout_classes( $existing_classes ) {
+ $classes = array( the_bootstrap_options()->theme_layout );
+ $classes = apply_filters( 'the_bootstrap_layout_classes', $classes );
+
+ return array_merge( $existing_classes, $classes );
+}
+add_filter( 'body_class', 'the_bootstrap_layout_classes' );
+
+
+/**
* Adds Custom Background support
*
* @author Konstantin Obenland
View
@@ -24,24 +24,28 @@ function the_bootstrap_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
- $wp_customize->add_section( 'the_bootstrap_theme_options', array(
- 'title' => __( 'Theme Options', 'the-bootstrap' ),
+ $wp_customize->add_section( 'the_bootstrap_theme_layout', array(
+ 'title' => __( 'Layout', 'the-bootstrap' ),
'priority' => 99,
) );
+ $wp_customize->add_section( 'the_bootstrap_navbar_options', array(
+ 'title' => __( 'Navbar Options', 'the-bootstrap' ),
+ 'priority' => 101,
+ ) );
// Add settings
foreach ( array_keys( the_bootstrap_get_default_theme_options() ) as $setting ) {
- $wp_customize->add_setting( "the_bootstrap_theme_options[{$setting}]", array(
- 'default' => the_bootstrap_options()->$setting,
- 'type' => 'option',
- 'transport' => 'postMessage',
+ $wp_customize->add_setting( "the_bootstrap_theme_options[{$setting}]", array(
+ 'default' => the_bootstrap_options()->$setting,
+ 'type' => 'option',
+ 'transport' => 'postMessage',
) );
}
// Theme Layout
$wp_customize->add_control( 'the_bootstrap_theme_layout', array(
'label' => __( 'Default Layout', 'the-bootstrap' ),
- 'section' => 'the_bootstrap_theme_options',
+ 'section' => 'the_bootstrap_theme_layout',
'settings' => 'the_bootstrap_theme_options[theme_layout]',
'type' => 'radio',
'choices' => array(
@@ -53,23 +57,31 @@ function the_bootstrap_customize_register( $wp_customize ) {
// Sitename in Navbar
$wp_customize->add_control( 'the_bootstrap_navbar_site_name', array(
'label' => __( 'Add site name to navigation bar.', 'the-bootstrap' ),
- 'section' => 'the_bootstrap_theme_options',
+ 'section' => 'the_bootstrap_navbar_options',
'settings' => 'the_bootstrap_theme_options[navbar_site_name]',
'type' => 'checkbox',
) );
// Searchform in Navbar
$wp_customize->add_control( 'the_bootstrap_navbar_searchform', array(
'label' => __( 'Add searchform to navigation bar.', 'the-bootstrap' ),
- 'section' => 'the_bootstrap_theme_options',
+ 'section' => 'the_bootstrap_navbar_options',
'settings' => 'the_bootstrap_theme_options[navbar_searchform]',
'type' => 'checkbox',
) );
+ // Navbar Colors
+ $wp_customize->add_control( 'the_bootstrap_navbar_inverse', array(
+ 'label' => __( 'Use inverse color on navigation bar.', 'the-bootstrap' ),
+ 'section' => 'the_bootstrap_navbar_options',
+ 'settings' => 'the_bootstrap_theme_options[navbar_inverse]',
+ 'type' => 'checkbox',
+ ) );
+
// Navbar Position
$wp_customize->add_control( 'the_bootstrap_navbar_position', array(
'label' => __( 'Navigation Bar Position', 'the-bootstrap' ),
- 'section' => 'the_bootstrap_theme_options',
+ 'section' => 'the_bootstrap_navbar_options',
'settings' => 'the_bootstrap_theme_options[navbar_position]',
'type' => 'radio',
'choices' => array(
View
@@ -153,42 +153,6 @@ function the_bootstrap_admin_bar_menu( $wp_admin_bar ) {
/**
- * Returns the options object for The Bootstrap.
- *
- * @author Automattic
- * @since 1.3.0 - 06.04.2012
- *
- * @return stdClass Theme Options
- */
-function the_bootstrap_options() {
- return (object) wp_parse_args(
- get_option( 'the_bootstrap_theme_options', array() ),
- the_bootstrap_get_default_theme_options()
- );
-}
-
-
-/**
- * Returns the default options for The Bootstrap.
- *
- * @author Automattic
- * @since 1.3.0 - 06.04.2012
- *
- * @return void
- */
-function the_bootstrap_get_default_theme_options() {
- $default_theme_options = array(
- 'theme_layout' => 'content-sidebar',
- 'navbar_site_name' => false,
- 'navbar_searchform' => true,
- 'navbar_position' => 'static',
- );
-
- return apply_filters( 'the_bootstrap_default_theme_options', $default_theme_options );
-}
-
-
-/**
* Returns an array of layout options registered for Twenty Eleven.
*
* @author WordPress.org
@@ -331,9 +295,10 @@ function the_bootstrap_theme_options_validate( $input ) {
if ( isset( $input['navbar_position'] ) AND in_array( $input['navbar_position'], array('static', 'navbar-fixed-top', 'navbar-fixed-bottom') ) )
$output['navbar_position'] = $input['navbar_position'];
- $output['navbar_site_name'] = isset( $input['navbar_site_name'] );
- $output['navbar_searchform'] = isset( $input['navbar_searchform'] );
-
+ $output['navbar_inverse'] = isset( $input['navbar_inverse'] ) AND $input['navbar_inverse'];
+ $output['navbar_site_name'] = isset( $input['navbar_site_name'] ) AND $input['navbar_site_name'];
+ $output['navbar_searchform'] = isset( $input['navbar_searchform'] ) AND $input['navbar_searchform'];
+
if ( ! get_settings_errors() ) {
add_settings_error( 'the-bootstrap-options', 'settings_updated', sprintf( __( 'Settings saved. <a href="%s">Visit your site</a> to see how it looks.', 'the-bootstrap' ), home_url( '/' ) ), 'updated' );
}
@@ -465,26 +430,5 @@ function _the_bootstrap_fetch_feed( $feed_url ) {
}
-///////////////////////////////////////////////////////////////////////////////
-// FRONT END
-///////////////////////////////////////////////////////////////////////////////
-
-/**
- * Adds The Bootstrap layout classes to the array of body classes.
- *
- * @author WordPress.org
- * @since 1.3.0 - 06.04.2012
- *
- * @return void
- */
-function the_bootstrap_layout_classes( $existing_classes ) {
- $classes = array( the_bootstrap_options()->theme_layout );
- $classes = apply_filters( 'the_bootstrap_layout_classes', $classes );
-
- return array_merge( $existing_classes, $classes );
-}
-add_filter( 'body_class', 'the_bootstrap_layout_classes' );
-
-
/* End of file theme-options.php */
/* Location: ./wp-content/themes/the-bootstrap/inc/theme-options.php */

0 comments on commit 6b1095b

Please sign in to comment.