[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Twenty Fifteen functions and definitions
   4   *
   5   * Set up the theme and provides some helper functions, which are used in the
   6   * theme as custom template tags. Others are attached to action and filter
   7   * hooks in WordPress to change core functionality.
   8   *
   9   * When using a child theme you can override certain functions (those wrapped
  10   * in a function_exists() call) by defining them first in your child theme's
  11   * functions.php file. The child theme's functions.php file is included before
  12   * the parent theme's file, so the child theme functions would be used.
  13   *
  14   * @link https://developer.wordpress.org/themes/basics/theme-functions/
  15   * @link https://developer.wordpress.org/themes/advanced-topics/child-themes/
  16   *
  17   * Functions that are not pluggable (not wrapped in function_exists()) are
  18   * instead attached to a filter or action hook.
  19   *
  20   * For more information on hooks, actions, and filters,
  21   * {@link https://developer.wordpress.org/plugins/}
  22   *
  23   * @package WordPress
  24   * @subpackage Twenty_Fifteen
  25   * @since Twenty Fifteen 1.0
  26   */
  27  
  28  /**
  29   * Set the content width based on the theme's design and stylesheet.
  30   *
  31   * @since Twenty Fifteen 1.0
  32   */
  33  if ( ! isset( $content_width ) ) {
  34      $content_width = 660;
  35  }
  36  
  37  /**
  38   * Twenty Fifteen only works in WordPress 4.1 or later.
  39   */
  40  if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
  41      require get_template_directory() . '/inc/back-compat.php';
  42  }
  43  
  44  if ( ! function_exists( 'twentyfifteen_setup' ) ) :
  45      /**
  46       * Sets up theme defaults and registers support for various WordPress features.
  47       *
  48       * Note that this function is hooked into the after_setup_theme hook, which
  49       * runs before the init hook. The init hook is too late for some features, such
  50       * as indicating support for post thumbnails.
  51       *
  52       * @since Twenty Fifteen 1.0
  53       */
  54  	function twentyfifteen_setup() {
  55  
  56          /*
  57           * Make theme available for translation.
  58           * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfifteen
  59           * If you're building a theme based on twentyfifteen, use a find and replace
  60           * to change 'twentyfifteen' to the name of your theme in all the template files.
  61           *
  62           * Manual loading of text domain is not required after the introduction of
  63           * just in time translation loading in WordPress version 4.6.
  64           *
  65           * @ticket 58318
  66           */
  67  
  68          if ( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ) {
  69              load_theme_textdomain( 'twentyfifteen' );
  70          }
  71  
  72          // Add default posts and comments RSS feed links to head.
  73          add_theme_support( 'automatic-feed-links' );
  74  
  75          /*
  76           * Let WordPress manage the document title.
  77           * By adding theme support, we declare that this theme does not use a
  78           * hard-coded <title> tag in the document head, and expect WordPress to
  79           * provide it for us.
  80           */
  81          add_theme_support( 'title-tag' );
  82  
  83          /*
  84           * Enable support for Post Thumbnails on posts and pages.
  85           *
  86           * See: https://developer.wordpress.org/reference/functions/add_theme_support/#post-thumbnails
  87           */
  88          add_theme_support( 'post-thumbnails' );
  89          set_post_thumbnail_size( 825, 510, true );
  90  
  91          // This theme uses wp_nav_menu() in two locations.
  92          register_nav_menus(
  93              array(
  94                  'primary' => __( 'Primary Menu', 'twentyfifteen' ),
  95                  'social'  => __( 'Social Links Menu', 'twentyfifteen' ),
  96              )
  97          );
  98  
  99          /*
 100           * Switch default core markup for search form, comment form, and comments
 101           * to output valid HTML5.
 102           */
 103          add_theme_support(
 104              'html5',
 105              array(
 106                  'search-form',
 107                  'comment-form',
 108                  'comment-list',
 109                  'gallery',
 110                  'caption',
 111                  'script',
 112                  'style',
 113                  'navigation-widgets',
 114              )
 115          );
 116  
 117          /*
 118           * Enable support for Post Formats.
 119           *
 120           * See: https://developer.wordpress.org/advanced-administration/wordpress/post-formats/
 121           */
 122          add_theme_support(
 123              'post-formats',
 124              array(
 125                  'aside',
 126                  'image',
 127                  'video',
 128                  'quote',
 129                  'link',
 130                  'gallery',
 131                  'status',
 132                  'audio',
 133                  'chat',
 134              )
 135          );
 136  
 137          /*
 138           * Enable support for custom logo.
 139           *
 140           * @since Twenty Fifteen 1.5
 141           */
 142          add_theme_support(
 143              'custom-logo',
 144              array(
 145                  'height'      => 248,
 146                  'width'       => 248,
 147                  'flex-height' => true,
 148              )
 149          );
 150  
 151          $color_scheme  = twentyfifteen_get_color_scheme();
 152          $default_color = trim( $color_scheme[0], '#' );
 153  
 154          // Setup the WordPress core custom background feature.
 155  
 156          add_theme_support(
 157              'custom-background',
 158              /**
 159               * Filters Twenty Fifteen custom-background support arguments.
 160               *
 161               * @since Twenty Fifteen 1.0
 162               *
 163               * @param array $args {
 164               *     An array of custom-background support arguments.
 165               *
 166               *     @type string $default-color      Default color of the background.
 167               *     @type string $default-attachment Default attachment of the background.
 168               * }
 169               */
 170              apply_filters(
 171                  'twentyfifteen_custom_background_args',
 172                  array(
 173                      'default-color'      => $default_color,
 174                      'default-attachment' => 'fixed',
 175                  )
 176              )
 177          );
 178  
 179          /*
 180           * This theme styles the visual editor to resemble the theme style,
 181           * specifically font, colors, icons, and column width. When fonts are
 182           * self-hosted, the theme directory needs to be removed first.
 183           */
 184          $font_stylesheet = str_replace(
 185              array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ),
 186              '',
 187              (string) twentyfifteen_fonts_url()
 188          );
 189          add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', $font_stylesheet ) );
 190  
 191          // Load regular editor styles into the new block-based editor.
 192          add_theme_support( 'editor-styles' );
 193  
 194          // Load default block styles.
 195          add_theme_support( 'wp-block-styles' );
 196  
 197          // Add support for responsive embeds.
 198          add_theme_support( 'responsive-embeds' );
 199  
 200          // Add support for custom color scheme.
 201          add_theme_support(
 202              'editor-color-palette',
 203              array(
 204                  array(
 205                      'name'  => __( 'Dark Gray', 'twentyfifteen' ),
 206                      'slug'  => 'dark-gray',
 207                      'color' => '#111',
 208                  ),
 209                  array(
 210                      'name'  => __( 'Light Gray', 'twentyfifteen' ),
 211                      'slug'  => 'light-gray',
 212                      'color' => '#f1f1f1',
 213                  ),
 214                  array(
 215                      'name'  => __( 'White', 'twentyfifteen' ),
 216                      'slug'  => 'white',
 217                      'color' => '#fff',
 218                  ),
 219                  array(
 220                      'name'  => __( 'Yellow', 'twentyfifteen' ),
 221                      'slug'  => 'yellow',
 222                      'color' => '#f4ca16',
 223                  ),
 224                  array(
 225                      'name'  => __( 'Dark Brown', 'twentyfifteen' ),
 226                      'slug'  => 'dark-brown',
 227                      'color' => '#352712',
 228                  ),
 229                  array(
 230                      'name'  => __( 'Medium Pink', 'twentyfifteen' ),
 231                      'slug'  => 'medium-pink',
 232                      'color' => '#e53b51',
 233                  ),
 234                  array(
 235                      'name'  => __( 'Light Pink', 'twentyfifteen' ),
 236                      'slug'  => 'light-pink',
 237                      'color' => '#ffe5d1',
 238                  ),
 239                  array(
 240                      'name'  => __( 'Dark Purple', 'twentyfifteen' ),
 241                      'slug'  => 'dark-purple',
 242                      'color' => '#2e2256',
 243                  ),
 244                  array(
 245                      'name'  => __( 'Purple', 'twentyfifteen' ),
 246                      'slug'  => 'purple',
 247                      'color' => '#674970',
 248                  ),
 249                  array(
 250                      'name'  => __( 'Blue Gray', 'twentyfifteen' ),
 251                      'slug'  => 'blue-gray',
 252                      'color' => '#22313f',
 253                  ),
 254                  array(
 255                      'name'  => __( 'Bright Blue', 'twentyfifteen' ),
 256                      'slug'  => 'bright-blue',
 257                      'color' => '#55c3dc',
 258                  ),
 259                  array(
 260                      'name'  => __( 'Light Blue', 'twentyfifteen' ),
 261                      'slug'  => 'light-blue',
 262                      'color' => '#e9f2f9',
 263                  ),
 264              )
 265          );
 266  
 267          // Add support for custom color scheme.
 268          add_theme_support(
 269              'editor-gradient-presets',
 270              array(
 271                  array(
 272                      'name'     => __( 'Dark Gray Gradient', 'twentyfifteen' ),
 273                      'slug'     => 'dark-gray-gradient-gradient',
 274                      'gradient' => 'linear-gradient(90deg, rgba(17,17,17,1) 0%, rgba(42,42,42,1) 100%)',
 275                  ),
 276                  array(
 277                      'name'     => __( 'Light Gray Gradient', 'twentyfifteen' ),
 278                      'slug'     => 'light-gray-gradient',
 279                      'gradient' => 'linear-gradient(90deg, rgba(241,241,241,1) 0%, rgba(215,215,215,1) 100%)',
 280                  ),
 281                  array(
 282                      'name'     => __( 'White Gradient', 'twentyfifteen' ),
 283                      'slug'     => 'white-gradient',
 284                      'gradient' => 'linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(230,230,230,1) 100%)',
 285                  ),
 286                  array(
 287                      'name'     => __( 'Yellow Gradient', 'twentyfifteen' ),
 288                      'slug'     => 'yellow-gradient',
 289                      'gradient' => 'linear-gradient(90deg, rgba(244,202,22,1) 0%, rgba(205,168,10,1) 100%)',
 290                  ),
 291                  array(
 292                      'name'     => __( 'Dark Brown Gradient', 'twentyfifteen' ),
 293                      'slug'     => 'dark-brown-gradient',
 294                      'gradient' => 'linear-gradient(90deg, rgba(53,39,18,1) 0%, rgba(91,67,31,1) 100%)',
 295                  ),
 296                  array(
 297                      'name'     => __( 'Medium Pink Gradient', 'twentyfifteen' ),
 298                      'slug'     => 'medium-pink-gradient',
 299                      'gradient' => 'linear-gradient(90deg, rgba(229,59,81,1) 0%, rgba(209,28,51,1) 100%)',
 300                  ),
 301                  array(
 302                      'name'     => __( 'Light Pink Gradient', 'twentyfifteen' ),
 303                      'slug'     => 'light-pink-gradient',
 304                      'gradient' => 'linear-gradient(90deg, rgba(255,229,209,1) 0%, rgba(255,200,158,1) 100%)',
 305                  ),
 306                  array(
 307                      'name'     => __( 'Dark Purple Gradient', 'twentyfifteen' ),
 308                      'slug'     => 'dark-purple-gradient',
 309                      'gradient' => 'linear-gradient(90deg, rgba(46,34,86,1) 0%, rgba(66,48,123,1) 100%)',
 310                  ),
 311                  array(
 312                      'name'     => __( 'Purple Gradient', 'twentyfifteen' ),
 313                      'slug'     => 'purple-gradient',
 314                      'gradient' => 'linear-gradient(90deg, rgba(103,73,112,1) 0%, rgba(131,93,143,1) 100%)',
 315                  ),
 316                  array(
 317                      'name'     => __( 'Blue Gray Gradient', 'twentyfifteen' ),
 318                      'slug'     => 'blue-gray-gradient',
 319                      'gradient' => 'linear-gradient(90deg, rgba(34,49,63,1) 0%, rgba(52,75,96,1) 100%)',
 320                  ),
 321                  array(
 322                      'name'     => __( 'Bright Blue Gradient', 'twentyfifteen' ),
 323                      'slug'     => 'bright-blue-gradient',
 324                      'gradient' => 'linear-gradient(90deg, rgba(85,195,220,1) 0%, rgba(43,180,211,1) 100%)',
 325                  ),
 326                  array(
 327                      'name'     => __( 'Light Blue Gradient', 'twentyfifteen' ),
 328                      'slug'     => 'light-blue-gradient',
 329                      'gradient' => 'linear-gradient(90deg, rgba(233,242,249,1) 0%, rgba(193,218,238,1) 100%)',
 330                  ),
 331              )
 332          );
 333  
 334          // Indicate widget sidebars can use selective refresh in the Customizer.
 335          add_theme_support( 'customize-selective-refresh-widgets' );
 336      }
 337  endif; // twentyfifteen_setup()
 338  add_action( 'after_setup_theme', 'twentyfifteen_setup' );
 339  
 340  /**
 341   * Register widget area.
 342   *
 343   * @since Twenty Fifteen 1.0
 344   *
 345   * @link https://developer.wordpress.org/reference/functions/register_sidebar/
 346   */
 347  function twentyfifteen_widgets_init() {
 348      register_sidebar(
 349          array(
 350              'name'          => __( 'Widget Area', 'twentyfifteen' ),
 351              'id'            => 'sidebar-1',
 352              'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentyfifteen' ),
 353              'before_widget' => '<aside id="%1$s" class="widget %2$s">',
 354              'after_widget'  => '</aside>',
 355              'before_title'  => '<h2 class="widget-title">',
 356              'after_title'   => '</h2>',
 357          )
 358      );
 359  }
 360  add_action( 'widgets_init', 'twentyfifteen_widgets_init' );
 361  
 362  if ( ! function_exists( 'twentyfifteen_fonts_url' ) ) :
 363      /**
 364       * Register fonts for Twenty Fifteen.
 365       *
 366       * @since Twenty Fifteen 1.0
 367       * @since Twenty Fifteen 3.4 Replaced Google URL with self-hosted fonts.
 368       *
 369       * @return string Fonts URL for the theme.
 370       */
 371  	function twentyfifteen_fonts_url() {
 372          $fonts_url = '';
 373          $fonts     = array();
 374  
 375          /*
 376           * translators: If there are characters in your language that are not supported
 377           * by Noto Sans, translate this to 'off'. Do not translate into your own language.
 378           */
 379          if ( 'off' !== _x( 'on', 'Noto Sans font: on or off', 'twentyfifteen' ) ) {
 380              $fonts[] = 'noto-sans';
 381          }
 382  
 383          /*
 384           * translators: If there are characters in your language that are not supported
 385           * by Noto Serif, translate this to 'off'. Do not translate into your own language.
 386           */
 387          if ( 'off' !== _x( 'on', 'Noto Serif font: on or off', 'twentyfifteen' ) ) {
 388              $fonts[] = 'noto-serif';
 389          }
 390  
 391          /*
 392           * translators: If there are characters in your language that are not supported
 393           * by Inconsolata, translate this to 'off'. Do not translate into your own language.
 394           */
 395          if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentyfifteen' ) ) {
 396              $fonts[] = 'inconsolata';
 397          }
 398  
 399          if ( $fonts ) {
 400              $fonts_url = get_template_directory_uri() . '/assets/fonts/' . implode( '-plus-', $fonts ) . '.css';
 401          }
 402  
 403          return $fonts_url;
 404      }
 405  endif;
 406  
 407  /**
 408   * JavaScript Detection.
 409   *
 410   * Adds a `js` class to the root `<html>` element when JavaScript is detected.
 411   *
 412   * @since Twenty Fifteen 1.1
 413   */
 414  function twentyfifteen_javascript_detection() {
 415      echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
 416  }
 417  add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 );
 418  
 419  /**
 420   * Enqueue scripts and styles.
 421   *
 422   * @since Twenty Fifteen 1.0
 423   */
 424  function twentyfifteen_scripts() {
 425      // Add custom fonts, used in the main stylesheet.
 426      $font_version = ( 0 === strpos( (string) twentyfifteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
 427      wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), $font_version );
 428  
 429      // Add Genericons, used in the main stylesheet.
 430      wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '20201026' );
 431  
 432      // Load our main stylesheet.
 433      wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri(), array(), '20241112' );
 434  
 435      // Theme block stylesheet.
 436      wp_enqueue_style( 'twentyfifteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentyfifteen-style' ), '20240715' );
 437  
 438      // Register the Internet Explorer specific stylesheet.
 439      wp_register_style( 'twentyfifteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfifteen-style' ), '20220908' );
 440      wp_style_add_data( 'twentyfifteen-ie', 'conditional', 'lt IE 9' );
 441  
 442      // Register the Internet Explorer 7 specific stylesheet.
 443      wp_register_style( 'twentyfifteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentyfifteen-style' ), '20141210' );
 444      wp_style_add_data( 'twentyfifteen-ie7', 'conditional', 'lt IE 8' );
 445  
 446      // Skip-link fix is no longer enqueued by default.
 447      wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', array( 'in_footer' => true ) );
 448  
 449      if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
 450          wp_enqueue_script( 'comment-reply' );
 451      }
 452  
 453      if ( is_singular() && wp_attachment_is_image() ) {
 454          wp_enqueue_script( 'twentyfifteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141210' );
 455      }
 456  
 457      wp_enqueue_script(
 458          'twentyfifteen-script',
 459          get_template_directory_uri() . '/js/functions.js',
 460          array( 'jquery' ),
 461          '20221101',
 462          array(
 463              'in_footer' => false, // Because involves header.
 464              'strategy'  => 'defer',
 465          )
 466      );
 467      wp_localize_script(
 468          'twentyfifteen-script',
 469          'screenReaderText',
 470          array(
 471              /* translators: Hidden accessibility text. */
 472              'expand'   => '<span class="screen-reader-text">' . __( 'expand child menu', 'twentyfifteen' ) . '</span>',
 473              /* translators: Hidden accessibility text. */
 474              'collapse' => '<span class="screen-reader-text">' . __( 'collapse child menu', 'twentyfifteen' ) . '</span>',
 475          )
 476      );
 477  }
 478  add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
 479  
 480  /**
 481   * Enqueue styles for the block-based editor.
 482   *
 483   * @since Twenty Fifteen 2.1
 484   */
 485  function twentyfifteen_block_editor_styles() {
 486      // Block styles.
 487      wp_enqueue_style( 'twentyfifteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20240720' );
 488      // Add custom fonts.
 489      $font_version = ( 0 === strpos( (string) twentyfifteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
 490      wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), $font_version );
 491  }
 492  add_action( 'enqueue_block_editor_assets', 'twentyfifteen_block_editor_styles' );
 493  
 494  
 495  /**
 496   * Add preconnect for Google Fonts.
 497   *
 498   * @since Twenty Fifteen 1.7
 499   * @deprecated Twenty Fifteen 3.4 Disabled filter because, by default, fonts are self-hosted.
 500   *
 501   * @param array   $urls          URLs to print for resource hints.
 502   * @param string  $relation_type The relation type the URLs are printed.
 503   * @return array URLs to print for resource hints.
 504   */
 505  function twentyfifteen_resource_hints( $urls, $relation_type ) {
 506      if ( wp_style_is( 'twentyfifteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
 507          if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
 508              $urls[] = array(
 509                  'href' => 'https://fonts.gstatic.com',
 510                  'crossorigin',
 511              );
 512          } else {
 513              $urls[] = 'https://fonts.gstatic.com';
 514          }
 515      }
 516  
 517      return $urls;
 518  }
 519  // add_filter( 'wp_resource_hints', 'twentyfifteen_resource_hints', 10, 2 );
 520  
 521  /**
 522   * Add featured image as background image to post navigation elements.
 523   *
 524   * @since Twenty Fifteen 1.0
 525   *
 526   * @see wp_add_inline_style()
 527   */
 528  function twentyfifteen_post_nav_background() {
 529      if ( ! is_single() ) {
 530          return;
 531      }
 532  
 533      $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
 534      $next     = get_adjacent_post( false, '', false );
 535      $css      = '';
 536  
 537      if ( is_attachment() && 'attachment' === $previous->post_type ) {
 538          return;
 539      }
 540  
 541      if ( $previous && has_post_thumbnail( $previous->ID ) ) {
 542          $prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'post-thumbnail' );
 543          $css      .= '
 544              .post-navigation .nav-previous { background-image: url(' . esc_url( $prevthumb[0] ) . '); }
 545              .post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; }
 546              .post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); }
 547          ';
 548      }
 549  
 550      if ( $next && has_post_thumbnail( $next->ID ) ) {
 551          $nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'post-thumbnail' );
 552          $css      .= '
 553              .post-navigation .nav-next { background-image: url(' . esc_url( $nextthumb[0] ) . '); border-top: 0; }
 554              .post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; }
 555              .post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); }
 556          ';
 557      }
 558  
 559      wp_add_inline_style( 'twentyfifteen-style', $css );
 560  }
 561  add_action( 'wp_enqueue_scripts', 'twentyfifteen_post_nav_background' );
 562  
 563  /**
 564   * Display descriptions in main navigation.
 565   *
 566   * @since Twenty Fifteen 1.0
 567   *
 568   * @param string   $item_output The menu item's starting HTML output.
 569   * @param WP_Post  $item        Menu item data object.
 570   * @param int      $depth       Depth of the menu. Used for padding.
 571   * @param stdClass $args        An object of wp_nav_menu() arguments.
 572   * @return string Menu item with possible description.
 573   */
 574  function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) {
 575      if ( 'primary' === $args->theme_location && $item->description ) {
 576          $item_output = str_replace( $args->link_after . '</a>', '<div class="menu-item-description">' . $item->description . '</div>' . $args->link_after . '</a>', $item_output );
 577      }
 578  
 579      return $item_output;
 580  }
 581  add_filter( 'walker_nav_menu_start_el', 'twentyfifteen_nav_description', 10, 4 );
 582  
 583  /**
 584   * Add a `screen-reader-text` class to the search form's submit button.
 585   *
 586   * @since Twenty Fifteen 1.0
 587   *
 588   * @param string $html Search form HTML.
 589   * @return string Modified search form HTML.
 590   */
 591  function twentyfifteen_search_form_modify( $html ) {
 592      return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html );
 593  }
 594  add_filter( 'get_search_form', 'twentyfifteen_search_form_modify' );
 595  
 596  /**
 597   * Modifies tag cloud widget arguments to display all tags in the same font size
 598   * and use list format for better accessibility.
 599   *
 600   * @since Twenty Fifteen 1.9
 601   *
 602   * @param array $args Arguments for tag cloud widget.
 603   * @return array The filtered arguments for tag cloud widget.
 604   */
 605  function twentyfifteen_widget_tag_cloud_args( $args ) {
 606      $args['largest']  = 22;
 607      $args['smallest'] = 8;
 608      $args['unit']     = 'pt';
 609      $args['format']   = 'list';
 610  
 611      return $args;
 612  }
 613  add_filter( 'widget_tag_cloud_args', 'twentyfifteen_widget_tag_cloud_args' );
 614  
 615  /**
 616   * Prevents `author-bio.php` partial template from interfering with rendering
 617   * an author archive of a user with the `bio` username.
 618   *
 619   * @since Twenty Fifteen 2.6
 620   *
 621   * @param string $template Template file.
 622   * @return string Replacement template file.
 623   */
 624  function twentyfifteen_author_bio_template( $template ) {
 625      if ( is_author() ) {
 626          $author = get_queried_object();
 627          if ( $author instanceof WP_User && 'bio' === $author->user_nicename ) {
 628              // Use author templates if exist, fall back to template hierarchy otherwise.
 629              return locate_template( array( "author-{$author->ID}.php", 'author.php' ) );
 630          }
 631      }
 632  
 633      return $template;
 634  }
 635  add_filter( 'author_template', 'twentyfifteen_author_bio_template' );
 636  
 637  
 638  /**
 639   * Implement the Custom Header feature.
 640   *
 641   * @since Twenty Fifteen 1.0
 642   */
 643  require get_template_directory() . '/inc/custom-header.php';
 644  
 645  /**
 646   * Custom template tags for this theme.
 647   *
 648   * @since Twenty Fifteen 1.0
 649   */
 650  require get_template_directory() . '/inc/template-tags.php';
 651  
 652  /**
 653   * Customizer additions.
 654   *
 655   * @since Twenty Fifteen 1.0
 656   */
 657  require get_template_directory() . '/inc/customizer.php';
 658  
 659  /**
 660   * Register block patterns and pattern categories.
 661   *
 662   * @since Twenty Fifteen 3.9
 663   */
 664  function twentyfifteen_register_block_patterns() {
 665      require get_template_directory() . '/inc/block-patterns.php';
 666  }
 667  
 668  add_action( 'init', 'twentyfifteen_register_block_patterns' );


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref