| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Twenty Twelve functions and definitions 4 * 5 * Sets up the theme and provides some helper functions, which are used 6 * in the theme as custom template tags. Others are attached to action and 7 * filter hooks in WordPress to change core functionality. 8 * 9 * When using a child theme you can override certain functions (those wrapped 10 * in a function_exists() call) by defining them first in your child theme's 11 * functions.php file. The child theme's functions.php file is included before 12 * the parent theme's file, so the child theme functions would be used. 13 * 14 * @link https://developer.wordpress.org/themes/basics/theme-functions/ 15 * @link https://developer.wordpress.org/themes/advanced-topics/child-themes/ 16 * 17 * Functions that are not pluggable (not wrapped in function_exists()) are instead attached 18 * to a filter or action hook. 19 * 20 * For more information on hooks, actions, and filters, @link https://developer.wordpress.org/plugins/ 21 * 22 * @package WordPress 23 * @subpackage Twenty_Twelve 24 * @since Twenty Twelve 1.0 25 */ 26 27 // Set up the content width value based on the theme's design and stylesheet. 28 if ( ! isset( $content_width ) ) { 29 $content_width = 625; 30 } 31 32 /** 33 * Twenty Twelve setup. 34 * 35 * Sets up theme defaults and registers the various WordPress features that 36 * Twenty Twelve supports. 37 * 38 * @uses load_theme_textdomain() For translation/localization support. 39 * @uses add_editor_style() To add a Visual Editor stylesheet. 40 * @uses add_theme_support() To add support for post thumbnails, automatic feed links, 41 * custom background, and post formats. 42 * @uses register_nav_menu() To add support for navigation menus. 43 * @uses set_post_thumbnail_size() To set a custom post thumbnail size. 44 * 45 * @since Twenty Twelve 1.0 46 */ 47 function twentytwelve_setup() { 48 /* 49 * Makes Twenty Twelve available for translation. 50 * 51 * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentytwelve 52 * If you're building a theme based on Twenty Twelve, use a find and replace 53 * to change 'twentytwelve' to the name of your theme in all the template files. 54 * 55 * Manual loading of text domain is not required after the introduction of 56 * just in time translation loading in WordPress version 4.6. 57 * 58 * @ticket 58318 59 */ 60 if ( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ) { 61 load_theme_textdomain( 'twentytwelve' ); 62 } 63 64 // This theme styles the visual editor with editor-style.css to match the theme style. 65 add_editor_style(); 66 67 // Load regular editor styles into the new block-based editor. 68 add_theme_support( 'editor-styles' ); 69 70 // Load default block styles. 71 add_theme_support( 'wp-block-styles' ); 72 73 // Add support for responsive embeds. 74 add_theme_support( 'responsive-embeds' ); 75 76 // Add support for custom color scheme. 77 add_theme_support( 78 'editor-color-palette', 79 array( 80 array( 81 'name' => __( 'Blue', 'twentytwelve' ), 82 'slug' => 'blue', 83 'color' => '#21759b', 84 ), 85 array( 86 'name' => __( 'Dark Gray', 'twentytwelve' ), 87 'slug' => 'dark-gray', 88 'color' => '#444', 89 ), 90 array( 91 'name' => __( 'Medium Gray', 'twentytwelve' ), 92 'slug' => 'medium-gray', 93 'color' => '#9f9f9f', 94 ), 95 array( 96 'name' => __( 'Light Gray', 'twentytwelve' ), 97 'slug' => 'light-gray', 98 'color' => '#e6e6e6', 99 ), 100 array( 101 'name' => __( 'White', 'twentytwelve' ), 102 'slug' => 'white', 103 'color' => '#fff', 104 ), 105 ) 106 ); 107 108 // Adds RSS feed links to <head> for posts and comments. 109 add_theme_support( 'automatic-feed-links' ); 110 111 // This theme supports a variety of post formats. 112 add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) ); 113 114 // This theme uses wp_nav_menu() in one location. 115 register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) ); 116 117 /* 118 * This theme supports custom background color and image, 119 * and here we also set up the default background color. 120 */ 121 add_theme_support( 122 'custom-background', 123 array( 124 'default-color' => 'e6e6e6', 125 ) 126 ); 127 128 // This theme uses a custom image size for featured images, displayed on "standard" posts. 129 add_theme_support( 'post-thumbnails' ); 130 set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop. 131 132 // Indicate widget sidebars can use selective refresh in the Customizer. 133 add_theme_support( 'customize-selective-refresh-widgets' ); 134 } 135 add_action( 'after_setup_theme', 'twentytwelve_setup' ); 136 137 /** 138 * Adds support for a custom header image. 139 */ 140 require get_template_directory() . '/inc/custom-header.php'; 141 142 /** 143 * Registers block patterns and pattern categories. 144 * 145 * @since Twenty Twelve 4.4 146 */ 147 function twentytwelve_register_block_patterns() { 148 require get_template_directory() . '/inc/block-patterns.php'; 149 } 150 151 add_action( 'init', 'twentytwelve_register_block_patterns' ); 152 153 if ( ! function_exists( 'twentytwelve_get_font_url' ) ) : 154 /** 155 * Return the font stylesheet URL if available. 156 * 157 * The use of Open Sans by default is localized. For languages that use 158 * characters not supported by the font, the font can be disabled. 159 * 160 * @since Twenty Twelve 1.2 161 * @since Twenty Twelve 3.9 Replaced Google URL with self-hosted font. 162 * 163 * @return string Font stylesheet or empty string if disabled. 164 */ 165 function twentytwelve_get_font_url() { 166 $font_url = ''; 167 168 /* 169 * translators: If there are characters in your language that are not supported 170 * by Open Sans, translate this to 'off'. Do not translate into your own language. 171 */ 172 if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { 173 $font_url = get_template_directory_uri() . '/fonts/font-open-sans.css'; 174 } 175 176 return $font_url; 177 } 178 endif; 179 180 /** 181 * Enqueues scripts and styles for front end. 182 * 183 * @since Twenty Twelve 1.0 184 */ 185 function twentytwelve_scripts_styles() { 186 global $wp_styles; 187 188 /* 189 * Adds JavaScript to pages with the comment form to support 190 * sites with threaded comments (when in use). 191 */ 192 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 193 wp_enqueue_script( 'comment-reply' ); 194 } 195 196 // Adds JavaScript for handling the navigation menu hide-and-show behavior. 197 wp_enqueue_script( 198 'twentytwelve-navigation', 199 get_template_directory_uri() . '/js/navigation.js', 200 array( 'jquery' ), 201 '20250303', 202 array( 203 'in_footer' => false, // Because involves header. 204 'strategy' => 'defer', 205 ) 206 ); 207 208 $font_url = twentytwelve_get_font_url(); 209 if ( ! empty( $font_url ) ) { 210 $font_version = ( 0 === strpos( (string) twentytwelve_get_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 211 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), $font_version ); 212 } 213 214 // Loads our main stylesheet. 215 wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri(), array(), '20250715' ); 216 217 // Theme block stylesheet. 218 wp_enqueue_style( 'twentytwelve-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentytwelve-style' ), '20240812' ); 219 220 // Register the Internet Explorer specific stylesheet. 221 wp_register_style( 'twentytwelve-ie', false, array( 'twentytwelve-style' ) ); 222 } 223 add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' ); 224 225 /** 226 * Enqueues styles for the block-based editor. 227 * 228 * @since Twenty Twelve 2.6 229 */ 230 function twentytwelve_block_editor_styles() { 231 // Block styles. 232 wp_enqueue_style( 'twentytwelve-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20250715' ); 233 // Add custom fonts. 234 $font_version = ( 0 === strpos( (string) twentytwelve_get_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 235 wp_enqueue_style( 'twentytwelve-fonts', twentytwelve_get_font_url(), array(), $font_version ); 236 } 237 add_action( 'enqueue_block_editor_assets', 'twentytwelve_block_editor_styles' ); 238 239 /** 240 * Adds preconnect for Google Fonts. 241 * 242 * @since Twenty Twelve 2.2 243 * @deprecated Twenty Twelve 3.9 Disabled filter because, by default, fonts are self-hosted. 244 * 245 * @param array $urls URLs to print for resource hints. 246 * @param string $relation_type The relation type the URLs are printed. 247 * @return array URLs to print for resource hints. 248 */ 249 function twentytwelve_resource_hints( $urls, $relation_type ) { 250 if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) && 'preconnect' === $relation_type ) { 251 if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) { 252 $urls[] = array( 253 'href' => 'https://fonts.gstatic.com', 254 'crossorigin', 255 ); 256 } else { 257 $urls[] = 'https://fonts.gstatic.com'; 258 } 259 } 260 261 return $urls; 262 } 263 // add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 ); 264 265 /** 266 * Filters TinyMCE CSS path to include hosted fonts. 267 * 268 * Adds additional stylesheets to the TinyMCE editor if needed. 269 * 270 * @uses twentytwelve_get_font_url() To get the font stylesheet URL. 271 * 272 * @since Twenty Twelve 1.2 273 * 274 * @param string $mce_css CSS path to load in TinyMCE. 275 * @return string Filtered CSS path. 276 */ 277 function twentytwelve_mce_css( $mce_css ) { 278 $font_url = twentytwelve_get_font_url(); 279 280 if ( empty( $font_url ) ) { 281 return $mce_css; 282 } 283 284 if ( ! empty( $mce_css ) ) { 285 $mce_css .= ','; 286 } 287 288 $mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) ); 289 290 return $mce_css; 291 } 292 add_filter( 'mce_css', 'twentytwelve_mce_css' ); 293 294 /** 295 * Filters the page title. 296 * 297 * Creates a nicely formatted and more specific title element text 298 * for output in head of document, based on current view. 299 * 300 * @since Twenty Twelve 1.0 301 * 302 * @param string $title Default title text for current view. 303 * @param string $sep Optional separator. 304 * @return string Filtered title. 305 */ 306 function twentytwelve_wp_title( $title, $sep ) { 307 global $paged, $page; 308 309 if ( is_feed() ) { 310 return $title; 311 } 312 313 // Add the site name. 314 $title .= get_bloginfo( 'name', 'display' ); 315 316 // Add the site description for the home/front page. 317 $site_description = get_bloginfo( 'description', 'display' ); 318 if ( $site_description && ( is_home() || is_front_page() ) ) { 319 $title = "$title $sep $site_description"; 320 } 321 322 // Add a page number if necessary. 323 if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { 324 /* translators: %s: Page number. */ 325 $title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) ); 326 } 327 328 return $title; 329 } 330 add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 ); 331 332 /** 333 * Filters the page menu arguments. 334 * 335 * Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link. 336 * 337 * @since Twenty Twelve 1.0 338 */ 339 function twentytwelve_page_menu_args( $args ) { 340 if ( ! isset( $args['show_home'] ) ) { 341 $args['show_home'] = true; 342 } 343 return $args; 344 } 345 add_filter( 'wp_page_menu_args', 'twentytwelve_page_menu_args' ); 346 347 /** 348 * Registers sidebars. 349 * 350 * Registers our main widget area and the front page widget areas. 351 * 352 * @since Twenty Twelve 1.0 353 */ 354 function twentytwelve_widgets_init() { 355 register_sidebar( 356 array( 357 'name' => __( 'Main Sidebar', 'twentytwelve' ), 358 'id' => 'sidebar-1', 359 'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ), 360 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 361 'after_widget' => '</aside>', 362 'before_title' => '<h3 class="widget-title">', 363 'after_title' => '</h3>', 364 ) 365 ); 366 367 register_sidebar( 368 array( 369 'name' => __( 'First Front Page Widget Area', 'twentytwelve' ), 370 'id' => 'sidebar-2', 371 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), 372 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 373 'after_widget' => '</aside>', 374 'before_title' => '<h3 class="widget-title">', 375 'after_title' => '</h3>', 376 ) 377 ); 378 379 register_sidebar( 380 array( 381 'name' => __( 'Second Front Page Widget Area', 'twentytwelve' ), 382 'id' => 'sidebar-3', 383 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), 384 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 385 'after_widget' => '</aside>', 386 'before_title' => '<h3 class="widget-title">', 387 'after_title' => '</h3>', 388 ) 389 ); 390 } 391 add_action( 'widgets_init', 'twentytwelve_widgets_init' ); 392 393 if ( ! function_exists( 'wp_get_list_item_separator' ) ) : 394 /** 395 * Retrieves the list item separator based on the locale. 396 * 397 * Added for backward compatibility to support pre-6.0.0 WordPress versions. 398 * 399 * @since 6.0.0 400 */ 401 function wp_get_list_item_separator() { 402 /* translators: Used between list items, there is a space after the comma. */ 403 return __( ', ', 'twentytwelve' ); 404 } 405 endif; 406 407 if ( ! function_exists( 'twentytwelve_content_nav' ) ) : 408 /** 409 * Displays navigation to next/previous pages when applicable. 410 * 411 * @since Twenty Twelve 1.0 412 */ 413 function twentytwelve_content_nav( $html_id ) { 414 global $wp_query; 415 416 if ( $wp_query->max_num_pages > 1 ) : ?> 417 <nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation"> 418 <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> 419 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> 420 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> 421 </nav><!-- .navigation --> 422 <?php 423 endif; 424 } 425 endif; 426 427 if ( ! function_exists( 'twentytwelve_comment' ) ) : 428 /** 429 * Template for comments and pingbacks. 430 * 431 * To override this walker in a child theme without modifying the comments template 432 * simply create your own twentytwelve_comment(), and that function will be used instead. 433 * 434 * Used as a callback by wp_list_comments() for displaying the comments. 435 * 436 * @since Twenty Twelve 1.0 437 * 438 * @global WP_Post $post Global post object. 439 */ 440 function twentytwelve_comment( $comment, $args, $depth ) { 441 $GLOBALS['comment'] = $comment; 442 switch ( $comment->comment_type ) : 443 case 'pingback': 444 case 'trackback': 445 // Display trackbacks differently than normal comments. 446 ?> 447 <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> 448 <p><?php _e( 'Pingback:', 'twentytwelve' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></p> 449 <?php 450 break; 451 default: 452 // Proceed with normal comments. 453 global $post; 454 ?> 455 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 456 <article id="comment-<?php comment_ID(); ?>" class="comment"> 457 <header class="comment-meta comment-author vcard"> 458 <?php 459 echo get_avatar( $comment, 44 ); 460 printf( 461 '<cite><b class="fn">%1$s</b> %2$s</cite>', 462 get_comment_author_link(), 463 // If current post author is also comment author, make it known visually. 464 ( $comment->user_id === $post->post_author ) ? '<span>' . __( 'Post author', 'twentytwelve' ) . '</span>' : '' 465 ); 466 printf( 467 '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', 468 esc_url( get_comment_link( $comment->comment_ID ) ), 469 get_comment_time( 'c' ), 470 /* translators: 1: Date, 2: Time. */ 471 sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() ) 472 ); 473 ?> 474 </header><!-- .comment-meta --> 475 476 <?php 477 $commenter = wp_get_current_commenter(); 478 if ( $commenter['comment_author_email'] ) { 479 $moderation_note = __( 'Your comment is awaiting moderation.', 'twentytwelve' ); 480 } else { 481 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentytwelve' ); 482 } 483 ?> 484 485 <?php if ( '0' === $comment->comment_approved ) : ?> 486 <p class="comment-awaiting-moderation"><?php echo $moderation_note; ?></p> 487 <?php endif; ?> 488 489 <section class="comment-content comment"> 490 <?php comment_text(); ?> 491 <?php edit_comment_link( __( 'Edit', 'twentytwelve' ), '<p class="edit-link">', '</p>' ); ?> 492 </section><!-- .comment-content --> 493 494 <div class="reply"> 495 <?php 496 comment_reply_link( 497 array_merge( 498 $args, 499 array( 500 'reply_text' => __( 'Reply', 'twentytwelve' ), 501 'after' => ' <span>↓</span>', 502 'depth' => $depth, 503 'max_depth' => $args['max_depth'], 504 ) 505 ) 506 ); 507 ?> 508 </div><!-- .reply --> 509 </article><!-- #comment-## --> 510 <?php 511 break; 512 endswitch; // End comment_type check. 513 } 514 endif; 515 516 if ( ! function_exists( 'twentytwelve_entry_meta' ) ) : 517 /** 518 * Sets up post entry meta. 519 * 520 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. 521 * 522 * Create your own twentytwelve_entry_meta() to override in a child theme. 523 * 524 * @since Twenty Twelve 1.0 525 */ 526 function twentytwelve_entry_meta() { 527 $categories_list = get_the_category_list( wp_get_list_item_separator() ); 528 529 $tags_list = get_the_tag_list( '', wp_get_list_item_separator() ); 530 531 $date = sprintf( 532 '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', 533 esc_url( get_permalink() ), 534 esc_attr( get_the_time() ), 535 esc_attr( get_the_date( 'c' ) ), 536 esc_html( get_the_date() ) 537 ); 538 539 $author = sprintf( 540 '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', 541 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), 542 /* translators: %s: Author display name. */ 543 esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ), 544 get_the_author() 545 ); 546 547 if ( $tags_list && ! is_wp_error( $tags_list ) ) { 548 /* translators: 1: Category name, 2: Tag name, 3: Date, 4: Author display name. */ 549 $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); 550 } elseif ( $categories_list ) { 551 /* translators: 1: Category name, 3: Date, 4: Author display name. */ 552 $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); 553 } else { 554 /* translators: 3: Date, 4: Author display name. */ 555 $utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); 556 } 557 558 printf( 559 $utility_text, 560 $categories_list, 561 $tags_list, 562 $date, 563 $author 564 ); 565 } 566 endif; 567 568 /** 569 * Extends the default WordPress body classes. 570 * 571 * Extends the default WordPress body class to denote: 572 * 1. Using a full-width layout, when no active widgets in the sidebar 573 * or full-width template. 574 * 2. Front Page template: thumbnail in use and number of sidebars for 575 * widget areas. 576 * 3. White or empty background color to change the layout and spacing. 577 * 4. Custom fonts enabled. 578 * 5. Single or multiple authors. 579 * 580 * @since Twenty Twelve 1.0 581 * 582 * @param array $classes Existing class values. 583 * @return array Filtered class values. 584 */ 585 function twentytwelve_body_class( $classes ) { 586 $background_color = get_background_color(); 587 $background_image = get_background_image(); 588 589 if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) ) { 590 $classes[] = 'full-width'; 591 } 592 593 if ( is_page_template( 'page-templates/front-page.php' ) ) { 594 $classes[] = 'template-front-page'; 595 if ( has_post_thumbnail() ) { 596 $classes[] = 'has-post-thumbnail'; 597 } 598 if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) { 599 $classes[] = 'two-sidebars'; 600 } 601 } 602 603 if ( empty( $background_image ) ) { 604 if ( empty( $background_color ) ) { 605 $classes[] = 'custom-background-empty'; 606 } elseif ( in_array( $background_color, array( 'fff', 'ffffff' ), true ) ) { 607 $classes[] = 'custom-background-white'; 608 } 609 } 610 611 // Enable custom font class only if the font CSS is queued to load. 612 if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) ) { 613 $classes[] = 'custom-font-enabled'; 614 } 615 616 if ( ! is_multi_author() ) { 617 $classes[] = 'single-author'; 618 } 619 620 return $classes; 621 } 622 add_filter( 'body_class', 'twentytwelve_body_class' ); 623 624 /** 625 * Adjusts content width in certain contexts. 626 * 627 * Adjusts content_width value for full-width and single image attachment 628 * templates, and when there are no active widgets in the sidebar. 629 * 630 * @since Twenty Twelve 1.0 631 */ 632 function twentytwelve_content_width() { 633 if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) { 634 global $content_width; 635 $content_width = 960; 636 } 637 } 638 add_action( 'template_redirect', 'twentytwelve_content_width' ); 639 640 /** 641 * Registers postMessage support. 642 * 643 * Adds postMessage support for site title and description for the Customizer. 644 * 645 * @since Twenty Twelve 1.0 646 * 647 * @param WP_Customize_Manager $wp_customize Customizer object. 648 */ 649 function twentytwelve_customize_register( $wp_customize ) { 650 $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 651 $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 652 $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; 653 654 if ( isset( $wp_customize->selective_refresh ) ) { 655 $wp_customize->selective_refresh->add_partial( 656 'blogname', 657 array( 658 'selector' => '.site-title > a', 659 'container_inclusive' => false, 660 'render_callback' => 'twentytwelve_customize_partial_blogname', 661 ) 662 ); 663 $wp_customize->selective_refresh->add_partial( 664 'blogdescription', 665 array( 666 'selector' => '.site-description', 667 'container_inclusive' => false, 668 'render_callback' => 'twentytwelve_customize_partial_blogdescription', 669 ) 670 ); 671 } 672 } 673 add_action( 'customize_register', 'twentytwelve_customize_register' ); 674 675 /** 676 * Renders the site title for the selective refresh partial. 677 * 678 * @since Twenty Twelve 2.0 679 * 680 * @see twentytwelve_customize_register() 681 * 682 * @return void 683 */ 684 function twentytwelve_customize_partial_blogname() { 685 bloginfo( 'name' ); 686 } 687 688 /** 689 * Renders the site tagline for the selective refresh partial. 690 * 691 * @since Twenty Twelve 2.0 692 * 693 * @see twentytwelve_customize_register() 694 * 695 * @return void 696 */ 697 function twentytwelve_customize_partial_blogdescription() { 698 bloginfo( 'description' ); 699 } 700 701 /** 702 * Enqueues JavaScript postMessage handlers for the Customizer. 703 * 704 * Binds JS handlers to make the Customizer preview reload changes asynchronously. 705 * 706 * @since Twenty Twelve 1.0 707 */ 708 function twentytwelve_customize_preview_js() { 709 wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20250217', array( 'in_footer' => true ) ); 710 } 711 add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' ); 712 713 /** 714 * Modifies tag cloud widget arguments to display all tags in the same font size 715 * and use list format for better accessibility. 716 * 717 * @since Twenty Twelve 2.4 718 * 719 * @param array $args Arguments for tag cloud widget. 720 * @return array The filtered arguments for tag cloud widget. 721 */ 722 function twentytwelve_widget_tag_cloud_args( $args ) { 723 $args['largest'] = 22; 724 $args['smallest'] = 8; 725 $args['unit'] = 'pt'; 726 $args['format'] = 'list'; 727 728 return $args; 729 } 730 add_filter( 'widget_tag_cloud_args', 'twentytwelve_widget_tag_cloud_args' ); 731 732 if ( ! function_exists( 'wp_body_open' ) ) : 733 /** 734 * Fires the wp_body_open action. 735 * 736 * Added for backward compatibility to support pre-5.2.0 WordPress versions. 737 * 738 * @since Twenty Twelve 3.0 739 */ 740 function wp_body_open() { 741 /** 742 * Triggered after the opening <body> tag. 743 * 744 * @since Twenty Twelve 3.0 745 */ 746 do_action( 'wp_body_open' ); 747 } 748 endif;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Oct 25 08:20:05 2025 | Cross-referenced by PHPXref |