- Timestamp:
- 08/14/2013 04:38:01 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/functions.php
r24990 r25021 28 28 * before the init hook. The init hook is too late for some features, such as indicating 29 29 * support post thumbnails. 30 *31 30 */ 32 31 function twentyfourteen_setup() { 33 /**34 * Custom template tags for this theme.35 */36 require( get_template_directory() . '/inc/template-tags.php' );37 38 /**39 * Customizer additions40 */41 require( get_template_directory() . '/inc/customizer.php' );42 32 43 33 /** … … 82 72 * This theme allows users to set a custom background. 83 73 */ 84 $args = apply_filters( 'twentyfourteen_custom_background_args', array( 'default-color' => 'f5f5f5' ) ); 85 86 if ( function_exists( 'wp_get_theme' ) ) { 87 add_theme_support( 'custom-background', $args ); 88 } else { 89 // Compat: Versions of WordPress prior to 3.4. 90 define( 'BACKGROUND_COLOR', $args['default-color'] ); 91 add_custom_background(); 92 } 74 add_theme_support( 'custom-background', apply_filters( 'twentyfourteen_custom_background_args', array( 75 'default-color' => 'f5f5f5', 76 ) ) ); 93 77 } 94 78 endif; // twentyfourteen_setup … … 113 97 return false; 114 98 115 $minimum = absint( $minimum );116 99 $featured_posts = apply_filters( 'twentyfourteen_get_featured_posts', array() ); 117 100 118 if ( ! is_array( $featured_posts ) ) 119 return false; 120 121 if ( $minimum > count( $featured_posts ) ) 122 return false; 123 124 return true; 101 return is_array( $featured_posts ) && count( $featured_posts ) > absint( $minimum ); 125 102 } 126 103 … … 192 169 193 170 /** 194 * Register Google fonts for Twenty Fourteen 171 * Register Google fonts for Twenty Fourteen. 195 172 * 196 173 */ … … 198 175 /* translators: If there are characters in your language that are not supported 199 176 by Lato, translate this to 'off'. Do not translate into your own language. */ 200 if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) { 201 202 $protocol = is_ssl() ? 'https' : 'http'; 203 204 wp_register_style( 'twentyfourteen-lato', "$protocol://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic", array(), null ); 205 } 177 if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) 178 wp_register_style( 'twentyfourteen-lato', '//fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic', array(), null ); 206 179 } 207 180 add_action( 'init', 'twentyfourteen_fonts' ); … … 216 189 wp_enqueue_style( 'twentyfourteen-lato' ); 217 190 218 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {191 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) 219 192 wp_enqueue_script( 'comment-reply' ); 220 } 221 222 if ( is_singular() && wp_attachment_is_image() ) { 193 194 if ( is_singular() && wp_attachment_is_image() ) 223 195 wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' ); 224 }225 196 226 197 wp_enqueue_script( 'twentyfourteen-theme', get_template_directory_uri() . '/js/theme.js', array( 'jquery' ), '20130402', true ); … … 232 203 * 233 204 */ 234 function twentyfourteen_admin_fonts( $hook_suffix ) { 235 if ( 'appearance_page_custom-header' != $hook_suffix ) 236 return; 237 205 function twentyfourteen_admin_fonts() { 238 206 wp_enqueue_style( 'twentyfourteen-lato' ); 239 207 } 240 add_action( 'admin_ enqueue_scripts', 'twentyfourteen_admin_fonts' );208 add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' ); 241 209 242 210 /** … … 285 253 } 286 254 add_filter( 'get_the_excerpt', 'twentyfourteen_custom_excerpt_more' ); 255 256 if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) : 257 /** 258 * Prints the attached image with a link to the next attached image. 259 * 260 * @since Twenty Thirteen 1.0 261 * 262 * @return void 263 */ 264 function twentyfourteen_the_attached_image() { 265 $post = get_post(); 266 $attachment_size = apply_filters( 'twentyfourteen_attachment_size', array( 1200, 1200 ) ); 267 $next_attachment_url = wp_get_attachment_url(); 268 269 /** 270 * Grab the IDs of all the image attachments in a gallery so we can get the URL 271 * of the next adjacent image in a gallery, or the first image (if we're 272 * looking at the last image in a gallery), or, in a gallery of one, just the 273 * link to that image file. 274 */ 275 $attachment_ids = get_posts( array( 276 'post_parent' => $post->post_parent, 277 'fields' => 'ids', 278 'numberposts' => -1, 279 'post_status' => 'inherit', 280 'post_type' => 'attachment', 281 'post_mime_type' => 'image', 282 'order' => 'ASC', 283 'orderby' => 'menu_order ID' 284 ) ); 285 286 // If there is more than 1 attachment in a gallery... 287 if ( count( $attachment_ids ) > 1 ) { 288 foreach ( $attachment_ids as $attachment_id ) { 289 if ( $attachment_id == $post->ID ) { 290 $next_id = current( $attachment_ids ); 291 break; 292 } 293 } 294 295 // get the URL of the next image attachment... 296 if ( $next_id ) 297 $next_attachment_url = get_attachment_link( $next_id ); 298 299 // or get the URL of the first image attachment. 300 else 301 $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); 302 } 303 304 printf( '<a href="%1$s" title="%2$s" rel="attachment">%3$s</a>', 305 esc_url( $next_attachment_url ), 306 the_title_attribute( array( 'echo' => false ) ), 307 wp_get_attachment_image( $post->ID, $attachment_size ) 308 ); 309 } 310 endif; 287 311 288 312 /** … … 329 353 330 354 if ( $class ) 331 echo 'class="clearfix ' . $class . '"';355 printf( 'class="%s"', $class ); 332 356 } 333 357 … … 445 469 } 446 470 add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 ); 471 472 /** 473 * Custom template tags for this theme. 474 */ 475 require get_template_directory() . '/inc/template-tags.php'; 476 477 /** 478 * Customizer additions 479 */ 480 require get_template_directory() . '/inc/customizer.php';
Note: See TracChangeset
for help on using the changeset viewer.