[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Twenty Seventeen functions and definitions 4 * 5 * @link https://developer.wordpress.org/themes/basics/theme-functions/ 6 * 7 * @package WordPress 8 * @subpackage Twenty_Seventeen 9 * @since Twenty Seventeen 1.0 10 */ 11 12 /** 13 * Twenty Seventeen only works in WordPress 4.7 or later. 14 */ 15 if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '<' ) ) { 16 require get_template_directory() . '/inc/back-compat.php'; 17 return; 18 } 19 20 /** 21 * Sets up theme defaults and registers support for various WordPress features. 22 * 23 * Note that this function is hooked into the after_setup_theme hook, which 24 * runs before the init hook. The init hook is too late for some features, such 25 * as indicating support for post thumbnails. 26 */ 27 function twentyseventeen_setup() { 28 29 // Add default posts and comments RSS feed links to head. 30 add_theme_support( 'automatic-feed-links' ); 31 32 /* 33 * Let WordPress manage the document title. 34 * By adding theme support, we declare that this theme does not use a 35 * hard-coded <title> tag in the document head, and expect WordPress to 36 * provide it for us. 37 */ 38 add_theme_support( 'title-tag' ); 39 40 /* 41 * Enables custom line height for blocks 42 */ 43 add_theme_support( 'custom-line-height' ); 44 45 /* 46 * Enable support for Post Thumbnails on posts and pages. 47 * 48 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ 49 */ 50 add_theme_support( 'post-thumbnails' ); 51 52 add_image_size( 'twentyseventeen-featured-image', 2000, 1200, true ); 53 54 add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true ); 55 56 // Set the default content width. 57 $GLOBALS['content_width'] = 525; 58 59 // This theme uses wp_nav_menu() in two locations. 60 register_nav_menus( 61 array( 62 'top' => __( 'Top Menu', 'twentyseventeen' ), 63 'social' => __( 'Social Links Menu', 'twentyseventeen' ), 64 ) 65 ); 66 67 /* 68 * Switch default core markup for search form, comment form, and comments 69 * to output valid HTML5. 70 */ 71 add_theme_support( 72 'html5', 73 array( 74 'comment-form', 75 'comment-list', 76 'gallery', 77 'caption', 78 'script', 79 'style', 80 'navigation-widgets', 81 ) 82 ); 83 84 /* 85 * Enable support for Post Formats. 86 * 87 * See: https://developer.wordpress.org/advanced-administration/wordpress/post-formats/ 88 */ 89 add_theme_support( 90 'post-formats', 91 array( 92 'aside', 93 'image', 94 'video', 95 'quote', 96 'link', 97 'gallery', 98 'audio', 99 ) 100 ); 101 102 // Add theme support for Custom Logo. 103 add_theme_support( 104 'custom-logo', 105 array( 106 'width' => 250, 107 'height' => 250, 108 'flex-width' => true, 109 ) 110 ); 111 112 // Add theme support for selective refresh for widgets. 113 add_theme_support( 'customize-selective-refresh-widgets' ); 114 115 /* 116 * This theme styles the visual editor to resemble the theme style, 117 * specifically font, colors, and column width. When fonts are 118 * self-hosted, the theme directory needs to be removed first. 119 */ 120 $font_stylesheet = str_replace( 121 array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ), 122 '', 123 (string) twentyseventeen_fonts_url() 124 ); 125 add_editor_style( array( 'assets/css/editor-style.css', $font_stylesheet ) ); 126 127 // Load regular editor styles into the new block-based editor. 128 add_theme_support( 'editor-styles' ); 129 130 // Load default block styles. 131 add_theme_support( 'wp-block-styles' ); 132 133 // Add support for responsive embeds. 134 add_theme_support( 'responsive-embeds' ); 135 136 // Define and register starter content to showcase the theme on new sites. 137 $starter_content = array( 138 'widgets' => array( 139 // Place three core-defined widgets in the sidebar area. 140 'sidebar-1' => array( 141 'text_business_info', 142 'search', 143 'text_about', 144 ), 145 146 // Add the core-defined business info widget to the footer 1 area. 147 'sidebar-2' => array( 148 'text_business_info', 149 ), 150 151 // Put two core-defined widgets in the footer 2 area. 152 'sidebar-3' => array( 153 'text_about', 154 'search', 155 ), 156 ), 157 158 // Specify the core-defined pages to create and add custom thumbnails to some of them. 159 'posts' => array( 160 'home', 161 'about' => array( 162 'thumbnail' => '{{image-sandwich}}', 163 ), 164 'contact' => array( 165 'thumbnail' => '{{image-espresso}}', 166 ), 167 'blog' => array( 168 'thumbnail' => '{{image-coffee}}', 169 ), 170 'homepage-section' => array( 171 'thumbnail' => '{{image-espresso}}', 172 ), 173 ), 174 175 // Create the custom image attachments used as post thumbnails for pages. 176 'attachments' => array( 177 'image-espresso' => array( 178 'post_title' => _x( 'Espresso', 'Theme starter content', 'twentyseventeen' ), 179 'file' => 'assets/images/espresso.jpg', // URL relative to the template directory. 180 ), 181 'image-sandwich' => array( 182 'post_title' => _x( 'Sandwich', 'Theme starter content', 'twentyseventeen' ), 183 'file' => 'assets/images/sandwich.jpg', 184 ), 185 'image-coffee' => array( 186 'post_title' => _x( 'Coffee', 'Theme starter content', 'twentyseventeen' ), 187 'file' => 'assets/images/coffee.jpg', 188 ), 189 ), 190 191 // Default to a static front page and assign the front and posts pages. 192 'options' => array( 193 'show_on_front' => 'page', 194 'page_on_front' => '{{home}}', 195 'page_for_posts' => '{{blog}}', 196 ), 197 198 // Set the front page section theme mods to the IDs of the core-registered pages. 199 'theme_mods' => array( 200 'panel_1' => '{{homepage-section}}', 201 'panel_2' => '{{about}}', 202 'panel_3' => '{{blog}}', 203 'panel_4' => '{{contact}}', 204 ), 205 206 // Set up nav menus for each of the two areas registered in the theme. 207 'nav_menus' => array( 208 // Assign a menu to the "top" location. 209 'top' => array( 210 'name' => __( 'Top Menu', 'twentyseventeen' ), 211 'items' => array( 212 'link_home', // Note that the core "home" page is actually a link in case a static front page is not used. 213 'page_about', 214 'page_blog', 215 'page_contact', 216 ), 217 ), 218 219 // Assign a menu to the "social" location. 220 'social' => array( 221 'name' => __( 'Social Links Menu', 'twentyseventeen' ), 222 'items' => array( 223 'link_yelp', 224 'link_facebook', 225 'link_twitter', 226 'link_instagram', 227 'link_email', 228 ), 229 ), 230 ), 231 ); 232 233 /** 234 * Filters Twenty Seventeen array of starter content. 235 * 236 * @since Twenty Seventeen 1.1 237 * 238 * @param array $starter_content Array of starter content. 239 */ 240 $starter_content = apply_filters( 'twentyseventeen_starter_content', $starter_content ); 241 242 add_theme_support( 'starter-content', $starter_content ); 243 } 244 add_action( 'after_setup_theme', 'twentyseventeen_setup' ); 245 246 /** 247 * Sets the content width in pixels, based on the theme's design and stylesheet. 248 * 249 * Priority 0 to make it available to lower priority callbacks. 250 * 251 * @global int $content_width 252 */ 253 function twentyseventeen_content_width() { 254 255 $content_width = $GLOBALS['content_width']; 256 257 // Get layout. 258 $page_layout = get_theme_mod( 'page_layout' ); 259 260 // Check if layout is one column. 261 if ( 'one-column' === $page_layout ) { 262 if ( twentyseventeen_is_frontpage() ) { 263 $content_width = 644; 264 } elseif ( is_page() ) { 265 $content_width = 740; 266 } 267 } 268 269 // Check if is single post and there is no sidebar. 270 if ( is_single() && ! is_active_sidebar( 'sidebar-1' ) ) { 271 $content_width = 740; 272 } 273 274 /** 275 * Filters Twenty Seventeen content width of the theme. 276 * 277 * @since Twenty Seventeen 1.0 278 * 279 * @param int $content_width Content width in pixels. 280 */ 281 $GLOBALS['content_width'] = apply_filters( 'twentyseventeen_content_width', $content_width ); 282 } 283 add_action( 'template_redirect', 'twentyseventeen_content_width', 0 ); 284 285 if ( ! function_exists( 'twentyseventeen_fonts_url' ) ) : 286 /** 287 * Registers custom fonts. 288 * 289 * @since Twenty Seventeen 1.0 290 * @since Twenty Seventeen 3.2 Replaced Google URL with self-hosted fonts. 291 * 292 * @return string Fonts URL for the theme. 293 */ 294 function twentyseventeen_fonts_url() { 295 $fonts_url = ''; 296 297 /* 298 * translators: If there are characters in your language that are not supported 299 * by Libre Franklin, translate this to 'off'. Do not translate into your own language. 300 */ 301 $libre_franklin = _x( 'on', 'Libre Franklin font: on or off', 'twentyseventeen' ); 302 303 if ( 'off' !== $libre_franklin ) { 304 $fonts_url = get_template_directory_uri() . '/assets/fonts/font-libre-franklin.css'; 305 } 306 307 return esc_url_raw( $fonts_url ); 308 } 309 endif; 310 311 /** 312 * Adds preconnect for Google Fonts. 313 * 314 * @since Twenty Seventeen 1.0 315 * @deprecated Twenty Seventeen 3.2 Disabled filter because, by default, fonts are self-hosted. 316 * 317 * @param array $urls URLs to print for resource hints. 318 * @param string $relation_type The relation type the URLs are printed. 319 * @return array URLs to print for resource hints. 320 */ 321 function twentyseventeen_resource_hints( $urls, $relation_type ) { 322 if ( wp_style_is( 'twentyseventeen-fonts', 'queue' ) && 'preconnect' === $relation_type ) { 323 $urls[] = array( 324 'href' => 'https://fonts.gstatic.com', 325 'crossorigin', 326 ); 327 } 328 329 return $urls; 330 } 331 // add_filter( 'wp_resource_hints', 'twentyseventeen_resource_hints', 10, 2 ); 332 333 /** 334 * Registers widget area. 335 * 336 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar 337 */ 338 function twentyseventeen_widgets_init() { 339 register_sidebar( 340 array( 341 'name' => __( 'Blog Sidebar', 'twentyseventeen' ), 342 'id' => 'sidebar-1', 343 'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'twentyseventeen' ), 344 'before_widget' => '<section id="%1$s" class="widget %2$s">', 345 'after_widget' => '</section>', 346 'before_title' => '<h2 class="widget-title">', 347 'after_title' => '</h2>', 348 ) 349 ); 350 351 register_sidebar( 352 array( 353 'name' => __( 'Footer 1', 'twentyseventeen' ), 354 'id' => 'sidebar-2', 355 'description' => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ), 356 'before_widget' => '<section id="%1$s" class="widget %2$s">', 357 'after_widget' => '</section>', 358 'before_title' => '<h2 class="widget-title">', 359 'after_title' => '</h2>', 360 ) 361 ); 362 363 register_sidebar( 364 array( 365 'name' => __( 'Footer 2', 'twentyseventeen' ), 366 'id' => 'sidebar-3', 367 'description' => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ), 368 'before_widget' => '<section id="%1$s" class="widget %2$s">', 369 'after_widget' => '</section>', 370 'before_title' => '<h2 class="widget-title">', 371 'after_title' => '</h2>', 372 ) 373 ); 374 } 375 add_action( 'widgets_init', 'twentyseventeen_widgets_init' ); 376 377 /** 378 * Replaces "[...]" (appended to automatically generated excerpts) with ... and 379 * a 'Continue reading' link. 380 * 381 * @since Twenty Seventeen 1.0 382 * 383 * @param string $link Link to single post/page. 384 * @return string 'Continue reading' link prepended with an ellipsis. 385 */ 386 function twentyseventeen_excerpt_more( $link ) { 387 if ( is_admin() ) { 388 return $link; 389 } 390 391 $link = sprintf( 392 '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>', 393 esc_url( get_permalink( get_the_ID() ) ), 394 /* translators: %s: Post title. Only visible to screen readers. */ 395 sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ), get_the_title( get_the_ID() ) ) 396 ); 397 return ' … ' . $link; 398 } 399 add_filter( 'excerpt_more', 'twentyseventeen_excerpt_more' ); 400 401 /** 402 * Handles JavaScript detection. 403 * 404 * Adds a `js` class to the root `<html>` element when JavaScript is detected. 405 * 406 * @since Twenty Seventeen 1.0 407 */ 408 function twentyseventeen_javascript_detection() { 409 echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; 410 } 411 add_action( 'wp_head', 'twentyseventeen_javascript_detection', 0 ); 412 413 /** 414 * Adds a pingback url auto-discovery header for singularly identifiable articles. 415 */ 416 function twentyseventeen_pingback_header() { 417 if ( is_singular() && pings_open() ) { 418 printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) ); 419 } 420 } 421 add_action( 'wp_head', 'twentyseventeen_pingback_header' ); 422 423 /** 424 * Displays custom color CSS. 425 */ 426 function twentyseventeen_colors_css_wrap() { 427 if ( 'custom' !== get_theme_mod( 'colorscheme' ) && ! is_customize_preview() ) { 428 return; 429 } 430 431 require_once get_parent_theme_file_path( '/inc/color-patterns.php' ); 432 $hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) ); 433 434 $customize_preview_data_hue = ''; 435 if ( is_customize_preview() ) { 436 $customize_preview_data_hue = 'data-hue="' . $hue . '"'; 437 } 438 ?> 439 <style type="text/css" id="custom-theme-colors" <?php echo $customize_preview_data_hue; ?>> 440 <?php echo twentyseventeen_custom_colors_css(); ?> 441 </style> 442 <?php 443 } 444 add_action( 'wp_head', 'twentyseventeen_colors_css_wrap' ); 445 446 /** 447 * Enqueues scripts and styles. 448 * 449 * @since Twenty Seventeen 1.0 450 */ 451 function twentyseventeen_scripts() { 452 // Add custom fonts, used in the main stylesheet. 453 $font_version = ( 0 === strpos( (string) twentyseventeen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 454 wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), $font_version ); 455 456 // Theme stylesheet. 457 wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri(), array(), '20250415' ); 458 459 // Theme block stylesheet. 460 wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), '20240729' ); 461 462 // Load the dark colorscheme. 463 if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) { 464 wp_enqueue_style( 'twentyseventeen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'twentyseventeen-style' ), '20240412' ); 465 } 466 467 // Register the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer. 468 if ( is_customize_preview() ) { 469 wp_register_style( 'twentyseventeen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'twentyseventeen-style' ), '20161202' ); 470 wp_style_add_data( 'twentyseventeen-ie9', 'conditional', 'IE 9' ); 471 } 472 473 // Register the Internet Explorer 8 specific stylesheet. 474 wp_register_style( 'twentyseventeen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'twentyseventeen-style' ), '20161202' ); 475 wp_style_add_data( 'twentyseventeen-ie8', 'conditional', 'lt IE 9' ); 476 477 // Register the html5 shiv. 478 wp_register_script( 'html5', get_theme_file_uri( '/assets/js/html5.js' ), array(), '20161020' ); 479 wp_script_add_data( 'html5', 'conditional', 'lt IE 9' ); 480 481 // Skip-link fix is no longer enqueued by default. 482 wp_register_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', array( 'in_footer' => true ) ); 483 484 wp_enqueue_script( 485 'twentyseventeen-global', 486 get_theme_file_uri( '/assets/js/global.js' ), 487 array( 'jquery' ), 488 '20211130', 489 array( 490 'in_footer' => false, // Because involves header. 491 'strategy' => 'defer', 492 ) 493 ); 494 495 $twentyseventeen_l10n = array( 496 'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ), 497 ); 498 499 if ( has_nav_menu( 'top' ) ) { 500 wp_enqueue_script( 501 'twentyseventeen-navigation', 502 get_theme_file_uri( '/assets/js/navigation.js' ), 503 array( 'jquery' ), 504 '20210122', 505 array( 506 'in_footer' => false, // Because involves header. 507 'strategy' => 'defer', 508 ) 509 ); 510 $twentyseventeen_l10n['expand'] = __( 'Expand child menu', 'twentyseventeen' ); 511 $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' ); 512 $twentyseventeen_l10n['icon'] = twentyseventeen_get_svg( 513 array( 514 'icon' => 'angle-down', 515 'fallback' => true, 516 ) 517 ); 518 } 519 520 wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n ); 521 522 wp_enqueue_script( 523 'jquery-scrollto', 524 get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), 525 array( 'jquery' ), 526 '2.1.3', 527 array( 528 'in_footer' => true, 529 'strategy' => 'defer', 530 ) 531 ); 532 533 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 534 wp_enqueue_script( 'comment-reply' ); 535 } 536 } 537 add_action( 'wp_enqueue_scripts', 'twentyseventeen_scripts' ); 538 539 /** 540 * Enqueues styles for the block-based editor. 541 * 542 * @since Twenty Seventeen 1.8 543 */ 544 function twentyseventeen_block_editor_styles() { 545 // Block styles. 546 wp_enqueue_style( 'twentyseventeen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ), array(), '20240824' ); 547 // Add custom fonts. 548 $font_version = ( 0 === strpos( (string) twentyseventeen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 549 wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), $font_version ); 550 } 551 add_action( 'enqueue_block_editor_assets', 'twentyseventeen_block_editor_styles' ); 552 553 /** 554 * Adds custom image sizes attribute to enhance responsive image functionality 555 * for content images. 556 * 557 * @since Twenty Seventeen 1.0 558 * 559 * @param string $sizes A source size value for use in a 'sizes' attribute. 560 * @param array $size Image size. Accepts an array of width and height 561 * values in pixels (in that order). 562 * @return string A source size value for use in a content image 'sizes' attribute. 563 */ 564 function twentyseventeen_content_image_sizes_attr( $sizes, $size ) { 565 $width = $size[0]; 566 567 if ( 740 <= $width ) { 568 $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px'; 569 } 570 571 if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) { 572 if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) { 573 $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; 574 } 575 } 576 577 return $sizes; 578 } 579 add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 ); 580 581 /** 582 * Filters the `sizes` value in the header image markup. 583 * 584 * @since Twenty Seventeen 1.0 585 * @since Twenty Seventeen 3.7 Added larger image size for small screens. 586 * 587 * @param string $html The HTML image tag markup being filtered. 588 * @param object $header The custom header object returned by 'get_custom_header()'. 589 * @param array $attr Array of the attributes for the image tag. 590 * @return string The filtered header image HTML. 591 */ 592 function twentyseventeen_header_image_tag( $html, $header, $attr ) { 593 if ( isset( $attr['sizes'] ) ) { 594 $html = str_replace( $attr['sizes'], '(max-width: 767px) 200vw, 100vw', $html ); 595 } 596 return $html; 597 } 598 add_filter( 'get_header_image_tag', 'twentyseventeen_header_image_tag', 10, 3 ); 599 600 /** 601 * Adds custom image sizes attribute to enhance responsive image functionality 602 * for post thumbnails. 603 * 604 * @since Twenty Seventeen 1.0 605 * 606 * @param string[] $attr Array of attribute values for the image markup, keyed by attribute name. 607 * See wp_get_attachment_image(). 608 * @param WP_Post $attachment Image attachment post. 609 * @param string|int[] $size Requested image size. Can be any registered image size name, or 610 * an array of width and height values in pixels (in that order). 611 * @return string[] The filtered attributes for the image markup. 612 */ 613 function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { 614 if ( is_archive() || is_search() || is_home() ) { 615 $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; 616 } else { 617 $attr['sizes'] = '100vw'; 618 } 619 620 return $attr; 621 } 622 add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 ); 623 624 /** 625 * Uses front-page.php when Front page displays is set to a static page. 626 * 627 * @since Twenty Seventeen 1.0 628 * 629 * @param string $template front-page.php. 630 * @return string The template to be used: blank if is_home() is true (defaults to index.php), 631 * otherwise $template. 632 */ 633 function twentyseventeen_front_page_template( $template ) { 634 return is_home() ? '' : $template; 635 } 636 add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' ); 637 638 /** 639 * Modifies tag cloud widget arguments to display all tags in the same font size 640 * and use list format for better accessibility. 641 * 642 * @since Twenty Seventeen 1.4 643 * 644 * @param array $args Arguments for tag cloud widget. 645 * @return array The filtered arguments for tag cloud widget. 646 */ 647 function twentyseventeen_widget_tag_cloud_args( $args ) { 648 $args['largest'] = 1; 649 $args['smallest'] = 1; 650 $args['unit'] = 'em'; 651 $args['format'] = 'list'; 652 653 return $args; 654 } 655 add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' ); 656 657 /** 658 * Gets unique ID. 659 * 660 * This is a PHP implementation of Underscore's uniqueId method. A static variable 661 * contains an integer that is incremented with each call. This number is returned 662 * with the optional prefix. As such the returned value is not universally unique, 663 * but it is unique across the life of the PHP process. 664 * 665 * @since Twenty Seventeen 2.0 666 * 667 * @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead. 668 * 669 * @param string $prefix Prefix for the returned ID. 670 * @return string Unique ID. 671 */ 672 function twentyseventeen_unique_id( $prefix = '' ) { 673 static $id_counter = 0; 674 if ( function_exists( 'wp_unique_id' ) ) { 675 return wp_unique_id( $prefix ); 676 } 677 return $prefix . (string) ++$id_counter; 678 } 679 680 if ( ! function_exists( 'wp_get_list_item_separator' ) ) : 681 /** 682 * Retrieves the list item separator based on the locale. 683 * 684 * Added for backward compatibility to support pre-6.0.0 WordPress versions. 685 * 686 * @since 6.0.0 687 */ 688 function wp_get_list_item_separator() { 689 /* translators: Used between list items, there is a space after the comma. */ 690 return __( ', ', 'twentyseventeen' ); 691 } 692 endif; 693 694 /** 695 * Shows the featured image below the header on single posts and pages, unless 696 * the page is the front page. 697 * 698 * Uses the filter `twentyseventeen_should_show_featured_image` in a child theme or 699 * plugin to change when the image is shown. This example prevents the image 700 * from showing: 701 * 702 * add_filter( 703 * 'twentyseventeen_should_show_featured_image', 704 * '__return_false' 705 * ); 706 * 707 * @since Twenty Seventeen 3.7 708 * 709 * @return bool Whether the post thumbnail should be shown. 710 */ 711 function twentyseventeen_should_show_featured_image() { 712 $show_featured_image = ( is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) && has_post_thumbnail( get_queried_object_id() ); 713 714 /** 715 * Filters whether to show the Twenty Seventeen featured image below the header. 716 * 717 * By default, the image is displayed on single posts and pages, unless the page is the front page. 718 * 719 * @since Twenty Seventeen 3.7 720 * 721 * @param bool $show_featured_image Whether to display the featured image below the header. 722 */ 723 return apply_filters( 'twentyseventeen_should_show_featured_image', $show_featured_image ); 724 } 725 726 /** 727 * Implement the Custom Header feature. 728 */ 729 require get_parent_theme_file_path( '/inc/custom-header.php' ); 730 731 /** 732 * Custom template tags for this theme. 733 */ 734 require get_parent_theme_file_path( '/inc/template-tags.php' ); 735 736 /** 737 * Additional features to allow styling of the templates. 738 */ 739 require get_parent_theme_file_path( '/inc/template-functions.php' ); 740 741 /** 742 * Customizer additions. 743 */ 744 require get_parent_theme_file_path( '/inc/customizer.php' ); 745 746 /** 747 * SVG icons functions and filters. 748 */ 749 require get_parent_theme_file_path( '/inc/icon-functions.php' ); 750 751 /** 752 * Registers block patterns and pattern categories. 753 * 754 * @since Twenty Seventeen 3.8 755 */ 756 function twentyseventeen_register_block_patterns() { 757 require get_template_directory() . '/inc/block-patterns.php'; 758 } 759 760 add_action( 'init', 'twentyseventeen_register_block_patterns' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Wed Aug 13 08:20:01 2025 | Cross-referenced by PHPXref |