Changeset 19915 for trunk/wp-content/themes/twentytwelve/functions.php
- Timestamp:
- 02/14/2012 03:54:46 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentytwelve/functions.php
r19845 r19915 37 37 add_action( 'after_setup_theme', 'twentytwelve_setup' ); 38 38 39 if ( ! function_exists( 'twentytwelve_setup' ) ) :39 if ( ! function_exists( 'twentytwelve_setup' ) ) : 40 40 /** 41 41 * Sets up theme defaults and registers support for various WordPress features. … … 60 60 add_theme_support( 'automatic-feed-links' ); 61 61 62 // Add support for a variety of post formats 63 add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote' ) ); 64 62 65 // This theme uses wp_nav_menu() in one location. 63 66 register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) ); 64 67 65 // Add support for custom background s68 // Add support for custom background. 66 69 add_custom_background(); 67 } 70 71 // Add support for a custom header image. 72 $header_args = array( 73 'random-default' => true, 74 'flex-height' => true, 75 'suggested-height' => apply_filters( 'twentytwelve_header_image_height', 250 ), 76 'flex-width' => true, 77 'max-width' => apply_filters( 'twentytwelve_header_image_max_width', 2000 ), 78 'suggested-width' => apply_filters( 'twentytwelve_header_image_width', 960 ), 79 ); 80 add_theme_support( 'custom-header', $header_args ); 81 add_custom_image_header( 'twentytwelve_header_style', 'twentytwelve_admin_header_style', 'twentytwelve_admin_header_image' ); 82 83 // The default header text color 84 define( 'HEADER_TEXTCOLOR', '444' ); 85 } 86 endif; 87 88 if ( ! function_exists( 'twentytwelve_header_style' ) ) : 89 /** 90 * Styles the header image and text displayed on the blog 91 * 92 * get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank'), or any hex value 93 * 94 * @since Twenty Twelve 1.0 95 */ 96 function twentytwelve_header_style() { 97 // If no custom options for text are set, let's bail 98 if ( HEADER_TEXTCOLOR == get_header_textcolor() ) 99 return; 100 // If we get this far, we have custom styles. 101 ?> 102 <style type="text/css"> 103 <?php 104 // Has the text been hidden? 105 if ( 'blank' == get_header_textcolor() ) : 106 ?> 107 .site-title, 108 .site-description { 109 position: absolute !important; 110 clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ 111 clip: rect(1px, 1px, 1px, 1px); 112 } 113 <?php 114 // If the user has set a custom color for the text, use that. 115 else : 116 ?> 117 .site-title a, 118 .site-description { 119 color: #<?php echo get_header_textcolor(); ?> !important; 120 } 121 <?php endif; ?> 122 </style> 123 <?php 124 } 125 endif; 126 127 if ( ! function_exists( 'twentytwelve_admin_header_style' ) ) : 128 /** 129 * Styles the header image displayed on the Appearance > Header admin panel. 130 * 131 * Referenced via add_custom_image_header() in twentytwelve_setup(). 132 * 133 * @since Twenty Twelve 1.0 134 */ 135 function twentytwelve_admin_header_style() { 136 ?> 137 <style type="text/css"> 138 .appearance_page_custom-header #headimg { 139 border: none; 140 } 141 #headimg h1, 142 #headimg h2 { 143 line-height: 1.6; 144 margin: 0; 145 padding: 0; 146 } 147 #headimg h1 { 148 font-size: 30px; 149 } 150 #headimg h1 a { 151 text-decoration: none; 152 } 153 #headimg h2 { 154 font: normal 13px/1.8 "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif; 155 margin-bottom: 24px; 156 } 157 #headimg img { 158 } 159 </style> 160 <?php 161 } 162 endif; 163 164 if ( ! function_exists( 'twentytwelve_admin_header_image' ) ) : 165 /** 166 * Custom header image markup displayed on the Appearance > Header admin panel. 167 * 168 * Referenced via add_custom_image_header() in twentytwelve_setup(). 169 * 170 * @since Twenty Twelve 1.0 171 */ 172 function twentytwelve_admin_header_image() { ?> 173 <div id="headimg"> 174 <?php 175 if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ) 176 $style = ' style="display:none;"'; 177 else 178 $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"'; 179 ?> 180 <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1> 181 <h2 id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></h2> 182 <?php $header_image = get_header_image(); 183 if ( ! empty( $header_image ) ) : ?> 184 <img src="<?php echo esc_url( $header_image ); ?>" alt="" /> 185 <?php endif; ?> 186 </div> 187 <?php } 68 188 endif; 69 189 … … 90 210 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 91 211 'after_widget' => "</aside>", 92 'before_title' => '<h3 class="widget-title ">',212 'before_title' => '<h3 class="widget-title all-caps-title">', 93 213 'after_title' => '</h3>', 94 214 ) ); … … 108 228 <nav id="<?php echo $nav_id; ?>"> 109 229 <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> 110 <div class="nav-previous "><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div>111 <div class="nav-next "><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div>230 <div class="nav-previous alignleft"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> 231 <div class="nav-next alignright"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> 112 232 </nav><!-- #nav-above --> 113 233 <?php endif; … … 203 323 } 204 324 endif; 325 326 /** 327 * Extends the default WordPress body class to denote a full-width layout. 328 * 329 * Used in two cases: no active widgets in sidebar, and full-width page template. 330 * 331 * @since Twenty Twelve 1.0 332 */ 333 function twentytwelve_body_class( $classes ) { 334 if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'full-width' ) ) 335 $classes[] = 'full-width'; 336 337 return $classes; 338 } 339 add_filter( 'body_class', 'twentytwelve_body_class' );
Note: See TracChangeset
for help on using the changeset viewer.