Skip to:
Content

bbPress.org

Changeset 3075


Ignore:
Timestamp:
05/02/2011 05:50:57 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Convert bbp-twentyten into a child theme for twentyten, reducing the size of the plugin file by almost half, eliminating code duplication, and avoiding inadvertently forking the twentyten theme only to support bbPress.

Location:
branches/plugin/bbp-themes/bbp-twentyten
Files:
26 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-themes/bbp-twentyten/functions.php

    r3023 r3075  
    11<?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
     2
     3 /**
     4 * @package bbPress
     5 * @subpackage BBP_Twenty_Ten
    386 * @since Twenty Ten 1.0
    397 */
    408
    41 /**
    42  * Set the content width based on the theme's design and stylesheet.
    43  *
    44  * Used to set the width of images and content. Should be equal to the width the theme
    45  * is designed for, generally via the style.css stylesheet.
    46  */
    47 if ( ! isset( $content_width ) )
    48     $content_width = 640;
    49 
    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 and automatic feed links.
    62  * @uses register_nav_menus() To add support for navigation menus.
    63  * @uses add_custom_background() To add support for a custom background.
    64  * @uses add_editor_style() To style the visual editor.
    65  * @uses load_theme_textdomain() For translation/localization support.
    66  * @uses add_custom_image_header() To add support for a custom header.
    67  * @uses register_default_headers() To register the default custom header images provided with the theme.
    68  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
    69  *
    70  * @since Twenty Ten 1.0
    71  */
    72 function twentyten_setup() {
    73 
    74     // This theme styles the visual editor with editor-style.css to match the theme style.
    75     add_editor_style();
    76 
    77     // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
    78     add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
    79 
    80     // This theme uses post thumbnails
    81     add_theme_support( 'post-thumbnails' );
    82 
    83     // Add default posts and comments RSS feed links to head
    84     add_theme_support( 'automatic-feed-links' );
     9if ( ! function_exists( 'bbp_twentyten_setup' ) ):
     10/**
     11 * Sets up theme support for bbPress
     12 *
     13 * @since bbPress Twenty Ten 1.0
     14 */
     15function bbp_twentyten_setup() {
    8516
    8617    // This theme comes bundled with bbPress template files
    8718    add_theme_support( 'bbpress' );
    88 
    89     // Make theme available for translation
    90     // Translations can be filed in the /languages/ directory
    91     load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
    92 
    93     $locale = get_locale();
    94     $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    95     if ( is_readable( $locale_file ) )
    96         require_once( $locale_file );
    97 
    98     // This theme uses wp_nav_menu() in one location.
    99     register_nav_menus( array(
    100         'primary' => __( 'Primary Navigation', 'twentyten' ),
    101     ) );
    102 
    103     // This theme allows users to set a custom background
    104     add_custom_background();
    105 
    106     // Your changeable header business starts here
    107     if ( ! defined( 'HEADER_TEXTCOLOR' ) )
    108         define( 'HEADER_TEXTCOLOR', '' );
    109 
    110     // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
    111     if ( ! defined( 'HEADER_IMAGE' ) )
    112         define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
    113 
    114     // The height and width of your custom header. You can hook into the theme's own filters to change these values.
    115     // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
    116     define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
    117     define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
    118 
    119     // We'll be using post thumbnails for custom header images on posts and pages.
    120     // We want them to be 940 pixels wide by 198 pixels tall.
    121     // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    122     set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
    123 
    124     // Don't support text inside the header image.
    125     if ( ! defined( 'NO_HEADER_TEXT' ) )
    126         define( 'NO_HEADER_TEXT', true );
    127 
    128     // Add a way for the custom header to be styled in the admin panel that controls
    129     // custom headers. See twentyten_admin_header_style(), below.
    130     add_custom_image_header( '', 'twentyten_admin_header_style' );
    131 
    132     // ... and thus ends the changeable header business.
    133 
    134     // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
    135     register_default_headers( array(
    136         'berries' => array(
    137             'url' => '%s/images/headers/berries.jpg',
    138             'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
    139             /* translators: header image description */
    140             'description' => __( 'Berries', 'twentyten' )
    141         ),
    142         'cherryblossom' => array(
    143             'url' => '%s/images/headers/cherryblossoms.jpg',
    144             'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
    145             /* translators: header image description */
    146             'description' => __( 'Cherry Blossoms', 'twentyten' )
    147         ),
    148         'concave' => array(
    149             'url' => '%s/images/headers/concave.jpg',
    150             'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
    151             /* translators: header image description */
    152             'description' => __( 'Concave', 'twentyten' )
    153         ),
    154         'fern' => array(
    155             'url' => '%s/images/headers/fern.jpg',
    156             'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
    157             /* translators: header image description */
    158             'description' => __( 'Fern', 'twentyten' )
    159         ),
    160         'forestfloor' => array(
    161             'url' => '%s/images/headers/forestfloor.jpg',
    162             'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
    163             /* translators: header image description */
    164             'description' => __( 'Forest Floor', 'twentyten' )
    165         ),
    166         'inkwell' => array(
    167             'url' => '%s/images/headers/inkwell.jpg',
    168             'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
    169             /* translators: header image description */
    170             'description' => __( 'Inkwell', 'twentyten' )
    171         ),
    172         'path' => array(
    173             'url' => '%s/images/headers/path.jpg',
    174             'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
    175             /* translators: header image description */
    176             'description' => __( 'Path', 'twentyten' )
    177         ),
    178         'sunset' => array(
    179             'url' => '%s/images/headers/sunset.jpg',
    180             'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
    181             /* translators: header image description */
    182             'description' => __( 'Sunset', 'twentyten' )
    183         )
    184     ) );
    18519}
    18620/** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
    187 add_action( 'after_setup_theme', 'twentyten_setup' );
    188 endif;
    189 
    190 if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
    191 /**
    192  * Styles the header image displayed on the Appearance > Header admin panel.
    193  *
    194  * Referenced via add_custom_image_header() in twentyten_setup().
    195  *
    196  * @since Twenty Ten 1.0
    197  */
    198 function twentyten_admin_header_style() {
     21add_action( 'after_setup_theme', 'bbp_twentyten_setup' );
     22endif;
     23
     24if ( !function_exists( 'bbp_twentyten_enqueue_styles' ) ) :
     25/**
     26 * Load the theme CSS
     27 *
     28 * @uses is_admin() To check if it's the admin section
     29 * @uses wp_enqueue_style() To enqueue the styles
     30 */
     31function bbp_twentyten_enqueue_styles () {
     32    if ( is_admin() )
     33        return false;
     34
     35    // bbPress specific
     36    wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress.css', 'bbp-twentyten-default', 20100312, 'screen' );
     37}
     38add_action( 'init', 'bbp_twentyten_enqueue_styles' );
     39endif;
     40
     41if ( !function_exists( 'bbp_twentyten_dim_favorite' ) ) :
     42/**
     43 * Add or remove a topic from a user's favorites
     44 *
     45 * @since bbPress (r2652)
     46 *
     47 * @uses bbp_get_current_user_id() To get the current user id
     48 * @uses current_user_can() To check if the current user can edit the user
     49 * @uses bbp_get_topic() To get the topic
     50 * @uses check_ajax_referer() To verify the nonce & check the referer
     51 * @uses bbp_is_user_favorite() To check if the topic is user's favorite
     52 * @uses bbp_remove_user_favorite() To remove the topic from user's favorites
     53 * @uses bbp_add_user_favorite() To add the topic from user's favorites
     54 */
     55function bbp_twentyten_dim_favorite () {
     56    $user_id = bbp_get_current_user_id();
     57    $id      = intval( $_POST['id'] );
     58
     59    if ( !current_user_can( 'edit_user', $user_id ) )
     60        die( '-1' );
     61
     62    if ( !$topic = bbp_get_topic( $id ) )
     63        die( '0' );
     64
     65    check_ajax_referer( "toggle-favorite_$topic->ID" );
     66
     67    if ( bbp_is_user_favorite( $user_id, $topic->ID ) ) {
     68        if ( bbp_remove_user_favorite( $user_id, $topic->ID ) )
     69            die( '1' );
     70    } else {
     71        if ( bbp_add_user_favorite( $user_id, $topic->ID ) )
     72            die( '1' );
     73    }
     74
     75    die( '0' );
     76}
     77add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' );
     78endif;
     79
     80if ( !function_exists( 'bbp_twentyten_dim_subscription' ) ) :
     81/**
     82 * Subscribe/Unsubscribe a user from a topic
     83 *
     84 * @since bbPress (r2668)
     85 *
     86 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
     87 * @uses bbp_get_current_user_id() To get the current user id
     88 * @uses current_user_can() To check if the current user can edit the user
     89 * @uses bbp_get_topic() To get the topic
     90 * @uses check_ajax_referer() To verify the nonce & check the referer
     91 * @uses bbp_is_user_subscribed() To check if the topic is in user's
     92 *                                 subscriptions
     93 * @uses bbp_remove_user_subscriptions() To remove the topic from user's
     94 *                                        subscriptions
     95 * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
     96 */
     97function bbp_twentyten_dim_subscription () {
     98    if ( !bbp_is_subscriptions_active() )
     99        return;
     100
     101    $user_id = bbp_get_current_user_id();
     102    $id      = intval( $_POST['id'] );
     103
     104    if ( !current_user_can( 'edit_user', $user_id ) )
     105        die( '-1' );
     106
     107    if ( !$topic = bbp_get_topic( $id ) )
     108        die( '0' );
     109
     110    check_ajax_referer( "toggle-subscription_$topic->ID" );
     111
     112    if ( bbp_is_user_subscribed( $user_id, $topic->ID ) ) {
     113        if ( bbp_remove_user_subscription( $user_id, $topic->ID ) )
     114            die( '1' );
     115    } else {
     116        if ( bbp_add_user_subscription( $user_id, $topic->ID ) )
     117            die( '1' );
     118    }
     119
     120    die( '0' );
     121}
     122add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' );
     123endif;
     124
     125if ( !function_exists( 'bbp_twentyten_enqueue_scripts' ) ) :
     126/**
     127 * Enqueue the required Javascript files
     128 *
     129 * @since bbPress (r2652)
     130 *
     131 * @uses bbp_is_topic() To check if it's the topic page
     132 * @uses get_stylesheet_directory_uri() To get the stylesheet directory uri
     133 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
     134 * @uses wp_enqueue_script() To enqueue the scripts
     135 */
     136function bbp_twentyten_enqueue_scripts () {
     137    if ( bbp_is_topic() )
     138        wp_enqueue_script( 'bbp_topic', get_stylesheet_directory_uri() . '/js/topic.js', array( 'wp-lists' ), '20101202' );
     139
     140    if ( bbp_is_user_profile_edit() )
     141        wp_enqueue_script( 'user-profile' );
     142}
     143add_action( 'wp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' );
     144endif;
     145
     146if ( !function_exists( 'bbp_twentyten_scripts' ) ) :
     147/**
     148 * Put some scripts in the header, like AJAX url for wp-lists
     149 *
     150 * @since bbPress (r2652)
     151 *
     152 * @uses bbp_is_topic() To check if it's the topic page
     153 * @uses admin_url() To get the admin url
     154 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
     155 */
     156function bbp_twentyten_scripts () {
     157    if ( bbp_is_topic() ) : ?>
     158
     159    <script type='text/javascript'>
     160        /* <![CDATA[ */
     161        var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
     162        /* ]]> */
     163    </script>
     164
     165    <?php elseif ( bbp_is_user_profile_edit() ) : ?>
     166
     167    <script type="text/javascript" charset="utf-8">
     168        if ( window.location.hash == '#password' ) {
     169            document.getElementById('pass1').focus();
     170        }
     171    </script>
     172
     173    <?php
     174    endif;
     175}
     176add_filter( 'wp_head', 'bbp_twentyten_scripts', -1 );
     177endif;
     178
     179if ( !function_exists( 'bbp_twentyten_topic_script_localization' ) ) :
     180/**
     181 * Load localizations for topic script.
     182 *
     183 * These localizations require information that may not be loaded even by init.
     184 *
     185 * @since bbPress (r2652)
     186 *
     187 * @uses bbp_is_topic() To check if it's the topic page
     188 * @uses bbp_get_current_user_id() To get the current user id
     189 * @uses bbp_get_topic_id() To get the topic id
     190 * @uses bbp_get_favorites_permalink() To get the favorites permalink
     191 * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
     192 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
     193 * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
     194 * @uses bbp_get_topic_permalink() To get the topic permalink
     195 * @uses wp_localize_script() To localize the script
     196 */
     197function bbp_twentyten_topic_script_localization () {
     198    if ( !bbp_is_topic() )
     199        return;
     200
     201    $user_id = bbp_get_current_user_id();
     202
     203    $localizations = array(
     204        'currentUserId' => $user_id,
     205        'topicId'       => bbp_get_topic_id(),
     206        'favoritesLink' => bbp_get_favorites_permalink( $user_id ),
     207        'isFav'         => (int) bbp_is_user_favorite( $user_id ),
     208        'favLinkYes'    => __( 'favorites',                                         'bbpress' ),
     209        'favLinkNo'     => __( '?',                                                 'bbpress' ),
     210        'favYes'        => __( 'This topic is one of your %favLinkYes% [%favDel%]', 'bbpress' ),
     211        'favNo'         => __( '%favAdd% (%favLinkNo%)',                            'bbpress' ),
     212        'favDel'        => __( '&times;',                                           'bbpress' ),
     213        'favAdd'        => __( 'Add this topic to your favorites',                  'bbpress' )
     214    );
     215
     216    if ( bbp_is_subscriptions_active() ) {
     217        $localizations['subsActive']   = 1;
     218        $localizations['isSubscribed'] = (int) bbp_is_user_subscribed( $user_id );
     219        $localizations['subsSub']      = __( 'Subscribe', 'bbpress' );
     220        $localizations['subsUns']      = __( 'Unsubscribe', 'bbpress' );
     221        $localizations['subsLink']     = bbp_get_topic_permalink();
     222    } else {
     223        $localizations['subsActive'] = 0;
     224    }
     225
     226    wp_localize_script( 'bbp_topic', 'bbpTopicJS', $localizations );
     227}
     228add_filter( 'wp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' );
     229endif;
     230
    199231?>
    200 <style type="text/css">
    201 /* Shows the same border as on front end */
    202 #headimg {
    203     border-bottom: 1px solid #000;
    204     border-top: 4px solid #000;
    205 }
    206 /* If NO_HEADER_TEXT is false, you would style the text with these selectors:
    207     #headimg #name { }
    208     #headimg #desc { }
    209 */
    210 </style>
    211 <?php
    212 }
    213 endif;
    214 
    215 if ( !function_exists( 'twentyten_page_menu_args' ) ) :
    216 /**
    217  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
    218  *
    219  * To override this in a child theme, remove the filter and optionally add
    220  * your own function tied to the wp_page_menu_args filter hook.
    221  *
    222  * @since Twenty Ten 1.0
    223  */
    224 function twentyten_page_menu_args( $args ) {
    225     $args['show_home'] = true;
    226     return $args;
    227 }
    228 add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
    229 endif;
    230 
    231 if ( !function_exists( 'twentyten_excerpt_length' ) ) :
    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 endif;
    246 
    247 if ( !function_exists( 'twentyten_continue_reading_link' ) ) :
    248 /**
    249  * Returns a "Continue Reading" link for excerpts
    250  *
    251  * @since Twenty Ten 1.0
    252  * @return string "Continue Reading" link
    253  */
    254 function twentyten_continue_reading_link() {
    255     return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
    256 }
    257 endif;
    258 
    259 if ( !function_exists( 'twentyten_auto_excerpt_more' ) ) :
    260 /**
    261  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
    262  *
    263  * To override this in a child theme, remove the filter and add your own
    264  * function tied to the excerpt_more filter hook.
    265  *
    266  * @since Twenty Ten 1.0
    267  * @return string An ellipsis
    268  */
    269 function twentyten_auto_excerpt_more( $more ) {
    270     return ' &hellip;' . twentyten_continue_reading_link();
    271 }
    272 add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
    273 endif;
    274 
    275 if ( !function_exists( 'twentyten_custom_excerpt_more' ) ) :
    276 /**
    277  * Adds a pretty "Continue Reading" link to custom post excerpts.
    278  *
    279  * To override this link in a child theme, remove the filter and add your own
    280  * function tied to the get_the_excerpt filter hook.
    281  *
    282  * @since Twenty Ten 1.0
    283  * @return string Excerpt with a pretty "Continue Reading" link
    284  */
    285 function twentyten_custom_excerpt_more( $output ) {
    286     if ( has_excerpt() && ! is_attachment() ) {
    287         $output .= twentyten_continue_reading_link();
    288     }
    289     return $output;
    290 }
    291 add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
    292 endif;
    293 
    294 /**
    295  * Remove inline styles printed when the gallery shortcode is used.
    296  *
    297  * Galleries are styled by the theme in Twenty Ten's style.css. This is just
    298  * a simple filter call that tells WordPress to not use the default styles.
    299  *
    300  * @since Twenty Ten 1.2
    301  */
    302 add_filter( 'use_default_gallery_style', '__return_false' );
    303 
    304 if ( !function_exists( 'twentyten_remove_gallery_css' ) ) :
    305 /**
    306  * Deprecated way to remove inline styles printed when the gallery shortcode is used.
    307  *
    308  * This function is no longer needed or used. Use the use_default_gallery_style
    309  * filter instead, as seen above.
    310  *
    311  * @since Twenty Ten 1.0
    312  * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
    313  *
    314  * @return string The gallery style filter, with the styles themselves removed.
    315  */
    316 function twentyten_remove_gallery_css( $css ) {
    317     return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
    318 }
    319 // Backwards compatibility with WordPress 3.0.
    320 if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
    321     add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
    322 endif;
    323 
    324 if ( ! function_exists( 'twentyten_comment' ) ) :
    325 /**
    326  * Template for comments and pingbacks.
    327  *
    328  * To override this walker in a child theme without modifying the comments template
    329  * simply create your own twentyten_comment(), and that function will be used instead.
    330  *
    331  * Used as a callback by wp_list_comments() for displaying the comments.
    332  *
    333  * @since Twenty Ten 1.0
    334  */
    335 function twentyten_comment( $comment, $args, $depth ) {
    336     $GLOBALS['comment'] = $comment;
    337     switch ( $comment->comment_type ) :
    338         case '' :
    339     ?>
    340     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    341         <div id="comment-<?php comment_ID(); ?>">
    342         <div class="comment-author vcard">
    343             <?php echo get_avatar( $comment, 40 ); ?>
    344             <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
    345         </div><!-- .comment-author .vcard -->
    346         <?php if ( $comment->comment_approved == '0' ) : ?>
    347             <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
    348             <br />
    349         <?php endif; ?>
    350 
    351         <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
    352             <?php
    353                 /* translators: 1: date, 2: time */
    354                 printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
    355             ?>
    356         </div><!-- .comment-meta .commentmetadata -->
    357 
    358         <div class="comment-body"><?php comment_text(); ?></div>
    359 
    360         <div class="reply">
    361             <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    362         </div><!-- .reply -->
    363     </div><!-- #comment-##  -->
    364 
    365     <?php
    366             break;
    367         case 'pingback'  :
    368         case 'trackback' :
    369     ?>
    370     <li class="post pingback">
    371         <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
    372     <?php
    373             break;
    374     endswitch;
    375 }
    376 endif;
    377 
    378 if ( !function_exists( 'twentyten_widgets_init' ) ) :
    379 /**
    380  * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
    381  *
    382  * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
    383  * function tied to the init hook.
    384  *
    385  * @since Twenty Ten 1.0
    386  * @uses register_sidebar
    387  */
    388 function twentyten_widgets_init() {
    389     // Area 1, located at the top of the sidebar.
    390     register_sidebar( array(
    391         'name' => __( 'Primary Widget Area', 'twentyten' ),
    392         'id' => 'primary-widget-area',
    393         'description' => __( 'The primary widget area', 'twentyten' ),
    394         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    395         'after_widget' => '</li>',
    396         'before_title' => '<h3 class="widget-title">',
    397         'after_title' => '</h3>',
    398     ) );
    399 
    400     // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
    401     register_sidebar( array(
    402         'name' => __( 'Secondary Widget Area', 'twentyten' ),
    403         'id' => 'secondary-widget-area',
    404         'description' => __( 'The secondary widget area', '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 
    411     // Area 3, located in the footer. Empty by default.
    412     register_sidebar( array(
    413         'name' => __( 'First Footer Widget Area', 'twentyten' ),
    414         'id' => 'first-footer-widget-area',
    415         'description' => __( 'The first footer widget area', 'twentyten' ),
    416         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    417         'after_widget' => '</li>',
    418         'before_title' => '<h3 class="widget-title">',
    419         'after_title' => '</h3>',
    420     ) );
    421 
    422     // Area 4, located in the footer. Empty by default.
    423     register_sidebar( array(
    424         'name' => __( 'Second Footer Widget Area', 'twentyten' ),
    425         'id' => 'second-footer-widget-area',
    426         'description' => __( 'The second footer widget area', 'twentyten' ),
    427         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    428         'after_widget' => '</li>',
    429         'before_title' => '<h3 class="widget-title">',
    430         'after_title' => '</h3>',
    431     ) );
    432 
    433     // Area 5, located in the footer. Empty by default.
    434     register_sidebar( array(
    435         'name' => __( 'Third Footer Widget Area', 'twentyten' ),
    436         'id' => 'third-footer-widget-area',
    437         'description' => __( 'The third footer widget area', 'twentyten' ),
    438         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    439         'after_widget' => '</li>',
    440         'before_title' => '<h3 class="widget-title">',
    441         'after_title' => '</h3>',
    442     ) );
    443 
    444     // Area 6, located in the footer. Empty by default.
    445     register_sidebar( array(
    446         'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
    447         'id' => 'fourth-footer-widget-area',
    448         'description' => __( 'The fourth footer widget area', 'twentyten' ),
    449         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    450         'after_widget' => '</li>',
    451         'before_title' => '<h3 class="widget-title">',
    452         'after_title' => '</h3>',
    453     ) );
    454 }
    455 /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
    456 add_action( 'widgets_init', 'twentyten_widgets_init' );
    457 endif;
    458 
    459 if ( !function_exists( 'twentyten_remove_recent_comments_style' ) ) :
    460 /**
    461  * Removes the default styles that are packaged with the Recent Comments widget.
    462  *
    463  * To override this in a child theme, remove the filter and optionally add your own
    464  * function tied to the widgets_init action hook.
    465  *
    466  * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
    467  * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
    468  * but they won't have any effect on the widget in default Twenty Ten styling.
    469  *
    470  * @since Twenty Ten 1.0
    471  */
    472 function twentyten_remove_recent_comments_style() {
    473     add_filter( 'show_recent_comments_widget_style', '__return_false' );
    474 }
    475 add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
    476 endif;
    477 
    478 if ( ! function_exists( 'twentyten_posted_on' ) ) :
    479 /**
    480  * Prints HTML with meta information for the current post-date/time and author.
    481  *
    482  * @since Twenty Ten 1.0
    483  */
    484 function twentyten_posted_on() {
    485     printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
    486         'meta-prep meta-prep-author',
    487         sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
    488             get_permalink(),
    489             esc_attr( get_the_time() ),
    490             get_the_date()
    491         ),
    492         sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
    493             get_author_posts_url( get_the_author_meta( 'ID' ) ),
    494             sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    495             get_the_author()
    496         )
    497     );
    498 }
    499 endif;
    500 
    501 if ( ! function_exists( 'twentyten_posted_in' ) ) :
    502 /**
    503  * Prints HTML with meta information for the current post (category, tags and permalink).
    504  *
    505  * @since Twenty Ten 1.0
    506  */
    507 function twentyten_posted_in() {
    508     // Retrieves tag list of current post, separated by commas.
    509     $tag_list = get_the_tag_list( '', ', ' );
    510     if ( $tag_list ) {
    511         $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' );
    512     } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
    513         $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' );
    514     } else {
    515         $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    516     }
    517     // Prints the string, replacing the placeholders.
    518     printf(
    519         $posted_in,
    520         get_the_category_list( ', ' ),
    521         $tag_list,
    522         get_permalink(),
    523         the_title_attribute( 'echo=0' )
    524     );
    525 }
    526 endif;
    527 
    528 // Include bbPress theme functions
    529 include( get_template_directory() . '/bbpress/functions.php' );
    530 
    531 ?>
  • branches/plugin/bbp-themes/bbp-twentyten/style.css

    r2943 r3075  
    44 * Description: Adds bbPress forums to the Twenty Ten theme
    55 * Author: WordPress and bbPress teams
    6  * Version: 1.1-alpha
     6 * Version: 1.1
    77 * Tags: bbpress, black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style
     8 * Template: twentyten
    89 *
    910 **
Note: See TracChangeset for help on using the changeset viewer.