Changeset 3227 for branches/1.2/bp-themes/bp-default/functions.php
- Timestamp:
- 08/30/2010 09:00:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/bp-themes/bp-default/functions.php
r3192 r3227 1 1 <?php 2 2 3 / * Stop the theme from killing WordPress if BuddyPress is not enabled. */3 // Stop the theme from killing WordPress if BuddyPress is not enabled. 4 4 if ( !class_exists( 'BP_Core_User' ) ) 5 5 return false; 6 6 7 / * Register the widget columns */7 // Register the widget columns 8 8 register_sidebars( 1, 9 9 array( 10 'name' => 'Sidebar',10 'name' => 'Sidebar', 11 11 '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>' 15 15 ) 16 16 ); 17 17 18 / * Load the AJAX functions for the theme */18 // Load the AJAX functions for the theme 19 19 require_once( TEMPLATEPATH . '/_inc/ajax.php' ); 20 20 21 / * Load the javascript for the theme */21 // Load the javascript for the theme 22 22 wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) ); 23 23 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 ); 35 wp_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 */ 25 43 function bp_dtheme_add_blog_comments_js() { 26 44 if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); … … 28 46 add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' ); 29 47 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 */ 31 58 function bp_dtheme_blog_comments( $comment, $args, $depth ) { 32 59 $GLOBALS['comment'] = $comment; ?> … … 69 96 } 70 97 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 */ 72 107 function bp_dtheme_wp_pages_filter( $page_html ) { 73 108 if ( !bp_is_active( 'activity' ) ) … … 88 123 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' ); 89 124 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 */ 91 134 function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) { 92 135 if ( !is_admin() || !is_super_admin() ) … … 100 143 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 ); 101 144 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 */ 103 154 function bp_dtheme_page_on_front_template( $template ) { 104 155 global $wp_query; … … 111 162 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' ); 112 163 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 */ 114 171 function bp_dtheme_page_on_front() { 115 172 if ( 'page' != get_option( 'show_on_front' ) ) … … 119 176 } 120 177 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 */ 122 185 function bp_dtheme_fix_get_posts_on_activity_front() { 123 186 global $wp_query; … … 128 191 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' ); 129 192 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 */ 131 202 function bp_dtheme_fix_the_posts_on_activity_front( $posts ) { 132 203 global $wp_query; … … 140 211 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' ); 141 212 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 */ 142 222 function bp_dtheme_activity_secondary_avatars( $action, $activity ) { 143 144 223 switch ( $activity->component ) { 145 224 case 'groups' : … … 159 238 add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 ); 160 239 161 /** **240 /** 162 241 * Custom header image support. You can remove this entirely in a child theme by adding this line 163 242 * to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true ); 243 * 244 * @package BuddyPress Theme 245 * @since 1.2 164 246 */ 165 247 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/) */248 // Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) 167 249 define( 'HEADER_TEXTCOLOR', 'FFFFFF' ); 168 250 define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri … … 236 318 add_action( 'init', 'bp_dtheme_add_custom_header_support' ); 237 319 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 */ 239 326 function bp_dtheme_show_notice() { ?> 240 327 <div id="message" class="updated fade"> … … 247 334 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) 248 335 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 336 ?>
Note: See TracChangeset
for help on using the changeset viewer.