[ 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   * @global string $wp_version The WordPress version string.
  41   */
  42  if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
  43      require get_template_directory() . '/inc/back-compat.php';
  44  }
  45  
  46  if ( ! function_exists( 'twentyfifteen_setup' ) ) :
  47      /**
  48       * Sets up theme defaults and registers support for various WordPress features.
  49       *
  50       * Note that this function is hooked into the after_setup_theme hook, which
  51       * runs before the init hook. The init hook is too late for some features, such
  52       * as indicating support for post thumbnails.
  53       *
  54       * @since Twenty Fifteen 1.0
  55       *
  56       * @global string $wp_version The WordPress version string.
  57       */
  58  	function twentyfifteen_setup() {
  59  
  60          /*
  61           * Make theme available for translation.
  62           * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfifteen
  63           * If you're building a theme based on twentyfifteen, use a find and replace
  64           * to change 'twentyfifteen' to the name of your theme in all the template files.
  65           *
  66           * Manual loading of text domain is not required after the introduction of
  67           * just in time translation loading in WordPress version 4.6.
  68           *
  69           * @ticket 58318
  70           */
  71  
  72          if ( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ) {
  73              load_theme_textdomain( 'twentyfifteen' );
  74          }
  75  
  76          // Add default posts and comments RSS feed links to head.
  77          add_theme_support( 'automatic-feed-links' );
  78  
  79          /*
  80           * Let WordPress manage the document title.
  81           * By adding theme support, we declare that this theme does not use a
  82           * hard-coded <title> tag in the document head, and expect WordPress to
  83           * provide it for us.
  84           */
  85          add_theme_support( 'title-tag' );
  86  
  87          /*
  88           * Enable support for Post Thumbnails on posts and pages.
  89           *
  90           * See: https://developer.wordpress.org/reference/functions/add_theme_support/#post-thumbnails
  91           */
  92          add_theme_support( 'post-thumbnails' );
  93          set_post_thumbnail_size( 825, 510, true );
  94  
  95          // This theme uses wp_nav_menu() in two locations.
  96          register_nav_menus(
  97              array(
  98                  'primary' => __( 'Primary Menu', 'twentyfifteen' ),
  99                  'social'  => __( 'Social Links Menu', 'twentyfifteen' ),
 100              )
 101          );
 102  
 103          /*
 104           * Switch default core markup for search form, comment form, and comments
 105           * to output valid HTML5.
 106           */
 107          add_theme_support(
 108              'html5',
 109              array(
 110                  'search-form',
 111                  'comment-form',
 112                  'comment-list',
 113                  'gallery',
 114                  'caption',
 115                  'script',
 116                  'style',
 117                  'navigation-widgets',
 118              )
 119          );
 120  
 121          /*
 122           * Enable support for Post Formats.
 123           *
 124           * See: https://developer.wordpress.org/advanced-administration/wordpress/post-formats/
 125           */
 126          add_theme_support(
 127              'post-formats',
 128              array(
 129                  'aside',
 130                  'image',
 131                  'video',
 132                  'quote',
 133                  'link',
 134                  'gallery',
 135                  'status',
 136                  'audio',
 137                  'chat',
 138              )
 139          );
 140  
 141          /*
 142           * Enable support for custom logo.
 143           *
 144           * @since Twenty Fifteen 1.5
 145           */
 146          add_theme_support(
 147              'custom-logo',
 148              array(
 149                  'height'      => 248,
 150                  'width'       => 248,
 151                  'flex-height' => true,
 152              )
 153          );
 154  
 155          $color_scheme  = twentyfifteen_get_color_scheme();
 156          $default_color = trim( $color_scheme[0], '#' );
 157  
 158          // Setup the WordPress core custom background feature.
 159  
 160          add_theme_support(
 161              'custom-background',
 162              /**
 163               * Filters Twenty Fifteen custom-background support arguments.
 164               *
 165               * @since Twenty Fifteen 1.0
 166               *
 167               * @param array $args {
 168               *     An array of custom-background support arguments.
 169               *
 170               *     @type string $default-color      Default color of the background.
 171               *     @type string $default-attachment Default attachment of the background.
 172               * }
 173               */
 174              apply_filters(
 175                  'twentyfifteen_custom_background_args',
 176                  array(
 177                      'default-color'      => $default_color,
 178                      'default-attachment' => 'fixed',
 179                  )
 180              )
 181          );
 182  
 183          /*
 184           * This theme styles the visual editor to resemble the theme style,
 185           * specifically font, colors, icons, and column width. When fonts are
 186           * self-hosted, the theme directory needs to be removed first.
 187           */
 188          $font_stylesheet = str_replace(
 189              array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ),
 190              '',
 191              (string) twentyfifteen_fonts_url()
 192          );
 193          add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', $font_stylesheet ) );
 194  
 195          // Load regular editor styles into the new block-based editor.
 196          add_theme_support( 'editor-styles' );
 197  
 198          // Load default block styles.
 199          add_theme_support( 'wp-block-styles' );
 200  
 201          // Add support for responsive embeds.
 202          add_theme_support( 'responsive-embeds' );
 203  
 204          // Add support for custom color scheme.
 205          add_theme_support(
 206              'editor-color-palette',
 207              array(
 208                  array(
 209                      'name'  => __( 'Dark Gray', 'twentyfifteen' ),
 210                      'slug'  => 'dark-gray',
 211                      'color' => '#111',
 212                  ),
 213                  array(
 214                      'name'  => __( 'Light Gray', 'twentyfifteen' ),
 215                      'slug'  => 'light-gray',
 216                      'color' => '#f1f1f1',
 217                  ),
 218                  array(
 219                      'name'  => __( 'White', 'twentyfifteen' ),
 220                      'slug'  => 'white',
 221                      'color' => '#fff',
 222                  ),
 223                  array(
 224                      'name'  => __( 'Yellow', 'twentyfifteen' ),
 225                      'slug'  => 'yellow',
 226                      'color' => '#f4ca16',
 227                  ),
 228                  array(
 229                      'name'  => __( 'Dark Brown', 'twentyfifteen' ),
 230                      'slug'  => 'dark-brown',
 231                      'color' => '#352712',
 232                  ),
 233                  array(
 234                      'name'  => __( 'Medium Pink', 'twentyfifteen' ),
 235                      'slug'  => 'medium-pink',
 236                      'color' => '#e53b51',
 237                  ),
 238                  array(
 239                      'name'  => __( 'Light Pink', 'twentyfifteen' ),
 240                      'slug'  => 'light-pink',
 241                      'color' => '#ffe5d1',
 242                  ),
 243                  array(
 244                      'name'  => __( 'Dark Purple', 'twentyfifteen' ),
 245                      'slug'  => 'dark-purple',
 246                      'color' => '#2e2256',
 247                  ),
 248                  array(
 249                      'name'  => __( 'Purple', 'twentyfifteen' ),
 250                      'slug'  => 'purple',
 251                      'color' => '#674970',
 252                  ),
 253                  array(
 254                      'name'  => __( 'Blue Gray', 'twentyfifteen' ),
 255                      'slug'  => 'blue-gray',
 256                      'color' => '#22313f',
 257                  ),
 258                  array(
 259                      'name'  => __( 'Bright Blue', 'twentyfifteen' ),
 260                      'slug'  => 'bright-blue',
 261                      'color' => '#55c3dc',
 262                  ),
 263                  array(
 264                      'name'  => __( 'Light Blue', 'twentyfifteen' ),
 265                      'slug'  => 'light-blue',
 266                      'color' => '#e9f2f9',
 267                  ),
 268              )
 269          );
 270  
 271          // Add support for custom color scheme.
 272          add_theme_support(
 273              'editor-gradient-presets',
 274              array(
 275                  array(
 276                      'name'     => __( 'Dark Gray Gradient', 'twentyfifteen' ),
 277                      'slug'     => 'dark-gray-gradient-gradient',
 278                      'gradient' => 'linear-gradient(90deg, rgba(17,17,17,1) 0%, rgba(42,42,42,1) 100%)',
 279                  ),
 280                  array(
 281                      'name'     => __( 'Light Gray Gradient', 'twentyfifteen' ),
 282                      'slug'     => 'light-gray-gradient',
 283                      'gradient' => 'linear-gradient(90deg, rgba(241,241,241,1) 0%, rgba(215,215,215,1) 100%)',
 284                  ),
 285                  array(
 286                      'name'     => __( 'White Gradient', 'twentyfifteen' ),
 287                      'slug'     => 'white-gradient',
 288                      'gradient' => 'linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(230,230,230,1) 100%)',
 289                  ),
 290                  array(
 291                      'name'     => __( 'Yellow Gradient', 'twentyfifteen' ),
 292                      'slug'     => 'yellow-gradient',
 293                      'gradient' => 'linear-gradient(90deg, rgba(244,202,22,1) 0%, rgba(205,168,10,1) 100%)',
 294                  ),
 295                  array(
 296                      'name'     => __( 'Dark Brown Gradient', 'twentyfifteen' ),
 297                      'slug'     => 'dark-brown-gradient',
 298                      'gradient' => 'linear-gradient(90deg, rgba(53,39,18,1) 0%, rgba(91,67,31,1) 100%)',
 299                  ),
 300                  array(
 301                      'name'     => __( 'Medium Pink Gradient', 'twentyfifteen' ),
 302                      'slug'     => 'medium-pink-gradient',
 303                      'gradient' => 'linear-gradient(90deg, rgba(229,59,81,1) 0%, rgba(209,28,51,1) 100%)',
 304                  ),
 305                  array(
 306                      'name'     => __( 'Light Pink Gradient', 'twentyfifteen' ),
 307                      'slug'     => 'light-pink-gradient',
 308                      'gradient' => 'linear-gradient(90deg, rgba(255,229,209,1) 0%, rgba(255,200,158,1) 100%)',
 309                  ),
 310                  array(
 311                      'name'     => __( 'Dark Purple Gradient', 'twentyfifteen' ),
 312                      'slug'     => 'dark-purple-gradient',
 313                      'gradient' => 'linear-gradient(90deg, rgba(46,34,86,1) 0%, rgba(66,48,123,1) 100%)',
 314                  ),
 315                  array(
 316                      'name'     => __( 'Purple Gradient', 'twentyfifteen' ),
 317                      'slug'     => 'purple-gradient',
 318                      'gradient' => 'linear-gradient(90deg, rgba(103,73,112,1) 0%, rgba(131,93,143,1) 100%)',
 319                  ),
 320                  array(
 321                      'name'     => __( 'Blue Gray Gradient', 'twentyfifteen' ),
 322                      'slug'     => 'blue-gray-gradient',
 323                      'gradient' => 'linear-gradient(90deg, rgba(34,49,63,1) 0%, rgba(52,75,96,1) 100%)',
 324                  ),
 325                  array(
 326                      'name'     => __( 'Bright Blue Gradient', 'twentyfifteen' ),
 327                      'slug'     => 'bright-blue-gradient',
 328                      'gradient' => 'linear-gradient(90deg, rgba(85,195,220,1) 0%, rgba(43,180,211,1) 100%)',
 329                  ),
 330                  array(
 331                      'name'     => __( 'Light Blue Gradient', 'twentyfifteen' ),
 332                      'slug'     => 'light-blue-gradient',
 333                      'gradient' => 'linear-gradient(90deg, rgba(233,242,249,1) 0%, rgba(193,218,238,1) 100%)',
 334                  ),
 335              )
 336          );
 337  
 338          // Indicate widget sidebars can use selective refresh in the Customizer.
 339          add_theme_support( 'customize-selective-refresh-widgets' );
 340      }
 341  endif; // twentyfifteen_setup()
 342  add_action( 'after_setup_theme', 'twentyfifteen_setup' );
 343  
 344  /**
 345   * Registers widget area.
 346   *
 347   * @since Twenty Fifteen 1.0
 348   *
 349   * @link https://developer.wordpress.org/reference/functions/register_sidebar/
 350   */
 351  function twentyfifteen_widgets_init() {
 352      register_sidebar(
 353          array(
 354              'name'          => __( 'Widget Area', 'twentyfifteen' ),
 355              'id'            => 'sidebar-1',
 356              'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentyfifteen' ),
 357              'before_widget' => '<aside id="%1$s" class="widget %2$s">',
 358              'after_widget'  => '</aside>',
 359              'before_title'  => '<h2 class="widget-title">',
 360              'after_title'   => '</h2>',
 361          )
 362      );
 363  }
 364  add_action( 'widgets_init', 'twentyfifteen_widgets_init' );
 365  
 366  if ( ! function_exists( 'twentyfifteen_fonts_url' ) ) :
 367      /**
 368       * Registers fonts for Twenty Fifteen.
 369       *
 370       * @since Twenty Fifteen 1.0
 371       * @since Twenty Fifteen 3.4 Replaced Google URL with self-hosted fonts.
 372       *
 373       * @return string Font stylesheet URL or empty string if disabled.
 374       */
 375  	function twentyfifteen_fonts_url() {
 376          $fonts_url = '';
 377          $fonts     = array();
 378  
 379          /*
 380           * translators: If there are characters in your language that are not supported
 381           * by Noto Sans, translate this to 'off'. Do not translate into your own language.
 382           */
 383          if ( 'off' !== _x( 'on', 'Noto Sans font: on or off', 'twentyfifteen' ) ) {
 384              $fonts[] = 'noto-sans';
 385          }
 386  
 387          /*
 388           * translators: If there are characters in your language that are not supported
 389           * by Noto Serif, translate this to 'off'. Do not translate into your own language.
 390           */
 391          if ( 'off' !== _x( 'on', 'Noto Serif font: on or off', 'twentyfifteen' ) ) {
 392              $fonts[] = 'noto-serif';
 393          }
 394  
 395          /*
 396           * translators: If there are characters in your language that are not supported
 397           * by Inconsolata, translate this to 'off'. Do not translate into your own language.
 398           */
 399          if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentyfifteen' ) ) {
 400              $fonts[] = 'inconsolata';
 401          }
 402  
 403          if ( $fonts ) {
 404              $fonts_url = get_template_directory_uri() . '/assets/fonts/' . implode( '-plus-', $fonts ) . '.css';
 405          }
 406  
 407          return $fonts_url;
 408      }
 409  endif;
 410  
 411  /**
 412   * JavaScript Detection.
 413   *
 414   * Adds a `js` class to the root `<html>` element when JavaScript is detected.
 415   *
 416   * @since Twenty Fifteen 1.1
 417   */
 418  function twentyfifteen_javascript_detection() {
 419      $js  = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);";
 420      $js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ );
 421  
 422      if ( function_exists( 'wp_print_inline_script_tag' ) ) {
 423          wp_print_inline_script_tag( $js );
 424      } else {
 425          echo "<script>$js</script>\n";
 426      }
 427  }
 428  add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 );
 429  
 430  /**
 431   * Enqueues scripts and styles.
 432   *
 433   * @since Twenty Fifteen 1.0
 434   */
 435  function twentyfifteen_scripts() {
 436      // Add custom fonts, used in the main stylesheet.
 437      $font_version = ( 0 === strpos( (string) twentyfifteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
 438      wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), $font_version );
 439  
 440      // Add Genericons, used in the main stylesheet.
 441      wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '20251101' );
 442  
 443      // Load our main stylesheet.
 444      wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri(), array(), '20260520' );
 445  
 446      // Theme block stylesheet.
 447      wp_enqueue_style( 'twentyfifteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentyfifteen-style' ), '20240715' );
 448  
 449      // Register handles for removed stylesheets and scripts.
 450      wp_register_style( 'twentyfifteen-ie', false, array( 'twentyfifteen-style' ) );
 451      wp_register_style( 'twentyfifteen-ie7', false, array( 'twentyfifteen-style' ) );
 452      wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', array( 'in_footer' => true ) );
 453  
 454      if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
 455          wp_enqueue_script( 'comment-reply' );
 456      }
 457  
 458      if ( is_singular() && wp_attachment_is_image() ) {
 459          wp_enqueue_script( 'twentyfifteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141210' );
 460      }
 461  
 462      wp_enqueue_script(
 463          'twentyfifteen-script',
 464          get_template_directory_uri() . '/js/functions.js',
 465          array( 'jquery' ),
 466          '20250729',
 467          array(
 468              'in_footer' => false, // Because involves header.
 469              'strategy'  => 'defer',
 470          )
 471      );
 472      wp_localize_script(
 473          'twentyfifteen-script',
 474          'screenReaderText',
 475          array(
 476              /* translators: Hidden accessibility text. */
 477              'expand'   => '<span class="screen-reader-text">' . __( 'expand child menu', 'twentyfifteen' ) . '</span>',
 478              /* translators: Hidden accessibility text. */
 479              'collapse' => '<span class="screen-reader-text">' . __( 'collapse child menu', 'twentyfifteen' ) . '</span>',
 480          )
 481      );
 482  }
 483  add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
 484  
 485  /**
 486   * Enqueues styles for the block-based editor.
 487   *
 488   * @since Twenty Fifteen 2.1
 489   */
 490  function twentyfifteen_block_editor_styles() {
 491      // Block styles.
 492      wp_enqueue_style( 'twentyfifteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20240720' );
 493      // Add custom fonts.
 494      $font_version = ( 0 === strpos( (string) twentyfifteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
 495      wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), $font_version );
 496  }
 497  add_action( 'enqueue_block_editor_assets', 'twentyfifteen_block_editor_styles' );
 498  
 499  
 500  /**
 501   * Adds preconnect for Google Fonts.
 502   *
 503   * @since Twenty Fifteen 1.7
 504   * @deprecated Twenty Fifteen 3.4 Disabled filter because, by default, fonts are self-hosted.
 505   *
 506   * @global string $wp_version The WordPress version string.
 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 : Sun Jun 28 08:20:12 2026 Cross-referenced by PHPXref