wp-content/themes/twentyten/functions.php

TwentyTen functions and definitions

Sets up the theme and provides some helper functions. Some helper functions are used in the theme as custom template tags. Others are attached to action and filter hooks in WordPress to change core functionality.

The first function, twentyten_setup(), sets up the theme by registering support for various features in WordPress, such as post thumbnails, navigation menus, and the like.

When using a child theme (see http://codex.wordpress.org/Theme_Development and http://codex.wordpress.org/Child_Themes), you can override certain functions (those wrapped in a function_exists() call) by defining them first in your child theme's functions.php file. The child theme's functions.php file is included before the parent theme's file, so the child theme functions would be used.

Functions that are not pluggable (not wrapped in function_exists()) are instead attached to a filter or action hook. The hook can be removed by using remove_action() or remove_filter() and you can attach your own function to the hook.

We can remove the parent theme's hook only after it is attached, which means we need to wait until setting up the child theme:

add_action( 'after_setup_theme', 'my_child_theme_setup' ); function my_child_theme_setup() { // We are providing our own filter for excerpt_length (or using the unfiltered value) remove_filter( 'excerpt_length', 'twentyten_excerpt_length' ); ... }

For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.

package
WordPress
since
Twenty Ten 1.0
subpackage
Twenty_Ten

Functions

function twentyten_admin_header_style( ) :
Styles the header image displayed on the Appearance > Header admin panel.

Referenced via add_custom_image_header() in twentyten_setup().

Details
since
Twenty Ten 1.0
function twentyten_auto_excerpt_more( $more ) : string
Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().

To override this in a child theme, remove the filter and add your own function tied to the excerpt_more filter hook.

Parameters
Name Type Description
$more
Returns
Type Description
string
Details
since
Twenty Ten 1.0
function twentyten_comment( $comment, $args, $depth ) :
Template for comments and pingbacks.

To override this walker in a child theme without modifying the comments template simply create your own twentyten_comment(), and that function will be used instead.

Used as a callback by wp_list_comments() for displaying the comments.

Parameters
Name Type Description
$comment
$args
$depth
Details
since
Twenty Ten 1.0
function twentyten_continue_reading_link( ) : string
Returns a "Continue Reading" link for excerpts
Returns
Type Description
string
Details
since
Twenty Ten 1.0
function twentyten_custom_excerpt_more( $output ) : string
Adds a pretty "Continue Reading" link to custom post excerpts.

To override this link in a child theme, remove the filter and add your own function tied to the get_the_excerpt filter hook.

Parameters
Name Type Description
$output
Returns
Type Description
string
Details
since
Twenty Ten 1.0
function twentyten_excerpt_length( $length ) : int
Sets the post excerpt length to 40 characters.

To override this length in a child theme, remove the filter and add your own function tied to the excerpt_length filter hook.

Parameters
Name Type Description
$length
Returns
Type Description
int
Details
since
Twenty Ten 1.0
function twentyten_page_menu_args( $args ) :
Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.

To override this in a child theme, remove the filter and optionally add your own function tied to the wp_page_menu_args filter hook.

Parameters
Name Type Description
$args
Details
since
Twenty Ten 1.0
function twentyten_posted_in( ) :
Prints HTML with meta information for the current post (category, tags and permalink).
Details
since
Twenty Ten 1.0
function twentyten_posted_on( ) :
Prints HTML with meta information for the current post-date/time and author.
Details
since
Twenty Ten 1.0
function twentyten_remove_gallery_css( $css ) : string
Deprecated way to remove inline styles printed when the gallery shortcode is used.

This function is no longer needed or used. Use the use_default_gallery_style filter instead, as seen above.

Parameters
Name Type Description
$css
Returns
Type Description
string
Details
deprecated
Deprecated in Twenty Ten 1.2 for WordPress 3.1
since
Twenty Ten 1.0
function twentyten_remove_recent_comments_style( ) :
Removes the default styles that are packaged with the Recent Comments widget.

To override this in a child theme, remove the filter and optionally add your own function tied to the widgets_init action hook.

This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1 to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles, but they won't have any effect on the widget in default Twenty Ten styling.

Details
since
Twenty Ten 1.0
function twentyten_setup( ) :
Sets up theme defaults and registers support for various WordPress features.

Note that this function is hooked into the after_setup_theme hook, which runs before the init hook. The init hook is too late for some features, such as indicating support post thumbnails.

To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's functions.php file.

Details
since
Twenty Ten 1.0
uses
\add_theme_support()
uses
\register_nav_menus()
uses
\add_custom_background()
uses
\add_editor_style()
uses
\load_theme_textdomain()
uses
\add_custom_image_header()
uses
\register_default_headers()
uses
\set_post_thumbnail_size()
function twentyten_widgets_init( ) :
Register widgetized areas, including two sidebars and four widget-ready columns in the footer.

To override twentyten_widgets_init() in a child theme, remove the action hook and add your own function tied to the init hook.

Details
since
Twenty Ten 1.0
uses
\register_sidebar
Documentation was generated by DocBlox 0.13.0.