Changeset 3374 for branches/plugin/bbp-themes/bbp-twentyten/functions.php
- Timestamp:
- 07/25/2011 05:37:37 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-themes/bbp-twentyten/functions.php
r3344 r3374 31 31 * @since bbPress (r2652) 32 32 * 33 * @uses is_admin() To check if it's the admin section34 33 * @uses wp_enqueue_style() To enqueue the styles 35 34 */ 36 35 function bbp_twentyten_enqueue_styles () { 37 if ( is_admin() )38 return false;39 36 40 37 // Right to left … … 58 55 } 59 56 } 60 add_action( 'init', 'bbp_twentyten_enqueue_styles' ); 61 endif; 62 63 if ( !function_exists( 'bbp_twentyten_dim_favorite' ) ) : 64 /** 65 * Add or remove a topic from a user's favorites 66 * 67 * @since bbPress (r2652) 68 * 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 bbp_get_topic() To get the topic 72 * @uses check_ajax_referer() To verify the nonce & check the referer 73 * @uses bbp_is_user_favorite() To check if the topic is user's favorite 74 * @uses bbp_remove_user_favorite() To remove the topic from user's favorites 75 * @uses bbp_add_user_favorite() To add the topic from user's favorites 76 */ 77 function bbp_twentyten_dim_favorite () { 78 $user_id = bbp_get_current_user_id(); 79 $id = intval( $_POST['id'] ); 80 81 if ( !current_user_can( 'edit_user', $user_id ) ) 82 die( '-1' ); 83 84 if ( !$topic = bbp_get_topic( $id ) ) 85 die( '0' ); 86 87 check_ajax_referer( "toggle-favorite_$topic->ID" ); 88 89 if ( bbp_is_user_favorite( $user_id, $topic->ID ) ) { 90 if ( bbp_remove_user_favorite( $user_id, $topic->ID ) ) 91 die( '1' ); 92 } else { 93 if ( bbp_add_user_favorite( $user_id, $topic->ID ) ) 94 die( '1' ); 95 } 96 97 die( '0' ); 98 } 99 add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' ); 100 endif; 101 102 if ( !function_exists( 'bbp_twentyten_dim_subscription' ) ) : 103 /** 104 * Subscribe/Unsubscribe a user from a topic 105 * 106 * @since bbPress (r2668) 107 * 108 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 109 * @uses bbp_get_current_user_id() To get the current user id 110 * @uses current_user_can() To check if the current user can edit the user 111 * @uses bbp_get_topic() To get the topic 112 * @uses check_ajax_referer() To verify the nonce & check the referer 113 * @uses bbp_is_user_subscribed() To check if the topic is in user's 114 * subscriptions 115 * @uses bbp_remove_user_subscriptions() To remove the topic from user's 116 * subscriptions 117 * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions 118 */ 119 function bbp_twentyten_dim_subscription () { 120 if ( !bbp_is_subscriptions_active() ) 121 return; 122 123 $user_id = bbp_get_current_user_id(); 124 $id = intval( $_POST['id'] ); 125 126 if ( !current_user_can( 'edit_user', $user_id ) ) 127 die( '-1' ); 128 129 if ( !$topic = bbp_get_topic( $id ) ) 130 die( '0' ); 131 132 check_ajax_referer( "toggle-subscription_$topic->ID" ); 133 134 if ( bbp_is_user_subscribed( $user_id, $topic->ID ) ) { 135 if ( bbp_remove_user_subscription( $user_id, $topic->ID ) ) 136 die( '1' ); 137 } else { 138 if ( bbp_add_user_subscription( $user_id, $topic->ID ) ) 139 die( '1' ); 140 } 141 142 die( '0' ); 143 } 144 add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' ); 57 add_action( 'bbp_enqueue_scripts', 'bbp_twentyten_enqueue_styles' ); 145 58 endif; 146 59 … … 163 76 wp_enqueue_script( 'user-profile' ); 164 77 } 165 add_action( ' wp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' );78 add_action( 'bbp_setup_theme_compat', 'bbp_twentyten_enqueue_scripts' ); 166 79 endif; 167 80 … … 196 109 endif; 197 110 } 198 add_filter( ' wp_head', 'bbp_twentyten_scripts', -1 );111 add_filter( 'bbp_head', 'bbp_twentyten_scripts', -1 ); 199 112 endif; 200 113 … … 248 161 wp_localize_script( 'bbp_topic', 'bbpTopicJS', $localizations ); 249 162 } 250 add_filter( 'wp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' ); 163 add_filter( 'bbp_setup_theme_compat', 'bbp_twentyten_topic_script_localization' ); 164 endif; 165 166 if ( !function_exists( 'bbp_twentyten_dim_favorite' ) ) : 167 /** 168 * Add or remove a topic from a user's favorites 169 * 170 * @since bbPress (r2652) 171 * 172 * @uses bbp_get_current_user_id() To get the current user id 173 * @uses current_user_can() To check if the current user can edit the user 174 * @uses bbp_get_topic() To get the topic 175 * @uses check_ajax_referer() To verify the nonce & check the referer 176 * @uses bbp_is_user_favorite() To check if the topic is user's favorite 177 * @uses bbp_remove_user_favorite() To remove the topic from user's favorites 178 * @uses bbp_add_user_favorite() To add the topic from user's favorites 179 */ 180 function bbp_twentyten_dim_favorite () { 181 $user_id = bbp_get_current_user_id(); 182 $id = intval( $_POST['id'] ); 183 184 if ( !current_user_can( 'edit_user', $user_id ) ) 185 die( '-1' ); 186 187 if ( !$topic = bbp_get_topic( $id ) ) 188 die( '0' ); 189 190 check_ajax_referer( "toggle-favorite_$topic->ID" ); 191 192 if ( bbp_is_user_favorite( $user_id, $topic->ID ) ) { 193 if ( bbp_remove_user_favorite( $user_id, $topic->ID ) ) 194 die( '1' ); 195 } else { 196 if ( bbp_add_user_favorite( $user_id, $topic->ID ) ) 197 die( '1' ); 198 } 199 200 die( '0' ); 201 } 202 add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' ); 203 endif; 204 205 if ( !function_exists( 'bbp_twentyten_dim_subscription' ) ) : 206 /** 207 * Subscribe/Unsubscribe a user from a topic 208 * 209 * @since bbPress (r2668) 210 * 211 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 212 * @uses bbp_get_current_user_id() To get the current user id 213 * @uses current_user_can() To check if the current user can edit the user 214 * @uses bbp_get_topic() To get the topic 215 * @uses check_ajax_referer() To verify the nonce & check the referer 216 * @uses bbp_is_user_subscribed() To check if the topic is in user's 217 * subscriptions 218 * @uses bbp_remove_user_subscriptions() To remove the topic from user's 219 * subscriptions 220 * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions 221 */ 222 function bbp_twentyten_dim_subscription () { 223 if ( !bbp_is_subscriptions_active() ) 224 return; 225 226 $user_id = bbp_get_current_user_id(); 227 $id = intval( $_POST['id'] ); 228 229 if ( !current_user_can( 'edit_user', $user_id ) ) 230 die( '-1' ); 231 232 if ( !$topic = bbp_get_topic( $id ) ) 233 die( '0' ); 234 235 check_ajax_referer( "toggle-subscription_$topic->ID" ); 236 237 if ( bbp_is_user_subscribed( $user_id, $topic->ID ) ) { 238 if ( bbp_remove_user_subscription( $user_id, $topic->ID ) ) 239 die( '1' ); 240 } else { 241 if ( bbp_add_user_subscription( $user_id, $topic->ID ) ) 242 die( '1' ); 243 } 244 245 die( '0' ); 246 } 247 add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' ); 251 248 endif; 252 249
Note: See TracChangeset
for help on using the changeset viewer.