[ 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 * Set 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 * Register 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 * Add 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 * Register 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 * Add 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 * Display 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 function twentyseventeen_scripts() { 450 // Add custom fonts, used in the main stylesheet. 451 $font_version = ( 0 === strpos( (string) twentyseventeen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 452 wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), $font_version ); 453 454 // Theme stylesheet. 455 wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri(), array(), '20241112' ); 456 457 // Theme block stylesheet. 458 wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), '20240729' ); 459 460 // Load the dark colorscheme. 461 if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) { 462 wp_enqueue_style( 'twentyseventeen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'twentyseventeen-style' ), '20240412' ); 463 } 464 465 // Register the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer. 466 if ( is_customize_preview() ) { 467 wp_register_style( 'twentyseventeen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'twentyseventeen-style' ), '20161202' ); 468 wp_style_add_data( 'twentyseventeen-ie9', 'conditional', 'IE 9' ); 469 } 470 471 // Register the Internet Explorer 8 specific stylesheet. 472 wp_register_style( 'twentyseventeen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'twentyseventeen-style' ), '20161202' ); 473 wp_style_add_data( 'twentyseventeen-ie8', 'conditional', 'lt IE 9' ); 474 475 // Register the html5 shiv. 476 wp_register_script( 'html5', get_theme_file_uri( '/assets/js/html5.js' ), array(), '20161020' ); 477 wp_script_add_data( 'html5', 'conditional', 'lt IE 9' ); 478 479 // Skip-link fix is no longer enqueued by default. 480 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 ) ); 481 482 wp_enqueue_script( 483 'twentyseventeen-global', 484 get_theme_file_uri( '/assets/js/global.js' ), 485 array( 'jquery' ), 486 '20211130', 487 array( 488 'in_footer' => false, // Because involves header. 489 'strategy' => 'defer', 490 ) 491 ); 492 493 $twentyseventeen_l10n = array( 494 'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ), 495 ); 496 497 if ( has_nav_menu( 'top' ) ) { 498 wp_enqueue_script( 499 'twentyseventeen-navigation', 500 get_theme_file_uri( '/assets/js/navigation.js' ), 501 array( 'jquery' ), 502 '20210122', 503 array( 504 'in_footer' => false, // Because involves header. 505 'strategy' => 'defer', 506 ) 507 ); 508 $twentyseventeen_l10n['expand'] = __( 'Expand child menu', 'twentyseventeen' ); 509 $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' ); 510 $twentyseventeen_l10n['icon'] = twentyseventeen_get_svg( 511 array( 512 'icon' => 'angle-down', 513 'fallback' => true, 514 ) 515 ); 516 } 517 518 wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n ); 519 520 wp_enqueue_script( 521 'jquery-scrollto', 522 get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), 523 array( 'jquery' ), 524 '2.1.3', 525 array( 526 'in_footer' => true, 527 'strategy' => 'defer', 528 ) 529 ); 530 531 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 532 wp_enqueue_script( 'comment-reply' ); 533 } 534 } 535 add_action( 'wp_enqueue_scripts', 'twentyseventeen_scripts' ); 536 537 /** 538 * Enqueues styles for the block-based editor. 539 * 540 * @since Twenty Seventeen 1.8 541 */ 542 function twentyseventeen_block_editor_styles() { 543 // Block styles. 544 wp_enqueue_style( 'twentyseventeen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ), array(), '20240824' ); 545 // Add custom fonts. 546 $font_version = ( 0 === strpos( (string) twentyseventeen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 547 wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), $font_version ); 548 } 549 add_action( 'enqueue_block_editor_assets', 'twentyseventeen_block_editor_styles' ); 550 551 /** 552 * Add custom image sizes attribute to enhance responsive image functionality 553 * for content images. 554 * 555 * @since Twenty Seventeen 1.0 556 * 557 * @param string $sizes A source size value for use in a 'sizes' attribute. 558 * @param array $size Image size. Accepts an array of width and height 559 * values in pixels (in that order). 560 * @return string A source size value for use in a content image 'sizes' attribute. 561 */ 562 function twentyseventeen_content_image_sizes_attr( $sizes, $size ) { 563 $width = $size[0]; 564 565 if ( 740 <= $width ) { 566 $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px'; 567 } 568 569 if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) { 570 if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) { 571 $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; 572 } 573 } 574 575 return $sizes; 576 } 577 add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 ); 578 579 /** 580 * Filters the `sizes` value in the header image markup. 581 * 582 * @since Twenty Seventeen 1.0 583 * @since Twenty Seventeen 3.7 Added larger image size for small screens. 584 * 585 * @param string $html The HTML image tag markup being filtered. 586 * @param object $header The custom header object returned by 'get_custom_header()'. 587 * @param array $attr Array of the attributes for the image tag. 588 * @return string The filtered header image HTML. 589 */ 590 function twentyseventeen_header_image_tag( $html, $header, $attr ) { 591 if ( isset( $attr['sizes'] ) ) { 592 $html = str_replace( $attr['sizes'], '(max-width: 767px) 200vw, 100vw', $html ); 593 } 594 return $html; 595 } 596 add_filter( 'get_header_image_tag', 'twentyseventeen_header_image_tag', 10, 3 ); 597 598 /** 599 * Add custom image sizes attribute to enhance responsive image functionality 600 * for post thumbnails. 601 * 602 * @since Twenty Seventeen 1.0 603 * 604 * @param string[] $attr Array of attribute values for the image markup, keyed by attribute name. 605 * See wp_get_attachment_image(). 606 * @param WP_Post $attachment Image attachment post. 607 * @param string|int[] $size Requested image size. Can be any registered image size name, or 608 * an array of width and height values in pixels (in that order). 609 * @return string[] The filtered attributes for the image markup. 610 */ 611 function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { 612 if ( is_archive() || is_search() || is_home() ) { 613 $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; 614 } else { 615 $attr['sizes'] = '100vw'; 616 } 617 618 return $attr; 619 } 620 add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 ); 621 622 /** 623 * Use front-page.php when Front page displays is set to a static page. 624 * 625 * @since Twenty Seventeen 1.0 626 * 627 * @param string $template front-page.php. 628 * @return string The template to be used: blank if is_home() is true (defaults to index.php), 629 * otherwise $template. 630 */ 631 function twentyseventeen_front_page_template( $template ) { 632 return is_home() ? '' : $template; 633 } 634 add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' ); 635 636 /** 637 * Modifies tag cloud widget arguments to display all tags in the same font size 638 * and use list format for better accessibility. 639 * 640 * @since Twenty Seventeen 1.4 641 * 642 * @param array $args Arguments for tag cloud widget. 643 * @return array The filtered arguments for tag cloud widget. 644 */ 645 function twentyseventeen_widget_tag_cloud_args( $args ) { 646 $args['largest'] = 1; 647 $args['smallest'] = 1; 648 $args['unit'] = 'em'; 649 $args['format'] = 'list'; 650 651 return $args; 652 } 653 add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' ); 654 655 /** 656 * Gets unique ID. 657 * 658 * This is a PHP implementation of Underscore's uniqueId method. A static variable 659 * contains an integer that is incremented with each call. This number is returned 660 * with the optional prefix. As such the returned value is not universally unique, 661 * but it is unique across the life of the PHP process. 662 * 663 * @since Twenty Seventeen 2.0 664 * 665 * @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead. 666 * 667 * @param string $prefix Prefix for the returned ID. 668 * @return string Unique ID. 669 */ 670 function twentyseventeen_unique_id( $prefix = '' ) { 671 static $id_counter = 0; 672 if ( function_exists( 'wp_unique_id' ) ) { 673 return wp_unique_id( $prefix ); 674 } 675 return $prefix . (string) ++$id_counter; 676 } 677 678 if ( ! function_exists( 'wp_get_list_item_separator' ) ) : 679 /** 680 * Retrieves the list item separator based on the locale. 681 * 682 * Added for backward compatibility to support pre-6.0.0 WordPress versions. 683 * 684 * @since 6.0.0 685 */ 686 function wp_get_list_item_separator() { 687 /* translators: Used between list items, there is a space after the comma. */ 688 return __( ', ', 'twentyseventeen' ); 689 } 690 endif; 691 692 /** 693 * Show the featured image below the header on single posts and pages, unless the 694 * page is the front page. 695 * 696 * Use the filter `twentyseventeen_should_show_featured_image` in a child theme or 697 * plugin to change when the image is shown. This example prevents the image 698 * from showing: 699 * 700 * add_filter( 701 * 'twentyseventeen_should_show_featured_image', 702 * '__return_false' 703 * ); 704 * 705 * @since Twenty Seventeen 3.7 706 * 707 * @return bool Whether the post thumbnail should be shown. 708 */ 709 function twentyseventeen_should_show_featured_image() { 710 $show_featured_image = ( is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) && has_post_thumbnail( get_queried_object_id() ); 711 return apply_filters( 'twentyseventeen_should_show_featured_image', $show_featured_image ); 712 } 713 714 /** 715 * Implement the Custom Header feature. 716 */ 717 require get_parent_theme_file_path( '/inc/custom-header.php' ); 718 719 /** 720 * Custom template tags for this theme. 721 */ 722 require get_parent_theme_file_path( '/inc/template-tags.php' ); 723 724 /** 725 * Additional features to allow styling of the templates. 726 */ 727 require get_parent_theme_file_path( '/inc/template-functions.php' ); 728 729 /** 730 * Customizer additions. 731 */ 732 require get_parent_theme_file_path( '/inc/customizer.php' ); 733 734 /** 735 * SVG icons functions and filters. 736 */ 737 require get_parent_theme_file_path( '/inc/icon-functions.php' ); 738 739 /** 740 * Register block patterns and pattern categories. 741 * 742 * @since Twenty Seventeen 3.8 743 */ 744 function twentyseventeen_register_block_patterns() { 745 require get_template_directory() . '/inc/block-patterns.php'; 746 } 747 748 add_action( 'init', 'twentyseventeen_register_block_patterns' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |