Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/30/2010 09:00:44 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Fixes #2607. Super props Paul Gibbs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-themes/bp-default/functions.php

    r3192 r3227  
    11<?php
    22
    3 /* Stop the theme from killing WordPress if BuddyPress is not enabled. */
     3// Stop the theme from killing WordPress if BuddyPress is not enabled.
    44if ( !class_exists( 'BP_Core_User' ) )
    55    return false;
    66
    7 /* Register the widget columns */
     7// Register the widget columns
    88register_sidebars( 1,
    99    array(
    10         'name' => 'Sidebar',
     10        'name'          => 'Sidebar',
    1111        'before_widget' => '<div id="%1$s" class="widget %2$s">',
    12         'after_widget' => '</div>',
    13         'before_title' => '<h3 class="widgettitle">',
    14         'after_title' => '</h3>'
     12        'after_widget'  => '</div>',
     13        'before_title'  => '<h3 class="widgettitle">',
     14        'after_title'   => '</h3>'
    1515    )
    1616);
    1717
    18 /* Load the AJAX functions for the theme */
     18// Load the AJAX functions for the theme
    1919require_once( TEMPLATEPATH . '/_inc/ajax.php' );
    2020
    21 /* Load the javascript for the theme */
     21// Load the javascript for the theme
    2222wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
    2323
    24 /* Add the JS needed for blog comment replies */
     24// Add words that we need to use in JS to the end of the page so they can be translated and still used.
     25$params = array(
     26    'my_favs'           => __( 'My Favorites', 'buddypress' ),
     27    'accepted'          => __( 'Accepted', 'buddypress' ),
     28    'rejected'          => __( 'Rejected', 'buddypress' ),
     29    'show_all_comments' => __( 'Show all comments for this thread', 'buddypress' ),
     30    'show_all'          => __( 'Show all', 'buddypress' ),
     31    'comments'          => __( 'comments', 'buddypress' ),
     32    'close'             => __( 'Close', 'buddypress' ),
     33    'mention_explain'   => sprintf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", 'buddypress' ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname( bp_get_displayed_user_fullname() ), bp_get_user_firstname( bp_get_displayed_user_fullname() ) )
     34);
     35wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
     36
     37/**
     38 * Add the JS needed for blog comment replies
     39 *
     40 * @package BuddyPress Theme
     41 * @since 1.2
     42 */
    2543function bp_dtheme_add_blog_comments_js() {
    2644    if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
     
    2846add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' );
    2947
    30 /* HTML for outputting blog comments as defined by the WP comment API */
     48/**
     49 * HTML for outputting blog comments as defined by the WP comment API
     50 *
     51 * @param mixed $comment Comment record from database
     52 * @param array $args Arguments from wp_list_comments() call
     53 * @param int $depth Comment nesting level
     54 * @see wp_list_comments()
     55 * @package BuddyPress Theme
     56 * @since 1.2
     57 */
    3158function bp_dtheme_blog_comments( $comment, $args, $depth ) {
    3259    $GLOBALS['comment'] = $comment; ?>
     
    6996}
    7097
    71 /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */
     98/**
     99 * Filter the dropdown for selecting the page to show on front to include "Activity Stream"
     100 *
     101 * @param string $page_html A list of pages as a dropdown (select list)
     102 * @see wp_dropdown_pages()
     103 * @return string
     104 * @package BuddyPress Theme
     105 * @since 1.2
     106 */
    72107function bp_dtheme_wp_pages_filter( $page_html ) {
    73108    if ( !bp_is_active( 'activity' ) )
     
    88123add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
    89124
    90 /* Hijack the saving of page on front setting to save the activity stream setting */
     125/**
     126 * Hijack the saving of page on front setting to save the activity stream setting
     127 *
     128 * @param $string $oldvalue Previous value of get_option( 'page_on_front' )
     129 * @param $string $oldvalue New value of get_option( 'page_on_front' )
     130 * @return string
     131 * @package BuddyPress Theme
     132 * @since 1.2
     133 */
    91134function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
    92135    if ( !is_admin() || !is_super_admin() )
     
    100143add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
    101144
    102 /* Load the activity stream template if settings allow */
     145/**
     146 * Load the activity stream template if settings allow
     147 *
     148 * @param string $template Absolute path to the page template
     149 * @return string
     150 * @global WP_Query $wp_query WordPress query object
     151 * @package BuddyPress Theme
     152 * @since 1.2
     153 */
    103154function bp_dtheme_page_on_front_template( $template ) {
    104155    global $wp_query;
     
    111162add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
    112163
    113 /* Return the ID of a page set as the home page. */
     164/**
     165 * Return the ID of a page set as the home page.
     166 *
     167 * @return false|int ID of page set as the home page
     168 * @package BuddyPress Theme
     169 * @since 1.2
     170 */
    114171function bp_dtheme_page_on_front() {
    115172    if ( 'page' != get_option( 'show_on_front' ) )
     
    119176}
    120177
    121 /* Force the page ID as a string to stop the get_posts query from kicking up a fuss. */
     178/**
     179 * Force the page ID as a string to stop the get_posts query from kicking up a fuss.
     180 *
     181 * @global WP_Query $wp_query WordPress query object
     182 * @package BuddyPress Theme
     183 * @since 1.2
     184 */
    122185function bp_dtheme_fix_get_posts_on_activity_front() {
    123186    global $wp_query;
     
    128191add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );
    129192
    130 /* WP 3.0 requires there to be a non-null post in the posts array */
     193/**
     194 * WP 3.0 requires there to be a non-null post in the posts array
     195 *
     196 * @param array $posts Posts as retrieved by WP_Query
     197 * @global WP_Query $wp_query WordPress query object
     198 * @return array
     199 * @package BuddyPress Theme
     200 * @since 1.2.5
     201 */
    131202function bp_dtheme_fix_the_posts_on_activity_front( $posts ) {
    132203    global $wp_query;
     
    140211add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );
    141212
     213/**
     214 * Add secondary avatar image to this activity stream's record, if supported
     215 *
     216 * @param string $action The text of this activity
     217 * @param BP_Activity_Activity $activity Activity object
     218 * @return string
     219 * @package BuddyPress Theme
     220 * @since 1.2.6
     221 */
    142222function bp_dtheme_activity_secondary_avatars( $action, $activity ) {
    143 
    144223    switch ( $activity->component ) {
    145224        case 'groups' :
     
    159238add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
    160239
    161 /****
     240/**
    162241 * Custom header image support. You can remove this entirely in a child theme by adding this line
    163242 * to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true );
     243 *
     244 * @package BuddyPress Theme
     245 * @since 1.2
    164246 */
    165247function bp_dtheme_add_custom_header_support() {
    166     /* Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) */
     248    // Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/)
    167249    define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
    168250    define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri
     
    236318    add_action( 'init', 'bp_dtheme_add_custom_header_support' );
    237319
    238 /* Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) */
     320/**
     321 * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html)
     322 *
     323 * @package BuddyPress Theme
     324 * @since 1.2
     325 */
    239326function bp_dtheme_show_notice() { ?>
    240327    <div id="message" class="updated fade">
     
    247334if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" )
    248335    add_action( 'admin_notices', 'bp_dtheme_show_notice' );
    249 
    250 /* Add words that we need to use in JS to the end of the page so they can be translated and still used. */
    251 function bp_dtheme_js_terms() { ?>
    252 <script type="text/javascript">
    253     var bp_terms_my_favs = '<?php _e( "My Favorites", "buddypress" ) ?>';
    254     var bp_terms_accepted = '<?php _e( "Accepted", "buddypress" ) ?>';
    255     var bp_terms_rejected = '<?php _e( "Rejected", "buddypress" ) ?>';
    256     var bp_terms_show_all_comments = '<?php _e( "Show all comments for this thread", "buddypress" ) ?>';
    257     var bp_terms_show_all = '<?php _e( "Show all", "buddypress" ) ?>';
    258     var bp_terms_comments = '<?php _e( "comments", "buddypress" ) ?>';
    259     var bp_terms_close = '<?php _e( "Close", "buddypress" ) ?>';
    260     var bp_terms_mention_explain = '<?php printf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", "buddypress" ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname(bp_get_displayed_user_fullname()), bp_get_user_firstname(bp_get_displayed_user_fullname()) ); ?>';
    261     </script>
    262 <?php
    263 }
    264 add_action( 'wp_footer', 'bp_dtheme_js_terms' );
    265 
    266336?>
Note: See TracChangeset for help on using the changeset viewer.