X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/bf5c68485ef07868ad0a91168ecd0092af7661ae..8f374b7233bc2815ccc387e448d208c5434eb961:/wp-content/themes/twentyeleven/functions.php diff --git a/wp-content/themes/twentyeleven/functions.php b/wp-content/themes/twentyeleven/functions.php index 9858126b..e9d97ed2 100644 --- a/wp-content/themes/twentyeleven/functions.php +++ b/wp-content/themes/twentyeleven/functions.php @@ -62,10 +62,9 @@ if ( ! function_exists( 'twentyeleven_setup' ) ): * * @uses load_theme_textdomain() For translation/localization support. * @uses add_editor_style() To style the visual editor. - * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats. + * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom headers + * and backgrounds, and post formats. * @uses register_nav_menus() To add support for navigation menus. - * @uses add_custom_background() To add support for a custom background. - * @uses add_custom_image_header() To add support for a custom header. * @uses register_default_headers() To register the default custom header images provided with the theme. * @uses set_post_thumbnail_size() To set a custom post thumbnail size. * @@ -80,11 +79,6 @@ function twentyeleven_setup() { */ load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' ); - $locale = get_locale(); - $locale_file = get_template_directory() . "/languages/$locale.php"; - if ( is_readable( $locale_file ) ) - require_once( $locale_file ); - // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); @@ -103,42 +97,63 @@ function twentyeleven_setup() { // Add support for a variety of post formats add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); - // Add support for custom backgrounds - add_custom_background(); + $theme_options = twentyeleven_get_theme_options(); + if ( 'dark' == $theme_options['color_scheme'] ) + $default_background_color = '1d1d1d'; + else + $default_background_color = 'f1f1f1'; + + // Add support for custom backgrounds. + add_theme_support( 'custom-background', array( + // Let WordPress know what our default background color is. + // This is dependent on our current color scheme. + 'default-color' => $default_background_color, + ) ); // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images add_theme_support( 'post-thumbnails' ); - // The next four constants set how Twenty Eleven supports custom headers. - - // The default header text color - define( 'HEADER_TEXTCOLOR', '000' ); - - // By leaving empty, we allow for random image rotation. - define( 'HEADER_IMAGE', '' ); - - // The height and width of your custom header. - // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values. - define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) ); - define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) ); + // Add support for custom headers. + $custom_header_support = array( + // The default header text color. + 'default-text-color' => '000', + // The height and width of our custom header. + 'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ), + 'height' => apply_filters( 'twentyeleven_header_image_height', 288 ), + // Support flexible heights. + 'flex-height' => true, + // Random image rotation by default. + 'random-default' => true, + // Callback for styling the header. + 'wp-head-callback' => 'twentyeleven_header_style', + // Callback for styling the header preview in the admin. + 'admin-head-callback' => 'twentyeleven_admin_header_style', + // Callback used to display the header preview in the admin. + 'admin-preview-callback' => 'twentyeleven_admin_header_image', + ); + + add_theme_support( 'custom-header', $custom_header_support ); + + if ( ! function_exists( 'get_custom_header' ) ) { + // This is all for compatibility with versions of WordPress prior to 3.4. + define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] ); + define( 'HEADER_IMAGE', '' ); + define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] ); + define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] ); + add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] ); + add_custom_background(); + } // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be the size of the header image that we just defined // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. - set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); - - // Add Twenty Eleven's custom image sizes - add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images - add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist - - // Turn on random header image rotation by default. - add_theme_support( 'custom-header', array( 'random-default' => true ) ); - - // Add a way for the custom header to be styled in the admin panel that controls - // custom headers. See twentyeleven_admin_header_style(), below. - add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' ); + set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true ); - // ... and thus ends the changeable header business. + // Add Twenty Eleven's custom image sizes. + // Used for large feature (header) images. + add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true ); + // Used for featured posts if a large-feature doesn't exist. + add_image_size( 'small-feature', 500, 300 ); // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( @@ -201,17 +216,18 @@ if ( ! function_exists( 'twentyeleven_header_style' ) ) : * @since Twenty Eleven 1.0 */ function twentyeleven_header_style() { + $text_color = get_header_textcolor(); - // If no custom options for text are set, let's bail - // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value - if ( HEADER_TEXTCOLOR == get_header_textcolor() ) + // If no custom options for text are set, let's bail. + if ( $text_color == HEADER_TEXTCOLOR ) return; + // If we get this far, we have custom styles. Let's do this. ?> @@ -237,7 +253,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) : /** * Styles the header image displayed on the Appearance > Header admin panel. * - * Referenced via add_custom_image_header() in twentyeleven_setup(). + * Referenced via add_theme_support('custom-header') in twentyeleven_setup(). * * @since Twenty Eleven 1.0 */ @@ -287,23 +303,24 @@ if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) : /** * Custom header image markup displayed on the Appearance > Header admin panel. * - * Referenced via add_custom_image_header() in twentyeleven_setup(). + * Referenced via add_theme_support('custom-header') in twentyeleven_setup(). * * @since Twenty Eleven 1.0 */ function twentyeleven_admin_header_image() { ?>

onclick="return false;" href="">

>
- - + +