[ 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   * Sets 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   * Registers 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       * Registers 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      $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', 'twentyfifteen_javascript_detection', 0 );
 425  
 426  /**
 427   * Enqueues scripts and styles.
 428   *
 429   * @since Twenty Fifteen 1.0
 430   */
 431  function twentyfifteen_scripts() {
 432      // Add custom fonts, used in the main stylesheet.
 433      $font_version = ( 0 === strpos( (string) twentyfifteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
 434      wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), $font_version );
 435  
 436      // Add Genericons, used in the main stylesheet.
 437      wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '20201026' );
 438  
 439      // Load our main stylesheet.
 440      wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri(), array(), '20250415' );
 441  
 442      // Theme block stylesheet.
 443      wp_enqueue_style( 'twentyfifteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentyfifteen-style' ), '20240715' );
 444  
 445      // Register the Internet Explorer specific stylesheet.
 446      wp_register_style( 'twentyfifteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfifteen-style' ), '20220908' );
 447      wp_style_add_data( 'twentyfifteen-ie', 'conditional', 'lt IE 9' );
 448  
 449      // Register the Internet Explorer 7 specific stylesheet.
 450      wp_register_style( 'twentyfifteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentyfifteen-style' ), '20141210' );
 451      wp_style_add_data( 'twentyfifteen-ie7', 'conditional', 'lt IE 8' );
 452  
 453      // Skip-link fix is no longer enqueued by default.
 454      wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', array( 'in_footer' => true ) );
 455  
 456      if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
 457          wp_enqueue_script( 'comment-reply' );
 458      }
 459  
 460      if ( is_singular() && wp_attachment_is_image() ) {
 461          wp_enqueue_script( 'twentyfifteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141210' );
 462      }
 463  
 464      wp_enqueue_script(
 465          'twentyfifteen-script',
 466          get_template_directory_uri() . '/js/functions.js',
 467          array( 'jquery' ),
 468          '20250303',
 469          array(
 470              'in_footer' => false, // Because involves header.
 471              'strategy'  => 'defer',
 472          )
 473      );
 474      wp_localize_script(
 475          'twentyfifteen-script',
 476          'screenReaderText',
 477          array(
 478              /* translators: Hidden accessibility text. */
 479              'expand'   => '<span class="screen-reader-text">' . __( 'expand child menu', 'twentyfifteen' ) . '</span>',
 480              /* translators: Hidden accessibility text. */
 481              'collapse' => '<span class="screen-reader-text">' . __( 'collapse child menu', 'twentyfifteen' ) . '</span>',
 482          )
 483      );
 484  }
 485  add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
 486  
 487  /**
 488   * Enqueues styles for the block-based editor.
 489   *
 490   * @since Twenty Fifteen 2.1
 491   */
 492  function twentyfifteen_block_editor_styles() {
 493      // Block styles.
 494      wp_enqueue_style( 'twentyfifteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20240720' );
 495      // Add custom fonts.
 496      $font_version = ( 0 === strpos( (string) twentyfifteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
 497      wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), $font_version );
 498  }
 499  add_action( 'enqueue_block_editor_assets', 'twentyfifteen_block_editor_styles' );
 500  
 501  
 502  /**
 503   * Adds preconnect for Google Fonts.
 504   *
 505   * @since Twenty Fifteen 1.7
 506   * @deprecated Twenty Fifteen 3.4 Disabled filter because, by default, fonts are self-hosted.
 507   *
 508   * @param array   $urls          URLs to print for resource hints.
 509   * @param string  $relation_type The relation type the URLs are printed.
 510   * @return array URLs to print for resource hints.
 511   */
 512  function twentyfifteen_resource_hints( $urls, $relation_type ) {
 513      if ( wp_style_is( 'twentyfifteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
 514          if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
 515              $urls[] = array(
 516                  'href' => 'https://fonts.gstatic.com',
 517                  'crossorigin',
 518              );
 519          } else {
 520              $urls[] = 'https://fonts.gstatic.com';
 521          }
 522      }
 523  
 524      return $urls;
 525  }
 526  // add_filter( 'wp_resource_hints', 'twentyfifteen_resource_hints', 10, 2 );
 527  
 528  /**
 529   * Adds featured image as background image to post navigation elements.
 530   *
 531   * @since Twenty Fifteen 1.0
 532   *
 533   * @see wp_add_inline_style()
 534   */
 535  function twentyfifteen_post_nav_background() {
 536      if ( ! is_single() ) {
 537          return;
 538      }
 539  
 540      $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
 541      $next     = get_adjacent_post( false, '', false );
 542      $css      = '';
 543  
 544      if ( is_attachment() && 'attachment' === $previous->post_type ) {
 545          return;
 546      }
 547  
 548      if ( $previous && has_post_thumbnail( $previous->ID ) ) {
 549          $prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'post-thumbnail' );
 550          $css      .= '
 551              .post-navigation .nav-previous { background-image: url(' . esc_url( $prevthumb[0] ) . '); }
 552              .post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; }
 553              .post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); }
 554          ';
 555      }
 556  
 557      if ( $next && has_post_thumbnail( $next->ID ) ) {
 558          $nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'post-thumbnail' );
 559          $css      .= '
 560              .post-navigation .nav-next { background-image: url(' . esc_url( $nextthumb[0] ) . '); border-top: 0; }
 561              .post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; }
 562              .post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); }
 563          ';
 564      }
 565  
 566      wp_add_inline_style( 'twentyfifteen-style', $css );
 567  }
 568  add_action( 'wp_enqueue_scripts', 'twentyfifteen_post_nav_background' );
 569  
 570  /**
 571   * Displays descriptions in main navigation.
 572   *
 573   * @since Twenty Fifteen 1.0
 574   *
 575   * @param string   $item_output The menu item's starting HTML output.
 576   * @param WP_Post  $item        Menu item data object.
 577   * @param int      $depth       Depth of the menu. Used for padding.
 578   * @param stdClass $args        An object of wp_nav_menu() arguments.
 579   * @return string Menu item with possible description.
 580   */
 581  function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) {
 582      if ( 'primary' === $args->theme_location && $item->description ) {
 583          $item_output = str_replace( $args->link_after . '</a>', '<div class="menu-item-description">' . $item->description . '</div>' . $args->link_after . '</a>', $item_output );
 584      }
 585  
 586      return $item_output;
 587  }
 588  add_filter( 'walker_nav_menu_start_el', 'twentyfifteen_nav_description', 10, 4 );
 589  
 590  /**
 591   * Adds a `screen-reader-text` class to the search form's submit button.
 592   *
 593   * @since Twenty Fifteen 1.0
 594   *
 595   * @param string $html Search form HTML.
 596   * @return string Modified search form HTML.
 597   */
 598  function twentyfifteen_search_form_modify( $html ) {
 599      return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html );
 600  }
 601  add_filter( 'get_search_form', 'twentyfifteen_search_form_modify' );
 602  
 603  /**
 604   * Modifies tag cloud widget arguments to display all tags in the same font size
 605   * and use list format for better accessibility.
 606   *
 607   * @since Twenty Fifteen 1.9
 608   *
 609   * @param array $args Arguments for tag cloud widget.
 610   * @return array The filtered arguments for tag cloud widget.
 611   */
 612  function twentyfifteen_widget_tag_cloud_args( $args ) {
 613      $args['largest']  = 22;
 614      $args['smallest'] = 8;
 615      $args['unit']     = 'pt';
 616      $args['format']   = 'list';
 617  
 618      return $args;
 619  }
 620  add_filter( 'widget_tag_cloud_args', 'twentyfifteen_widget_tag_cloud_args' );
 621  
 622  /**
 623   * Prevents `author-bio.php` partial template from interfering with rendering
 624   * an author archive of a user with the `bio` username.
 625   *
 626   * @since Twenty Fifteen 2.6
 627   *
 628   * @param string $template Template file.
 629   * @return string Replacement template file.
 630   */
 631  function twentyfifteen_author_bio_template( $template ) {
 632      if ( is_author() ) {
 633          $author = get_queried_object();
 634          if ( $author instanceof WP_User && 'bio' === $author->user_nicename ) {
 635              // Use author templates if exist, fall back to template hierarchy otherwise.
 636              return locate_template( array( "author-{$author->ID}.php", 'author.php' ) );
 637          }
 638      }
 639  
 640      return $template;
 641  }
 642  add_filter( 'author_template', 'twentyfifteen_author_bio_template' );
 643  
 644  
 645  /**
 646   * Implement the Custom Header feature.
 647   *
 648   * @since Twenty Fifteen 1.0
 649   */
 650  require get_template_directory() . '/inc/custom-header.php';
 651  
 652  /**
 653   * Custom template tags for this theme.
 654   *
 655   * @since Twenty Fifteen 1.0
 656   */
 657  require get_template_directory() . '/inc/template-tags.php';
 658  
 659  /**
 660   * Customizer additions.
 661   *
 662   * @since Twenty Fifteen 1.0
 663   */
 664  require get_template_directory() . '/inc/customizer.php';
 665  
 666  /**
 667   * Registers block patterns and pattern categories.
 668   *
 669   * @since Twenty Fifteen 3.9
 670   */
 671  function twentyfifteen_register_block_patterns() {
 672      require get_template_directory() . '/inc/block-patterns.php';
 673  }
 674  
 675  add_action( 'init', 'twentyfifteen_register_block_patterns' );


Generated : Fri Oct 10 08:20:03 2025 Cross-referenced by PHPXref