[ 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               * Filters 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               * Filters 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 The filtered Read More text.
 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 "Continue 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  // Backward 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 WP_Comment $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              case 'comment':
 422                  ?>
 423          <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
 424          <div id="comment-<?php comment_ID(); ?>">
 425              <div class="comment-author vcard">
 426                  <?php echo get_avatar( $comment, 40 ); ?>
 427                  <?php
 428                  /* translators: %s: Author display name. */
 429                  printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) );
 430                  ?>
 431              </div><!-- .comment-author .vcard -->
 432  
 433                  <?php
 434                  $commenter = wp_get_current_commenter();
 435                  if ( $commenter['comment_author_email'] ) {
 436                      $moderation_note = __( 'Your comment is awaiting moderation.', 'twentyten' );
 437                  } else {
 438                      $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentyten' );
 439                  }
 440                  ?>
 441  
 442                  <?php if ( '0' == $comment->comment_approved ) : ?>
 443              <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
 444              <br />
 445              <?php endif; ?>
 446  
 447              <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
 448                  <?php
 449                      /* translators: 1: Date, 2: Time. */
 450                      printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() );
 451                  ?>
 452                      </a>
 453                      <?php
 454                      edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
 455                      ?>
 456                  </div><!-- .comment-meta .commentmetadata -->
 457  
 458                  <div class="comment-body"><?php comment_text(); ?></div>
 459  
 460                  <div class="reply">
 461                  <?php
 462                  comment_reply_link(
 463                      array_merge(
 464                          $args,
 465                          array(
 466                              'depth'     => $depth,
 467                              'max_depth' => $args['max_depth'],
 468                          )
 469                      )
 470                  );
 471                  ?>
 472                  </div><!-- .reply -->
 473              </div><!-- #comment-##  -->
 474  
 475                  <?php
 476                  break;
 477              case 'pingback':
 478              case 'trackback':
 479                  ?>
 480          <li class="post pingback">
 481          <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
 482                  <?php
 483                  break;
 484          endswitch;
 485      }
 486  endif;
 487  
 488  /**
 489   * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
 490   *
 491   * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
 492   * function tied to the init hook.
 493   *
 494   * @since Twenty Ten 1.0
 495   *
 496   * @uses register_sidebar()
 497   */
 498  function twentyten_widgets_init() {
 499      // Area 1, located at the top of the sidebar.
 500      register_sidebar(
 501          array(
 502              'name'          => __( 'Primary Widget Area', 'twentyten' ),
 503              'id'            => 'primary-widget-area',
 504              'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
 505              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 506              'after_widget'  => '</li>',
 507              'before_title'  => '<h3 class="widget-title">',
 508              'after_title'   => '</h3>',
 509          )
 510      );
 511  
 512      // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
 513      register_sidebar(
 514          array(
 515              'name'          => __( 'Secondary Widget Area', 'twentyten' ),
 516              'id'            => 'secondary-widget-area',
 517              'description'   => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
 518              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 519              'after_widget'  => '</li>',
 520              'before_title'  => '<h3 class="widget-title">',
 521              'after_title'   => '</h3>',
 522          )
 523      );
 524  
 525      // Area 3, located in the footer. Empty by default.
 526      register_sidebar(
 527          array(
 528              'name'          => __( 'First Footer Widget Area', 'twentyten' ),
 529              'id'            => 'first-footer-widget-area',
 530              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 531              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 532              'after_widget'  => '</li>',
 533              'before_title'  => '<h3 class="widget-title">',
 534              'after_title'   => '</h3>',
 535          )
 536      );
 537  
 538      // Area 4, located in the footer. Empty by default.
 539      register_sidebar(
 540          array(
 541              'name'          => __( 'Second Footer Widget Area', 'twentyten' ),
 542              'id'            => 'second-footer-widget-area',
 543              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 544              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 545              'after_widget'  => '</li>',
 546              'before_title'  => '<h3 class="widget-title">',
 547              'after_title'   => '</h3>',
 548          )
 549      );
 550  
 551      // Area 5, located in the footer. Empty by default.
 552      register_sidebar(
 553          array(
 554              'name'          => __( 'Third Footer Widget Area', 'twentyten' ),
 555              'id'            => 'third-footer-widget-area',
 556              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 557              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 558              'after_widget'  => '</li>',
 559              'before_title'  => '<h3 class="widget-title">',
 560              'after_title'   => '</h3>',
 561          )
 562      );
 563  
 564      // Area 6, located in the footer. Empty by default.
 565      register_sidebar(
 566          array(
 567              'name'          => __( 'Fourth Footer Widget Area', 'twentyten' ),
 568              'id'            => 'fourth-footer-widget-area',
 569              'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
 570              'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
 571              'after_widget'  => '</li>',
 572              'before_title'  => '<h3 class="widget-title">',
 573              'after_title'   => '</h3>',
 574          )
 575      );
 576  }
 577  /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
 578  add_action( 'widgets_init', 'twentyten_widgets_init' );
 579  
 580  /**
 581   * Remove the default styles that are packaged with the Recent Comments widget.
 582   *
 583   * To override this in a child theme, remove the filter and optionally add your own
 584   * function tied to the widgets_init action hook.
 585   *
 586   * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
 587   * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
 588   * but they won't have any effect on the widget in default Twenty Ten styling.
 589   *
 590   * @since Twenty Ten 1.0
 591   */
 592  function twentyten_remove_recent_comments_style() {
 593      add_filter( 'show_recent_comments_widget_style', '__return_false' );
 594  }
 595  add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
 596  
 597  if ( ! function_exists( 'twentyten_posted_on' ) ) :
 598      /**
 599       * Print HTML with meta information for the current post-date/time and author.
 600       *
 601       * @since Twenty Ten 1.0
 602       */
 603  	function twentyten_posted_on() {
 604          printf(
 605              /* translators: 1: CSS classes, 2: Date, 3: Author display name. */
 606              __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
 607              'meta-prep meta-prep-author',
 608              sprintf(
 609                  '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
 610                  get_permalink(),
 611                  esc_attr( get_the_time() ),
 612                  get_the_date()
 613              ),
 614              sprintf(
 615                  '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
 616                  get_author_posts_url( get_the_author_meta( 'ID' ) ),
 617                  /* translators: %s: Author display name. */
 618                  esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
 619                  get_the_author()
 620              )
 621          );
 622      }
 623  endif;
 624  
 625  if ( ! function_exists( 'twentyten_posted_in' ) ) :
 626      /**
 627       * Print HTML with meta information for the current post (category, tags and permalink).
 628       *
 629       * @since Twenty Ten 1.0
 630       */
 631  	function twentyten_posted_in() {
 632          // Retrieves tag list of current post, separated by commas.
 633          $tags_list = get_the_tag_list( '', ', ' );
 634  
 635          if ( $tags_list && ! is_wp_error( $tags_list ) ) {
 636              /* translators: 1: Category name, 2: Tag name, 3: Post permalink, 4: Post title. */
 637              $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' );
 638          } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
 639              /* translators: 1: Category name, 3: Post permalink, 4: Post title. */
 640              $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' );
 641          } else {
 642              /* translators: 3: Post permalink, 4: Post title. */
 643              $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
 644          }
 645  
 646          // Prints the string, replacing the placeholders.
 647          printf(
 648              $posted_in,
 649              get_the_category_list( ', ' ),
 650              $tags_list,
 651              get_permalink(),
 652              the_title_attribute( 'echo=0' )
 653          );
 654      }
 655  endif;
 656  
 657  /**
 658   * Retrieve the IDs for images in a gallery.
 659   *
 660   * @uses get_post_galleries() First, if available. Falls back to shortcode parsing,
 661   *                            then as last option uses a get_posts() call.
 662   *
 663   * @since Twenty Ten 1.6.
 664   *
 665   * @return array List of image IDs from the post gallery.
 666   */
 667  function twentyten_get_gallery_images() {
 668      $images = array();
 669  
 670      if ( function_exists( 'get_post_galleries' ) ) {
 671          $galleries = get_post_galleries( get_the_ID(), false );
 672          if ( isset( $galleries[0]['ids'] ) ) {
 673              $images = explode( ',', $galleries[0]['ids'] );
 674          }
 675      } else {
 676          $pattern = get_shortcode_regex();
 677          preg_match( "/$pattern/s", get_the_content(), $match );
 678          $atts = shortcode_parse_atts( $match[3] );
 679          if ( isset( $atts['ids'] ) ) {
 680              $images = explode( ',', $atts['ids'] );
 681          }
 682      }
 683  
 684      if ( ! $images ) {
 685          $images = get_posts(
 686              array(
 687                  'fields'         => 'ids',
 688                  'numberposts'    => 999,
 689                  'order'          => 'ASC',
 690                  'orderby'        => 'menu_order',
 691                  'post_mime_type' => 'image',
 692                  'post_parent'    => get_the_ID(),
 693                  'post_type'      => 'attachment',
 694              )
 695          );
 696      }
 697  
 698      return $images;
 699  }
 700  
 701  /**
 702   * Modifies tag cloud widget arguments to display all tags in the same font size
 703   * and use list format for better accessibility.
 704   *
 705   * @since Twenty Ten 2.4
 706   *
 707   * @param array $args Arguments for tag cloud widget.
 708   * @return array The filtered arguments for tag cloud widget.
 709   */
 710  function twentyten_widget_tag_cloud_args( $args ) {
 711      $args['largest']  = 22;
 712      $args['smallest'] = 8;
 713      $args['unit']     = 'pt';
 714      $args['format']   = 'list';
 715  
 716      return $args;
 717  }
 718  add_filter( 'widget_tag_cloud_args', 'twentyten_widget_tag_cloud_args' );
 719  
 720  /**
 721   * Enqueue scripts and styles for front end.
 722   *
 723   * @since Twenty Ten 2.6
 724   */
 725  function twentyten_scripts_styles() {
 726      // Theme block stylesheet.
 727      wp_enqueue_style( 'twentyten-block-style', get_template_directory_uri() . '/blocks.css', array(), '20181218' );
 728  }
 729  add_action( 'wp_enqueue_scripts', 'twentyten_scripts_styles' );
 730  
 731  /**
 732   * Enqueue styles for the block-based editor.
 733   *
 734   * @since Twenty Ten 2.6
 735   */
 736  function twentyten_block_editor_styles() {
 737      // Block styles.
 738      wp_enqueue_style( 'twentyten-block-editor-style', get_template_directory_uri() . '/editor-blocks.css', array(), '20201208' );
 739  }
 740  add_action( 'enqueue_block_editor_assets', 'twentyten_block_editor_styles' );
 741  
 742  // Block Patterns.
 743  require get_template_directory() . '/block-patterns.php';
 744  
 745  if ( ! function_exists( 'wp_body_open' ) ) :
 746      /**
 747       * Fire the wp_body_open action.
 748       *
 749       * Added for backward compatibility to support pre-5.2.0 WordPress versions.
 750       *
 751       * @since Twenty Ten 2.9
 752       */
 753  	function wp_body_open() {
 754          /**
 755           * Triggered after the opening <body> tag.
 756           *
 757           * @since Twenty Ten 2.9
 758           */
 759          do_action( 'wp_body_open' );
 760      }
 761  endif;


Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1