Ticket #2607: patch-2607-2.patch
File patch-2607-2.patch, 11.1 KB (added by , 15 years ago) |
---|
-
bp-themes/bp-default/functions.php
1 1 <?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. 4 3 if ( !class_exists( 'BP_Core_User' ) ) 5 4 return false; 6 5 7 / * Register the widget columns */6 // Register the widget columns 8 7 register_sidebars( 1, 9 8 array( 10 9 'name' => 'Sidebar', … … 15 14 ) 16 15 ); 17 16 18 / * Load the AJAX functions for the theme */17 // Load the AJAX functions for the theme 19 18 require_once( TEMPLATEPATH . '/_inc/ajax.php' ); 20 19 21 / * Load the javascript for the theme */20 // Load the javascript for the theme 22 21 wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) ); 23 22 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 ); 34 wp_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 */ 25 42 function bp_dtheme_add_blog_comments_js() { 26 43 if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); 27 44 } 28 45 add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' ); 29 46 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 */ 31 57 function bp_dtheme_blog_comments( $comment, $args, $depth ) { 32 58 $GLOBALS['comment'] = $comment; ?> 33 59 … … 68 94 <?php 69 95 } 70 96 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 */ 72 106 function bp_dtheme_wp_pages_filter( $page_html ) { 73 107 if ( !bp_is_active( 'activity' ) ) 74 108 return $page_html; … … 87 121 } 88 122 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' ); 89 123 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 */ 91 133 function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) { 92 134 if ( !is_admin() || !is_super_admin() ) 93 135 return false; … … 99 141 } 100 142 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 ); 101 143 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 */ 103 153 function bp_dtheme_page_on_front_template( $template ) { 104 154 global $wp_query; 105 155 … … 110 160 } 111 161 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' ); 112 162 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 */ 114 170 function bp_dtheme_page_on_front() { 115 171 if ( 'page' != get_option( 'show_on_front' ) ) 116 172 return false; … … 118 174 return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) ); 119 175 } 120 176 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 */ 122 184 function bp_dtheme_fix_get_posts_on_activity_front() { 123 185 global $wp_query; 124 186 … … 127 189 } 128 190 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' ); 129 191 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 */ 131 201 function bp_dtheme_fix_the_posts_on_activity_front( $posts ) { 132 202 global $wp_query; 133 203 … … 139 209 } 140 210 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' ); 141 211 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 */ 142 221 function bp_dtheme_activity_secondary_avatars( $action, $activity ) { 143 144 222 switch ( $activity->component ) { 145 223 case 'groups' : 146 224 case 'blogs' : … … 158 236 } 159 237 add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 ); 160 238 161 /** **239 /** 162 240 * Custom header image support. You can remove this entirely in a child theme by adding this line 163 241 * to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true ); 242 * 243 * @package BuddyPress Theme 244 * @since 1.2 164 245 */ 165 246 function 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/) 167 248 define( 'HEADER_TEXTCOLOR', 'FFFFFF' ); 168 249 define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri 169 250 define( 'HEADER_IMAGE_WIDTH', 1250 ); … … 235 316 if ( !defined( 'BP_DTHEME_DISABLE_CUSTOM_HEADER' ) ) 236 317 add_action( 'init', 'bp_dtheme_add_custom_header_support' ); 237 318 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 */ 239 325 function bp_dtheme_show_notice() { ?> 240 326 <div id="message" class="updated fade"> 241 327 <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> … … 246 332 } 247 333 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) 248 334 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 <?php263 }264 add_action( 'wp_footer', 'bp_dtheme_js_terms' );265 266 335 ?> 267 No newline at end of file -
bp-themes/bp-default/_inc/global.js
168 168 169 169 if ( 'fav' == type ) { 170 170 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>'); 172 172 173 173 target.removeClass('fav'); 174 174 target.addClass('unfav'); … … 460 460 461 461 jq('span.highlight span').click( function() { 462 462 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>' ); 464 464 jq('div.help').hide().slideDown(200); 465 465 } else { 466 466 jq('div.help').hide().remove(); … … 712 712 } else { 713 713 button.fadeOut( 100, function() { 714 714 if ( jq(this).hasClass('accept') ) { 715 jq(this).html( bp_terms_accepted ).fadeIn(50);715 jq(this).html( BP_DTheme.accepted ).fadeIn(50); 716 716 jq(this).addClass('accepted'); 717 717 } else { 718 jq(this).html( bp_terms_rejected ).fadeIn(50);718 jq(this).html( BP_DTheme.rejected ).fadeIn(50); 719 719 jq(this).addClass('rejected'); 720 720 } 721 721 }); … … 1205 1205 jq(this).toggle(); 1206 1206 1207 1207 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>' ); 1209 1209 } 1210 1210 }); 1211 1211