Changeset 2758 for branches/plugin/bbp-themes/bbp-twentyten/functions.php
- Timestamp:
- 01/06/2011 08:25:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-themes/bbp-twentyten/functions.php
r2740 r2758 2 2 3 3 /** 4 * bbp_twentyten_enqueue_styles () 5 * 4 * bbPress Theme Functions 5 * 6 * @package bbPress 7 * @subpackage Theme 8 */ 9 10 /** 6 11 * Load the theme CSS 12 * 13 * @uses is_admin() To check if it's the admin section 14 * @uses wp_enqueue_style() To enqueue the styles 7 15 */ 8 16 function bbp_twentyten_enqueue_styles () { … … 16 24 wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress.css', 'bbp-twentyten-default', 20100312, 'screen' ); 17 25 } 18 add_action( 'init', 'bbp_twentyten_enqueue_styles' ); 19 20 /** 21 * bbp_twentyten_dim_favorite () 22 * 26 27 /** 23 28 * Add or remove a topic from a user's favorites 24 29 * 25 * @package bbPress 26 * @subpackage bbPress TwentyTen 27 * @since bbPress (r2652) 28 * 29 * @return void 30 * @since bbPress (r2652) 31 * 32 * @uses bbp_get_current_user_id() To get the current user id 33 * @uses current_user_can() To check if the current user can edit the user 34 * @uses get_post() To get the topic 35 * @uses check_ajax_referer() To verify the nonce & check the referer 36 * @uses bbp_is_user_favorite() To check if the topic is user's favorite 37 * @uses bbp_remove_user_favorite() To remove the topic from user's favorites 38 * @uses bbp_add_user_favorite() To add the topic from user's favorites 30 39 */ 31 40 function bbp_twentyten_dim_favorite () { 32 global $current_user; 33 34 $current_user = wp_get_current_user(); 35 $user_id = $current_user->ID; 36 $id = intval( $_POST['id'] ); 41 $user_id = bbp_get_current_user_id(); 42 $id = intval( $_POST['id'] ); 37 43 38 44 if ( !current_user_can( 'edit_user', $user_id ) ) … … 54 60 die( '0' ); 55 61 } 56 add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' ); 57 58 /** 59 * bbp_twentyten_dim_subscription () 60 * 62 63 /** 61 64 * Subscribe/Unsubscribe a user from a topic 62 65 * 63 * @package bbPress64 * @subpackage bbPress TwentyTen65 66 * @since bbPress (r2668) 66 67 * 67 * @return void 68 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 69 * @uses bbp_get_current_user_id() To get the current user id 70 * @uses current_user_can() To check if the current user can edit the user 71 * @uses get_post() To get the topic 72 * @uses check_ajax_referer() To verify the nonce & check the referer 73 * @uses bbp_is_user_subscribed() To check if the topic is in user's 74 * subscriptions 75 * @uses bbp_remove_user_subscriptions() To remove the topic from user's 76 * subscriptions 77 * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions 68 78 */ 69 79 function bbp_twentyten_dim_subscription () { 70 global $current_user;71 72 80 if ( !bbp_is_subscriptions_active() ) 73 81 return; 74 82 75 $current_user = wp_get_current_user(); 76 $user_id = $current_user->ID; 77 $id = intval( $_POST['id'] ); 83 $user_id = bbp_get_current_user_id(); 84 $id = intval( $_POST['id'] ); 78 85 79 86 if ( !current_user_can( 'edit_user', $user_id ) ) … … 95 102 die( '0' ); 96 103 } 97 add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' ); 98 99 /** 100 * bbp_twentyten_enqueue_scripts () 101 * 104 105 /** 102 106 * Enqueue the required Javascript files 103 107 * 104 * @package bbPress 105 * @subpackage bbPress TwentyTen 106 * @since bbPress (r2652) 107 * 108 * @return void 108 * @since bbPress (r2652) 109 * 110 * @uses bbp_is_topic() To check if it's the topic page 111 * @uses get_stylesheet_directory_uri() To get the stylesheet directory uri 112 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page 113 * @uses wp_enqueue_script() To enqueue the scripts 109 114 */ 110 115 function bbp_twentyten_enqueue_scripts () { … … 115 120 wp_enqueue_script( 'user-profile' ); 116 121 } 117 add_action( 'wp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' ); 118 119 /** 120 * bbp_twentyten_scripts () 121 * 122 123 /** 122 124 * Put some scripts in the header, like AJAX url for wp-lists 123 125 * 124 * @ package bbPress125 * @subpackage bbPress TwentyTen126 * @ since bbPress (r2652)127 * 128 * @ return void126 * @since bbPress (r2652) 127 * 128 * @uses bbp_is_topic() To check if it's the topic page 129 * @uses admin_url() To get the admin url 130 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page 129 131 */ 130 132 function bbp_twentyten_scripts () { … … 148 150 endif; 149 151 } 150 add_filter( 'wp_head', 'bbp_twentyten_scripts', -1 ); 151 152 /** 153 * bbp_twentyten_topic_script_localization () 154 * 152 153 /** 155 154 * Load localizations for topic script. 156 155 * 157 156 * These localizations require information that may not be loaded even by init. 158 157 * 159 * @package bbPress 160 * @subpackage bbPress TwentyTen 161 * @since bbPress (r2652) 162 * 163 * @return void 158 * @since bbPress (r2652) 159 * 160 * @uses bbp_is_topic() To check if it's the topic page 161 * @uses bbp_get_current_user_id() To get the current user id 162 * @uses bbp_get_topic_id() To get the topic id 163 * @uses bbp_get_favorites_permalink() To get the favorites permalink 164 * @uses bbp_is_user_favorite() To check if the topic is in user's favorites 165 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 166 * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic 167 * @uses bbp_get_topic_permalink() To get the topic permalink 168 * @uses wp_localize_script() To localize the script 164 169 */ 165 170 function bbp_twentyten_topic_script_localization () { … … 167 172 return; 168 173 169 global $current_user; 170 171 $current_user = wp_get_current_user(); 172 $user_id = $current_user->ID; 174 $user_id = bbp_get_current_user_id(); 173 175 174 176 $localizations = array( … … 197 199 wp_localize_script( 'bbp_topic', 'bbpTopicJS', $localizations ); 198 200 } 199 add_filter( 'wp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' ); 201 202 /* Actions */ 203 add_action( 'init', 'bbp_twentyten_enqueue_styles' ); 204 add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' ); 205 add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' ); 206 add_action( 'wp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' ); 207 add_filter( 'wp_head', 'bbp_twentyten_scripts', -1 ); 208 add_filter( 'wp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' ); 200 209 201 210 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)