PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/twentyten/functions.php

https://github.com/dipakdotyadav/WordPress
PHP | 569 lines | 277 code | 47 blank | 245 comment | 26 complexity | cec127de5b2638f4c278a90adc677ae0 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  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 (see http://codex.wordpress.org/Theme_Development and
  13. * http://codex.wordpress.org/Child_Themes), you can override certain functions
  14. * (those wrapped in a function_exists() call) by defining them first in your child theme's
  15. * functions.php file. The child theme's functions.php file is included before the parent
  16. * theme's file, so the child theme functions would be used.
  17. *
  18. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  19. * to a filter or action hook. The hook can be removed by using remove_action() or
  20. * remove_filter() and you can attach your own function to the hook.
  21. *
  22. * We can remove the parent theme's hook only after it is attached, which means we need to
  23. * wait until setting up the child theme:
  24. *
  25. * <code>
  26. * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  27. * function my_child_theme_setup() {
  28. * // We are providing our own filter for excerpt_length (or using the unfiltered value)
  29. * remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  30. * ...
  31. * }
  32. * </code>
  33. *
  34. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  35. *
  36. * @package WordPress
  37. * @subpackage Twenty_Ten
  38. * @since Twenty Ten 1.0
  39. */
  40. /**
  41. * Set the content width based on the theme's design and stylesheet.
  42. *
  43. * Used to set the width of images and content. Should be equal to the width the theme
  44. * is designed for, generally via the style.css stylesheet.
  45. */
  46. if ( ! isset( $content_width ) )
  47. $content_width = 640;
  48. /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
  49. add_action( 'after_setup_theme', 'twentyten_setup' );
  50. if ( ! function_exists( 'twentyten_setup' ) ):
  51. /**
  52. * Sets up theme defaults and registers support for various WordPress features.
  53. *
  54. * Note that this function is hooked into the after_setup_theme hook, which runs
  55. * before the init hook. The init hook is too late for some features, such as indicating
  56. * support post thumbnails.
  57. *
  58. * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
  59. * functions.php file.
  60. *
  61. * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
  62. * @uses register_nav_menus() To add support for navigation menus.
  63. * @uses add_editor_style() To style the visual editor.
  64. * @uses load_theme_textdomain() For translation/localization support.
  65. * @uses register_default_headers() To register the default custom header images provided with the theme.
  66. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  67. *
  68. * @since Twenty Ten 1.0
  69. */
  70. function twentyten_setup() {
  71. // This theme styles the visual editor with editor-style.css to match the theme style.
  72. add_editor_style();
  73. // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
  74. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
  75. // This theme uses post thumbnails
  76. add_theme_support( 'post-thumbnails' );
  77. // Add default posts and comments RSS feed links to head
  78. add_theme_support( 'automatic-feed-links' );
  79. // Make theme available for translation
  80. // Translations can be filed in the /languages/ directory
  81. load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );
  82. // This theme uses wp_nav_menu() in one location.
  83. register_nav_menus( array(
  84. 'primary' => __( 'Primary Navigation', 'twentyten' ),
  85. ) );
  86. // This theme allows users to set a custom background.
  87. add_theme_support( 'custom-background', array(
  88. // Let WordPress know what our default background color is.
  89. 'default-color' => 'f1f1f1',
  90. ) );
  91. // The custom header business starts here.
  92. $custom_header_support = array(
  93. // The default image to use.
  94. // The %s is a placeholder for the theme template directory URI.
  95. 'default-image' => '%s/images/headers/path.jpg',
  96. // The height and width of our custom header.
  97. 'width' => apply_filters( 'twentyten_header_image_width', 940 ),
  98. 'height' => apply_filters( 'twentyten_header_image_height', 198 ),
  99. // Support flexible heights.
  100. 'flex-height' => true,
  101. // Don't support text inside the header image.
  102. 'header-text' => false,
  103. // Callback for styling the header preview in the admin.
  104. 'admin-head-callback' => 'twentyten_admin_header_style',
  105. );
  106. add_theme_support( 'custom-header', $custom_header_support );
  107. if ( ! function_exists( 'get_custom_header' ) ) {
  108. // This is all for compatibility with versions of WordPress prior to 3.4.
  109. define( 'HEADER_TEXTCOLOR', '' );
  110. define( 'NO_HEADER_TEXT', true );
  111. define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
  112. define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
  113. define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
  114. add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
  115. add_custom_background();
  116. }
  117. // We'll be using post thumbnails for custom header images on posts and pages.
  118. // We want them to be 940 pixels wide by 198 pixels tall.
  119. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  120. set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
  121. // ... and thus ends the custom header business.
  122. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  123. register_default_headers( array(
  124. 'berries' => array(
  125. 'url' => '%s/images/headers/berries.jpg',
  126. 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  127. /* translators: header image description */
  128. 'description' => __( 'Berries', 'twentyten' )
  129. ),
  130. 'cherryblossom' => array(
  131. 'url' => '%s/images/headers/cherryblossoms.jpg',
  132. 'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  133. /* translators: header image description */
  134. 'description' => __( 'Cherry Blossoms', 'twentyten' )
  135. ),
  136. 'concave' => array(
  137. 'url' => '%s/images/headers/concave.jpg',
  138. 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  139. /* translators: header image description */
  140. 'description' => __( 'Concave', 'twentyten' )
  141. ),
  142. 'fern' => array(
  143. 'url' => '%s/images/headers/fern.jpg',
  144. 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  145. /* translators: header image description */
  146. 'description' => __( 'Fern', 'twentyten' )
  147. ),
  148. 'forestfloor' => array(
  149. 'url' => '%s/images/headers/forestfloor.jpg',
  150. 'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  151. /* translators: header image description */
  152. 'description' => __( 'Forest Floor', 'twentyten' )
  153. ),
  154. 'inkwell' => array(
  155. 'url' => '%s/images/headers/inkwell.jpg',
  156. 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  157. /* translators: header image description */
  158. 'description' => __( 'Inkwell', 'twentyten' )
  159. ),
  160. 'path' => array(
  161. 'url' => '%s/images/headers/path.jpg',
  162. 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  163. /* translators: header image description */
  164. 'description' => __( 'Path', 'twentyten' )
  165. ),
  166. 'sunset' => array(
  167. 'url' => '%s/images/headers/sunset.jpg',
  168. 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  169. /* translators: header image description */
  170. 'description' => __( 'Sunset', 'twentyten' )
  171. )
  172. ) );
  173. }
  174. endif;
  175. if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
  176. /**
  177. * Styles the header image displayed on the Appearance > Header admin panel.
  178. *
  179. * Referenced via add_custom_image_header() in twentyten_setup().
  180. *
  181. * @since Twenty Ten 1.0
  182. */
  183. function twentyten_admin_header_style() {
  184. ?>
  185. <style type="text/css">
  186. /* Shows the same border as on front end */
  187. #headimg {
  188. border-bottom: 1px solid #000;
  189. border-top: 4px solid #000;
  190. }
  191. /* If header-text was supported, you would style the text with these selectors:
  192. #headimg #name { }
  193. #headimg #desc { }
  194. */
  195. </style>
  196. <?php
  197. }
  198. endif;
  199. /**
  200. * Enqueue scripts and styles.
  201. *
  202. * Hooked on priority 0 to make sure they are enqueued prior to dependent
  203. * scripts/styles. This is only necessary because they were previously enqueued
  204. * prior to wp_head() running, and we want to provide maximum
  205. * backwards compatibility.
  206. *
  207. * @since Twenty Ten 1.6
  208. */
  209. function twentyten_scripts() {
  210. wp_enqueue_style( 'twentyten', get_stylesheet_uri() );
  211. /* We add some JavaScript to pages with the comment form
  212. * to support sites with threaded comments (when in use).
  213. */
  214. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  215. wp_enqueue_script( 'comment-reply' );
  216. }
  217. add_action( 'wp_enqueue_scripts', 'twentyten_scripts', 0 );
  218. /**
  219. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  220. *
  221. * To override this in a child theme, remove the filter and optionally add
  222. * your own function tied to the wp_page_menu_args filter hook.
  223. *
  224. * @since Twenty Ten 1.0
  225. */
  226. function twentyten_page_menu_args( $args ) {
  227. if ( ! isset( $args['show_home'] ) )
  228. $args['show_home'] = true;
  229. return $args;
  230. }
  231. add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
  232. /**
  233. * Sets the post excerpt length to 40 characters.
  234. *
  235. * To override this length in a child theme, remove the filter and add your own
  236. * function tied to the excerpt_length filter hook.
  237. *
  238. * @since Twenty Ten 1.0
  239. * @return int
  240. */
  241. function twentyten_excerpt_length( $length ) {
  242. return 40;
  243. }
  244. add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  245. if ( ! function_exists( 'twentyten_continue_reading_link' ) ) :
  246. /**
  247. * Returns a "Continue Reading" link for excerpts
  248. *
  249. * @since Twenty Ten 1.0
  250. * @return string "Continue Reading" link
  251. */
  252. function twentyten_continue_reading_link() {
  253. return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
  254. }
  255. endif;
  256. /**
  257. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
  258. *
  259. * To override this in a child theme, remove the filter and add your own
  260. * function tied to the excerpt_more filter hook.
  261. *
  262. * @since Twenty Ten 1.0
  263. * @return string An ellipsis
  264. */
  265. function twentyten_auto_excerpt_more( $more ) {
  266. return ' &hellip;' . twentyten_continue_reading_link();
  267. }
  268. add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
  269. /**
  270. * Adds a pretty "Continue Reading" link to custom post excerpts.
  271. *
  272. * To override this link in a child theme, remove the filter and add your own
  273. * function tied to the get_the_excerpt filter hook.
  274. *
  275. * @since Twenty Ten 1.0
  276. * @return string Excerpt with a pretty "Continue Reading" link
  277. */
  278. function twentyten_custom_excerpt_more( $output ) {
  279. if ( has_excerpt() && ! is_attachment() ) {
  280. $output .= twentyten_continue_reading_link();
  281. }
  282. return $output;
  283. }
  284. add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
  285. /**
  286. * Remove inline styles printed when the gallery shortcode is used.
  287. *
  288. * Galleries are styled by the theme in Twenty Ten's style.css. This is just
  289. * a simple filter call that tells WordPress to not use the default styles.
  290. *
  291. * @since Twenty Ten 1.2
  292. */
  293. add_filter( 'use_default_gallery_style', '__return_false' );
  294. /**
  295. * Deprecated way to remove inline styles printed when the gallery shortcode is used.
  296. *
  297. * This function is no longer needed or used. Use the use_default_gallery_style
  298. * filter instead, as seen above.
  299. *
  300. * @since Twenty Ten 1.0
  301. * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
  302. *
  303. * @return string The gallery style filter, with the styles themselves removed.
  304. */
  305. function twentyten_remove_gallery_css( $css ) {
  306. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  307. }
  308. // Backwards compatibility with WordPress 3.0.
  309. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
  310. add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
  311. if ( ! function_exists( 'twentyten_comment' ) ) :
  312. /**
  313. * Template for comments and pingbacks.
  314. *
  315. * To override this walker in a child theme without modifying the comments template
  316. * simply create your own twentyten_comment(), and that function will be used instead.
  317. *
  318. * Used as a callback by wp_list_comments() for displaying the comments.
  319. *
  320. * @since Twenty Ten 1.0
  321. */
  322. function twentyten_comment( $comment, $args, $depth ) {
  323. $GLOBALS['comment'] = $comment;
  324. switch ( $comment->comment_type ) :
  325. case '' :
  326. ?>
  327. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  328. <div id="comment-<?php comment_ID(); ?>">
  329. <div class="comment-author vcard">
  330. <?php echo get_avatar( $comment, 40 ); ?>
  331. <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  332. </div><!-- .comment-author .vcard -->
  333. <?php if ( $comment->comment_approved == '0' ) : ?>
  334. <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  335. <br />
  336. <?php endif; ?>
  337. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  338. <?php
  339. /* translators: 1: date, 2: time */
  340. printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
  341. ?>
  342. </div><!-- .comment-meta .commentmetadata -->
  343. <div class="comment-body"><?php comment_text(); ?></div>
  344. <div class="reply">
  345. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  346. </div><!-- .reply -->
  347. </div><!-- #comment-## -->
  348. <?php
  349. break;
  350. case 'pingback' :
  351. case 'trackback' :
  352. ?>
  353. <li class="post pingback">
  354. <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
  355. <?php
  356. break;
  357. endswitch;
  358. }
  359. endif;
  360. /**
  361. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  362. *
  363. * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
  364. * function tied to the init hook.
  365. *
  366. * @since Twenty Ten 1.0
  367. * @uses register_sidebar
  368. */
  369. function twentyten_widgets_init() {
  370. // Area 1, located at the top of the sidebar.
  371. register_sidebar( array(
  372. 'name' => __( 'Primary Widget Area', 'twentyten' ),
  373. 'id' => 'primary-widget-area',
  374. 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
  375. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  376. 'after_widget' => '</li>',
  377. 'before_title' => '<h3 class="widget-title">',
  378. 'after_title' => '</h3>',
  379. ) );
  380. // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
  381. register_sidebar( array(
  382. 'name' => __( 'Secondary Widget Area', 'twentyten' ),
  383. 'id' => 'secondary-widget-area',
  384. 'description' => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
  385. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  386. 'after_widget' => '</li>',
  387. 'before_title' => '<h3 class="widget-title">',
  388. 'after_title' => '</h3>',
  389. ) );
  390. // Area 3, located in the footer. Empty by default.
  391. register_sidebar( array(
  392. 'name' => __( 'First Footer Widget Area', 'twentyten' ),
  393. 'id' => 'first-footer-widget-area',
  394. 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  395. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  396. 'after_widget' => '</li>',
  397. 'before_title' => '<h3 class="widget-title">',
  398. 'after_title' => '</h3>',
  399. ) );
  400. // Area 4, located in the footer. Empty by default.
  401. register_sidebar( array(
  402. 'name' => __( 'Second Footer Widget Area', 'twentyten' ),
  403. 'id' => 'second-footer-widget-area',
  404. 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  405. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  406. 'after_widget' => '</li>',
  407. 'before_title' => '<h3 class="widget-title">',
  408. 'after_title' => '</h3>',
  409. ) );
  410. // Area 5, located in the footer. Empty by default.
  411. register_sidebar( array(
  412. 'name' => __( 'Third Footer Widget Area', 'twentyten' ),
  413. 'id' => 'third-footer-widget-area',
  414. 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  415. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  416. 'after_widget' => '</li>',
  417. 'before_title' => '<h3 class="widget-title">',
  418. 'after_title' => '</h3>',
  419. ) );
  420. // Area 6, located in the footer. Empty by default.
  421. register_sidebar( array(
  422. 'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
  423. 'id' => 'fourth-footer-widget-area',
  424. 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  425. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  426. 'after_widget' => '</li>',
  427. 'before_title' => '<h3 class="widget-title">',
  428. 'after_title' => '</h3>',
  429. ) );
  430. }
  431. /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
  432. add_action( 'widgets_init', 'twentyten_widgets_init' );
  433. /**
  434. * Removes the default styles that are packaged with the Recent Comments widget.
  435. *
  436. * To override this in a child theme, remove the filter and optionally add your own
  437. * function tied to the widgets_init action hook.
  438. *
  439. * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
  440. * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
  441. * but they won't have any effect on the widget in default Twenty Ten styling.
  442. *
  443. * @since Twenty Ten 1.0
  444. */
  445. function twentyten_remove_recent_comments_style() {
  446. add_filter( 'show_recent_comments_widget_style', '__return_false' );
  447. }
  448. add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
  449. if ( ! function_exists( 'twentyten_posted_on' ) ) :
  450. /**
  451. * Prints HTML with meta information for the current post-date/time and author.
  452. *
  453. * @since Twenty Ten 1.0
  454. */
  455. function twentyten_posted_on() {
  456. printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
  457. 'meta-prep meta-prep-author',
  458. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  459. get_permalink(),
  460. esc_attr( get_the_time() ),
  461. get_the_date()
  462. ),
  463. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  464. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  465. esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
  466. get_the_author()
  467. )
  468. );
  469. }
  470. endif;
  471. if ( ! function_exists( 'twentyten_posted_in' ) ) :
  472. /**
  473. * Prints HTML with meta information for the current post (category, tags and permalink).
  474. *
  475. * @since Twenty Ten 1.0
  476. */
  477. function twentyten_posted_in() {
  478. // Retrieves tag list of current post, separated by commas.
  479. $tag_list = get_the_tag_list( '', ', ' );
  480. if ( $tag_list ) {
  481. $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' );
  482. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  483. $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' );
  484. } else {
  485. $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  486. }
  487. // Prints the string, replacing the placeholders.
  488. printf(
  489. $posted_in,
  490. get_the_category_list( ', ' ),
  491. $tag_list,
  492. get_permalink(),
  493. the_title_attribute( 'echo=0' )
  494. );
  495. }
  496. endif;
  497. /**
  498. * Creates a nicely formatted and more specific title element text
  499. * for output in head of document, based on current view.
  500. *
  501. * @since Twenty Ten 1.6
  502. *
  503. * @param string $title Default title text for current view.
  504. * @param string $sep Optional separator.
  505. * @return string Filtered title.
  506. */
  507. function twentyten_wp_title( $title, $sep ) {
  508. global $paged, $page;
  509. if ( is_feed() )
  510. return $title;
  511. // Add the site name.
  512. $title .= get_bloginfo( 'name' );
  513. // Add the site description for the home/front page.
  514. $site_description = get_bloginfo( 'description', 'display' );
  515. if ( $site_description && ( is_home() || is_front_page() ) )
  516. $title = "$title $sep $site_description";
  517. // Add a page number if necessary.
  518. if ( $paged >= 2 || $page >= 2 )
  519. $title = "$title $sep " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
  520. return $title;
  521. }
  522. add_filter( 'wp_title', 'twentyten_wp_title', 10, 2 );