Changeset 5436 for trunk/src/includes/users/functions.php
- Timestamp:
- 07/09/2014 10:59:31 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/users/functions.php (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/functions.php
r5369 r5436 28 28 29 29 // Raw redirect_to was passed, so use it 30 if ( !empty( $raw_url ) ) 30 if ( !empty( $raw_url ) ) { 31 31 $url = $raw_url; 32 32 33 33 // $url was manually set in wp-login.php to redirect to admin 34 elseif ( admin_url() === $url )34 } elseif ( admin_url() === $url ) { 35 35 $url = home_url(); 36 36 37 37 // $url is empty 38 elseif ( empty( $url ) )38 } elseif ( empty( $url ) ) { 39 39 $url = home_url(); 40 } 40 41 41 42 return apply_filters( 'bbp_redirect_login', $url, $raw_url, $user ); … … 54 55 */ 55 56 function bbp_is_anonymous() { 56 if ( !is_user_logged_in() && bbp_allow_anonymous() ) 57 if ( !is_user_logged_in() && bbp_allow_anonymous() ) { 57 58 $is_anonymous = true; 58 else59 } else { 59 60 $is_anonymous = false; 61 } 60 62 61 63 return apply_filters( 'bbp_is_anonymous', $is_anonymous ); … … 102 104 $bbp_current_poster = wp_get_current_commenter(); 103 105 104 if ( !empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) 106 if ( !empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) { 105 107 return $bbp_current_poster[$cookie_names[$key]]; 108 } 106 109 107 110 return $bbp_current_poster; … … 122 125 */ 123 126 function bbp_set_current_anonymous_user_data( $anonymous_data = array() ) { 124 if ( empty( $anonymous_data ) || !is_array( $anonymous_data ) ) 125 return; 127 if ( empty( $anonymous_data ) || !is_array( $anonymous_data ) ) { 128 return; 129 } 126 130 127 131 $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 ); … … 173 177 function bbp_get_topic_favoriters( $topic_id = 0 ) { 174 178 $topic_id = bbp_get_topic_id( $topic_id ); 175 if ( empty( $topic_id ) ) 176 return; 179 if ( empty( $topic_id ) ) { 180 return; 181 } 177 182 178 183 global $wpdb; … … 202 207 function bbp_get_user_favorites( $user_id = 0 ) { 203 208 $user_id = bbp_get_user_id( $user_id ); 204 if ( empty( $user_id ) ) 205 return false; 209 if ( empty( $user_id ) ) { 210 return false; 211 } 206 212 207 213 // If user has favorites, load them … … 230 236 function bbp_get_user_favorites_topic_ids( $user_id = 0 ) { 231 237 $user_id = bbp_get_user_id( $user_id ); 232 if ( empty( $user_id ) ) 233 return false; 238 if ( empty( $user_id ) ) { 239 return false; 240 } 234 241 235 242 $favorites = get_user_option( '_bbp_favorites', $user_id ); … … 257 264 258 265 $user_id = bbp_get_user_id( $user_id, true, true ); 259 if ( empty( $user_id ) ) 260 return false; 266 if ( empty( $user_id ) ) { 267 return false; 268 } 261 269 262 270 $retval = false; … … 301 309 */ 302 310 function bbp_add_user_favorite( $user_id = 0, $topic_id = 0 ) { 303 if ( empty( $user_id ) || empty( $topic_id ) ) 304 return false; 311 if ( empty( $user_id ) || empty( $topic_id ) ) { 312 return false; 313 } 305 314 306 315 $topic = bbp_get_topic( $topic_id ); 307 if ( empty( $topic ) ) 308 return false; 316 if ( empty( $topic ) ) { 317 return false; 318 } 309 319 310 320 $favorites = bbp_get_user_favorites_topic_ids( $user_id ); … … 335 345 */ 336 346 function bbp_remove_user_favorite( $user_id, $topic_id ) { 337 if ( empty( $user_id ) || empty( $topic_id ) ) 338 return false; 347 if ( empty( $user_id ) || empty( $topic_id ) ) { 348 return false; 349 } 339 350 340 351 $favorites = (array) bbp_get_user_favorites_topic_ids( $user_id ); 341 if ( empty( $favorites ) ) 342 return false; 352 if ( empty( $favorites ) ) { 353 return false; 354 } 343 355 344 356 $pos = array_search( $topic_id, $favorites ); … … 380 392 function bbp_favorites_handler( $action = '' ) { 381 393 382 if ( !bbp_is_favorites_active() ) 383 return false; 394 if ( !bbp_is_favorites_active() ) { 395 return false; 396 } 384 397 385 398 // Bail if no topic ID is passed 386 if ( empty( $_GET['topic_id'] ) ) 387 return; 399 if ( empty( $_GET['topic_id'] ) ) { 400 return; 401 } 388 402 389 403 // Setup possible get actions … … 394 408 395 409 // Bail if actions aren't meant for this function 396 if ( !in_array( $action, $possible_actions ) ) 397 return; 410 if ( !in_array( $action, $possible_actions ) ) { 411 return; 412 } 398 413 399 414 // What action is taking place? … … 415 430 416 431 // Bail if errors 417 if ( bbp_has_errors() ) 418 return; 432 if ( bbp_has_errors() ) { 433 return; 434 } 419 435 420 436 /** No errors *************************************************************/ … … 423 439 $success = false; 424 440 425 if ( true === $is_favorite && 'bbp_favorite_remove' === $action ) 441 if ( true === $is_favorite && 'bbp_favorite_remove' === $action ) { 426 442 $success = bbp_remove_user_favorite( $user_id, $topic_id ); 427 elseif ( false === $is_favorite && 'bbp_favorite_add' === $action )443 } elseif ( false === $is_favorite && 'bbp_favorite_add' === $action ) { 428 444 $success = bbp_add_user_favorite( $user_id, $topic_id ); 445 } 429 446 430 447 // Do additional favorites actions … … 474 491 function bbp_get_forum_subscribers( $forum_id = 0 ) { 475 492 $forum_id = bbp_get_forum_id( $forum_id ); 476 if ( empty( $forum_id ) ) 477 return; 493 if ( empty( $forum_id ) ) { 494 return; 495 } 478 496 479 497 global $wpdb; … … 501 519 function bbp_get_topic_subscribers( $topic_id = 0 ) { 502 520 $topic_id = bbp_get_topic_id( $topic_id ); 503 if ( empty( $topic_id ) ) 504 return; 521 if ( empty( $topic_id ) ) { 522 return; 523 } 505 524 506 525 global $wpdb; … … 609 628 function bbp_get_user_subscribed_forum_ids( $user_id = 0 ) { 610 629 $user_id = bbp_get_user_id( $user_id ); 611 if ( empty( $user_id ) ) 612 return false; 630 if ( empty( $user_id ) ) { 631 return false; 632 } 613 633 614 634 $subscriptions = get_user_option( '_bbp_forum_subscriptions', $user_id ); … … 632 652 function bbp_get_user_subscribed_topic_ids( $user_id = 0 ) { 633 653 $user_id = bbp_get_user_id( $user_id ); 634 if ( empty( $user_id ) ) 635 return false; 654 if ( empty( $user_id ) ) { 655 return false; 656 } 636 657 637 658 $subscriptions = get_user_option( '_bbp_subscriptions', $user_id ); … … 1317 1338 1318 1339 // Bail if action is not 'bbp-update-user' 1319 if ( 'bbp-update-user' !== $action ) 1320 return; 1340 if ( 'bbp-update-user' !== $action ) { 1341 return; 1342 } 1321 1343 1322 1344 // Get the displayed user ID … … 1432 1454 // Validate user 1433 1455 $user_id = bbp_get_user_id( $user_id ); 1434 if ( empty( $user_id ) ) 1435 return false; 1456 if ( empty( $user_id ) ) { 1457 return false; 1458 } 1436 1459 1437 1460 // Try to get the topics … … 1457 1480 // Validate user 1458 1481 $user_id = bbp_get_user_id( $user_id ); 1459 if ( empty( $user_id ) ) 1460 return false; 1482 if ( empty( $user_id ) ) { 1483 return false; 1484 } 1461 1485 1462 1486 // Try to get the topics … … 1679 1703 1680 1704 // Bail if not editing a topic 1681 if ( ! bbp_is_single_user_edit() ) 1682 return; 1705 if ( ! bbp_is_single_user_edit() ) { 1706 return; 1707 } 1683 1708 1684 1709 // Default to false … … 1810 1835 // Bail if no username 1811 1836 $username = !empty( $_POST['log'] ) ? $_POST['log'] : ''; 1812 if ( empty( $username ) ) 1813 return; 1837 if ( empty( $username ) ) { 1838 return; 1839 } 1814 1840 1815 1841 global $wpdb; … … 1817 1843 // Bail if no user password to convert 1818 1844 $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON user_id = ID WHERE meta_key = '_bbp_class' AND user_login = '%s' LIMIT 1", $username ) ); 1819 if ( empty( $row ) || is_wp_error( $row ) ) 1820 return; 1845 if ( empty( $row ) || is_wp_error( $row ) ) { 1846 return; 1847 } 1821 1848 1822 1849 // Setup admin (to include converter)
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)