Changeset 5441
- Timestamp:
- 07/10/2014 03:54:41 PM (12 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 7 edited
-
admin/replies.php (modified) (1 diff)
-
extend/akismet.php (modified) (10 diffs)
-
extend/buddypress/activity.php (modified) (12 diffs)
-
extend/buddypress/functions.php (modified) (16 diffs)
-
extend/buddypress/groups.php (modified) (17 diffs)
-
extend/buddypress/loader.php (modified) (3 diffs)
-
extend/buddypress/members.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/replies.php
r5440 r5441 532 532 public function toggle_reply_notice() { 533 533 534 if ( $this->bail() ) return; 534 if ( $this->bail() ) { 535 return; 536 } 535 537 536 538 // Only proceed if GET is a reply toggle action -
trunk/src/includes/extend/akismet.php
r5321 r5441 64 64 65 65 // Add the checks 66 foreach ( $checks as $type => $functions ) 67 foreach ( $functions as $function => $priority ) 66 foreach ( $checks as $type => $functions ) { 67 foreach ( $functions as $function => $priority ) { 68 68 add_filter( $function, array( $this, $type . '_post' ), $priority ); 69 } 70 } 69 71 70 72 // Update post meta … … 103 105 104 106 // Post is not published 105 if ( bbp_get_public_status_id() !== $post_data['post_status'] ) 107 if ( bbp_get_public_status_id() !== $post_data['post_status'] ) { 106 108 return $post_data; 109 } 107 110 108 111 // Cast the post_author to 0 if it's empty 109 if ( empty( $post_data['post_author'] ) ) 112 if ( empty( $post_data['post_author'] ) ) { 110 113 $post_data['post_author'] = 0; 114 } 111 115 112 116 /** Author ************************************************************/ … … 138 142 139 143 // Use post parent for permalink 140 if ( !empty( $post_data['post_parent'] ) ) 144 if ( !empty( $post_data['post_parent'] ) ) { 141 145 $post_permalink = get_permalink( $post_data['post_parent'] ); 146 } 142 147 143 148 // Put post_data back into usable array … … 256 261 257 262 // Bail if get_post() fails 258 if ( empty( $_post ) ) 263 if ( empty( $_post ) ) { 259 264 return; 265 } 260 266 261 267 // Bail if we're spamming, but the post_status isn't spam 262 if ( ( 'spam' === $request_type ) && ( bbp_get_spam_status_id() !== $_post->post_status ) ) 268 if ( ( 'spam' === $request_type ) && ( bbp_get_spam_status_id() !== $_post->post_status ) ) { 263 269 return; 270 } 264 271 265 272 // Set some default post_data … … 282 289 // Use the original version stored in post_meta if available 283 290 $as_submitted = get_post_meta( $post_id, '_bbp_akismet_as_submitted', true ); 284 if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) ) 291 if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) ) { 285 292 $post_data = array_merge( $post_data, $as_submitted ); 293 } 286 294 287 295 // Add the reporter IP address … … 289 297 290 298 // Add some reporter info 291 if ( is_object( $current_user ) ) 299 if ( is_object( $current_user ) ) { 292 300 $post_data['reporter'] = $current_user->user_login; 301 } 293 302 294 303 // Add the current site domain 295 if ( is_object( $current_site ) ) 304 if ( is_object( $current_site ) ) { 296 305 $post_data['site_domain'] = $current_site->domain; 306 } 297 307 298 308 // Place your slide beneath the microscope … … 434 444 435 445 // Ensure we have a post object 436 if ( empty( $_post ) ) 446 if ( empty( $_post ) ) { 437 447 $_post = get_post( $post_id ); 448 } 438 449 439 450 // Set up Akismet last post data 440 if ( !empty( $this->last_post ) ) 451 if ( !empty( $this->last_post ) ) { 441 452 $as_submitted = $this->last_post['bbp_post_as_submitted']; 453 } 442 454 443 455 // wp_insert_post() might be called in other contexts. Ensure this is … … 587 599 588 600 // Save the terms for later in case the reply gets hammed 589 if ( !empty( $terms ) ) 601 if ( !empty( $terms ) ) { 590 602 update_post_meta( $reply_id, '_bbp_akismet_spam_terms', $terms ); 603 } 591 604 592 605 // Keep the topic tags the same for now … … 626 639 627 640 // Use specific IP (if provided) 628 if ( !empty( $ip ) && long2ip( ip2long( $ip ) ) ) 641 if ( !empty( $ip ) && long2ip( ip2long( $ip ) ) ) { 629 642 $http_host = $ip; 643 } 630 644 631 645 // WP HTTP class is available … … 651 665 652 666 // Bail if the response is an error 653 if ( is_wp_error( $response ) ) 667 if ( is_wp_error( $response ) ) { 654 668 return ''; 669 } 655 670 656 671 // No errors so return response -
trunk/src/includes/extend/buddypress/activity.php
r4995 r5441 271 271 272 272 // Bail if no activity ID is in post meta 273 if ( empty( $activity_id ) ) 273 if ( empty( $activity_id ) ) { 274 274 return null; 275 } 275 276 276 277 // Get the activity stream item, bail if it doesn't exist 277 278 $existing = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all', ) ); 278 if ( empty( $existing['total'] ) || ( 1 !== (int) $existing['total'] ) ) 279 if ( empty( $existing['total'] ) || ( 1 !== (int) $existing['total'] ) ) { 279 280 return null; 281 } 280 282 281 283 // Return the activity ID since we've verified the connection … … 296 298 297 299 // Already forced off, so comply 298 if ( false === $can_comment ) 300 if ( false === $can_comment ) { 299 301 return $can_comment; 302 } 300 303 301 304 // Check if blog & forum activity stream commenting is off … … 383 386 384 387 // Bail early if topic is by anonymous user 385 if ( !empty( $anonymous_data ) ) 386 return; 388 if ( !empty( $anonymous_data ) ) { 389 return; 390 } 387 391 388 392 // Bail if site is private 389 if ( !bbp_is_site_public() ) 390 return; 393 if ( !bbp_is_site_public() ) { 394 return; 395 } 391 396 392 397 // Validate activity data … … 396 401 397 402 // Bail if user is not active 398 if ( bbp_is_user_inactive( $user_id ) ) 399 return; 403 if ( bbp_is_user_inactive( $user_id ) ) { 404 return; 405 } 400 406 401 407 // Bail if topic is not published 402 if ( !bbp_is_topic_published( $topic_id ) ) 403 return; 408 if ( !bbp_is_topic_published( $topic_id ) ) { 409 return; 410 } 404 411 405 412 // User link for topic author … … 451 458 452 459 // Get activity ID, bail if it doesn't exist 453 if ( $activity_id = $this->get_activity_id( $topic_id ) ) 460 $activity_id = $this->get_activity_id( $topic_id ); 461 if ( !empty( $activity_id ) ) { 454 462 return bp_activity_delete( array( 'id' => $activity_id ) ); 463 } 455 464 456 465 return false; … … 460 469 * Update the activity stream entry when a topic status changes 461 470 * 462 * @param int $ post_id471 * @param int $topic_id 463 472 * @param obj $post 464 473 * @uses get_post_type() … … 475 484 476 485 // Bail early if not a topic 477 if ( get_post_type( $post ) !== bbp_get_topic_post_type() ) 478 return; 486 if ( get_post_type( $post ) !== bbp_get_topic_post_type() ) { 487 return; 488 } 479 489 480 490 $topic_id = bbp_get_topic_id( $topic_id ); 481 491 482 492 // Bail early if topic is by anonymous user 483 if ( bbp_is_topic_anonymous( $topic_id ) ) 484 return; 493 if ( bbp_is_topic_anonymous( $topic_id ) ) { 494 return; 495 } 485 496 486 497 // Action based on new status … … 524 535 525 536 // Do not log activity of anonymous users 526 if ( !empty( $anonymous_data ) ) 527 return; 537 if ( !empty( $anonymous_data ) ) { 538 return; 539 } 528 540 529 541 // Bail if site is private 530 if ( !bbp_is_site_public() ) 531 return; 542 if ( !bbp_is_site_public() ) { 543 return; 544 } 532 545 533 546 // Validate activity data … … 538 551 539 552 // Bail if user is not active 540 if ( bbp_is_user_inactive( $user_id ) ) 541 return; 553 if ( bbp_is_user_inactive( $user_id ) ) { 554 return; 555 } 542 556 543 557 // Bail if reply is not published 544 if ( !bbp_is_reply_published( $reply_id ) ) 545 return; 558 if ( !bbp_is_reply_published( $reply_id ) ) { 559 return; 560 } 546 561 547 562 // Setup links for activity stream … … 597 612 598 613 // Get activity ID, bail if it doesn't exist 599 if ( $activity_id = $this->get_activity_id( $reply_id ) ) 614 $activity_id = $this->get_activity_id( $reply_id ); 615 if ( !empty( $activity_id ) ) { 600 616 return bp_activity_delete( array( 'id' => $activity_id ) ); 617 } 601 618 602 619 return false; … … 606 623 * Update the activity stream entry when a reply status changes 607 624 * 608 * @param int $ post_id625 * @param int $reply_id 609 626 * @param obj $post 610 627 * @uses get_post_type() … … 622 639 623 640 // Bail early if not a reply 624 if ( get_post_type( $post ) !== bbp_get_reply_post_type() ) 625 return; 641 if ( get_post_type( $post ) !== bbp_get_reply_post_type() ) { 642 return; 643 } 626 644 627 645 $reply_id = bbp_get_reply_id( $reply_id ); 628 646 629 647 // Bail early if reply is by anonymous user 630 if ( bbp_is_reply_anonymous( $reply_id ) ) 631 return; 648 if ( bbp_is_reply_anonymous( $reply_id ) ) { 649 return; 650 } 632 651 633 652 // Action based on new status -
trunk/src/includes/extend/buddypress/functions.php
r5232 r5441 57 57 58 58 // Easy empty checking 59 if ( !empty( $user_id ) && is_numeric( $user_id ) ) 59 if ( !empty( $user_id ) && is_numeric( $user_id ) ) { 60 60 $bbp_user_id = $user_id; 61 } 61 62 62 63 // Currently viewing or editing a user 63 elseif ( ( true === $displayed_user_fallback ) && !empty( $did ) ) 64 elseif ( ( true === $displayed_user_fallback ) && !empty( $did ) ) { 64 65 $bbp_user_id = $did; 66 } 65 67 66 68 // Maybe fallback on the current_user ID 67 elseif ( ( true === $current_user_fallback ) && !empty( $lid ) ) 69 elseif ( ( true === $current_user_fallback ) && !empty( $lid ) ) { 68 70 $bbp_user_id = $lid; 71 } 69 72 70 73 return $bbp_user_id; … … 81 84 */ 82 85 function bbp_filter_is_single_user( $is = false ) { 83 if ( !empty( $is ) ) 86 if ( !empty( $is ) ) { 84 87 return $is; 88 } 85 89 86 90 return bp_is_user(); … … 97 101 */ 98 102 function bbp_filter_is_user_home( $is = false ) { 99 if ( !empty( $is ) ) 103 if ( !empty( $is ) ) { 100 104 return $is; 105 } 101 106 102 107 return bp_is_my_profile(); … … 293 298 294 299 // Use current group if none is set 295 if ( empty( $group_id ) ) 300 if ( empty( $group_id ) ) { 296 301 $group_id = bp_get_current_group_id(); 302 } 297 303 298 304 // Get the forums 299 if ( !empty( $group_id ) ) 305 if ( !empty( $group_id ) ) { 300 306 $forum_ids = groups_get_groupmeta( $group_id, 'forum_id' ); 307 } 301 308 302 309 // Make sure result is an array 303 if ( !is_array( $forum_ids ) ) 310 if ( !is_array( $forum_ids ) ) { 304 311 $forum_ids = (array) $forum_ids; 312 } 305 313 306 314 // Trim out any empty array items … … 322 330 323 331 // Use current group if none is set 324 if ( empty( $forum_id ) ) 332 if ( empty( $forum_id ) ) { 325 333 $forum_id = bbp_get_forum_id(); 334 } 326 335 327 336 // Get the forums 328 if ( !empty( $forum_id ) ) 337 if ( !empty( $forum_id ) ) { 329 338 $group_ids = get_post_meta( $forum_id, '_bbp_group_ids', true ); 339 } 330 340 331 341 // Make sure result is an array 332 if ( !is_array( $group_ids ) ) 342 if ( !is_array( $group_ids ) ) { 333 343 $group_ids = (array) $group_ids; 344 } 334 345 335 346 // Trim out any empty array items … … 348 359 349 360 // Use current group if none is set 350 if ( empty( $group_id ) ) 361 if ( empty( $group_id ) ) { 351 362 $group_id = bp_get_current_group_id(); 363 } 352 364 353 365 // Trim out any empties … … 386 398 387 399 // Use current group if none is set 388 if ( empty( $group_id ) ) 400 if ( empty( $group_id ) ) { 389 401 $group_id = bp_get_current_group_id(); 402 } 390 403 391 404 // Get current group IDs … … 411 424 412 425 // Use current group if none is set 413 if ( empty( $group_id ) ) 426 if ( empty( $group_id ) ) { 414 427 $group_id = bp_get_current_group_id(); 428 } 415 429 416 430 // Get current group IDs … … 436 450 437 451 // Use current group if none is set 438 if ( empty( $group_id ) ) 452 if ( empty( $group_id ) ) { 439 453 $group_id = bp_get_current_group_id(); 454 } 440 455 441 456 // Get current group IDs … … 461 476 462 477 // Use current group if none is set 463 if ( empty( $group_id ) ) 478 if ( empty( $group_id ) ) { 464 479 $group_id = bp_get_current_group_id(); 480 } 465 481 466 482 // Get current group IDs … … 483 499 484 500 // Use current group if none is set 485 if ( empty( $group_id ) ) 501 if ( empty( $group_id ) ) { 486 502 $group_id = bp_get_current_group_id(); 503 } 487 504 488 505 // Get current group IDs … … 556 573 557 574 // Bail if user is not logged in or not looking at a group 558 if ( ! is_user_logged_in() || ! bp_is_group() ) 575 if ( ! is_user_logged_in() || ! bp_is_group() ) { 559 576 return false; 577 } 560 578 561 579 $bbp = bbpress(); 562 580 563 581 // Set the global if not set 564 if ( ! isset( $bbp->current_user->is_group_admin ) ) 582 if ( ! isset( $bbp->current_user->is_group_admin ) ) { 565 583 $bbp->current_user->is_group_admin = groups_is_user_admin( get_current_user_id(), bp_get_current_group_id() ); 584 } 566 585 567 586 // Return the value … … 585 604 586 605 // Bail if user is not logged in or not looking at a group 587 if ( ! is_user_logged_in() || ! bp_is_group() ) 606 if ( ! is_user_logged_in() || ! bp_is_group() ) { 588 607 return false; 608 } 589 609 590 610 $bbp = bbpress(); 591 611 592 612 // Set the global if not set 593 if ( ! isset( $bbp->current_user->is_group_mod ) ) 613 if ( ! isset( $bbp->current_user->is_group_mod ) ) { 594 614 $bbp->current_user->is_group_mod = groups_is_user_mod( get_current_user_id(), bp_get_current_group_id() ); 615 } 595 616 596 617 // Return the value … … 614 635 615 636 // Bail if user is not logged in or not looking at a group 616 if ( ! is_user_logged_in() || ! bp_is_group() ) 637 if ( ! is_user_logged_in() || ! bp_is_group() ) { 617 638 return false; 639 } 618 640 619 641 $bbp = bbpress(); 620 642 621 643 // Set the global if not set 622 if ( ! isset( $bbp->current_user->is_group_member ) ) 644 if ( ! isset( $bbp->current_user->is_group_member ) ) { 623 645 $bbp->current_user->is_group_member = groups_is_user_member( get_current_user_id(), bp_get_current_group_id() ); 646 } 624 647 625 648 // Return the value … … 643 666 644 667 // Bail if user is not logged in or not looking at a group 645 if ( ! is_user_logged_in() || ! bp_is_group() ) 668 if ( ! is_user_logged_in() || ! bp_is_group() ) { 646 669 return false; 670 } 647 671 648 672 $bbp = bbpress(); 649 673 650 674 // Set the global if not set 651 if ( ! isset( $bbp->current_user->is_group_banned ) ) 675 if ( ! isset( $bbp->current_user->is_group_banned ) ) { 652 676 $bbp->current_user->is_group_banned = groups_is_user_banned( get_current_user_id(), bp_get_current_group_id() ); 677 } 653 678 654 679 // Return the value … … 672 697 673 698 // Bail if user is not logged in or not looking at a group 674 if ( ! is_user_logged_in() || ! bp_is_group() ) 699 if ( ! is_user_logged_in() || ! bp_is_group() ) { 675 700 return false; 701 } 676 702 677 703 $bbp = bbpress(); 678 704 679 705 // Set the global if not set 680 if ( ! isset( $bbp->current_user->is_group_creator ) ) 706 if ( ! isset( $bbp->current_user->is_group_creator ) ) { 681 707 $bbp->current_user->is_group_creator = groups_is_user_creator( get_current_user_id(), bp_get_current_group_id() ); 708 } 682 709 683 710 // Return the value -
trunk/src/includes/extend/buddypress/groups.php
r5416 r5441 179 179 180 180 // Bail if not viewing a single group 181 if ( ! bp_is_group() ) 181 if ( ! bp_is_group() ) { 182 182 return; 183 } 183 184 184 185 // Are forums enabled for this group? … … 328 329 329 330 // Bail if not a POST action 330 if ( ! bbp_is_post_request() ) 331 if ( ! bbp_is_post_request() ) { 331 332 return; 333 } 332 334 333 335 // Admin Nonce check … … 466 468 467 469 // Bail if not looking at this screen 468 if ( !bp_is_group_creation_step( $this->slug ) ) 470 if ( !bp_is_group_creation_step( $this->slug ) ) { 469 471 return false; 472 } 470 473 471 474 // Check for possibly empty group_id … … 509 512 $forum_ids = bbp_get_group_forum_ids( $group_id ); 510 513 511 if ( !empty( $forum_ids ) ) 514 if ( !empty( $forum_ids ) ) { 512 515 $forum_id = (int) is_array( $forum_ids ) ? $forum_ids[0] : $forum_ids; 516 } 513 517 514 518 // Create a forum, or not … … 517 521 518 522 // Bail if initial content was already created 519 if ( !empty( $forum_id ) ) 523 if ( !empty( $forum_id ) ) { 520 524 return; 525 } 521 526 522 527 // Set the default forum status … … 605 610 606 611 // Bail if no forum_id was passed 607 if ( empty( $forum_args['forum_id'] ) ) 612 if ( empty( $forum_args['forum_id'] ) ) { 608 613 return; 614 } 609 615 610 616 // Validate forum_id … … 631 637 632 638 // Bail if no forum_id was passed 633 if ( empty( $forum_args['forum_id'] ) ) 639 if ( empty( $forum_args['forum_id'] ) ) { 634 640 return; 641 } 635 642 636 643 // Validate forum_id … … 662 669 663 670 // Use the first forum ID 664 if ( empty( $forum_ids ) ) 671 if ( empty( $forum_ids ) ) { 665 672 return; 673 } 666 674 667 675 // Get the first forum ID … … 689 697 690 698 // Bail if group cannot be found 691 if ( empty( $group ) ) 699 if ( empty( $group ) ) { 692 700 return false; 701 } 693 702 694 703 // Set forum enabled status … … 1033 1042 1034 1043 // If this is a group of any kind, empty out the redirect URL 1035 if ( bp_is_group_admin_screen( $this->slug ) ) 1044 if ( bp_is_group_admin_screen( $this->slug ) ) { 1036 1045 $redirect_url = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/' . $this->slug ); 1046 } 1037 1047 1038 1048 return $redirect_url; … … 1132 1142 1133 1143 // if a forum is not enabled, we don't need to add this field 1134 if ( ! bp_group_is_forum_enabled() ) 1135 return; ?> 1144 if ( ! bp_group_is_forum_enabled() ) { 1145 return; 1146 } ?> 1136 1147 1137 1148 <input type="hidden" name="group-show-forum" id="group-show-forum" value="1" /> … … 1197 1208 1198 1209 // Bail if the post isn't associated with a group 1199 if ( empty( $group_ids ) ) 1210 if ( empty( $group_ids ) ) { 1200 1211 return $url; 1212 } 1201 1213 1202 1214 // @todo Multiple group forums/forum groups … … 1268 1280 $new = $this->maybe_map_permalink_to_group( $reply_id ); 1269 1281 1270 if ( empty( $new ) ) 1282 if ( empty( $new ) ) { 1271 1283 return $url; 1284 } 1272 1285 1273 1286 return trailingslashit( $new ) . bbpress()->edit_id . '/'; … … 1334 1347 $new = $this->maybe_map_permalink_to_group( bbp_get_forum_id() ); 1335 1348 1336 if ( empty( $new ) ) 1349 if ( empty( $new ) ) { 1337 1350 return $args; 1351 } 1338 1352 1339 1353 global $wp_rewrite; … … 1357 1371 public function replies_pagination( $args ) { 1358 1372 $new = $this->maybe_map_permalink_to_group( bbp_get_topic_id() ); 1359 if ( empty( $new ) ) 1373 if ( empty( $new ) ) { 1360 1374 return $args; 1375 } 1361 1376 1362 1377 global $wp_rewrite; … … 1393 1408 1394 1409 // Bail if not a group forum 1395 if ( empty( $group_ids ) ) 1410 if ( empty( $group_ids ) ) { 1396 1411 return; 1412 } 1397 1413 1398 1414 // Use the first group ID … … 1428 1444 1429 1445 // Not posting from a BuddyPress group? stop now! 1430 if ( empty( $group ) ) 1446 if ( empty( $group ) ) { 1431 1447 return $args; 1448 } 1432 1449 1433 1450 // Set the component to 'groups' so the activity item shows up in the group -
trunk/src/includes/extend/buddypress/loader.php
r5155 r5441 90 90 91 91 // Define the parent forum ID 92 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 92 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) { 93 93 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 94 } 94 95 95 96 // Define a slug, if necessary 96 if ( !defined( 'BP_FORUMS_SLUG' ) ) 97 if ( !defined( 'BP_FORUMS_SLUG' ) ) { 97 98 define( 'BP_FORUMS_SLUG', $this->id ); 99 } 98 100 99 101 // All arguments for forums component … … 165 167 166 168 // Stop if there is no user displayed or logged in 167 if ( !is_user_logged_in() && !bp_displayed_user_id() ) 169 if ( !is_user_logged_in() && !bp_displayed_user_id() ) { 168 170 return; 171 } 169 172 170 173 // Define local variable(s) … … 182 185 183 186 // Determine user to use 184 if ( bp_displayed_user_id() ) 187 if ( bp_displayed_user_id() ) { 185 188 $user_domain = bp_displayed_user_domain(); 186 elseif ( bp_loggedin_user_domain() )189 } elseif ( bp_loggedin_user_domain() ) { 187 190 $user_domain = bp_loggedin_user_domain(); 188 else191 } else { 189 192 return; 193 } 190 194 191 195 // User link -
trunk/src/includes/extend/buddypress/members.php
r4941 r5441 159 159 160 160 // Special handling for forum component 161 if ( ! bp_is_my_profile() ) 161 if ( ! bp_is_my_profile() ) { 162 162 return; 163 } 163 164 164 165 global $wp_query;
Note: See TracChangeset
for help on using the changeset viewer.