[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Twenty Fourteen 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_Fourteen
  25   * @since Twenty Fourteen 1.0
  26   */
  27  
  28  /**
  29   * Set up the content width value based on the theme's design.
  30   *
  31   * @see twentyfourteen_content_width()
  32   *
  33   * @since Twenty Fourteen 1.0
  34   */
  35  if ( ! isset( $content_width ) ) {
  36      $content_width = 474;
  37  }
  38  
  39  /**
  40   * Twenty Fourteen only works in WordPress 3.6 or later.
  41   */
  42  if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) {
  43      require get_template_directory() . '/inc/back-compat.php';
  44  }
  45  
  46  if ( ! function_exists( 'twentyfourteen_setup' ) ) :
  47      /**
  48       * Twenty Fourteen setup.
  49       *
  50       * Set up theme defaults and registers support for various WordPress features.
  51       *
  52       * Note that this function is hooked into the after_setup_theme hook, which
  53       * runs before the init hook. The init hook is too late for some features, such
  54       * as indicating support post thumbnails.
  55       *
  56       * @since Twenty Fourteen 1.0
  57       */
  58  	function twentyfourteen_setup() {
  59  
  60          /*
  61           * Make Twenty Fourteen available for translation.
  62           *
  63           * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfourteen
  64           * If you're building a theme based on Twenty Fourteen, use a find and
  65           * replace to change 'twentyfourteen' to the name of your theme in all
  66           * template files.
  67           */
  68          load_theme_textdomain( 'twentyfourteen' );
  69  
  70          // This theme styles the visual editor to resemble the theme style.
  71          add_editor_style( array( 'css/editor-style.css', twentyfourteen_font_url(), 'genericons/genericons.css' ) );
  72  
  73          // Load regular editor styles into the new block-based editor.
  74          add_theme_support( 'editor-styles' );
  75  
  76          // Load default block styles.
  77          add_theme_support( 'wp-block-styles' );
  78  
  79          // Add support for responsive embeds.
  80          add_theme_support( 'responsive-embeds' );
  81  
  82          // Add support for custom color scheme.
  83          add_theme_support(
  84              'editor-color-palette',
  85              array(
  86                  array(
  87                      'name'  => __( 'Green', 'twentyfourteen' ),
  88                      'slug'  => 'green',
  89                      'color' => '#24890d',
  90                  ),
  91                  array(
  92                      'name'  => __( 'Black', 'twentyfourteen' ),
  93                      'slug'  => 'black',
  94                      'color' => '#000',
  95                  ),
  96                  array(
  97                      'name'  => __( 'Dark Gray', 'twentyfourteen' ),
  98                      'slug'  => 'dark-gray',
  99                      'color' => '#2b2b2b',
 100                  ),
 101                  array(
 102                      'name'  => __( 'Medium Gray', 'twentyfourteen' ),
 103                      'slug'  => 'medium-gray',
 104                      'color' => '#767676',
 105                  ),
 106                  array(
 107                      'name'  => __( 'Light Gray', 'twentyfourteen' ),
 108                      'slug'  => 'light-gray',
 109                      'color' => '#f5f5f5',
 110                  ),
 111                  array(
 112                      'name'  => __( 'White', 'twentyfourteen' ),
 113                      'slug'  => 'white',
 114                      'color' => '#fff',
 115                  ),
 116              )
 117          );
 118  
 119          // Add RSS feed links to <head> for posts and comments.
 120          add_theme_support( 'automatic-feed-links' );
 121  
 122          // Enable support for Post Thumbnails, and declare two sizes.
 123          add_theme_support( 'post-thumbnails' );
 124          set_post_thumbnail_size( 672, 372, true );
 125          add_image_size( 'twentyfourteen-full-width', 1038, 576, true );
 126  
 127          // This theme uses wp_nav_menu() in two locations.
 128          register_nav_menus(
 129              array(
 130                  'primary'   => __( 'Top primary menu', 'twentyfourteen' ),
 131                  'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ),
 132              )
 133          );
 134  
 135          /*
 136           * Switch default core markup for search form, comment form, and comments
 137           * to output valid HTML5.
 138           */
 139          add_theme_support(
 140              'html5',
 141              array(
 142                  'search-form',
 143                  'comment-form',
 144                  'comment-list',
 145                  'gallery',
 146                  'caption',
 147                  'script',
 148                  'style',
 149                  'navigation-widgets',
 150              )
 151          );
 152  
 153          /*
 154           * Enable support for Post Formats.
 155           * See https://wordpress.org/support/article/post-formats/
 156           */
 157          add_theme_support(
 158              'post-formats',
 159              array(
 160                  'aside',
 161                  'image',
 162                  'video',
 163                  'audio',
 164                  'quote',
 165                  'link',
 166                  'gallery',
 167              )
 168          );
 169  
 170          // This theme allows users to set a custom background.
 171          add_theme_support(
 172              'custom-background',
 173              /**
 174               * Filters Twenty Fourteen custom-background support arguments.
 175               *
 176               * @since Twenty Fourteen 1.0
 177               *
 178               * @param array $args {
 179               *     An array of custom-background support arguments.
 180               *
 181               *     @type string $default-color Default color of the background.
 182               * }
 183               */
 184              apply_filters(
 185                  'twentyfourteen_custom_background_args',
 186                  array(
 187                      'default-color' => 'f5f5f5',
 188                  )
 189              )
 190          );
 191  
 192          // Add support for featured content.
 193          add_theme_support(
 194              'featured-content',
 195              array(
 196                  'featured_content_filter' => 'twentyfourteen_get_featured_posts',
 197                  'max_posts'               => 6,
 198              )
 199          );
 200  
 201          // This theme uses its own gallery styles.
 202          add_filter( 'use_default_gallery_style', '__return_false' );
 203  
 204          // Indicate widget sidebars can use selective refresh in the Customizer.
 205          add_theme_support( 'customize-selective-refresh-widgets' );
 206      }
 207  endif; // twentyfourteen_setup()
 208  add_action( 'after_setup_theme', 'twentyfourteen_setup' );
 209  
 210  /**
 211   * Adjust content_width value for image attachment template.
 212   *
 213   * @since Twenty Fourteen 1.0
 214   */
 215  function twentyfourteen_content_width() {
 216      if ( is_attachment() && wp_attachment_is_image() ) {
 217          $GLOBALS['content_width'] = 810;
 218      }
 219  }
 220  add_action( 'template_redirect', 'twentyfourteen_content_width' );
 221  
 222  /**
 223   * Getter function for Featured Content Plugin.
 224   *
 225   * @since Twenty Fourteen 1.0
 226   *
 227   * @return array An array of WP_Post objects.
 228   */
 229  function twentyfourteen_get_featured_posts() {
 230      /**
 231       * Filters the featured posts to return in Twenty Fourteen.
 232       *
 233       * @since Twenty Fourteen 1.0
 234       *
 235       * @param array|bool $posts Array of featured posts, otherwise false.
 236       */
 237      return apply_filters( 'twentyfourteen_get_featured_posts', array() );
 238  }
 239  
 240  /**
 241   * A helper conditional function that returns a boolean value.
 242   *
 243   * @since Twenty Fourteen 1.0
 244   *
 245   * @return bool Whether there are featured posts.
 246   */
 247  function twentyfourteen_has_featured_posts() {
 248      return ! is_paged() && (bool) twentyfourteen_get_featured_posts();
 249  }
 250  
 251  /**
 252   * Register three Twenty Fourteen widget areas.
 253   *
 254   * @since Twenty Fourteen 1.0
 255   */
 256  function twentyfourteen_widgets_init() {
 257      require get_template_directory() . '/inc/widgets.php';
 258      register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
 259  
 260      register_sidebar(
 261          array(
 262              'name'          => __( 'Primary Sidebar', 'twentyfourteen' ),
 263              'id'            => 'sidebar-1',
 264              'description'   => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
 265              'before_widget' => '<aside id="%1$s" class="widget %2$s">',
 266              'after_widget'  => '</aside>',
 267              'before_title'  => '<h1 class="widget-title">',
 268              'after_title'   => '</h1>',
 269          )
 270      );
 271      register_sidebar(
 272          array(
 273              'name'          => __( 'Content Sidebar', 'twentyfourteen' ),
 274              'id'            => 'sidebar-2',
 275              'description'   => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
 276              'before_widget' => '<aside id="%1$s" class="widget %2$s">',
 277              'after_widget'  => '</aside>',
 278              'before_title'  => '<h1 class="widget-title">',
 279              'after_title'   => '</h1>',
 280          )
 281      );
 282      register_sidebar(
 283          array(
 284              'name'          => __( 'Footer Widget Area', 'twentyfourteen' ),
 285              'id'            => 'sidebar-3',
 286              'description'   => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
 287              'before_widget' => '<aside id="%1$s" class="widget %2$s">',
 288              'after_widget'  => '</aside>',
 289              'before_title'  => '<h1 class="widget-title">',
 290              'after_title'   => '</h1>',
 291          )
 292      );
 293  }
 294  add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
 295  
 296  /**
 297   * Register Lato Google font for Twenty Fourteen.
 298   *
 299   * @since Twenty Fourteen 1.0
 300   *
 301   * @return string
 302   */
 303  function twentyfourteen_font_url() {
 304      $font_url = '';
 305      /*
 306       * translators: If there are characters in your language that are not supported
 307       * by Lato, translate this to 'off'. Do not translate into your own language.
 308       */
 309      if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) {
 310          $query_args = array(
 311              'family'  => urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ),
 312              'subset'  => urlencode( 'latin,latin-ext' ),
 313              'display' => urlencode( 'fallback' ),
 314          );
 315          $font_url   = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
 316      }
 317  
 318      return $font_url;
 319  }
 320  
 321  /**
 322   * Enqueue scripts and styles for the front end.
 323   *
 324   * @since Twenty Fourteen 1.0
 325   */
 326  function twentyfourteen_scripts() {
 327      // Add Lato font, used in the main stylesheet.
 328      wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
 329  
 330      // Add Genericons font, used in the main stylesheet.
 331      wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.3' );
 332  
 333      // Load our main stylesheet.
 334      wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri(), array(), '20190507' );
 335  
 336      // Theme block stylesheet.
 337      wp_enqueue_style( 'twentyfourteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentyfourteen-style' ), '20190102' );
 338  
 339      // Load the Internet Explorer specific stylesheet.
 340      wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), '20140701' );
 341      wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );
 342  
 343      if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
 344          wp_enqueue_script( 'comment-reply' );
 345      }
 346  
 347      if ( is_singular() && wp_attachment_is_image() ) {
 348          wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20150120' );
 349      }
 350  
 351      if ( is_active_sidebar( 'sidebar-3' ) ) {
 352          wp_enqueue_script( 'jquery-masonry' );
 353      }
 354  
 355      if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) {
 356          wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20150120', true );
 357          wp_localize_script(
 358              'twentyfourteen-slider',
 359              'featuredSliderDefaults',
 360              array(
 361                  'prevText' => __( 'Previous', 'twentyfourteen' ),
 362                  'nextText' => __( 'Next', 'twentyfourteen' ),
 363              )
 364          );
 365      }
 366  
 367      wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20171218', true );
 368  }
 369  add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
 370  
 371  /**
 372   * Enqueue Google fonts style to admin screen for custom header display.
 373   *
 374   * @since Twenty Fourteen 1.0
 375   */
 376  function twentyfourteen_admin_fonts() {
 377      wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
 378  }
 379  add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' );
 380  
 381  /**
 382   * Add preconnect for Google Fonts.
 383   *
 384   * @since Twenty Fourteen 1.9
 385   *
 386   * @param array   $urls          URLs to print for resource hints.
 387   * @param string  $relation_type The relation type the URLs are printed.
 388   * @return array URLs to print for resource hints.
 389   */
 390  function twentyfourteen_resource_hints( $urls, $relation_type ) {
 391      if ( wp_style_is( 'twentyfourteen-lato', 'queue' ) && 'preconnect' === $relation_type ) {
 392          if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
 393              $urls[] = array(
 394                  'href' => 'https://fonts.gstatic.com',
 395                  'crossorigin',
 396              );
 397          } else {
 398              $urls[] = 'https://fonts.gstatic.com';
 399          }
 400      }
 401  
 402      return $urls;
 403  }
 404  add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 );
 405  
 406  /**
 407   * Enqueue styles for the block-based editor.
 408   *
 409   * @since Twenty Fourteen 2.3
 410   */
 411  function twentyfourteen_block_editor_styles() {
 412      // Block styles.
 413      wp_enqueue_style( 'twentyfourteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20201208' );
 414      // Add custom fonts.
 415      wp_enqueue_style( 'twentyfourteen-fonts', twentyfourteen_font_url(), array(), null );
 416  }
 417  add_action( 'enqueue_block_editor_assets', 'twentyfourteen_block_editor_styles' );
 418  
 419  if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) :
 420      /**
 421       * Print the attached image with a link to the next attached image.
 422       *
 423       * @since Twenty Fourteen 1.0
 424       */
 425  	function twentyfourteen_the_attached_image() {
 426          $post = get_post();
 427          /**
 428           * Filters the default Twenty Fourteen attachment size.
 429           *
 430           * @since Twenty Fourteen 1.0
 431           *
 432           * @param array $dimensions {
 433           *     An array of height and width dimensions.
 434           *
 435           *     @type int $height Height of the image in pixels. Default 810.
 436           *     @type int $width  Width of the image in pixels. Default 810.
 437           * }
 438           */
 439          $attachment_size     = apply_filters( 'twentyfourteen_attachment_size', array( 810, 810 ) );
 440          $next_attachment_url = wp_get_attachment_url();
 441  
 442          /*
 443           * Grab the IDs of all the image attachments in a gallery so we can get the URL
 444           * of the next adjacent image in a gallery, or the first image (if we're
 445           * looking at the last image in a gallery), or, in a gallery of one, just the
 446           * link to that image file.
 447           */
 448          $attachment_ids = get_posts(
 449              array(
 450                  'post_parent'    => $post->post_parent,
 451                  'fields'         => 'ids',
 452                  'numberposts'    => -1,
 453                  'post_status'    => 'inherit',
 454                  'post_type'      => 'attachment',
 455                  'post_mime_type' => 'image',
 456                  'order'          => 'ASC',
 457                  'orderby'        => 'menu_order ID',
 458              )
 459          );
 460  
 461          // If there is more than 1 attachment in a gallery...
 462          if ( count( $attachment_ids ) > 1 ) {
 463              foreach ( $attachment_ids as $idx => $attachment_id ) {
 464                  if ( $attachment_id == $post->ID ) {
 465                      $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ];
 466                      break;
 467                  }
 468              }
 469  
 470              if ( $next_id ) {
 471                  // ...get the URL of the next image attachment.
 472                  $next_attachment_url = get_attachment_link( $next_id );
 473              } else {
 474                  // ...or get the URL of the first image attachment.
 475                  $next_attachment_url = get_attachment_link( reset( $attachment_ids ) );
 476              }
 477          }
 478  
 479          printf(
 480              '<a href="%1$s" rel="attachment">%2$s</a>',
 481              esc_url( $next_attachment_url ),
 482              wp_get_attachment_image( $post->ID, $attachment_size )
 483          );
 484      }
 485  endif;
 486  
 487  if ( ! function_exists( 'twentyfourteen_list_authors' ) ) :
 488      /**
 489       * Print a list of all site contributors who published at least one post.
 490       *
 491       * @since Twenty Fourteen 1.0
 492       */
 493  	function twentyfourteen_list_authors() {
 494          $args = array(
 495              'fields'     => 'ID',
 496              'orderby'    => 'post_count',
 497              'order'      => 'DESC',
 498              'capability' => array( 'edit_posts' ),
 499          );
 500  
 501          // Capability queries were only introduced in WP 5.9.
 502          if ( version_compare( $GLOBALS['wp_version'], '5.9-alpha', '<' ) ) {
 503              $args['who'] = 'authors';
 504              unset( $args['capability'] );
 505          }
 506  
 507          /**
 508           * Filters query arguments for listing authors.
 509           *
 510           * @since 3.3
 511           *
 512           * @param array $args Query arguments.
 513           */
 514          $args = apply_filters( 'twentyfourteen_list_authors_query_args', $args );
 515  
 516          $contributor_ids = get_users( $args );
 517  
 518          foreach ( $contributor_ids as $contributor_id ) :
 519              $post_count = count_user_posts( $contributor_id );
 520  
 521              // Move on if user has not published a post (yet).
 522              if ( ! $post_count ) {
 523                  continue;
 524              }
 525              ?>
 526  
 527          <div class="contributor">
 528          <div class="contributor-info">
 529              <div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div>
 530              <div class="contributor-summary">
 531                  <h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2>
 532                  <p class="contributor-bio">
 533                      <?php echo get_the_author_meta( 'description', $contributor_id ); ?>
 534                  </p>
 535                  <a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>">
 536                      <?php
 537                      /* translators: %d: Post count. */
 538                      printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count );
 539                      ?>
 540                  </a>
 541              </div><!-- .contributor-summary -->
 542          </div><!-- .contributor-info -->
 543      </div><!-- .contributor -->
 544  
 545              <?php
 546      endforeach;
 547      }
 548  endif;
 549  
 550  /**
 551   * Extend the default WordPress body classes.
 552   *
 553   * Adds body classes to denote:
 554   * 1. Single or multiple authors.
 555   * 2. Presence of header image except in Multisite signup and activate pages.
 556   * 3. Index views.
 557   * 4. Full-width content layout.
 558   * 5. Presence of footer widgets.
 559   * 6. Single views.
 560   * 7. Featured content layout.
 561   *
 562   * @since Twenty Fourteen 1.0
 563   *
 564   * @param array $classes A list of existing body class values.
 565   * @return array The filtered body class list.
 566   */
 567  function twentyfourteen_body_classes( $classes ) {
 568      if ( is_multi_author() ) {
 569          $classes[] = 'group-blog';
 570      }
 571  
 572      if ( get_header_image() ) {
 573          $classes[] = 'header-image';
 574      } elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ), true ) ) {
 575          $classes[] = 'masthead-fixed';
 576      }
 577  
 578      if ( is_archive() || is_search() || is_home() ) {
 579          $classes[] = 'list-view';
 580      }
 581  
 582      if ( ( ! is_active_sidebar( 'sidebar-2' ) )
 583          || is_page_template( 'page-templates/full-width.php' )
 584          || is_page_template( 'page-templates/contributors.php' )
 585          || is_attachment() ) {
 586          $classes[] = 'full-width';
 587      }
 588  
 589      if ( is_active_sidebar( 'sidebar-3' ) ) {
 590          $classes[] = 'footer-widgets';
 591      }
 592  
 593      if ( is_singular() && ! is_front_page() ) {
 594          $classes[] = 'singular';
 595      }
 596  
 597      if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) {
 598          $classes[] = 'slider';
 599      } elseif ( is_front_page() ) {
 600          $classes[] = 'grid';
 601      }
 602  
 603      return $classes;
 604  }
 605  add_filter( 'body_class', 'twentyfourteen_body_classes' );
 606  
 607  /**
 608   * Extend the default WordPress post classes.
 609   *
 610   * Adds a post class to denote:
 611   * Non-password protected page with a post thumbnail.
 612   *
 613   * @since Twenty Fourteen 1.0
 614   *
 615   * @param array $classes A list of existing post class values.
 616   * @return array The filtered post class list.
 617   */
 618  function twentyfourteen_post_classes( $classes ) {
 619      if ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) {
 620          $classes[] = 'has-post-thumbnail';
 621      }
 622  
 623      return $classes;
 624  }
 625  add_filter( 'post_class', 'twentyfourteen_post_classes' );
 626  
 627  /**
 628   * Create a nicely formatted and more specific title element text for output
 629   * in head of document, based on current view.
 630   *
 631   * @since Twenty Fourteen 1.0
 632   *
 633   * @global int $paged WordPress archive pagination page count.
 634   * @global int $page  WordPress paginated post page count.
 635   *
 636   * @param string $title Default title text for current view.
 637   * @param string $sep Optional separator.
 638   * @return string The filtered title.
 639   */
 640  function twentyfourteen_wp_title( $title, $sep ) {
 641      global $paged, $page;
 642  
 643      if ( is_feed() ) {
 644          return $title;
 645      }
 646  
 647      // Add the site name.
 648      $title .= get_bloginfo( 'name', 'display' );
 649  
 650      // Add the site description for the home/front page.
 651      $site_description = get_bloginfo( 'description', 'display' );
 652      if ( $site_description && ( is_home() || is_front_page() ) ) {
 653          $title = "$title $sep $site_description";
 654      }
 655  
 656      // Add a page number if necessary.
 657      if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
 658          /* translators: %s: Page number. */
 659          $title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) );
 660      }
 661  
 662      return $title;
 663  }
 664  add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );
 665  
 666  
 667  /**
 668   * Modifies tag cloud widget arguments to display all tags in the same font size
 669   * and use list format for better accessibility.
 670   *
 671   * @since Twenty Fourteen 2.1
 672   *
 673   * @param array $args Arguments for tag cloud widget.
 674   * @return array The filtered arguments for tag cloud widget.
 675   */
 676  function twentyfourteen_widget_tag_cloud_args( $args ) {
 677      $args['largest']  = 22;
 678      $args['smallest'] = 8;
 679      $args['unit']     = 'pt';
 680      $args['format']   = 'list';
 681  
 682      return $args;
 683  }
 684  add_filter( 'widget_tag_cloud_args', 'twentyfourteen_widget_tag_cloud_args' );
 685  
 686  
 687  // Implement Custom Header features.
 688  require get_template_directory() . '/inc/custom-header.php';
 689  
 690  // Custom template tags for this theme.
 691  require get_template_directory() . '/inc/template-tags.php';
 692  
 693  // Add Customizer functionality.
 694  require get_template_directory() . '/inc/customizer.php';
 695  
 696  // Add support for block patterns.
 697  require get_template_directory() . '/inc/block-patterns.php';
 698  
 699  /*
 700   * Add Featured Content functionality.
 701   *
 702   * To overwrite in a plugin, define your own Featured_Content class on or
 703   * before the 'setup_theme' hook.
 704   */
 705  if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
 706      require get_template_directory() . '/inc/featured-content.php';
 707  }
 708  
 709  /**
 710   * Add an `is_customize_preview` function if it is missing.
 711   *
 712   * Enables installing Twenty Fourteen in WordPress versions before 4.0.0 when the
 713   * `is_customize_preview` function was introduced.
 714   */
 715  if ( ! function_exists( 'is_customize_preview' ) ) :
 716  	function is_customize_preview() {
 717          global $wp_customize;
 718  
 719          return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
 720      }
 721  endif;


Generated: Tue Mar 19 01:00:02 2024 Cross-referenced by PHPXref 0.7.1