Permalink
Browse files

Add file with functions to write custom style in head and new field f…

…or link color
  • Loading branch information...
1 parent 8bb3dee commit ff4c3b5dd6200d555666f5446ea26736a2b47697 @bueltge committed Sep 7, 2012
Showing with 180 additions and 28 deletions.
  1. +1 −1 css/style.css
  2. +0 −3 css/style.dev.css
  3. +5 −2 functions.php
  4. +110 −0 inc/head-style.php
  5. +10 −1 inc/theme-customize.php
  6. +2 −2 inc/theme-options.css
  7. +13 −12 inc/theme-options.js
  8. +39 −7 inc/theme-options.php
View

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

Oops, something went wrong.
View
@@ -8,7 +8,6 @@
body {
background: #fff;
-color: #111;
font-family: 'Lucida Sans Unicode','Lucida Sans', 'Trebuchet MS', 'Lucida Grande', 'Bitstream Sans Vera', Verdana, Arial, Tahoma, Helvetica, Sans-Serif;
font-style: normal;
line-height: 1.5em;
@@ -113,7 +112,6 @@ line-height: 1.7em;
}
#content h2 a:link, #content h2 a:visited, #header h1 a:link, #header h1 a:visited {
-color: #0100be;
font-weight: 400;
text-decoration: none;
border: none;
@@ -344,7 +342,6 @@ margin: 0;
a:link, a:visited {
font-weight: 400;
-color: #0100be;
text-decoration: none;
}
View
@@ -52,9 +52,12 @@ function documentation_setup() {
// Load up our theme options page and related code.
require_once( get_template_directory() . '/inc/theme-options.php' );
$documentation_options = new Documentation_Options( $args );
-
+ // Include the theme customizer for options of theme options
require_once( get_template_directory() . '/inc/theme-customize.php' );
$documentation_customize = new Documentation_Customize( $args );
+ // include to write the custom theme options in theme head
+ require_once( get_template_directory() . '/inc/head-style.php' );
+ $documentation_head_style = new Documentation_Head_Style( $args );
// Add default posts and comments RSS feed links to <head>.
add_theme_support( 'automatic-feed-links' );
@@ -65,7 +68,7 @@ function documentation_setup() {
// Add support for custom background.
$args = array(
'default-image' => '',
- 'default-color' => '',
+ 'default-color' => 'fff',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
View
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Documentation Theme Style
+ * Write style settings in head
+ *
+ * @package WordPress
+ * @subpackage Documentation
+ * @since 09/05/2012
+ */
+
+class Documentation_Head_Style extends Documentation_Options {
+
+ /**
+ * Identifier, namespace
+ */
+ public static $theme_key = '';
+
+ /**
+ * The option value in the database will be based on get_stylesheet()
+ * so child themes don't share the parent theme's option value.
+ */
+ public static $option_key = '';
+
+ /**
+ * Initialize our options.
+ */
+ var $options = array();
+
+ /**
+ * Constructor
+ *
+ * @since 09/07/2012
+ * @param $args Array
+ * @return void
+ */
+ public function __construct( $args = NULL ) {
+
+ if ( is_admin() )
+ return NULL;
+
+ // Set option key based on get_stylesheet()
+ if ( NULL === $args )
+ $args['theme_key'] = strtolower( get_stylesheet() );
+
+ // Set option key based on get_stylesheet()
+ $this->theme_key = $args['theme_key'];
+ $this->option_key = $this->theme_key . '_theme_options';
+
+ add_action( 'wp_head', array( $this, 'get_custom_style' ) );
+ }
+
+ /**
+ * 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
+ *
+ * @since 09/07/2012
+ * @return void
+ */
+ public function get_custom_style() {
+
+ $options = $this->get_theme_options();
+ ?>
+ <style type="text/css">
+ body { color: <?php echo $options['text_color']; ?>; }
+ a:link, a:visited,
+ #content h2 a:link, #content h2 a:visited,
+ #header h1 a:link, #header h1 a:visited { color: <?php echo $options['link_color']; ?>; }
+ </style>
+ <?php
+ }
+
+} // end class
View
@@ -73,12 +73,21 @@ public function customize_register( $wp_customize ) {
'type' => 'option',
'capability' => 'edit_theme_options',
) );
- // add color field include
+
+ // add color field include color picker for text color
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $this->option_key . '_text_color', array(
'label' => __( 'Text Color', 'documentation' ),
'section' => 'colors',
'settings' => $this->option_key . '[text_color]',
) ) );
+
+ // add color field include color picker for link color
+ $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $this->option_key . '_link_color', array(
+ 'label' => __( 'Link Color', 'documentation' ),
+ 'section' => 'colors',
+ 'settings' => $this->option_key . '[link_color]',
+ ) ) );
+
}
} // end class
View
@@ -20,7 +20,7 @@
.image-radio-option img {
margin: 0 0 0 -2px;
}
-#text-color-example {
+#text-color-example, #link-color-example {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
@@ -29,7 +29,7 @@
padding: 4px 14px;
}
-#colorPickerDiv {
+.colorPickerDiv {
z-index: 100;
background: #eee;
border: 1px solid #ccc;
View
@@ -3,24 +3,25 @@ var farbtastic;
( function($) {
// set ID or class for the textarea
- var colorpicker = '#text-color',
- example = '#text-color-example';
+ var colorpicker = '#text-color',
+ example = '#text-color-example',
+ colorpickerdiv = '#text-colorPickerDiv';
var pickColor = function(a) {
- farbtastic.setColor(a);
- $(colorpicker).val(a);
- $(example).css('background-color', a);
+ farbtastic.setColor(a);
+ $(colorpicker).val(a);
+ $(example).css('background-color', a);
};
$(document).ready( function() {
- $('#default-color').wrapInner('<a href="#" />');
+ $('#text-default-color').wrapInner('<a href="#" />');
- farbtastic = $.farbtastic('#colorPickerDiv', pickColor);
+ farbtastic = $.farbtastic(colorpickerdiv, pickColor);
pickColor( $(colorpicker).val() );
- $('.pickcolor').click( function(e) {
- $('#colorPickerDiv').show();
+ $('#text-color-example').click( function(e) {
+ $(colorpickerdiv).show();
e.preventDefault();
});
@@ -36,16 +37,16 @@ var farbtastic;
});
$(document).mousedown( function() {
- $('#colorPickerDiv').hide();
+ $(colorpickerdiv).hide();
});
- $('#default-color a').click( function(e) {
+ $('#text-default-color a').click( function(e) {
pickColor( '#' + this.innerHTML.replace(/[^a-fA-F0-9]/, '') );
e.preventDefault();
});
$('.image-radio-option.color-scheme input:radio').change( function() {
- var currentDefault = $('#default-color a'),
+ var currentDefault = $('#text-default-color a'),
newDefault = $(this).next().val();
if ( $(colorpicker).val() == currentDefault.text() )
Oops, something went wrong.

0 comments on commit ff4c3b5

Please sign in to comment.