[ Index ]

PHP Cross Reference of WordPress

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


Generated: Sat Apr 27 01:00:02 2024 Cross-referenced by PHPXref 0.7.1