[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentyseventeen/ -> functions.php (source)

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


Generated : Sun Jun 14 08:20:09 2026 Cross-referenced by PHPXref