WordPress/wp-content/themes/twentyeleven/inc/theme-options.php

330 lines
11 KiB
PHP
Raw Normal View History

<?php
/**
* Twenty Eleven Theme Options
*
* @package WordPress
* @subpackage Twenty Eleven
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* @since Twenty Eleven 1.0
*/
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Properly enqueue styles and scripts for our theme options page.
*
* This function is attached to the admin_enqueue_scripts action hook.
*
* @since Twenty Eleven 1.0
*
* @param string $hook_suffix The action passes the current page to the function. We don't
* do anything if we're not on our theme options page.
*/
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
function twentyeleven_admin_enqueue_scripts( $hook_suffix ) {
if ( $hook_suffix != 'appearance_page_theme_options' )
return;
wp_enqueue_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' );
wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( 'farbtastic' ), '2011-04-28' );
wp_enqueue_style( 'farbtastic' );
}
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
add_action( 'admin_enqueue_scripts', 'twentyeleven_admin_enqueue_scripts' );
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Register the form setting for our twentyeleven_options array.
*
* This function is attached to the admin_init action hook.
*
* This call to register_setting() registers a validation callback, twentyeleven_theme_options_validate(),
* which is used when the option is saved, to ensure that our option values are complete, properly
* formatted, and safe.
*
* We also use this function to add our theme option if it doesn't already exist.
*
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* @since Twenty Eleven 1.0
*/
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
function twentyeleven_theme_options_init() {
// If we have no options in the database, let's add them now.
if ( false === twentyeleven_get_theme_options() )
add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() );
register_setting(
'twentyeleven_options', // Options group, see settings_fields() call in theme_options_render_page()
'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options()
'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate()
);
}
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
add_action( 'admin_init', 'twentyeleven_theme_options_init' );
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Add our theme options page to the admin menu.
*
* This function is attached to the admin_menu action hook.
*
* @since Twenty Eleven 1.0
*/
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
function twentyeleven_theme_options_add_page() {
add_theme_page(
__( 'Theme Options', 'twentyeleven' ), // Name of page
__( 'Theme Options', 'twentyeleven' ), // Label in menu
'edit_theme_options', // Capability required
'theme_options', // Menu slug, used to uniquely identify the page
'theme_options_render_page' // Function that renders the options page
);
}
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
add_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Returns an array of color schemes registered for Twenty Eleven.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_color_schemes() {
$color_scheme_options = array(
'light' => array(
'value' => 'light',
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
'label' => __( 'Light', 'twentyeleven' ),
'thumbnail' => get_template_directory_uri() . '/inc/images/light.png',
),
'dark' => array(
'value' => 'dark',
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
'label' => __( 'Dark', 'twentyeleven' ),
'thumbnail' => get_template_directory_uri() . '/inc/images/dark.png',
),
);
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
return apply_filters( 'twentyeleven_color_schemes', $color_scheme_options );
}
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Returns an array of layout options registered for Twenty Eleven.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_layouts() {
$layout_options = array(
'content-sidebar' => array(
'value' => 'content-sidebar',
'label' => __( 'Content on left', 'twentyeleven' ),
'thumbnail' => get_template_directory_uri() . '/inc/images/content-sidebar.png',
),
'sidebar-content' => array(
'value' => 'sidebar-content',
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
'label' => __( 'Content on right', 'twentyeleven' ),
'thumbnail' => get_template_directory_uri() . '/inc/images/sidebar-content.png',
),
'content' => array(
'value' => 'content',
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
'label' => __( 'One-column, no Sidebar', 'twentyeleven' ),
'thumbnail' => get_template_directory_uri() . '/inc/images/content.png',
),
);
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
return apply_filters( 'twentyeleven_layouts', $layout_options );
}
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Returns the default options for Twenty Eleven.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_get_default_theme_options() {
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
$default_theme_options = array(
'color_scheme' => 'light',
'link_color' => '#1b8be0',
'theme_layout' => 'content-sidebar',
);
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );
}
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Returns the options array for Twenty Eleven.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_get_theme_options() {
return get_option( 'twentyeleven_theme_options' );
}
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Returns the options array for Twenty Eleven.
*
* @since Twenty Eleven 1.0
*/
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
function theme_options_render_page() {
?>
<div class="wrap">
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<?php screen_icon(); ?>
<h2><?php printf( __( '%s Theme Options', 'twentyeleven' ), get_current_theme() ); ?></h2>
<?php settings_errors(); ?>
<form method="post" action="options.php">
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<?php
settings_fields( 'twentyeleven_options' );
$options = twentyeleven_get_theme_options();
$default_options = twentyeleven_get_default_theme_options();
?>
<table class="form-table">
<tr valign="top" class="image-radio-option"><th scope="row"><?php _e( 'Color Scheme', 'twentyeleven' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Color Scheme', 'twentyeleven' ); ?></span></legend>
<?php
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
foreach ( twentyeleven_color_schemes() as $color ) {
?>
<div class="layout">
<label class="description">
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<input type="radio" name="twentyeleven_theme_options[color_scheme]" value="<?php echo esc_attr( $color['value'] ); ?>" <?php checked( $options['color_scheme'], $color['value'] ); ?> />
<span>
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<img src="<?php echo esc_url( $color['thumbnail'] ); ?>"/>
<?php echo $color['label']; ?>
</span>
</label>
</div>
<?php
}
?>
</fieldset>
</td>
</tr>
<tr valign="top"><th scope="row"><?php _e( 'Link Color', 'twentyeleven' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Link Color', 'twentyeleven' ); ?></span></legend>
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<input type="text" name="twentyeleven_theme_options[link_color]" id="link-color" value="<?php echo esc_attr( $options['link_color'] ); ?>" />
<a href="#" class="pickcolor hide-if-no-js" id="link-color-example"></a>
<input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color', 'twentyeleven' ); ?>">
<div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
<br />
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<small class="description"><?php printf( __( 'Default color: %s', 'twentyeleven' ), $default_options['link_color'] ); ?></small>
</fieldset>
</td>
</tr>
<tr valign="top" class="image-radio-option"><th scope="row"><?php _e( 'Layout', 'twentyeleven' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Color Scheme', 'twentyeleven' ); ?></span></legend>
<?php
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
foreach ( twentyeleven_layouts() as $layout ) {
?>
<div class="layout">
<label class="description">
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<input type="radio" name="twentyeleven_theme_options[theme_layout]" value="<?php echo esc_attr( $layout['value'] ); ?>" <?php checked( $options['theme_layout'], $layout['value'] ); ?> />
<span>
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<img src="<?php echo esc_url( $layout['thumbnail'] ); ?>"/>
<?php echo $layout['label']; ?>
</span>
</label>
</div>
<?php
}
?>
</fieldset>
</td>
</tr>
</table>
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
<?php submit_button(); ?>
</form>
</div>
<?php
}
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Sanitize and validate form input. Accepts an array, return a sanitized array.
*
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* @see twentyeleven_theme_options_init()
* @todo set up Reset Options action
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_theme_options_validate( $input ) {
$output = $defaults = twentyeleven_get_default_theme_options();
// Color scheme must be in our array of color scheme options
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
if ( isset( $input['color_scheme'] ) && array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) )
$output['color_scheme'] = $input['color_scheme'];
// Link color must be 3 or 6 hexadecimal characters
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
if ( isset( $input['link_color'] ) && preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) )
$output['link_color'] = '#' . strtolower( ltrim( $input['link_color'], '#' ) );
// Theme layout must be in our array of theme layout options
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
if ( isset( $input['theme_layout'] ) && array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) )
$output['theme_layout'] = $input['theme_layout'];
return apply_filters( 'twentyeleven_theme_options_validate', $output, $input, $defaults );
}
/**
* Enqueue the styles for the current color scheme.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_enqueue_color_scheme() {
$options = twentyeleven_get_theme_options();
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
$color_scheme = $options['color_scheme'];
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
if ( 'dark' == $color_scheme )
wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', array(), null );
do_action( 'twentyeleven_enqueue_color_scheme', $color_scheme );
}
add_action( 'wp_enqueue_scripts', 'twentyeleven_enqueue_color_scheme' );
/**
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
* Add a style block to the theme for the current link color.
*
* This function is attached to the wp_head action hook.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_print_link_color_style() {
$options = twentyeleven_get_theme_options();
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
$link_color = $options['link_color'];
$default_options = twentyeleven_get_default_theme_options();
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
// Don't do anything if the current link color is the default.
if ( $default_options['link_color'] == $link_color )
return;
?>
<style>
/* Link color */
a,
.entry-title a:hover,
.widget_twentyeleven_ephemera .comments-link a:hover,
section.recent-posts .other-recent-posts a[rel="bookmark"]:hover,
section.recent-posts .other-recent-posts .comments-link a:hover,
.format-image footer.entry-meta a:hover {
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
color: <?php echo $link_color; ?>;
}
section.recent-posts .other-recent-posts .comments-link a:hover {
border-color: <?php echo $link_color; ?>;
}
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
</style>
<?php
}
add_action( 'wp_head', 'twentyeleven_print_link_color_style' );
/**
* Adds Twenty Eleven layout classes to the array of body classes.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_layout_classes( $existing_classes ) {
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
if ( in_array( $current_layout, array( 'content-sidebar', 'sidebar-content' ) ) )
$classes = array( 'two-column' );
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
else
$classes = array( 'one-column' );
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
$classes[] = $current_layout;
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
$classes = apply_filters( 'twentyeleven_layout_classes', $classes, $current_layout );
return array_merge( $existing_classes, $classes );
}
Rewrite of Twenty Eleven theme-options.php. Including: * Full inline documentation. * Enqueue scripts/styles on admin_enqueue_scripts and use hook_suffix rather than GET[page] * Add filters to twentyeleven_color_schemes(), twentyeleven_layouts(), which necessitates adding a thumbnail URL value here, rather than generating them in the form. * Add a twentyeleven_default_theme_options filter. * Remove manual check for REQUEST[settings-updated], instead using settings_errors(), since we're using options.php. * Abstract out the default link color, rather than hardcoding it in certain places. * Use checked(). * Rename some variables and functions for clarity. * Remove unnecessary functions twentyeleven_current_layout() and twentyeleven_current_color_scheme(), as we already have twentyeleven_get_theme_options(). * Add a twentyeleven_color_schemes action to allow for enqueueing custom color schemes. * Add a twentyeleven_layout_classes filter, to allow filtering what gets sent back to body_class(). * Hook into wp_enqueue_scripts rather than wp_print_styles for enqueueing the color stylesheet. * Rewrite the register_setting() callback to start from scratch with an empty array. Improve the link_color logic. * Use submit_button(). * Use esc_attr() rather than esc_attr_e() for non-translations. TODO: * Implement settings sections/fields logic to allow extension of the options page. * Consider re-doing this in a class. It'll be cleaner. * Store a DB version so we can do an add_option(), rather than calling get_option() with defaults. see #17198. git-svn-id: http://svn.automattic.com/wordpress/trunk@17733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 10:06:57 +02:00
add_filter( 'body_class', 'twentyeleven_layout_classes' );