[ Index ]

PHP Cross Reference of WordPress

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


Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1