[ 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 * Add support for a custom header image. 139 */ 140 require get_template_directory() . '/inc/custom-header.php'; 141 142 /** 143 * Add block patterns. 144 */ 145 require get_template_directory() . '/inc/block-patterns.php'; 146 147 if ( ! function_exists( 'twentytwelve_get_font_url' ) ) : 148 /** 149 * Return the font stylesheet URL if available. 150 * 151 * The use of Open Sans by default is localized. For languages that use 152 * characters not supported by the font, the font can be disabled. 153 * 154 * @since Twenty Twelve 1.2 155 * @since Twenty Twelve 3.9 Replaced Google URL with self-hosted font. 156 * 157 * @return string Font stylesheet or empty string if disabled. 158 */ 159 function twentytwelve_get_font_url() { 160 $font_url = ''; 161 162 /* 163 * translators: If there are characters in your language that are not supported 164 * by Open Sans, translate this to 'off'. Do not translate into your own language. 165 */ 166 if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { 167 $font_url = get_template_directory_uri() . '/fonts/font-open-sans.css'; 168 } 169 170 return $font_url; 171 } 172 endif; 173 174 /** 175 * Enqueue scripts and styles for front end. 176 * 177 * @since Twenty Twelve 1.0 178 */ 179 function twentytwelve_scripts_styles() { 180 global $wp_styles; 181 182 /* 183 * Adds JavaScript to pages with the comment form to support 184 * sites with threaded comments (when in use). 185 */ 186 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 187 wp_enqueue_script( 'comment-reply' ); 188 } 189 190 // Adds JavaScript for handling the navigation menu hide-and-show behavior. 191 wp_enqueue_script( 192 'twentytwelve-navigation', 193 get_template_directory_uri() . '/js/navigation.js', 194 array( 'jquery' ), 195 '20141205', 196 array( 197 'in_footer' => false, // Because involves header. 198 'strategy' => 'defer', 199 ) 200 ); 201 202 $font_url = twentytwelve_get_font_url(); 203 if ( ! empty( $font_url ) ) { 204 $font_version = ( 0 === strpos( (string) twentytwelve_get_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 205 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), $font_version ); 206 } 207 208 // Loads our main stylesheet. 209 wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri(), array(), '20231107' ); 210 211 // Theme block stylesheet. 212 wp_enqueue_style( 'twentytwelve-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentytwelve-style' ), '20230213' ); 213 214 // Loads the Internet Explorer specific stylesheet. 215 wp_enqueue_style( 'twentytwelve-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentytwelve-style' ), '20150214' ); 216 $wp_styles->add_data( 'twentytwelve-ie', 'conditional', 'lt IE 9' ); 217 } 218 add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' ); 219 220 /** 221 * Enqueue styles for the block-based editor. 222 * 223 * @since Twenty Twelve 2.6 224 */ 225 function twentytwelve_block_editor_styles() { 226 // Block styles. 227 wp_enqueue_style( 'twentytwelve-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20230213' ); 228 // Add custom fonts. 229 $font_version = ( 0 === strpos( (string) twentytwelve_get_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 230 wp_enqueue_style( 'twentytwelve-fonts', twentytwelve_get_font_url(), array(), $font_version ); 231 } 232 add_action( 'enqueue_block_editor_assets', 'twentytwelve_block_editor_styles' ); 233 234 /** 235 * Add preconnect for Google Fonts. 236 * 237 * @since Twenty Twelve 2.2 238 * @deprecated Twenty Twelve 3.9 Disabled filter because, by default, fonts are self-hosted. 239 * 240 * @param array $urls URLs to print for resource hints. 241 * @param string $relation_type The relation type the URLs are printed. 242 * @return array URLs to print for resource hints. 243 */ 244 function twentytwelve_resource_hints( $urls, $relation_type ) { 245 if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) && 'preconnect' === $relation_type ) { 246 if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) { 247 $urls[] = array( 248 'href' => 'https://fonts.gstatic.com', 249 'crossorigin', 250 ); 251 } else { 252 $urls[] = 'https://fonts.gstatic.com'; 253 } 254 } 255 256 return $urls; 257 } 258 // add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 ); 259 260 /** 261 * Filter TinyMCE CSS path to include hosted fonts. 262 * 263 * Adds additional stylesheets to the TinyMCE editor if needed. 264 * 265 * @uses twentytwelve_get_font_url() To get the font stylesheet URL. 266 * 267 * @since Twenty Twelve 1.2 268 * 269 * @param string $mce_css CSS path to load in TinyMCE. 270 * @return string Filtered CSS path. 271 */ 272 function twentytwelve_mce_css( $mce_css ) { 273 $font_url = twentytwelve_get_font_url(); 274 275 if ( empty( $font_url ) ) { 276 return $mce_css; 277 } 278 279 if ( ! empty( $mce_css ) ) { 280 $mce_css .= ','; 281 } 282 283 $mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) ); 284 285 return $mce_css; 286 } 287 add_filter( 'mce_css', 'twentytwelve_mce_css' ); 288 289 /** 290 * Filter the page title. 291 * 292 * Creates a nicely formatted and more specific title element text 293 * for output in head of document, based on current view. 294 * 295 * @since Twenty Twelve 1.0 296 * 297 * @param string $title Default title text for current view. 298 * @param string $sep Optional separator. 299 * @return string Filtered title. 300 */ 301 function twentytwelve_wp_title( $title, $sep ) { 302 global $paged, $page; 303 304 if ( is_feed() ) { 305 return $title; 306 } 307 308 // Add the site name. 309 $title .= get_bloginfo( 'name', 'display' ); 310 311 // Add the site description for the home/front page. 312 $site_description = get_bloginfo( 'description', 'display' ); 313 if ( $site_description && ( is_home() || is_front_page() ) ) { 314 $title = "$title $sep $site_description"; 315 } 316 317 // Add a page number if necessary. 318 if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { 319 /* translators: %s: Page number. */ 320 $title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) ); 321 } 322 323 return $title; 324 } 325 add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 ); 326 327 /** 328 * Filter the page menu arguments. 329 * 330 * Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link. 331 * 332 * @since Twenty Twelve 1.0 333 */ 334 function twentytwelve_page_menu_args( $args ) { 335 if ( ! isset( $args['show_home'] ) ) { 336 $args['show_home'] = true; 337 } 338 return $args; 339 } 340 add_filter( 'wp_page_menu_args', 'twentytwelve_page_menu_args' ); 341 342 /** 343 * Register sidebars. 344 * 345 * Registers our main widget area and the front page widget areas. 346 * 347 * @since Twenty Twelve 1.0 348 */ 349 function twentytwelve_widgets_init() { 350 register_sidebar( 351 array( 352 'name' => __( 'Main Sidebar', 'twentytwelve' ), 353 'id' => 'sidebar-1', 354 'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ), 355 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 356 'after_widget' => '</aside>', 357 'before_title' => '<h3 class="widget-title">', 358 'after_title' => '</h3>', 359 ) 360 ); 361 362 register_sidebar( 363 array( 364 'name' => __( 'First Front Page Widget Area', 'twentytwelve' ), 365 'id' => 'sidebar-2', 366 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), 367 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 368 'after_widget' => '</aside>', 369 'before_title' => '<h3 class="widget-title">', 370 'after_title' => '</h3>', 371 ) 372 ); 373 374 register_sidebar( 375 array( 376 'name' => __( 'Second Front Page Widget Area', 'twentytwelve' ), 377 'id' => 'sidebar-3', 378 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), 379 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 380 'after_widget' => '</aside>', 381 'before_title' => '<h3 class="widget-title">', 382 'after_title' => '</h3>', 383 ) 384 ); 385 } 386 add_action( 'widgets_init', 'twentytwelve_widgets_init' ); 387 388 if ( ! function_exists( 'wp_get_list_item_separator' ) ) : 389 /** 390 * Retrieves the list item separator based on the locale. 391 * 392 * Added for backward compatibility to support pre-6.0.0 WordPress versions. 393 * 394 * @since 6.0.0 395 */ 396 function wp_get_list_item_separator() { 397 /* translators: Used between list items, there is a space after the comma. */ 398 return __( ', ', 'twentytwelve' ); 399 } 400 endif; 401 402 if ( ! function_exists( 'twentytwelve_content_nav' ) ) : 403 /** 404 * Displays navigation to next/previous pages when applicable. 405 * 406 * @since Twenty Twelve 1.0 407 */ 408 function twentytwelve_content_nav( $html_id ) { 409 global $wp_query; 410 411 if ( $wp_query->max_num_pages > 1 ) : ?> 412 <nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation"> 413 <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> 414 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> 415 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> 416 </nav><!-- .navigation --> 417 <?php 418 endif; 419 } 420 endif; 421 422 if ( ! function_exists( 'twentytwelve_comment' ) ) : 423 /** 424 * Template for comments and pingbacks. 425 * 426 * To override this walker in a child theme without modifying the comments template 427 * simply create your own twentytwelve_comment(), and that function will be used instead. 428 * 429 * Used as a callback by wp_list_comments() for displaying the comments. 430 * 431 * @since Twenty Twelve 1.0 432 * 433 * @global WP_Post $post Global post object. 434 */ 435 function twentytwelve_comment( $comment, $args, $depth ) { 436 $GLOBALS['comment'] = $comment; 437 switch ( $comment->comment_type ) : 438 case 'pingback': 439 case 'trackback': 440 // Display trackbacks differently than normal comments. 441 ?> 442 <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> 443 <p><?php _e( 'Pingback:', 'twentytwelve' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></p> 444 <?php 445 break; 446 default: 447 // Proceed with normal comments. 448 global $post; 449 ?> 450 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 451 <article id="comment-<?php comment_ID(); ?>" class="comment"> 452 <header class="comment-meta comment-author vcard"> 453 <?php 454 echo get_avatar( $comment, 44 ); 455 printf( 456 '<cite><b class="fn">%1$s</b> %2$s</cite>', 457 get_comment_author_link(), 458 // If current post author is also comment author, make it known visually. 459 ( $comment->user_id === $post->post_author ) ? '<span>' . __( 'Post author', 'twentytwelve' ) . '</span>' : '' 460 ); 461 printf( 462 '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', 463 esc_url( get_comment_link( $comment->comment_ID ) ), 464 get_comment_time( 'c' ), 465 /* translators: 1: Date, 2: Time. */ 466 sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() ) 467 ); 468 ?> 469 </header><!-- .comment-meta --> 470 471 <?php 472 $commenter = wp_get_current_commenter(); 473 if ( $commenter['comment_author_email'] ) { 474 $moderation_note = __( 'Your comment is awaiting moderation.', 'twentytwelve' ); 475 } else { 476 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentytwelve' ); 477 } 478 ?> 479 480 <?php if ( '0' === $comment->comment_approved ) : ?> 481 <p class="comment-awaiting-moderation"><?php echo $moderation_note; ?></p> 482 <?php endif; ?> 483 484 <section class="comment-content comment"> 485 <?php comment_text(); ?> 486 <?php edit_comment_link( __( 'Edit', 'twentytwelve' ), '<p class="edit-link">', '</p>' ); ?> 487 </section><!-- .comment-content --> 488 489 <div class="reply"> 490 <?php 491 comment_reply_link( 492 array_merge( 493 $args, 494 array( 495 'reply_text' => __( 'Reply', 'twentytwelve' ), 496 'after' => ' <span>↓</span>', 497 'depth' => $depth, 498 'max_depth' => $args['max_depth'], 499 ) 500 ) 501 ); 502 ?> 503 </div><!-- .reply --> 504 </article><!-- #comment-## --> 505 <?php 506 break; 507 endswitch; // End comment_type check. 508 } 509 endif; 510 511 if ( ! function_exists( 'twentytwelve_entry_meta' ) ) : 512 /** 513 * Set up post entry meta. 514 * 515 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. 516 * 517 * Create your own twentytwelve_entry_meta() to override in a child theme. 518 * 519 * @since Twenty Twelve 1.0 520 */ 521 function twentytwelve_entry_meta() { 522 $categories_list = get_the_category_list( wp_get_list_item_separator() ); 523 524 $tags_list = get_the_tag_list( '', wp_get_list_item_separator() ); 525 526 $date = sprintf( 527 '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', 528 esc_url( get_permalink() ), 529 esc_attr( get_the_time() ), 530 esc_attr( get_the_date( 'c' ) ), 531 esc_html( get_the_date() ) 532 ); 533 534 $author = sprintf( 535 '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', 536 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), 537 /* translators: %s: Author display name. */ 538 esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ), 539 get_the_author() 540 ); 541 542 if ( $tags_list && ! is_wp_error( $tags_list ) ) { 543 /* translators: 1: Category name, 2: Tag name, 3: Date, 4: Author display name. */ 544 $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' ); 545 } elseif ( $categories_list ) { 546 /* translators: 1: Category name, 3: Date, 4: Author display name. */ 547 $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); 548 } else { 549 /* translators: 3: Date, 4: Author display name. */ 550 $utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); 551 } 552 553 printf( 554 $utility_text, 555 $categories_list, 556 $tags_list, 557 $date, 558 $author 559 ); 560 } 561 endif; 562 563 /** 564 * Extend the default WordPress body classes. 565 * 566 * Extends the default WordPress body class to denote: 567 * 1. Using a full-width layout, when no active widgets in the sidebar 568 * or full-width template. 569 * 2. Front Page template: thumbnail in use and number of sidebars for 570 * widget areas. 571 * 3. White or empty background color to change the layout and spacing. 572 * 4. Custom fonts enabled. 573 * 5. Single or multiple authors. 574 * 575 * @since Twenty Twelve 1.0 576 * 577 * @param array $classes Existing class values. 578 * @return array Filtered class values. 579 */ 580 function twentytwelve_body_class( $classes ) { 581 $background_color = get_background_color(); 582 $background_image = get_background_image(); 583 584 if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) ) { 585 $classes[] = 'full-width'; 586 } 587 588 if ( is_page_template( 'page-templates/front-page.php' ) ) { 589 $classes[] = 'template-front-page'; 590 if ( has_post_thumbnail() ) { 591 $classes[] = 'has-post-thumbnail'; 592 } 593 if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) { 594 $classes[] = 'two-sidebars'; 595 } 596 } 597 598 if ( empty( $background_image ) ) { 599 if ( empty( $background_color ) ) { 600 $classes[] = 'custom-background-empty'; 601 } elseif ( in_array( $background_color, array( 'fff', 'ffffff' ), true ) ) { 602 $classes[] = 'custom-background-white'; 603 } 604 } 605 606 // Enable custom font class only if the font CSS is queued to load. 607 if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) ) { 608 $classes[] = 'custom-font-enabled'; 609 } 610 611 if ( ! is_multi_author() ) { 612 $classes[] = 'single-author'; 613 } 614 615 return $classes; 616 } 617 add_filter( 'body_class', 'twentytwelve_body_class' ); 618 619 /** 620 * Adjust content width in certain contexts. 621 * 622 * Adjusts content_width value for full-width and single image attachment 623 * templates, and when there are no active widgets in the sidebar. 624 * 625 * @since Twenty Twelve 1.0 626 */ 627 function twentytwelve_content_width() { 628 if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) { 629 global $content_width; 630 $content_width = 960; 631 } 632 } 633 add_action( 'template_redirect', 'twentytwelve_content_width' ); 634 635 /** 636 * Register postMessage support. 637 * 638 * Add postMessage support for site title and description for the Customizer. 639 * 640 * @since Twenty Twelve 1.0 641 * 642 * @param WP_Customize_Manager $wp_customize Customizer object. 643 */ 644 function twentytwelve_customize_register( $wp_customize ) { 645 $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 646 $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 647 $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; 648 649 if ( isset( $wp_customize->selective_refresh ) ) { 650 $wp_customize->selective_refresh->add_partial( 651 'blogname', 652 array( 653 'selector' => '.site-title > a', 654 'container_inclusive' => false, 655 'render_callback' => 'twentytwelve_customize_partial_blogname', 656 ) 657 ); 658 $wp_customize->selective_refresh->add_partial( 659 'blogdescription', 660 array( 661 'selector' => '.site-description', 662 'container_inclusive' => false, 663 'render_callback' => 'twentytwelve_customize_partial_blogdescription', 664 ) 665 ); 666 } 667 } 668 add_action( 'customize_register', 'twentytwelve_customize_register' ); 669 670 /** 671 * Render the site title for the selective refresh partial. 672 * 673 * @since Twenty Twelve 2.0 674 * 675 * @see twentytwelve_customize_register() 676 * 677 * @return void 678 */ 679 function twentytwelve_customize_partial_blogname() { 680 bloginfo( 'name' ); 681 } 682 683 /** 684 * Render the site tagline for the selective refresh partial. 685 * 686 * @since Twenty Twelve 2.0 687 * 688 * @see twentytwelve_customize_register() 689 * 690 * @return void 691 */ 692 function twentytwelve_customize_partial_blogdescription() { 693 bloginfo( 'description' ); 694 } 695 696 /** 697 * Enqueue JavaScript postMessage handlers for the Customizer. 698 * 699 * Binds JS handlers to make the Customizer preview reload changes asynchronously. 700 * 701 * @since Twenty Twelve 1.0 702 */ 703 function twentytwelve_customize_preview_js() { 704 wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20200516', array( 'in_footer' => true ) ); 705 } 706 add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' ); 707 708 /** 709 * Modifies tag cloud widget arguments to display all tags in the same font size 710 * and use list format for better accessibility. 711 * 712 * @since Twenty Twelve 2.4 713 * 714 * @param array $args Arguments for tag cloud widget. 715 * @return array The filtered arguments for tag cloud widget. 716 */ 717 function twentytwelve_widget_tag_cloud_args( $args ) { 718 $args['largest'] = 22; 719 $args['smallest'] = 8; 720 $args['unit'] = 'pt'; 721 $args['format'] = 'list'; 722 723 return $args; 724 } 725 add_filter( 'widget_tag_cloud_args', 'twentytwelve_widget_tag_cloud_args' ); 726 727 if ( ! function_exists( 'wp_body_open' ) ) : 728 /** 729 * Fire the wp_body_open action. 730 * 731 * Added for backward compatibility to support pre-5.2.0 WordPress versions. 732 * 733 * @since Twenty Twelve 3.0 734 */ 735 function wp_body_open() { 736 /** 737 * Triggered after the opening <body> tag. 738 * 739 * @since Twenty Twelve 3.0 740 */ 741 do_action( 'wp_body_open' ); 742 } 743 endif;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Tue Mar 19 08:20:01 2024 | Cross-referenced by PHPXref |