[ 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  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 ' &hellip; ' . $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(), '20240116' );
 456  
 457      // Theme block stylesheet.
 458      wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), '20220912' );
 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' ), '20191025' );
 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(), '20230614' );
 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   *
 584   * @param string $html   The HTML image tag markup being filtered.
 585   * @param object $header The custom header object returned by 'get_custom_header()'.
 586   * @param array  $attr   Array of the attributes for the image tag.
 587   * @return string The filtered header image HTML.
 588   */
 589  function twentyseventeen_header_image_tag( $html, $header, $attr ) {
 590      if ( isset( $attr['sizes'] ) ) {
 591          $html = str_replace( $attr['sizes'], '100vw', $html );
 592      }
 593      return $html;
 594  }
 595  add_filter( 'get_header_image_tag', 'twentyseventeen_header_image_tag', 10, 3 );
 596  
 597  /**
 598   * Add custom image sizes attribute to enhance responsive image functionality
 599   * for post thumbnails.
 600   *
 601   * @since Twenty Seventeen 1.0
 602   *
 603   * @param string[]     $attr       Array of attribute values for the image markup, keyed by attribute name.
 604   *                                 See wp_get_attachment_image().
 605   * @param WP_Post      $attachment Image attachment post.
 606   * @param string|int[] $size       Requested image size. Can be any registered image size name, or
 607   *                                 an array of width and height values in pixels (in that order).
 608   * @return string[] The filtered attributes for the image markup.
 609   */
 610  function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
 611      if ( is_archive() || is_search() || is_home() ) {
 612          $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
 613      } else {
 614          $attr['sizes'] = '100vw';
 615      }
 616  
 617      return $attr;
 618  }
 619  add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 );
 620  
 621  /**
 622   * Use front-page.php when Front page displays is set to a static page.
 623   *
 624   * @since Twenty Seventeen 1.0
 625   *
 626   * @param string $template front-page.php.
 627   * @return string The template to be used: blank if is_home() is true (defaults to index.php),
 628   *                otherwise $template.
 629   */
 630  function twentyseventeen_front_page_template( $template ) {
 631      return is_home() ? '' : $template;
 632  }
 633  add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' );
 634  
 635  /**
 636   * Modifies tag cloud widget arguments to display all tags in the same font size
 637   * and use list format for better accessibility.
 638   *
 639   * @since Twenty Seventeen 1.4
 640   *
 641   * @param array $args Arguments for tag cloud widget.
 642   * @return array The filtered arguments for tag cloud widget.
 643   */
 644  function twentyseventeen_widget_tag_cloud_args( $args ) {
 645      $args['largest']  = 1;
 646      $args['smallest'] = 1;
 647      $args['unit']     = 'em';
 648      $args['format']   = 'list';
 649  
 650      return $args;
 651  }
 652  add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' );
 653  
 654  /**
 655   * Gets unique ID.
 656   *
 657   * This is a PHP implementation of Underscore's uniqueId method. A static variable
 658   * contains an integer that is incremented with each call. This number is returned
 659   * with the optional prefix. As such the returned value is not universally unique,
 660   * but it is unique across the life of the PHP process.
 661   *
 662   * @since Twenty Seventeen 2.0
 663   *
 664   * @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
 665   *
 666   * @param string $prefix Prefix for the returned ID.
 667   * @return string Unique ID.
 668   */
 669  function twentyseventeen_unique_id( $prefix = '' ) {
 670      static $id_counter = 0;
 671      if ( function_exists( 'wp_unique_id' ) ) {
 672          return wp_unique_id( $prefix );
 673      }
 674      return $prefix . (string) ++$id_counter;
 675  }
 676  
 677  if ( ! function_exists( 'wp_get_list_item_separator' ) ) :
 678      /**
 679       * Retrieves the list item separator based on the locale.
 680       *
 681       * Added for backward compatibility to support pre-6.0.0 WordPress versions.
 682       *
 683       * @since 6.0.0
 684       */
 685  	function wp_get_list_item_separator() {
 686          /* translators: Used between list items, there is a space after the comma. */
 687          return __( ', ', 'twentyseventeen' );
 688      }
 689  endif;
 690  
 691  /**
 692   * Implement the Custom Header feature.
 693   */
 694  require get_parent_theme_file_path( '/inc/custom-header.php' );
 695  
 696  /**
 697   * Custom template tags for this theme.
 698   */
 699  require get_parent_theme_file_path( '/inc/template-tags.php' );
 700  
 701  /**
 702   * Additional features to allow styling of the templates.
 703   */
 704  require get_parent_theme_file_path( '/inc/template-functions.php' );
 705  
 706  /**
 707   * Customizer additions.
 708   */
 709  require get_parent_theme_file_path( '/inc/customizer.php' );
 710  
 711  /**
 712   * SVG icons functions and filters.
 713   */
 714  require get_parent_theme_file_path( '/inc/icon-functions.php' );
 715  
 716  /**
 717   * Block Patterns.
 718   */
 719  require get_template_directory() . '/inc/block-patterns.php';


Generated : Tue Mar 19 08:20:01 2024 Cross-referenced by PHPXref