Permalink
Browse files

Add new settings via Customizer

  • Loading branch information...
1 parent 523ddef commit 23073bb59691d480a5de96f4f3aa276975328735 @bueltge committed Sep 18, 2012
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -53,6 +53,7 @@ font-size: 100%;
h1, h2, h3, h4 {
font-family: Georgia,'Trebuchet MS', 'Lucida Sans', 'Lucida Grande', 'Bitstream Sans Vera', Verdana, Arial, Tahoma, Helvetica, Sans-Serif;
+color: #333;
clear: both;
margin: 20px 0 0;
padding: 2px 0;
@@ -191,6 +192,8 @@ padding: 5px;
}
#sidebar {
+background: #fff;
+color: #111;
width: 25%;
float: right;
margin: 5px 0;
@@ -218,6 +221,7 @@ padding: 4px 0;
font-size: 100%;
font-weight: 900;
font-family: Georgia,'Trebuchet MS', 'Lucida Sans', 'Lucida Grande', 'Bitstream Sans Vera', Verdana, Arial, Tahoma, Helvetica, Sans-Serif;
+color: #333;
}
#sidebar li a {
@@ -240,6 +244,7 @@ width: 30%;
#footer {
border-top: 1px solid #ccc;
+color: #111;
clear: both;
text-align: center;
margin: 5px;
@@ -350,13 +355,15 @@ input, textarea, select, option {
font-family: 'Lucida Sans', 'Trebuchet MS', 'Lucida Grande', 'Bitstream Sans Vera', Verdana, Arial, Tahoma, Helvetica, Sans-Serif;
font-size: 100%;
background: #eee;
+color: #111;
border: 1px solid #ccc;
margin: 2px;
padding: 2px;
}
fieldset, legend {
background: transparent;
+color: #111;
border: none;
padding: 5px;
}
@@ -399,6 +406,7 @@ padding: 2px 15px 2px 0;
}
table {
+color: #111;
width: 100%;
margin: 2px auto;
padding: 0;
@@ -422,6 +430,7 @@ background: #fff;
}
caption {
+color: #333;
font-weight: 700;
padding: 5px;
}
View
@@ -36,8 +36,11 @@
echo apply_filters('loginout', $link);
?></p>
<h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo('name'); ?></a></h1>
- <p><?php bloginfo('description'); ?></p>
<?php
+ // check for custom options to echo the description
+ if ( '1' === documentation_get_options( 'echo_desc' ) )
+ echo '<p>' . get_bloginfo( 'description' ) . '</p>';
+
$args = array(
'theme_location' => 'primary',
'fallback_cb' => FALSE
View
@@ -8,7 +8,8 @@
* @since 09/05/2012
*/
-class Documentation_Head_Style {
+// extends the class with the seetings via Customizer
+class Documentation_Head_Style extends Documentation_Customize {
/**
* Identifier, namespace
@@ -46,47 +47,12 @@ public function __construct( $args = NULL ) {
$this->theme_key = $args['theme_key'];
$this->option_key = $this->theme_key . '_theme_options';
+ // add the custom styles in head
add_action( 'wp_head', array( $this, 'get_custom_style' ) );
+ // enqueue the the different color scheme
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_color_scheme' ) );
}
-
- /**
- * Returns the default options.
- * Use the hook 'documentation_default_theme_options' for change via plugin
- *
- * @since 08/09/2012
- * @return Array
- */
- public function get_default_theme_options( $value = NULL ) {
-
- $default_theme_options = array(
- 'rewrite_url' => 'wp-admin/edit.php',
- 'text_color' => '#333',
- 'link_color' => '#0100BE'
- );
-
- if ( NULL !== $value )
- return $default_theme_options[$value];
- return apply_filters( $this->theme_key . '_default_theme_options', $default_theme_options );
- }
-
- /**
- * Returns the options array.
- *
- * @since 09/07/2012
- * @return Array
- */
- public function get_theme_options() {
-
- $saved = (array) get_option( $this->option_key );
- $defaults = $this->get_default_theme_options();
-
- $options = wp_parse_args( $saved, $defaults );
- $options = array_intersect_key( $options, $defaults );
-
- return apply_filters( $this->theme_key . '_theme_options', $options );
- }
-
/**
* Styles from theme options
* Write in head of frontend
@@ -96,7 +62,7 @@ public function get_theme_options() {
*/
public function get_custom_style() {
- $options = $this->get_theme_options();
+ $options = parent::get_theme_options();
?>
<style type="text/css">
body { color: <?php echo $options['text_color']; ?>; }
@@ -107,4 +73,38 @@ public function get_custom_style() {
<?php
}
+ /**
+ * Enqueue the color scheme
+ *
+ * @since 09/18/2012
+ * @return void
+ */
+ public function enqueue_color_scheme() {
+
+ // get the option value for item 'color_scheme'
+ $option = parent::get_theme_options( 'color_scheme' );
+ // define suffix for development on scripts and styles
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
+ // register the styles; easy to change from outside the theme
+ wp_register_style(
+ $this->theme_key . '_dark',
+ get_stylesheet_directory_uri() . '/css/dark' . $suffix . '.css',
+ array(),
+ NULL
+ );
+ wp_register_style(
+ $this->theme_key . '_light',
+ get_stylesheet_directory_uri() . '/css/light' . $suffix . '.css',
+ array(),
+ NULL
+ );
+ // check options and enqueue style
+ if ( 'dark' === $option )
+ wp_enqueue_style( $this->theme_key . '_dark' );
+ else
+ wp_enqueue_style( $this->theme_key . '_light' );
+ // use this hook for add to the set option
+ do_action( $this->theme_key . '_enqueue_color_scheme', $option );
+ }
+
} // end class
View
@@ -33,6 +33,7 @@ public function __construct( $args = NULL ) {
$this->theme_key = $args['theme_key'];
$this->option_key = $this->theme_key . '_theme_options';
+ // register our custom settings
add_action( 'customize_register', array( $this, 'customize_register' ) );
}
@@ -46,9 +47,11 @@ public function __construct( $args = NULL ) {
public function get_default_theme_options( $value = NULL ) {
$default_theme_options = array(
- 'rewrite_url' => 'wp-admin/edit.php',
- 'text_color' => '#111',
- 'link_color' => '#0100BE'
+ 'echo_desc' => '1',
+ 'rewrite_url' => 'wp-admin/edit.php',
+ 'color_scheme' => 'light',
+ 'text_color' => '#111',
+ 'link_color' => '#0100BE'
);
if ( NULL !== $value )
@@ -63,15 +66,20 @@ public function get_default_theme_options( $value = NULL ) {
* @since 08/09/2012
* @return Array
*/
- public function get_theme_options() {
+ public function get_theme_options( $value = NULL ) {
$saved = (array) get_option( $this->option_key );
$defaults = $this->get_default_theme_options();
$options = wp_parse_args( $saved, $defaults );
$options = array_intersect_key( $options, $defaults );
- return apply_filters( $this->theme_key . '_theme_options', $options );
+ $options = apply_filters( $this->theme_key . '_theme_options', $options );
+
+ if ( NULL !== $value )
+ return $options[$value];
+
+ return $options;
}
/**
@@ -86,12 +94,32 @@ public function customize_register( $wp_customize ) {
$defaults = $this->get_default_theme_options();
+ $wp_customize->add_setting( $this->option_key . '[echo_desc]', array(
+ 'default' => $defaults['echo_desc'],
+ 'type' => 'option',
+ 'capability' => 'edit_theme_options'
+ ) );
+
+ // Add control and output for select field
+ $wp_customize->add_control( $this->option_key . '_echo_desc', array(
+ 'label' => __( 'Display Description', 'documentation' ),
+ 'section' => 'title_tagline',
+ 'settings' => $this->option_key . '[echo_desc]',
+ 'type' => 'select',
+ 'choices' => array(
+ '0' => __( 'False', 'documentation' ),
+ '1' => __( 'True', 'documentation' )
+ ),
+ ) );
+
+ // ===== Custom Section =====
// create custom section for rewrite url
$wp_customize->add_section( $this->option_key . '_rewrite_url', array(
'title' => __( 'Rewrite', 'documentation' ),
'priority' => 35,
) );
+ // ===== Text Input Field =====
// add field for rewrite url in custom section
$wp_customize->add_setting( $this->option_key . '[rewrite_url]', array(
'default' => $defaults['rewrite_url'],
@@ -106,6 +134,27 @@ public function customize_register( $wp_customize ) {
'type' => 'text',
) );
+ // ===== Sample Radio Buttons Fields =====
+ // Add field for radio buttons to dark or light scheme
+ $wp_customize->add_setting( $this->option_key . '[color_scheme]', array(
+ 'default' => $defaults['color_scheme'],
+ 'type' => 'option',
+ 'capability' => 'edit_theme_options',
+ ) );
+
+ // Add control and output for select field
+ $wp_customize->add_control( $this->option_key . '_color_scheme', array(
+ 'label' => __( 'Color Scheme', 'documentation' ),
+ 'section' => 'colors',
+ 'settings' => $this->option_key . '[color_scheme]',
+ 'type' => 'radio',
+ 'choices' => array(
+ 'dark' => __( 'Dark', 'documentation' ),
+ 'light' => __( 'Light', 'documentation' )
+ ),
+ ) );
+
+ // ===== Color picker Fields =====
// add field for text color in default section for 'colors'
$wp_customize->add_setting( $this->option_key . '[text_color]', array(
'default' => $defaults['text_color'],
Oops, something went wrong.

0 comments on commit 23073bb

Please sign in to comment.