[ Index ]

PHP Cross Reference of WordPress

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


Generated: Wed Sep 18 01:00:03 2019 Cross-referenced by PHPXref 0.7.1