diff -r 2f6f6f7551ca -r 32102edaa81b web/wp-content/themes/twentyeleven/inc/theme-options.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/themes/twentyeleven/inc/theme-options.php Mon Nov 19 18:26:13 2012 +0100 @@ -0,0 +1,531 @@ +' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Twenty Eleven, provides the following Theme Options:', 'twentyeleven' ) . '
' . + '' . __( 'Remember to click "Save Changes" to save any changes you have made to the theme options.', 'twentyeleven' ) . '
'; + + $sidebar = '' . __( 'For more information:', 'twentyeleven' ) . '
' . + '' . __( 'Documentation on Theme Options', 'twentyeleven' ) . '
' . + '' . __( 'Support Forums', 'twentyeleven' ) . '
'; + + $screen = get_current_screen(); + + if ( method_exists( $screen, 'add_help_tab' ) ) { + // WordPress 3.3 + $screen->add_help_tab( array( + 'title' => __( 'Overview', 'twentyeleven' ), + 'id' => 'theme-options-help', + 'content' => $help, + ) + ); + + $screen->set_help_sidebar( $sidebar ); + } else { + // WordPress 3.2 + add_contextual_help( $screen, $help . $sidebar ); + } +} + +/** + * 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', + 'label' => __( 'Light', 'twentyeleven' ), + 'thumbnail' => get_template_directory_uri() . '/inc/images/light.png', + 'default_link_color' => '#1b8be0', + ), + 'dark' => array( + 'value' => 'dark', + 'label' => __( 'Dark', 'twentyeleven' ), + 'thumbnail' => get_template_directory_uri() . '/inc/images/dark.png', + 'default_link_color' => '#e4741f', + ), + ); + + return apply_filters( 'twentyeleven_color_schemes', $color_scheme_options ); +} + +/** + * 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', + 'label' => __( 'Content on right', 'twentyeleven' ), + 'thumbnail' => get_template_directory_uri() . '/inc/images/sidebar-content.png', + ), + 'content' => array( + 'value' => 'content', + 'label' => __( 'One-column, no sidebar', 'twentyeleven' ), + 'thumbnail' => get_template_directory_uri() . '/inc/images/content.png', + ), + ); + + return apply_filters( 'twentyeleven_layouts', $layout_options ); +} + +/** + * Returns the default options for Twenty Eleven. + * + * @since Twenty Eleven 1.0 + */ +function twentyeleven_get_default_theme_options() { + $default_theme_options = array( + 'color_scheme' => 'light', + 'link_color' => twentyeleven_get_default_link_color( 'light' ), + 'theme_layout' => 'content-sidebar', + ); + + if ( is_rtl() ) + $default_theme_options['theme_layout'] = 'sidebar-content'; + + return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options ); +} + +/** + * Returns the default link color for Twenty Eleven, based on color scheme. + * + * @since Twenty Eleven 1.0 + * + * @param $string $color_scheme Color scheme. Defaults to the active color scheme. + * @return $string Color. +*/ +function twentyeleven_get_default_link_color( $color_scheme = null ) { + if ( null === $color_scheme ) { + $options = twentyeleven_get_theme_options(); + $color_scheme = $options['color_scheme']; + } + + $color_schemes = twentyeleven_color_schemes(); + if ( ! isset( $color_schemes[ $color_scheme ] ) ) + return false; + + return $color_schemes[ $color_scheme ]['default_link_color']; +} + +/** + * Returns the options array for Twenty Eleven. + * + * @since Twenty Eleven 1.0 + */ +function twentyeleven_get_theme_options() { + return get_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() ); +} + +/** + * Renders the Color Scheme setting field. + * + * @since Twenty Eleven 1.3 + */ +function twentyeleven_settings_field_color_scheme() { + $options = twentyeleven_get_theme_options(); + + foreach ( twentyeleven_color_schemes() as $scheme ) { + ?> +