[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * TwentyTen functions and definitions
   4   *
   5   * Sets up the theme and provides some helper functions. Some helper functions
   6   * are used in the theme as custom template tags. Others are attached to action and
   7   * filter hooks in WordPress to change core functionality.
   8   *
   9   * The first function, twentyten_setup(), sets up the theme by registering support
  10   * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  11   *
  12   * When using a child theme you can override certain functions (those wrapped
  13   * in a function_exists() call) by defining them first in your child theme's
  14   * functions.php file. The child theme's functions.php file is included before
  15   * the parent theme's file, so the child theme functions would be used.
  16   *
  17   * @link https://developer.wordpress.org/themes/basics/theme-functions/
  18   * @link https://developer.wordpress.org/themes/advanced-topics/child-themes/
  19   *
  20   * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  21   * to a filter or action hook. The hook can be removed by using remove_action() or
  22   * remove_filter() and you can attach your own function to the hook.
  23   *
  24   * We can remove the parent theme's hook only after it is attached, which means we need to
  25   * wait until setting up the child theme:
  26   *
  27   * <code>
  28   * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  29   * function my_child_theme_setup() {
  30   *     // We are providing our own filter for excerpt_length (or using the unfiltered value).
  31   *     remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  32   *     ...
  33   * }
  34   * </code>
  35   *
  36   * For more information on hooks, actions, and filters, see https://developer.wordpress.org/plugins/.
  37   *
  38   * @package WordPress
  39   * @subpackage Twenty_Ten
  40   * @since Twenty Ten 1.0
  41   */
  42  
  43  /*
  44   * Set the content width based on the theme's design and stylesheet.
  45   *
  46   * Used to set the width of images and content. Should be equal to the width the theme
  47   * is designed for, generally via the style.css stylesheet.
  48   */
  49  if ( ! isset( $content_width ) ) {
  50      $content_width = 640;
  51  }
  52  
  53  /* Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
  54  add_action( 'after_setup_theme', 'twentyten_setup' );
  55  
  56  if ( ! function_exists( 'twentyten_setup' ) ) :
  57      /**
  58       * Sets up theme defaults and registers support for various WordPress features.
  59       *
  60       * Note that this function is hooked into the after_setup_theme hook, which runs
  61       * before the init hook. The init hook is too late for some features, such as indicating
  62       * support post thumbnails.
  63       *
  64       * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
  65       * functions.php file.
  66       *
  67       * @uses add_theme_support()        To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
  68       * @uses register_nav_menus()       To add support for navigation menus.
  69       * @uses add_editor_style()         To style the visual editor.
  70       * @uses load_theme_textdomain()    For translation/localization support.
  71       * @uses register_default_headers() To register the default custom header images provided with the theme.
  72       * @uses set_post_thumbnail_size()  To set a custom post thumbnail size.
  73       *
  74       * @since Twenty Ten 1.0
  75       *
  76       * @global string $wp_version The WordPress version string.
  77       */
  78  	function twentyten_setup() {
  79  
  80          // This theme styles the visual editor with editor-style.css to match the theme style.
  81          add_editor_style();
  82  
  83          // Load regular editor styles into the new block-based editor.
  84          add_theme_support( 'editor-styles' );
  85  
  86          // Load default block styles.
  87          add_theme_support( 'wp-block-styles' );
  88  
  89          // Add support for custom color scheme.
  90          add_theme_support(
  91              'editor-color-palette',
  92              array(
  93                  array(
  94                      'name'  => __( 'Blue', 'twentyten' ),
  95                      'slug'  => 'blue',
  96                      'color' => '#0066cc',
  97                  ),
  98                  array(
  99                      'name'  => __( 'Black', 'twentyten' ),
 100                      'slug'  => 'black',
 101                      'color' => '#000',
 102                  ),
 103                  array(
 104                      'name'  => __( 'Medium Gray', 'twentyten' ),
 105                      'slug'  => 'medium-gray',
 106                      'color' => '#666',
 107                  ),
 108                  array(
 109                      'name'  => __( 'Light Gray', 'twentyten' ),
 110                      'slug'  => 'light-gray',
 111                      'color' => '#f1f1f1',
 112                  ),
 113                  array(
 114                      'name'  => __( 'White', 'twentyten' ),
 115                      'slug'  => 'white',
 116                      'color' => '#fff',
 117                  ),
 118              )
 119          );
 120  
 121          // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
 122          add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
 123  
 124          // This theme uses post thumbnails.
 125          add_theme_support( 'post-thumbnails' );
 126  
 127          // Add default posts and comments RSS feed links to head.
 128          add_theme_support( 'automatic-feed-links' );
 129  
 130          /*
 131           * Make theme available for translation.
 132           * Translations can be filed in the /languages/ directory.
 133           *
 134           * Manual loading of text domain is not required after the introduction of
 135           * just in time translation loading in WordPress version 4.6.
 136           *
 137           * @ticket 58318
 138           */
 139          if ( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ) {
 140              load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );
 141          }
 142  
 143          // This theme uses wp_nav_menu() in one location.
 144          register_nav_menus(
 145              array(
 146                  'primary' => __( 'Primary Navigation', 'twentyten' ),
 147              )
 148          );
 149  
 150          // This theme allows users to set a custom background.
 151          add_theme_support(
 152              'custom-background',
 153              array(
 154                  // Let WordPress know what our default background color is.
 155                  'default-color' => 'f1f1f1',
 156              )
 157          );
 158  
 159          // The custom header business starts here.
 160  
 161          $custom_header_support = array(
 162              /*
 163               * The default image to use.
 164               * The %s is a placeholder for the theme template directory URI.
 165               */
 166              'default-image'       => '%s/images/headers/path.jpg',
 167              // The height and width of our custom header.
 168              /**
 169               * Filters the Twenty Ten default header image width.
 170               *
 171               * @since Twenty Ten 1.0
 172               *
 173               * @param int The default header image width in pixels. Default 940.
 174               */
 175              'width'               => apply_filters( 'twentyten_header_image_width', 940 ),
 176              /**
 177               * Filters the Twenty Ten default header image height.
 178               *
 179               * @since Twenty Ten 1.0
 180               *
 181               * @param int The default header image height in pixels. Default 198.
 182               */
 183              'height'              => apply_filters( 'twentyten_header_image_height', 198 ),
 184              // Support flexible heights.
 185              'flex-height'         => true,
 186              // Don't support text inside the header image.
 187              'header-text'         => false,
 188              // Callback for styling the header preview in the admin.
 189              'admin-head-callback' => 'twentyten_admin_header_style',
 190          );
 191  
 192          add_theme_support( 'custom-header', $custom_header_support );
 193  
 194          if ( ! function_exists( 'get_custom_header' ) ) {
 195              // This is all for compatibility with versions of WordPress prior to 3.4.
 196              define( 'HEADER_TEXTCOLOR', '' );
 197              define( 'NO_HEADER_TEXT', true );
 198              define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
 199              define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
 200              define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
 201              add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
 202              add_custom_background();
 203          }
 204  
 205          /*
 206           * We'll be using post thumbnails for custom header images on posts and pages.
 207           * We want them to be 940 pixels wide by 198 pixels tall.
 208           * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
 209           */
 210          set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
 211  
 212          // ...and thus ends the custom header business.
 213  
 214          // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
 215          register_default_headers(
 216              array(
 217                  'berries'       => array(
 218                      'url'           => '%s/images/headers/berries.jpg',
 219                      'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
 220                      /* translators: Header image description. */
 221                      'description'   => __( 'Berries', 'twentyten' ),
 222                  ),
 223                  'cherryblossom' => array(
 224                      'url'           => '%s/images/headers/cherryblossoms.jpg',
 225                      'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
 226                      /* translators: Header image description. */
 227                      'description'   => __( 'Cherry Blossoms', 'twentyten' ),
 228                  ),
 229                  'concave'       => array(
 230                      'url'           => '%s/images/headers/concave.jpg',
 231                      'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
 232                      /* translators: Header image description. */
 233                      'description'   => __( 'Concave', 'twentyten' ),
 234                  ),
 235                  'fern'          => array(
 236                      'url'           => '%s/images/headers/fern.jpg',
 237                      'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
 238                      /* translators: Header image description. */
 239                      'description'   => __( 'Fern', 'twentyten' ),
 240                  ),
 241                  'forestfloor'   => array(
 242                      'url'           => '%s/images/headers/forestfloor.jpg',
 243                      'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
 244                      /* translators: Header image description. */
 245                      'description'   => __( 'Forest Floor', 'twentyten' ),
 246                  ),
 247                  'inkwell'       => array(
 248                      'url'           => '%s/images/headers/inkwell.jpg',
 249                      'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
 250                      /* translators: Header image description. */
 251                      'description'   => __( 'Inkwell', 'twentyten' ),
 252                  ),
 253                  'path'          => array(
 254                      'url'           => '%s/images/headers/path.jpg',
 255                      'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
 256                      /* translators: Header image description. */
 257                      'description'   => __( 'Path', 'twentyten' ),
 258                  ),
 259                  'sunset'        => array(
 260                      'url'           => '%s/images/headers/sunset.jpg',
 261                      'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
 262                      /* translators: Header image description. */
 263                      'description'   => __( 'Sunset', 'twentyten' ),
 264                  ),
 265              )
 266          );
 267      }
 268  endif;
 269  
 270  if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
 271      /**
 272       * Styles the header image displayed on the Appearance > Header admin panel.
 273       *
 274       * Referenced via add_custom_image_header() in twentyten_setup().
 275       *
 276       * @since Twenty Ten 1.0
 277       */
 278  	function twentyten_admin_header_style() {
 279          ?>
 280      <style id="twentyten-admin-header-css">
 281      /* Shows the same border as on front end */
 282      #headimg {
 283      border-bottom: 1px solid #000;
 284      border-top: 4px solid #000;
 285      }
 286      /* If header-text was supported, you would style the text with these selectors:
 287      #headimg #name { }
 288      #headimg #desc { }
 289      */
 290      </style>
 291          <?php
 292      }
 293  endif;
 294  
 295  
 296  if ( ! function_exists( 'twentyten_header_image' ) ) :
 297      /**
 298       * Displays the custom header image markup.
 299       *
 300       * @since Twenty Ten 4.0
 301       */
 302  	function twentyten_header_image() {
 303          $attrs = array(
 304              'alt' => get_bloginfo( 'name', 'display' ),
 305          );
 306  
 307          // Compatibility with versions of WordPress prior to 3.4.
 308          if ( function_exists( 'get_custom_header' ) ) {
 309              $custom_header   = get_custom_header();
 310              $attrs['width']  = $custom_header->width;
 311              $attrs['height'] = $custom_header->height;
 312          } else {
 313              $attrs['width']  = HEADER_IMAGE_WIDTH;
 314              $attrs['height'] = HEADER_IMAGE_HEIGHT;
 315          }
 316  
 317          if ( function_exists( 'the_header_image_tag' ) ) {
 318              the_header_image_tag( $attrs );
 319              return;
 320          }
 321  
 322          ?>
 323          <img src="<?php header_image(); ?>" width="<?php echo esc_attr( $attrs['width'] ); ?>" height="<?php echo esc_attr( $attrs['height'] ); ?>" alt="<?php echo esc_attr( $attrs['alt'] ); ?>" />
 324          <?php
 325      }
 326  endif; // twentyten_header_image()
 327  
 328  /**
 329   * Shows a home link for our wp_nav_menu() fallback, wp_page_menu().
 330   *
 331   * To override this in a child theme, remove the filter and optionally add
 332   * your own function tied to the wp_page_menu_args filter hook.
 333   *
 334   * @since Twenty Ten 1.0
 335   *
 336   * @param array $args An optional array of arguments. @see wp_page_menu()
 337   */
 338  function twentyten_page_menu_args( $args ) {
 339      if ( ! isset( $args['show_home'] ) ) {
 340          $args['show_home'] = true;
 341      }
 342      return $args;
 343  }
 344  add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
 345  
 346  /**
 347   * Sets the post excerpt length to 40 characters.
 348   *
 349   * To override this length in a child theme, remove the filter and add your own
 350   * function tied to the excerpt_length filter hook.
 351   *
 352   * @since Twenty Ten 1.0
 353   *
 354   * @param int $length The number of excerpt characters.
 355   * @return int The filtered number of excerpt characters.
 356   */
 357  function twentyten_excerpt_length( $length ) {
 358      return 40;
 359  }
 360  add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
 361  
 362  if ( ! function_exists( 'twentyten_continue_reading_link' ) ) :
 363      /**
 364       * Returns a "Continue Reading" link for excerpts.
 365       *
 366       * @since Twenty Ten 1.0
 367       *
 368       * @return string "Continue Reading" link.
 369       */
 370  	function twentyten_continue_reading_link() {
 371          return ' <a href="' . esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
 372      }
 373  endif;
 374  
 375  /**
 376   * Replaces "[...]" with an ellipsis and twentyten_continue_reading_link().
 377   *
 378   * "[...]" is appended to automatically generated excerpts.
 379   *
 380   * To override this in a child theme, remove the filter and add your own
 381   * function tied to the excerpt_more filter hook.
 382   *
 383   * @since Twenty Ten 1.0
 384   *
 385   * @param string $more The Read More text.
 386   * @return string The filtered Read More text.
 387   */
 388  function twentyten_auto_excerpt_more( $more ) {
 389      if ( ! is_admin() ) {
 390          return ' &hellip;' . twentyten_continue_reading_link();
 391      }
 392      return $more;
 393  }
 394  add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
 395  
 396  /**
 397   * Adds a pretty "Continue Reading" link to custom post excerpts.
 398   *
 399   * To override this link in a child theme, remove the filter and add your own
 400   * function tied to the get_the_excerpt filter hook.
 401   *
 402   * @since Twenty Ten 1.0
 403   *
 404   * @param string $output The "Continue Reading" link.
 405   * @return string Excerpt with a pretty "Continue Reading" link.
 406   */
 407  function twentyten_custom_excerpt_more( $output ) {
 408      if ( has_excerpt() && ! is_attachment() && ! is_admin() ) {
 409          $output .= twentyten_continue_reading_link();
 410      }
 411      return $output;
 412  }
 413  add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
 414  
 415  /**
 416   * Removes inline styles printed when the gallery shortcode is used.
 417   *
 418   * Galleries are styled by the theme in Twenty Ten's style.css. This is just
 419   * a simple filter call that tells WordPress to not use the default styles.
 420   *
 421   * @since Twenty Ten 1.2
 422   */
 423  add_filter( 'use_default_gallery_style', '__return_false' );
 424  
 425  /**
 426   * Deprecated way to remove inline styles printed when the gallery shortcode is used.
 427   *
 428   * This function is no longer needed or used. Use the use_default_gallery_style
 429   * filter instead, as seen above.
 430   *
 431   * @since Twenty Ten 1.0
 432   * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
 433   *
 434   * @param string $css Default CSS styles and opening HTML div container
 435   *                    for the gallery shortcode output.
 436   * @return string The gallery style filter, with the styles themselves removed.
 437   */
 438  function twentyten_remove_gallery_css( $css ) {
 439      return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
 440  }
 441  
 442  /**
 443   * Backward compatibility with WordPress 3.0.
 444   *
 445   * @global string $wp_version The WordPress version string.
 446   */
 447  if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) ) {
 448      add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
 449  }
 450  
 451  if ( ! function_exists( 'twentyten_comment' ) ) :
 452      /**
 453       * Template for comments and pingbacks.
 454       *
 455       * To override this walker in a child theme without modifying the comments template
 456       * simply create your own twentyten_comment(), and that function will be used instead.
 457       *
 458       * Used as a callback by wp_list_comments() for displaying the comments.
 459       *
 460       * @since Twenty Ten 1.0
 461       *
 462       * @global WP_Comment $comment Global comment object.
 463       *
 464       * @param WP_Comment $comment The comment object.
 465       * @param array      $args    An array of comment arguments. @see get_comment_reply_link()
 466       * @param int        $depth   The depth of the comment.
 467       */
 468  	function twentyten_comment( $comment, $args, $depth ) {
 469          $GLOBALS['comment'] = $comment;
 470          switch ( $comment->comment_type ) :
 471              case '':
 472              case 'comment':
 473                  ?>
 474          <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
 475          <div id="comment-<?php comment_ID(); ?>">
 476              <div class="comment-author vcard">
 477                  <?php echo get_avatar( $comment, 40 ); ?>
 478                  <?php
 479                  /* translators: %s: Author display name. */
 480                  printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) );
 481                  ?>
 482              </div><!-- .comment-author .vcard -->
 483  
 484                  <?php
 485                  $commenter = wp_get_current_commenter();
 486                  if ( $commenter['comment_author_email'] ) {
 487                      $moderation_note = __( 'Your comment is awaiting moderation.', 'twentyten' );
 488                  } else {
 489                      $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentyten' );
 490                  }
 491                  ?>
 492  
 493                  <?php if ( '0' === $comment->comment_approved ) : ?>
 494              <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
 495              <br />
 496              <?php endif; ?>
 497  
 498              <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
 499                  <?php
 500                      /* translators: 1: Date, 2: Time. */
 501                      printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() );
 502                  ?>
 503                      </a>
 504                      <?php
 505                      edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
 506                      ?>
 507                  </div><!-- .comment-meta .commentmetadata -->
 508  
 509                  <div class="comment-body"><?php comment_text(); ?></div>
 510  
 511                  <div class="reply">
 512                  <?php
 513                  comment_reply_link(
 514                      array_merge(
 515                          $args,
 516                          array(
 517                              'depth'     => $depth,
 518                              'max_depth' => $args['max_depth'],
 519                          )
 520                      )
 521                  );
 522                  ?>
 523                  </div><!-- .reply -->
 524              </div><!-- #comment-##  -->
 525  
 526                  <?php
 527                  break;
 528              case 'pingback':
 529              case 'trackback':
 530                  ?>
 531          <li class="post pingback">
 532          <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
 533                  <?php
 534                  break;
 535          endswitch;
 536      }
 537  endif;
 538  
 539  /**
 540   * Registers widgetized areas, including two sidebars and four widget-ready columns in the footer.
 541   *
 542   * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
 543   * function tied to the init hook.
 544   *
 545   * @since Twenty Ten 1.0
 546   *
 547   * @uses register_sidebar()
 548   */
 549  function twentyten_widgets_init() {
 550      // Area 1, located at the top of the sidebar.
 551      register_sidebar(
 552          array(
 553              'name'          => __( 'Primary Widget Area', 'twentyten' ),
 554              'id'            => 'primary-widget-area',
 555              'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
 556              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 557              'after_widget'  => '</li>',
 558              'before_title'  => '<h3 class="widget-title">',
 559              'after_title'   => '</h3>',
 560          )
 561      );
 562  
 563      // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
 564      register_sidebar(
 565          array(
 566              'name'          => __( 'Secondary Widget Area', 'twentyten' ),
 567              'id'            => 'secondary-widget-area',
 568              'description'   => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
 569              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 570              'after_widget'  => '</li>',
 571              'before_title'  => '<h3 class="widget-title">',
 572              'after_title'   => '</h3>',
 573          )
 574      );
 575  
 576      // Area 3, located in the footer. Empty by default.
 577      register_sidebar(
 578          array(
 579              'name'          => __( 'First Footer Widget Area', 'twentyten' ),
 580              'id'            => 'first-footer-widget-area',
 581              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 582              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 583              'after_widget'  => '</li>',
 584              'before_title'  => '<h3 class="widget-title">',
 585              'after_title'   => '</h3>',
 586          )
 587      );
 588  
 589      // Area 4, located in the footer. Empty by default.
 590      register_sidebar(
 591          array(
 592              'name'          => __( 'Second Footer Widget Area', 'twentyten' ),
 593              'id'            => 'second-footer-widget-area',
 594              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 595              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 596              'after_widget'  => '</li>',
 597              'before_title'  => '<h3 class="widget-title">',
 598              'after_title'   => '</h3>',
 599          )
 600      );
 601  
 602      // Area 5, located in the footer. Empty by default.
 603      register_sidebar(
 604          array(
 605              'name'          => __( 'Third Footer Widget Area', 'twentyten' ),
 606              'id'            => 'third-footer-widget-area',
 607              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 608              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 609              'after_widget'  => '</li>',
 610              'before_title'  => '<h3 class="widget-title">',
 611              'after_title'   => '</h3>',
 612          )
 613      );
 614  
 615      // Area 6, located in the footer. Empty by default.
 616      register_sidebar(
 617          array(
 618              'name'          => __( 'Fourth Footer Widget Area', 'twentyten' ),
 619              'id'            => 'fourth-footer-widget-area',
 620              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 621              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 622              'after_widget'  => '</li>',
 623              'before_title'  => '<h3 class="widget-title">',
 624              'after_title'   => '</h3>',
 625          )
 626      );
 627  }
 628  /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
 629  add_action( 'widgets_init', 'twentyten_widgets_init' );
 630  
 631  /**
 632   * Removes the default styles that are packaged with the Recent Comments widget.
 633   *
 634   * To override this in a child theme, remove the filter and optionally add your own
 635   * function tied to the widgets_init action hook.
 636   *
 637   * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
 638   * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
 639   * but they won't have any effect on the widget in default Twenty Ten styling.
 640   *
 641   * @since Twenty Ten 1.0
 642   */
 643  function twentyten_remove_recent_comments_style() {
 644      add_filter( 'show_recent_comments_widget_style', '__return_false' );
 645  }
 646  add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
 647  
 648  if ( ! function_exists( 'twentyten_posted_on' ) ) :
 649      /**
 650       * Prints HTML with meta information for the current post-date/time and author.
 651       *
 652       * @since Twenty Ten 1.0
 653       */
 654  	function twentyten_posted_on() {
 655          printf(
 656              /* translators: 1: CSS classes, 2: Date, 3: Author display name. */
 657              __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
 658              'meta-prep meta-prep-author',
 659              sprintf(
 660                  '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
 661                  esc_url( get_permalink() ),
 662                  esc_attr( get_the_time() ),
 663                  get_the_date()
 664              ),
 665              sprintf(
 666                  '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
 667                  esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
 668                  /* translators: %s: Author display name. */
 669                  esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
 670                  get_the_author()
 671              )
 672          );
 673      }
 674  endif;
 675  
 676  if ( ! function_exists( 'twentyten_posted_in' ) ) :
 677      /**
 678       * Prints HTML with meta information for the current post (category, tags and permalink).
 679       *
 680       * @since Twenty Ten 1.0
 681       */
 682  	function twentyten_posted_in() {
 683          // Retrieves tag list of current post, separated by commas.
 684          $tags_list = get_the_tag_list( '', ', ' );
 685  
 686          if ( $tags_list && ! is_wp_error( $tags_list ) ) {
 687              /* translators: 1: Category name, 2: Tag name, 3: Post permalink, 4: Post title. */
 688              $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
 689          } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
 690              /* translators: 1: Category name, 3: Post permalink, 4: Post title. */
 691              $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
 692          } else {
 693              /* translators: 3: Post permalink, 4: Post title. */
 694              $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
 695          }
 696  
 697          // Prints the string, replacing the placeholders.
 698          printf(
 699              $posted_in,
 700              get_the_category_list( ', ' ),
 701              $tags_list,
 702              esc_url( get_permalink() ),
 703              the_title_attribute( 'echo=0' )
 704          );
 705      }
 706  endif;
 707  
 708  /**
 709   * Retrieves the IDs for images in a gallery.
 710   *
 711   * @uses get_post_galleries() First, if available. Falls back to shortcode parsing,
 712   *                            then as last option uses a get_posts() call.
 713   *
 714   * @since Twenty Ten 1.6.
 715   *
 716   * @return array List of image IDs from the post gallery.
 717   */
 718  function twentyten_get_gallery_images() {
 719      $images = array();
 720  
 721      if ( function_exists( 'get_post_galleries' ) ) {
 722          $galleries = get_post_galleries( get_the_ID(), false );
 723          if ( isset( $galleries[0]['ids'] ) ) {
 724              $images = explode( ',', $galleries[0]['ids'] );
 725          }
 726      } else {
 727          $pattern = get_shortcode_regex();
 728          preg_match( "/$pattern/s", get_the_content(), $match );
 729          $atts = shortcode_parse_atts( $match[3] );
 730          if ( isset( $atts['ids'] ) ) {
 731              $images = explode( ',', $atts['ids'] );
 732          }
 733      }
 734  
 735      if ( ! $images ) {
 736          $images = get_posts(
 737              array(
 738                  'fields'         => 'ids',
 739                  'numberposts'    => 999,
 740                  'order'          => 'ASC',
 741                  'orderby'        => 'menu_order',
 742                  'post_mime_type' => 'image',
 743                  'post_parent'    => get_the_ID(),
 744                  'post_type'      => 'attachment',
 745              )
 746          );
 747      }
 748  
 749      return $images;
 750  }
 751  
 752  /**
 753   * Modifies tag cloud widget arguments to display all tags in the same font size
 754   * and use list format for better accessibility.
 755   *
 756   * @since Twenty Ten 2.4
 757   *
 758   * @param array $args Arguments for tag cloud widget.
 759   * @return array The filtered arguments for tag cloud widget.
 760   */
 761  function twentyten_widget_tag_cloud_args( $args ) {
 762      $args['largest']  = 22;
 763      $args['smallest'] = 8;
 764      $args['unit']     = 'pt';
 765      $args['format']   = 'list';
 766  
 767      return $args;
 768  }
 769  add_filter( 'widget_tag_cloud_args', 'twentyten_widget_tag_cloud_args' );
 770  
 771  /**
 772   * Enqueues scripts and styles for front end.
 773   *
 774   * @since Twenty Ten 2.6
 775   */
 776  function twentyten_scripts_styles() {
 777      // Theme block stylesheet.
 778      wp_enqueue_style( 'twentyten-block-style', get_template_directory_uri() . '/blocks.css', array(), '20250220' );
 779  }
 780  add_action( 'wp_enqueue_scripts', 'twentyten_scripts_styles' );
 781  
 782  /**
 783   * Enqueues styles for the block-based editor.
 784   *
 785   * @since Twenty Ten 2.6
 786   */
 787  function twentyten_block_editor_styles() {
 788      // Block styles.
 789      wp_enqueue_style( 'twentyten-block-editor-style', get_template_directory_uri() . '/editor-blocks.css', array(), '20240703' );
 790  }
 791  add_action( 'enqueue_block_editor_assets', 'twentyten_block_editor_styles' );
 792  
 793  /**
 794   * Registers block patterns and pattern categories.
 795   *
 796   * @since Twenty Ten 4.3
 797   */
 798  function twentyten_register_block_patterns() {
 799      require get_template_directory() . '/block-patterns.php';
 800  }
 801  
 802  add_action( 'init', 'twentyten_register_block_patterns' );
 803  
 804  if ( ! function_exists( 'wp_body_open' ) ) :
 805      /**
 806       * Fires the wp_body_open action.
 807       *
 808       * Added for backward compatibility to support pre-5.2.0 WordPress versions.
 809       *
 810       * @since Twenty Ten 2.9
 811       */
 812  	function wp_body_open() {
 813          /**
 814           * Triggered after the opening <body> tag.
 815           *
 816           * @since Twenty Ten 2.9
 817           */
 818          do_action( 'wp_body_open' );
 819      }
 820  endif;


Generated : Wed Jun 24 08:20:11 2026 Cross-referenced by PHPXref