Skip to:
Content

BuddyPress.org

Ticket #2607: patch-2607-2.patch

File patch-2607-2.patch, 11.1 KB (added by DJPaul, 14 years ago)

v2

  • bp-themes/bp-default/functions.php

     
    11<?php
    2 
    3 /* Stop the theme from killing WordPress if BuddyPress is not enabled. */
     2// Stop the theme from killing WordPress if BuddyPress is not enabled.
    43if ( !class_exists( 'BP_Core_User' ) )
    54        return false;
    65
    7 /* Register the widget columns */
     6// Register the widget columns
    87register_sidebars( 1,
    98        array(
    109                'name' => 'Sidebar',
     
    1514        )
    1615);
    1716
    18 /* Load the AJAX functions for the theme */
     17// Load the AJAX functions for the theme
    1918require_once( TEMPLATEPATH . '/_inc/ajax.php' );
    2019
    21 /* Load the javascript for the theme */
     20// Load the javascript for the theme
    2221wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
    2322
    24 /* Add the JS needed for blog comment replies */
     23// Add words that we need to use in JS to the end of the page so they can be translated and still used.
     24$params = array(
     25        'my_favs' => __( "My Favorites", "buddypress" ),
     26        'accepted' => __( "Accepted", "buddypress" ),
     27        'rejected' => __( "Rejected", "buddypress" ),
     28        'show_all_comments' => __( "Show all comments for this thread", "buddypress" ),
     29        'show_all' => __( "Show all", "buddypress" ),
     30        'comments' => __( "comments", "buddypress" ),
     31        'close' => __( "Close", "buddypress" ),
     32        '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() ) )
     33);
     34wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
     35
     36/**
     37 * Add the JS needed for blog comment replies
     38 *
     39 * @package BuddyPress Theme
     40 * @since 1.2
     41 */
    2542function bp_dtheme_add_blog_comments_js() {
    2643        if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
    2744}
    2845add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' );
    2946
    30 /* HTML for outputting blog comments as defined by the WP comment API */
     47/**
     48 * HTML for outputting blog comments as defined by the WP comment API
     49 *
     50 * @param mixed $comment Comment record from database
     51 * @param array $args Arguments from wp_list_comments() call
     52 * @param int $depth Comment nesting level
     53 * @see wp_list_comments()
     54 * @package BuddyPress Theme
     55 * @since 1.2
     56 */
    3157function bp_dtheme_blog_comments( $comment, $args, $depth ) {
    3258        $GLOBALS['comment'] = $comment; ?>
    3359
     
    6894<?php
    6995}
    7096
    71 /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */
     97/**
     98 * Filter the dropdown for selecting the page to show on front to include "Activity Stream"
     99 *
     100 * @param string $page_html A list of pages as a dropdown (select list)
     101 * @see wp_dropdown_pages()
     102 * @return string
     103 * @package BuddyPress Theme
     104 * @since 1.2
     105 */
    72106function bp_dtheme_wp_pages_filter( $page_html ) {
    73107        if ( !bp_is_active( 'activity' ) )
    74108                return $page_html;
     
    87121}
    88122add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
    89123
    90 /* Hijack the saving of page on front setting to save the activity stream setting */
     124/**
     125 * Hijack the saving of page on front setting to save the activity stream setting
     126 *
     127 * @param $string $oldvalue Previous value of get_option( 'page_on_front' )
     128 * @param $string $oldvalue New value of get_option( 'page_on_front' )
     129 * @return string
     130 * @package BuddyPress Theme
     131 * @since 1.2
     132 */
    91133function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
    92134        if ( !is_admin() || !is_super_admin() )
    93135                return false;
     
    99141}
    100142add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
    101143
    102 /* Load the activity stream template if settings allow */
     144/**
     145 * Load the activity stream template if settings allow
     146 *
     147 * @param string $template Absolute path to the page template
     148 * @return string
     149 * @global WP_Query $wp_query WordPress query object
     150 * @package BuddyPress Theme
     151 * @since 1.2
     152 */
    103153function bp_dtheme_page_on_front_template( $template ) {
    104154        global $wp_query;
    105155
     
    110160}
    111161add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
    112162
    113 /* Return the ID of a page set as the home page. */
     163/**
     164 * Return the ID of a page set as the home page.
     165 *
     166 * @return false|int ID of page set as the home page
     167 * @package BuddyPress Theme
     168 * @since 1.2
     169 */
    114170function bp_dtheme_page_on_front() {
    115171        if ( 'page' != get_option( 'show_on_front' ) )
    116172                return false;
     
    118174        return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) );
    119175}
    120176
    121 /* Force the page ID as a string to stop the get_posts query from kicking up a fuss. */
     177/**
     178 * Force the page ID as a string to stop the get_posts query from kicking up a fuss.
     179 *
     180 * @global WP_Query $wp_query WordPress query object
     181 * @package BuddyPress Theme
     182 * @since 1.2
     183 */
    122184function bp_dtheme_fix_get_posts_on_activity_front() {
    123185        global $wp_query;
    124186
     
    127189}
    128190add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );
    129191
    130 /* WP 3.0 requires there to be a non-null post in the posts array */
     192/**
     193 * WP 3.0 requires there to be a non-null post in the posts array
     194 *
     195 * @param array $posts Posts as retrieved by WP_Query
     196 * @global WP_Query $wp_query WordPress query object
     197 * @return array
     198 * @package BuddyPress Theme
     199 * @since 1.2.5
     200 */
    131201function bp_dtheme_fix_the_posts_on_activity_front( $posts ) {
    132202        global $wp_query;
    133203
     
    139209}
    140210add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );
    141211
     212/**
     213 * Add secondary avatar image to this activity stream's record, if supported
     214 *
     215 * @param string $action The text of this activity
     216 * @param BP_Activity_Activity $activity Activity object
     217 * @return string
     218 * @package BuddyPress Theme
     219 * @since 1.2.6
     220 */
    142221function bp_dtheme_activity_secondary_avatars( $action, $activity ) {
    143 
    144222        switch ( $activity->component ) {
    145223                case 'groups' :
    146224                case 'blogs' :
     
    158236}
    159237add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
    160238
    161 /****
     239/**
    162240 * Custom header image support. You can remove this entirely in a child theme by adding this line
    163241 * to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true );
     242 *
     243 * @package BuddyPress Theme
     244 * @since 1.2
    164245 */
    165246function 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/) */
     247        // Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/)
    167248        define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
    168249        define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri
    169250        define( 'HEADER_IMAGE_WIDTH', 1250 );
     
    235316if ( !defined( 'BP_DTHEME_DISABLE_CUSTOM_HEADER' ) )
    236317        add_action( 'init', 'bp_dtheme_add_custom_header_support' );
    237318
    238 /* Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) */
     319/**
     320 * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html)
     321 *
     322 * @package BuddyPress Theme
     323 * @since 1.2
     324 */
    239325function bp_dtheme_show_notice() { ?>
    240326        <div id="message" class="updated fade">
    241327                <p><?php printf( __( 'Theme activated! This theme contains <a href="%s">custom header image</a> support and <a href="%s">sidebar widgets</a>.', 'buddypress' ), admin_url( 'themes.php?page=custom-header' ), admin_url( 'widgets.php' ) ) ?></p>
     
    246332}
    247333if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" )
    248334        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 
    266335?>
    267  No newline at end of file
  • bp-themes/bp-default/_inc/global.js

     
    168168
    169169                                if ( 'fav' == type ) {
    170170                                        if ( !jq('div.item-list-tabs li#activity-favorites').length )
    171                                                 jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + bp_terms_my_favs + ' (<span>0</span>)</a></li>');
     171                                                jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' (<span>0</span>)</a></li>');
    172172
    173173                                        target.removeClass('fav');
    174174                                        target.addClass('unfav');
     
    460460
    461461        jq('span.highlight span').click( function() {
    462462                if ( !jq('div.help').length ) {
    463                         jq(this).parent().after( '<div id="message" class="info help"><p>' + bp_terms_mention_explain + '</p></div>' );
     463                        jq(this).parent().after( '<div id="message" class="info help"><p>' + BP_DTheme.mention_explain + '</p></div>' );
    464464                        jq('div.help').hide().slideDown(200);
    465465                } else {
    466466                        jq('div.help').hide().remove();
     
    712712                        } else {
    713713                                button.fadeOut( 100, function() {
    714714                                        if ( jq(this).hasClass('accept') ) {
    715                                                 jq(this).html( bp_terms_accepted ).fadeIn(50);
     715                                                jq(this).html( BP_DTheme.accepted ).fadeIn(50);
    716716                                                jq(this).addClass('accepted');
    717717                                        } else {
    718                                                 jq(this).html( bp_terms_rejected ).fadeIn(50);
     718                                                jq(this).html( BP_DTheme.rejected ).fadeIn(50);
    719719                                                jq(this).addClass('rejected');
    720720                                        }
    721721                                });
     
    12051205                                jq(this).toggle();
    12061206
    12071207                                if ( !i )
    1208                                         jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + bp_terms_show_all_comments + '">' + bp_terms_show_all + ' ' + comment_count + ' ' + bp_terms_comments + '</a></li>' );
     1208                                        jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_all + ' ' + comment_count + ' ' + BP_DTheme.comments + '</a></li>' );
    12091209                        }
    12101210                });
    12111211