twentyeleven_setup

Definition:
function twentyeleven_setup() {}

Sets up theme defaults and registers support for various WordPress features.
Note that this function is hooked into the after_setup_theme hook, which runs before the init hook. The init hook is too late for some features, such as indicating support post thumbnails.

Defined filters

  • twentyeleven_header_image_width
    apply_filters( 'twentyeleven_header_image_width', 1000 )
  • twentyeleven_header_image_height
    apply_filters( 'twentyeleven_header_image_height', 288 )

Source code

function twentyeleven_setup() {



	/* Make Twenty Eleven available for translation.

	 * Translations can be added to the /languages/ directory.

	 * If you're building a theme based on Twenty Eleven, use a find and replace

	 * to change 'twentyeleven' to the name of your theme in all the template files.

	 */

	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();



	// Load up our theme options page and related code.

	require( get_template_directory() . '/inc/theme-options.php' );



	// Grab Twenty Eleven's Ephemera widget.

	require( get_template_directory() . '/inc/widgets.php' );



	// Add default posts and comments RSS feed links to <head>.

	add_theme_support( 'automatic-feed-links' );



	// This theme uses wp_nav_menu() in one location.

	register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );



	// 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();



	// 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 ) );



	// 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' );



	// ... and thus ends the changeable header business.



	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.

	register_default_headers( array(

		'wheel' => array(

			'url' => '%s/images/headers/wheel.jpg',

			'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Wheel', 'twentyeleven' )

		),

		'shore' => array(

			'url' => '%s/images/headers/shore.jpg',

			'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Shore', 'twentyeleven' )

		),

		'trolley' => array(

			'url' => '%s/images/headers/trolley.jpg',

			'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Trolley', 'twentyeleven' )

		),

		'pine-cone' => array(

			'url' => '%s/images/headers/pine-cone.jpg',

			'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Pine Cone', 'twentyeleven' )

		),

		'chessboard' => array(

			'url' => '%s/images/headers/chessboard.jpg',

			'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Chessboard', 'twentyeleven' )

		),

		'lanterns' => array(

			'url' => '%s/images/headers/lanterns.jpg',

			'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Lanterns', 'twentyeleven' )

		),

		'willow' => array(

			'url' => '%s/images/headers/willow.jpg',

			'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Willow', 'twentyeleven' )

		),

		'hanoi' => array(

			'url' => '%s/images/headers/hanoi.jpg',

			'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',

			/* translators: header image description */

			'description' => __( 'Hanoi Plant', 'twentyeleven' )

		)

	) );

}

14753

twentyeleven_print_link_color_style

Definition:
function twentyeleven_print_link_color_style() {}

Add a style block to the theme for the current link color.
This function is attached to the wp_head action hook.

Source code

function twentyeleven_print_link_color_style() {

	$options = twentyeleven_get_theme_options();

	$link_color = $options['link_color'];



	$default_options = twentyeleven_get_default_theme_options();



	// Don't do anything if the current link color is the default.

	if ( $default_options['link_color'] == $link_color )

		return;

?>

	<style>

		/* Link color */

		a,

		#site-title a:focus,

		#site-title a:hover,

		#site-title a:active,

		.entry-title a:hover,

		.entry-title a:focus,

		.entry-title a:active,

		.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,

		#site-generator a:hover {

			color: <?php echo $link_color; ?>;

		}

		section.recent-posts .other-recent-posts .comments-link a:hover {

			border-color: <?php echo $link_color; ?>;

		}

		article.feature-image.small .entry-summary p a:hover,

		.entry-header .comments-link a:hover,

		.entry-header .comments-link a:focus,

		.entry-header .comments-link a:active,

		.feature-slider a.active {

			background-color: <?php echo $link_color; ?>;

		}

	</style>

<?php

}

14751

twentyeleven_posted_on

Definition:
function twentyeleven_posted_on() {}

Prints HTML with meta information for the current post-date/time and author.
Create your own twentyeleven_posted_on to override in a child theme

Source code

function twentyeleven_posted_on() {

	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),

		esc_url( get_permalink() ),

		esc_attr( get_the_time() ),

		esc_attr( get_the_date( 'c' ) ),

		esc_html( get_the_date() ),

		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),

		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),

		get_the_author()

	);

}

14749

twentyeleven_page_menu_args

Definition:
function twentyeleven_page_menu_args( $args ) {}

Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.

Parameters

  • $args

Source code

function twentyeleven_page_menu_args( $args ) {

	$args['show_home'] = true;

	return $args;

}

14747

twentyeleven_option_page_capability

Definition:
function twentyeleven_option_page_capability( $capability ) {}

Change the capability required to save the ‘twentyeleven_options’ options group.

Parameters

  • string $capability: The capability used for the page, which is manage_options by default.

Return values

returns:The capability to actually use.

Source code

function twentyeleven_option_page_capability( $capability ) {

	return 'edit_theme_options';

}

14745