Ticket #2645: 2645.diff
File 2645.diff, 42.0 KB (added by , 11 years ago) |
---|
-
src/includes/admin/replies.php
155 155 'content' => 156 156 '<p>' . __( 'Hovering over a row in the replies list will display action links that allow you to manage your reply. You can perform the following actions:', 'bbpress' ) . '</p>' . 157 157 '<ul>' . 158 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.', 'bbpress' ) . '</li>' . 159 //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.', 'bbpress' ) . '</li>' . 160 '<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 162 '<li>' . __( '<strong>Preview</strong> will show you what your draft reply will look like if you publish it. View will take you to your live site to view the reply. Which link is available depends on your reply’s status.', 'bbpress' ) . '</li>' . 158 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.', 'bbpress' ) . '</li>' . 159 //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.', 'bbpress' ) . '</li>' . 160 '<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 162 '<li>' . __( '<strong>View</strong> will take you to your live site to view the reply.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.', 'bbpress' ) . '</li>' . 163 164 '</ul>' 164 165 ) ); 165 166 … … 417 418 background-color: #faeaea; 418 419 } 419 420 421 .status-pending { 422 background-color: #fef7f1; 423 } 424 420 425 /*]]>*/ 421 426 </style> 422 427 … … 449 454 if ( $this->bail() ) return; 450 455 451 456 // Only proceed if GET is a reply toggle action 452 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam' ) ) && !empty( $_GET['reply_id'] ) ) {457 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam', 'bbp_toggle_reply_approve' ) ) && !empty( $_GET['reply_id'] ) ) { 453 458 $action = $_GET['action']; // What action is taking place? 454 459 $reply_id = (int) $_GET['reply_id']; // What's the reply id? 455 460 $success = false; // Flag 456 461 $post_data = array( 'ID' => $reply_id ); // Prelim array 462 $reply = bbp_get_reply( $reply_id ); 457 463 458 464 // Get reply and die if empty 459 $reply = bbp_get_reply( $reply_id ); 460 if ( empty( $reply ) ) // Which reply? 465 if ( empty( $reply ) ) { 461 466 wp_die( __( 'The reply was not found!', 'bbpress' ) ); 467 } 462 468 463 if ( !current_user_can( 'moderate', $reply->ID ) ) // What is the user doing here? 469 // What is the user doing here? 470 if ( ! current_user_can( 'moderate', $reply->ID ) ) { 464 471 wp_die( __( 'You do not have the permission to do that!', 'bbpress' ) ); 472 } 465 473 466 474 switch ( $action ) { 475 case 'bbp_toggle_reply_approve' : 476 check_admin_referer( 'approve-reply_' . $reply_id ); 477 478 $is_approve = bbp_is_reply_pending( $reply_id ); 479 $message = $is_approve ? 'approved' : 'unapproved'; 480 $success = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id ); 481 482 break; 483 467 484 case 'bbp_toggle_reply_spam' : 468 485 check_admin_referer( 'spam-reply_' . $reply_id ); 469 486 … … 474 491 break; 475 492 } 476 493 477 $success = wp_update_post( $post_data );478 494 $message = array( 'bbp_reply_toggle_notice' => $message, 'reply_id' => $reply->ID ); 479 495 480 496 if ( false === $success || is_wp_error( $success ) ) … … 511 527 if ( $this->bail() ) return; 512 528 513 529 // Only proceed if GET is a reply toggle action 514 if ( bbp_is_get_request() && !empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed' ) ) && !empty( $_GET['reply_id'] ) ) {530 if ( bbp_is_get_request() && !empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && !empty( $_GET['reply_id'] ) ) { 515 531 $notice = $_GET['bbp_reply_toggle_notice']; // Which notice? 516 532 $reply_id = (int) $_GET['reply_id']; // What's the reply id? 517 533 $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure? 518 534 519 535 // Empty? No reply? 520 if ( empty( $notice ) || empty( $reply_id ) ) 536 if ( empty( $notice ) || empty( $reply_id ) ) { 521 537 return; 538 } 522 539 523 540 // Get reply and bail if empty 524 541 $reply = bbp_get_reply( $reply_id ); 525 if ( empty( $reply ) ) 542 if ( empty( $reply ) ) { 526 543 return; 544 } 527 545 528 546 $reply_title = bbp_get_reply_title( $reply->ID ); 529 547 530 548 switch ( $notice ) { 531 549 case 'spammed' : 532 $message = $is_failure === true ? sprintf( __( 'There was a problem marking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully marked as spam.','bbpress' ), $reply_title );550 $message = $is_failure === true ? sprintf( __( 'There was a problem marking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully marked as spam.', 'bbpress' ), $reply_title ); 533 551 break; 534 552 535 553 case 'unspammed' : 536 554 $message = $is_failure === true ? sprintf( __( 'There was a problem unmarking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully unmarked as spam.', 'bbpress' ), $reply_title ); 537 555 break; 556 557 case 'approved' : 558 $message = $is_failure === true ? sprintf( __( 'There was a problem approving the reply "%1$s".', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully approved.', 'bbpress' ), $reply_title ); 559 break; 560 561 case 'unapproved' : 562 $message = $is_failure === true ? sprintf( __( 'There was a problem unapproving the reply "%1$s".', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully unapproved.', 'bbpress' ), $reply_title ); 563 break; 538 564 } 539 565 540 566 // Do additional reply toggle notice filters (admin side) … … 718 744 */ 719 745 public function row_actions( $actions, $reply ) { 720 746 721 if ( $this->bail() ) return $actions; 747 if ( $this->bail() ) return $actions; { 748 unset( $actions['inline hide-if-no-js'] ); 749 } 722 750 723 unset( $actions['inline hide-if-no-js'] );724 725 751 // Reply view links to topic 726 752 $actions['view'] = '<a href="' . esc_url( bbp_get_reply_url( $reply->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 727 753 … … 729 755 if ( ( bbp_get_trash_status_id() === $reply->post_status ) && !current_user_can( 'view_trash' ) ) 730 756 unset( $actions['view'] ); 731 757 758 // Pending 759 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 760 $approve_uri = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_approve' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'approve-reply_' . $reply->ID ); 761 if ( bbp_is_reply_published( $reply->ID ) ) { 762 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this reply', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove reply', 'bbpress' ) . '</a>'; 763 } elseif ( ! bbp_is_reply_private( $reply->ID ) ) { 764 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply', 'bbpress' ) . '">' . _x( 'Approve', 'Approve reply', 'bbpress' ) . '</a>'; 765 } 766 732 767 // Only show the actions if the user is capable of viewing them 733 768 if ( current_user_can( 'moderate', $reply->ID ) ) { 734 769 if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) { -
src/includes/admin/topics.php
154 154 'content' => 155 155 '<p>' . __( 'Hovering over a row in the topics list will display action links that allow you to manage your topic. You can perform the following actions:', 'bbpress' ) . '</p>' . 156 156 '<ul>' . 157 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.', 'bbpress' ) . '</li>' . 158 '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 159 '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 160 '<li>' . __( '<strong>Preview</strong> will show you what your draft topic will look like if you publish it. View will take you to your live site to view the topic. Which link is available depends on your topic’s status.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Close</strong> will mark the selected topic as ’closed’ and disable the option to post new replies to the topic.', 'bbpress' ) . '</li>' . 162 '<li>' . __( '<strong>Stick</strong> will keep the selected topic ’pinned’ to the top the parent forum topic list.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic ’pinned’ to the top of ALL forums and be visable in any forums topics list.', 'bbpress' ) . '</li>' . 157 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.', 'bbpress' ) . '</li>' . 158 '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 159 '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 160 '<li>' . __( '<strong>View</strong> will take you to your live site to view the topic.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.', 'bbpress' ) . '</li>' . 162 '<li>' . __( '<strong>Close</strong> will mark the selected topic as ’closed’ and disable the option to post new replies to the topic.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>Stick</strong> will keep the selected topic ’pinned’ to the top the parent forum topic list.', 'bbpress' ) . '</li>' . 164 '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic ’pinned’ to the top of ALL forums and be visable in any forums topics list.', 'bbpress' ) . '</li>' . 164 165 '</ul>' 165 166 ) ); 166 167 … … 433 434 background-color: #faeaea; 434 435 } 435 436 437 .status-pending { 438 background-color: #fef7f1; 439 } 440 436 441 /*]]>*/ 437 442 </style> 438 443 … … 473 478 if ( $this->bail() ) return; 474 479 475 480 // Only proceed if GET is a topic toggle action 476 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam' ) ) && !empty( $_GET['topic_id'] ) ) {481 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_approve' ) ) && !empty( $_GET['topic_id'] ) ) { 477 482 $action = $_GET['action']; // What action is taking place? 478 483 $topic_id = (int) $_GET['topic_id']; // What's the topic id? 479 484 $success = false; // Flag … … 481 486 $topic = bbp_get_topic( $topic_id ); 482 487 483 488 // Bail if topic is missing 484 if ( empty( $topic ) ) 489 if ( empty( $topic ) ) { 485 490 wp_die( __( 'The topic was not found!', 'bbpress' ) ); 491 } 486 492 487 if ( !current_user_can( 'moderate', $topic->ID ) ) // What is the user doing here? 493 // What is the user doing here? 494 if ( ! current_user_can( 'moderate', $topic->ID ) ) { 488 495 wp_die( __( 'You do not have the permission to do that!', 'bbpress' ) ); 496 } 489 497 490 498 switch ( $action ) { 499 case 'bbp_toggle_topic_approve' : 500 check_admin_referer( 'approve-topic_' . $topic_id ); 501 502 $is_approve = bbp_is_topic_pending( $topic_id ); 503 $message = true === $is_approve ? 'approved' : 'unapproved'; 504 $success = true === $is_approve ? bbp_approve_topic( $topic_id ) : bbp_unapprove_topic( $topic_id ); 505 506 break; 507 491 508 case 'bbp_toggle_topic_close' : 492 509 check_admin_referer( 'close-topic_' . $topic_id ); 493 510 … … 554 571 if ( $this->bail() ) return; 555 572 556 573 // Only proceed if GET is a topic toggle action 557 if ( bbp_is_get_request() && !empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed' ) ) && !empty( $_GET['topic_id'] ) ) {574 if ( bbp_is_get_request() && !empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && !empty( $_GET['topic_id'] ) ) { 558 575 $notice = $_GET['bbp_topic_toggle_notice']; // Which notice? 559 576 $topic_id = (int) $_GET['topic_id']; // What's the topic id? 560 577 $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure? 561 578 562 // Bai sif no topic_id or notice563 if ( empty( $notice ) || empty( $topic_id ) ) 579 // Bail if no topic_id or notice 580 if ( empty( $notice ) || empty( $topic_id ) ) { 564 581 return; 582 } 565 583 566 584 // Bail if topic is missing 567 585 $topic = bbp_get_topic( $topic_id ); 568 if ( empty( $topic ) ) 586 if ( empty( $topic ) ) { 569 587 return; 588 } 570 589 571 590 $topic_title = bbp_get_topic_title( $topic->ID ); 572 591 … … 598 617 case 'unspammed' : 599 618 $message = $is_failure === true ? sprintf( __( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) : sprintf( __( 'Topic "%1$s" successfully unmarked as spam.', 'bbpress' ), $topic_title ); 600 619 break; 620 621 case 'approved' : 622 $message = $is_failure === true ? sprintf( __( 'There was a problem approving the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( __( 'Topic "%1$s" successfully approved.', 'bbpress' ), $topic_title ); 623 break; 624 625 case 'unapproved' : 626 $message = $is_failure === true ? sprintf( __( 'There was a problem unapproving the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( __( 'Topic "%1$s" successfully unapproved.', 'bbpress' ), $topic_title ); 627 break; 601 628 } 602 629 603 630 // Do additional topic toggle notice filters (admin side) … … 768 795 */ 769 796 public function row_actions( $actions, $topic ) { 770 797 771 if ( $this->bail() ) return $actions; 798 if ( $this->bail() ) return $actions; { 799 unset( $actions['inline hide-if-no-js'] ); 800 } 772 801 773 unset( $actions['inline hide-if-no-js'] );774 775 802 // Show view link if it's not set, the topic is trashed and the user can view trashed topics 776 if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) 803 if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) { 777 804 $actions['view'] = '<a href="' . esc_url( bbp_get_topic_permalink( $topic->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 805 } 778 806 779 807 // Only show the actions if the user is capable of viewing them :) 780 808 if ( current_user_can( 'moderate', $topic->ID ) ) { 781 809 810 // Pending 811 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 812 $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID ); 813 if ( bbp_is_topic_published( $topic->ID ) ) { 814 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>'; 815 } elseif ( ! bbp_is_topic_private( $topic->ID ) ) { 816 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic', 'bbpress' ) . '">' . _x( 'Approve', 'Approve Topic', 'bbpress' ) . '</a>'; 817 $actions['view'] = '<a href="' . esc_url( bbp_get_topic_permalink( $topic->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 818 } 819 782 820 // Close 783 821 // Show the 'close' and 'open' link on published and closed posts only 784 822 if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) { … … 789 827 $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Open this topic', 'bbpress' ) . '">' . _x( 'Open', 'Open a Topic', 'bbpress' ) . '</a>'; 790 828 } 791 829 792 // Dont show sticky if topic links is spam or trash793 if ( ! bbp_is_topic_spam( $topic->ID ) && !bbp_is_topic_trash( $topic->ID ) ) {830 // Dont show sticky if topic links is spam, trash or pending 831 if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) { 794 832 795 833 // Sticky 796 834 $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_' . $topic->ID ); -
src/includes/core/actions.php
155 155 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' ); 156 156 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 ); 157 157 158 // Before Delete/Trash/Untrash Topic158 // Before Delete/Trash/Untrash Forum 159 159 add_action( 'wp_trash_post', 'bbp_trash_forum' ); 160 160 add_action( 'trash_post', 'bbp_trash_forum' ); 161 161 add_action( 'untrash_post', 'bbp_untrash_forum' ); 162 162 add_action( 'delete_post', 'bbp_delete_forum' ); 163 163 164 // After Deleted/Trashed/Untrashed Topic164 // After Deleted/Trashed/Untrashed Forum 165 165 add_action( 'trashed_post', 'bbp_trashed_forum' ); 166 166 add_action( 'untrashed_post', 'bbp_untrashed_forum' ); 167 167 add_action( 'deleted_post', 'bbp_deleted_forum' ); … … 242 242 add_action( 'bbp_deleted_topic', 'bbp_update_topic_walker' ); 243 243 add_action( 'bbp_spammed_topic', 'bbp_update_topic_walker' ); 244 244 add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' ); 245 add_action( 'bbp_approve_topic', 'bbp_update_topic_walker' ); 246 add_action( 'bbp_unapprove_topic', 'bbp_update_topic_walker' ); 245 247 246 248 // Update reply branch 247 249 add_action( 'bbp_trashed_reply', 'bbp_update_reply_walker' ); … … 249 251 add_action( 'bbp_deleted_reply', 'bbp_update_reply_walker' ); 250 252 add_action( 'bbp_spammed_reply', 'bbp_update_reply_walker' ); 251 253 add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' ); 254 add_action( 'bbp_approve_reply', 'bbp_update_reply_walker' ); 255 add_action( 'bbp_unapprove_reply', 'bbp_update_reply_walker' ); 252 256 253 257 // Users topic & reply counts 254 258 add_action( 'bbp_new_topic', 'bbp_increase_user_topic_count' ); … … 267 271 add_action( 'bbp_untrash_topic', 'bbp_untrash_topic_replies' ); 268 272 add_action( 'bbp_delete_topic', 'bbp_delete_topic_replies' ); 269 273 add_action( 'bbp_spam_topic', 'bbp_spam_topic_replies' ); 270 add_action( 'bbp_unspam_topic', 'bbp_unspam_topic_replies' );274 add_action( 'bbp_unspam_topic', 'bbp_unspam_topic_replies' ); 271 275 272 276 // User status 273 277 // @todo make these sub-actions … … 332 336 // Maybe convert the users password 333 337 add_action( 'bbp_login_form_login', 'bbp_user_maybe_convert_pass' ); 334 338 335 add_action( 'bbp_activation', 'bbp_add_activation_redirect' ); 336 No newline at end of file 339 add_action( 'bbp_activation', 'bbp_add_activation_redirect' ); -
src/includes/replies/functions.php
1143 1143 * @return array 1144 1144 */ 1145 1145 function bbp_get_reply_ancestors( $reply_id = 0 ) { 1146 1146 1147 1147 // Validation 1148 1148 $reply_id = bbp_get_reply_id( $reply_id ); 1149 1149 $ancestors = array(); … … 1446 1446 bbp_update_reply_to( $child->ID, $parent ); 1447 1447 1448 1448 // Remove reply_to from moved reply 1449 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1449 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1450 1450 1451 1451 // It is a new topic and we need to set some default metas to make 1452 1452 // the topic display in bbp_has_topics() list … … 1558 1558 // Setup possible get actions 1559 1559 $possible_actions = array( 1560 1560 'bbp_toggle_reply_spam', 1561 'bbp_toggle_reply_trash' 1561 'bbp_toggle_reply_trash', 1562 'bbp_toggle_reply_approve' 1562 1563 ); 1563 1564 1564 1565 // Bail if actions aren't meant for this function … … 1585 1586 // What action are we trying to perform? 1586 1587 switch ( $action ) { 1587 1588 1589 // Toggle approve 1590 case 'bbp_toggle_reply_approve' : 1591 check_ajax_referer( 'approve-reply_' . $reply_id ); 1592 1593 $is_approve = bbp_is_reply_pending( $reply_id ); 1594 $success = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id ); 1595 $failure = $is_approve ? __( '<strong>ERROR</strong>: There was a problem approving the reply!', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving thereply!', 'bbpress' ); 1596 $view_all = !$is_approve; 1597 1598 break; 1599 1588 1600 // Toggle spam 1589 1601 case 'bbp_toggle_reply_spam' : 1590 1602 check_ajax_referer( 'spam-reply_' . $reply_id ); … … 1782 1794 return $reply_id; 1783 1795 } 1784 1796 1797 /** 1798 * Approves a reply 1799 * 1800 * @since bbPress (rXXXX) 1801 * 1802 * @param int $reply_id Reply id 1803 * @uses bbp_get_reply() To get the reply 1804 * @uses do_action() Calls 'bbp_approve_reply' with the reply id 1805 /* @uses add_post_meta() To add the previous status to a meta 1806 /* @uses delete_post_meta() To delete the previous status meta 1807 * @uses wp_update_post() To update the reply with the new status 1808 * @uses do_action() Calls 'bbp_approved_reply' with the reply id 1809 * @return mixed False or {@link WP_Error} on failure, reply id on success 1810 */ 1811 function bbp_approve_reply( $reply_id = 0 ) { 1812 1813 // Get reply 1814 $reply = bbp_get_reply( $reply_id ); 1815 if ( empty( $reply ) ) { 1816 return $reply; 1817 } 1818 1819 // Bail if already approved 1820 if ( bbp_get_pending_status_id() !== $reply->post_status ) { 1821 return false; 1822 } 1823 1824 // Execute pre pending code 1825 do_action( 'bbp_approve_reply', $reply_id ); 1826 1827 // Set publish status 1828 $reply->post_status = bbp_get_public_status_id(); 1829 1830 // No revisions 1831 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 1832 1833 // Update reply 1834 $reply_id = wp_update_post( $reply ); 1835 1836 // Execute post pending code 1837 do_action( 'bbp_approved_reply', $reply_id ); 1838 1839 // Return reply_id 1840 return $reply_id; 1841 } 1842 1843 /** 1844 * Unapproves a reply 1845 * 1846 * @since bbPress (rXXXX) 1847 * 1848 * @param int $reply_id Reply id 1849 * @uses bbp_get_reply() To get the reply 1850 * @uses do_action() Calls 'bbp_unapprove_reply' with the reply id 1851 /* @uses get_post_meta() To get the previous status 1852 /* @uses delete_post_meta() To delete the previous status meta 1853 * @uses wp_update_post() To update the reply with the new status 1854 * @uses do_action() Calls 'bbp_unapproved_reply' with the reply id 1855 * @return mixed False or {@link WP_Error} on failure, reply id on success 1856 */ 1857 function bbp_unapprove_reply( $reply_id = 0 ) { 1858 1859 // Get reply 1860 $reply = bbp_get_reply( $reply_id ); 1861 if ( empty( $reply ) ) { 1862 return $reply; 1863 } 1864 1865 // Bail if already pending 1866 if ( bbp_get_pending_status_id() === $reply->post_status ) { 1867 return false; 1868 } 1869 1870 // Execute pre open code 1871 do_action( 'bbp_unapprove_reply', $reply_id ); 1872 1873 // Set pending status 1874 $reply->post_status = bbp_get_pending_status_id(); 1875 1876 // No revisions 1877 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 1878 1879 // Update reply 1880 $reply_id = wp_update_post( $reply ); 1881 1882 // Execute post open code 1883 do_action( 'bbp_unapproved_reply', $reply_id ); 1884 1885 // Return reply_id 1886 return $reply_id; 1887 } 1888 1785 1889 /** Before Delete/Trash/Untrash ***********************************************/ 1786 1890 1787 1891 /** … … 2290 2394 2291 2395 /** 2292 2396 * Validate a `reply_to` field for hierarchical replies 2293 * 2397 * 2294 2398 * Checks for 2 scenarios: 2295 2399 * -- The reply to ID is actually a reply 2296 2400 * -- The reply to ID does not match the current reply -
src/includes/replies/template.php
150 150 bbp_get_public_status_id(), 151 151 bbp_get_closed_status_id(), 152 152 bbp_get_spam_status_id(), 153 bbp_get_trash_status_id() 153 bbp_get_trash_status_id(), 154 bbp_get_pending_status_id() 154 155 ); 155 156 156 157 // Add support for private status … … 944 945 } 945 946 946 947 /** 948 * Is the reply pending? 949 * 950 * @since bbPress (rXXXX) 951 * 952 * @param int $reply_id Optional. Topic id 953 * @uses bbp_get_reply_id() To get the reply id 954 * @uses bbp_get_reply_status() To get the reply status 955 * @uses apply_filters() Calls 'bbp_is_reply_pending' with the reply id 956 * @return bool True if pending, false if not. 957 */ 958 function bbp_is_reply_pending( $reply_id = 0 ) { 959 $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) ) === bbp_get_pending_status_id(); 960 return (bool) apply_filters( 'bbp_is_reply_pending', (bool) $reply_status, $reply_id ); 961 } 962 963 /** 964 * Is the reply private? 965 * 966 * @since bbPress (rXXXX) 967 * 968 * @param int $reply_id Optional. Topic id 969 * @uses bbp_get_reply_id() To get the reply id 970 * @uses bbp_get_reply_status() To get the reply status 971 * @uses apply_filters() Calls 'bbp_is_reply_private' with the reply id 972 * @return bool True if private, false if not. 973 */ 974 function bbp_is_reply_private( $reply_id = 0 ) { 975 $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) ) === bbp_get_private_status_id(); 976 return (bool) apply_filters( 'bbp_is_reply_private', (bool) $reply_status, $reply_id ); 977 } 978 979 /** 947 980 * Is the reply by an anonymous user? 948 981 * 949 982 * @since bbPress (r2753) … … 1839 1872 // If no links were passed, default to the standard 1840 1873 if ( empty( $r['links'] ) ) { 1841 1874 $r['links'] = apply_filters( 'bbp_reply_admin_links', array( 1842 'edit' => bbp_get_reply_edit_link ( $r ), 1843 'move' => bbp_get_reply_move_link ( $r ), 1844 'split' => bbp_get_topic_split_link( $r ), 1845 'trash' => bbp_get_reply_trash_link( $r ), 1846 'spam' => bbp_get_reply_spam_link ( $r ), 1847 'reply' => bbp_get_reply_to_link ( $r ) 1875 'edit' => bbp_get_reply_edit_link ( $r ), 1876 'move' => bbp_get_reply_move_link ( $r ), 1877 'split' => bbp_get_topic_split_link ( $r ), 1878 'trash' => bbp_get_reply_trash_link ( $r ), 1879 'spam' => bbp_get_reply_spam_link ( $r ), 1880 'approve' => bbp_get_reply_approve_link( $r ), 1881 'reply' => bbp_get_reply_to_link ( $r ) 1848 1882 ), $r['id'] ); 1849 1883 } 1850 1884 1851 1885 // See if links need to be unset 1852 1886 $reply_status = bbp_get_reply_status( $r['id'] ); 1853 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {1887 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) { 1854 1888 1855 1889 // Spam link shouldn't be visible on trashed topics 1856 1890 if ( bbp_get_trash_status_id() === $reply_status ) { … … 2254 2288 } 2255 2289 2256 2290 /** 2291 * Output the approve link of the reply 2292 * 2293 * @since bbPress (rXXXX) 2294 * 2295 * @param mixed $args See {@link bbp_get_reply_approve_link()} 2296 * @uses bbp_get_reply_approve_link() To get the reply approve link 2297 */ 2298 function bbp_reply_approve_link( $args = '' ) { 2299 echo bbp_get_reply_approve_link( $args ); 2300 } 2301 2302 /** 2303 * Return the approve link of the reply 2304 * 2305 * @since bbPress (rXXXX) 2306 * 2307 * @param mixed $args This function supports these args: 2308 * - id: Optional. Reply id 2309 * - link_before: Before the link 2310 * - link_after: After the link 2311 * - sep: Separator between links 2312 * - approve_text: Approve text 2313 * - unapprove_text: Unapprove text 2314 * @uses bbp_get_reply_id() To get the reply id 2315 * @uses bbp_get_reply() To get the reply 2316 * @uses current_user_can() To check if the current user can approve the reply 2317 * @uses bbp_is_reply_pending() To check if the reply is pending 2318 * @uses add_query_arg() To add custom args to the url 2319 * @uses wp_nonce_url() To nonce the url 2320 * @uses esc_url() To escape the url 2321 * @uses apply_filters() Calls 'bbp_get_reply_approve_link' with the link 2322 * and args 2323 * @return string Reply approve link 2324 */ 2325 function bbp_get_reply_approve_link( $args = '' ) { 2326 2327 // Parse arguments against default values 2328 $r = bbp_parse_args( $args, array( 2329 'id' => 0, 2330 'link_before' => '', 2331 'link_after' => '', 2332 'sep' => ' | ', 2333 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ), 2334 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' ) 2335 ), 'get_reply_approve_link' ); 2336 2337 $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) ); 2338 2339 if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) ) 2340 return; 2341 2342 $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text']; 2343 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) ); 2344 $uri = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID ); 2345 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after']; 2346 2347 return apply_filters( 'bbp_get_reply_approve_link', $retval, $r ); 2348 } 2349 2350 /** 2257 2351 * Output the row class of a reply 2258 2352 * 2259 2353 * @since bbPress (r2678) -
src/includes/topics/functions.php
2068 2068 'bbp_toggle_topic_close', 2069 2069 'bbp_toggle_topic_stick', 2070 2070 'bbp_toggle_topic_spam', 2071 'bbp_toggle_topic_trash' 2071 'bbp_toggle_topic_trash', 2072 'bbp_toggle_topic_approve' 2072 2073 ); 2073 2074 2074 2075 // Bail if actions aren't meant for this function … … 2096 2097 // What action are we trying to perform? 2097 2098 switch ( $action ) { 2098 2099 2100 // Toggle approve/unapprove 2101 case 'bbp_toggle_topic_approve' : 2102 check_ajax_referer( 'approve-topic_' . $topic_id ); 2103 2104 $is_pending = bbp_is_topic_pending( $topic_id ); 2105 $success = true === $is_pending ? bbp_approve_topic( $topic_id ) : bbp_unapprove_topic( $topic_id ); 2106 $failure = true === $is_pending ? __( '<strong>ERROR</strong>: There was a problem approving the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving the topic.', 'bbpress' ); 2107 2108 break; 2109 2099 2110 // Toggle open/close 2100 2111 case 'bbp_toggle_topic_close' : 2101 2112 check_ajax_referer( 'close-topic_' . $topic_id ); … … 3124 3135 } 3125 3136 3126 3137 /** 3138 * Approves a topic 3139 * 3140 * @since bbPress (rXXXX) 3141 * 3142 * @param int $topic_id Topic id 3143 * @uses bbp_get_topic() To get the topic 3144 * @uses do_action() Calls 'bbp_approve_topic' with the topic id 3145 /* @uses add_post_meta() To add the previous status to a meta 3146 /* @uses delete_post_meta() To delete the previous status meta 3147 * @uses wp_update_post() To update the topic with the new status 3148 * @uses do_action() Calls 'bbp_approved_topic' with the topic id 3149 * @return mixed False or {@link WP_Error} on failure, topic id on success 3150 */ 3151 function bbp_approve_topic( $topic_id = 0 ) { 3152 3153 // Get topic 3154 $topic = bbp_get_topic( $topic_id ); 3155 if ( empty( $topic ) ) { 3156 return $topic; 3157 } 3158 3159 // Bail if already approved 3160 if ( bbp_get_pending_status_id() !== $topic->post_status ) { 3161 return false; 3162 } 3163 3164 // Execute pre pending code 3165 do_action( 'bbp_approve_topic', $topic_id ); 3166 3167 // Set publish status 3168 $topic->post_status = bbp_get_public_status_id(); 3169 3170 // No revisions 3171 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 3172 3173 // Update topic 3174 $topic_id = wp_update_post( $topic ); 3175 3176 // Execute post pending code 3177 do_action( 'bbp_approved_topic', $topic_id ); 3178 3179 // Return topic_id 3180 return $topic_id; 3181 } 3182 3183 /** 3184 * Unapproves a topic 3185 * 3186 * @since bbPress (rXXXX) 3187 * 3188 * @param int $topic_id Topic id 3189 * @uses bbp_get_topic() To get the topic 3190 * @uses do_action() Calls 'bbp_unapprove_topic' with the topic id 3191 /* @uses get_post_meta() To get the previous status 3192 /* @uses delete_post_meta() To delete the previous status meta 3193 * @uses wp_update_post() To update the topic with the new status 3194 * @uses do_action() Calls 'bbp_unapproved_topic' with the topic id 3195 * @return mixed False or {@link WP_Error} on failure, topic id on success 3196 */ 3197 function bbp_unapprove_topic( $topic_id = 0 ) { 3198 3199 // Get topic 3200 $topic = bbp_get_topic( $topic_id ); 3201 if ( empty( $topic ) ) { 3202 return $topic; 3203 } 3204 3205 // Bail if already pending 3206 if ( bbp_get_pending_status_id() === $topic->post_status ) { 3207 return false; 3208 } 3209 3210 // Execute pre open code 3211 do_action( 'bbp_unapprove_topic', $topic_id ); 3212 3213 // Set pending status 3214 $topic->post_status = bbp_get_pending_status_id(); 3215 3216 // No revisions 3217 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 3218 3219 // Update topic 3220 $topic_id = wp_update_post( $topic ); 3221 3222 // Execute post open code 3223 do_action( 'bbp_unapproved_topic', $topic_id ); 3224 3225 // Return topic_id 3226 return $topic_id; 3227 } 3228 3229 /** 3127 3230 * Unsticks a topic both from front and it's forum 3128 3231 * 3129 3232 * @since bbPress (r2754) -
src/includes/topics/template.php
170 170 bbp_get_public_status_id(), 171 171 bbp_get_closed_status_id(), 172 172 bbp_get_spam_status_id(), 173 bbp_get_trash_status_id() 173 bbp_get_trash_status_id(), 174 bbp_get_pending_status_id() 174 175 ); 175 176 176 177 // Add support for private status … … 1212 1213 } 1213 1214 1214 1215 /** 1216 * Is the topic pending? 1217 * 1218 * @since bbPress (rXXXX) 1219 * 1220 * @param int $topic_id Optional. Topic id 1221 * @uses bbp_get_topic_id() To get the topic id 1222 * @uses bbp_get_topic_status() To get the topic status 1223 * @uses apply_filters() Calls 'bbp_is_topic_pending' with the topic id 1224 * @return bool True if pending, false if not. 1225 */ 1226 function bbp_is_topic_pending( $topic_id = 0 ) { 1227 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_pending_status_id(); 1228 return (bool) apply_filters( 'bbp_is_topic_pending', (bool) $topic_status, $topic_id ); 1229 } 1230 1231 /** 1232 * Is the topic private? 1233 * 1234 * @since bbPress (rXXXX) 1235 * 1236 * @param int $topic_id Optional. Topic id 1237 * @uses bbp_get_topic_id() To get the topic id 1238 * @uses bbp_get_topic_status() To get the topic status 1239 * @uses apply_filters() Calls 'bbp_is_topic_private' with the topic id 1240 * @return bool True if private, false if not. 1241 */ 1242 function bbp_is_topic_private( $topic_id = 0 ) { 1243 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_private_status_id(); 1244 return (bool) apply_filters( 'bbp_is_topic_private', (bool) $topic_status, $topic_id ); 1245 } 1246 1247 /** 1215 1248 * Is the posted by an anonymous user? 1216 1249 * 1217 1250 * @since bbPress (r2753) … … 2420 2453 2421 2454 if ( empty( $r['links'] ) ) { 2422 2455 $r['links'] = apply_filters( 'bbp_topic_admin_links', array( 2423 'edit' => bbp_get_topic_edit_link ( $r ), 2424 'close' => bbp_get_topic_close_link( $r ), 2425 'stick' => bbp_get_topic_stick_link( $r ), 2426 'merge' => bbp_get_topic_merge_link( $r ), 2427 'trash' => bbp_get_topic_trash_link( $r ), 2428 'spam' => bbp_get_topic_spam_link ( $r ), 2429 'reply' => bbp_get_topic_reply_link( $r ) 2456 'edit' => bbp_get_topic_edit_link ( $r ), 2457 'close' => bbp_get_topic_close_link ( $r ), 2458 'stick' => bbp_get_topic_stick_link ( $r ), 2459 'merge' => bbp_get_topic_merge_link ( $r ), 2460 'trash' => bbp_get_topic_trash_link ( $r ), 2461 'spam' => bbp_get_topic_spam_link ( $r ), 2462 'approve' => bbp_get_topic_approve_link( $r ), 2463 'reply' => bbp_get_topic_reply_link ( $r ) 2430 2464 ), $r['id'] ); 2431 2465 } 2432 2466 2433 2467 // See if links need to be unset 2434 2468 $topic_status = bbp_get_topic_status( $r['id'] ); 2435 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {2469 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) { 2436 2470 2437 // Close link shouldn't be visible on trashed/spammed topics2471 // Close link shouldn't be visible on trashed/spammed/pending topics 2438 2472 unset( $r['links']['close'] ); 2439 2473 2440 2474 // Spam link shouldn't be visible on trashed topics … … 2704 2738 } 2705 2739 2706 2740 /** 2741 * Output the approve link of the topic 2742 * 2743 * @since bbPress (rXXXX) 2744 * 2745 * @param mixed $args See {@link bbp_get_topic_approve_link()} 2746 * @uses bbp_get_topic_approve_link() To get the topic approve link 2747 */ 2748 function bbp_topic_approve_link( $args = '' ) { 2749 echo bbp_get_topic_approve_link( $args ); 2750 } 2751 2752 /** 2753 * Return the approve link of the topic 2754 * 2755 * @since bbPress (rXXXX) 2756 * 2757 * @param mixed $args This function supports these args: 2758 * - id: Optional. Topic id 2759 * - link_before: Before the link 2760 * - link_after: After the link 2761 * - sep: Separator between links 2762 * - approve_text: Approve text 2763 * - unapprove_text: Unapprove text 2764 * @uses bbp_get_topic_id() To get the topic id 2765 * @uses bbp_get_topic() To get the topic 2766 * @uses current_user_can() To check if the current user can approve the topic 2767 * @uses bbp_is_topic_pending() To check if the topic is pending 2768 * @uses add_query_arg() To add custom args to the url 2769 * @uses wp_nonce_url() To nonce the url 2770 * @uses esc_url() To escape the url 2771 * @uses apply_filters() Calls 'bbp_get_topic_approve_link' with the link 2772 * and args 2773 * @return string Topic approve link 2774 */ 2775 function bbp_get_topic_approve_link( $args = '' ) { 2776 2777 // Parse arguments against default values 2778 $r = bbp_parse_args( $args, array( 2779 'id' => 0, 2780 'link_before' => '', 2781 'link_after' => '', 2782 'sep' => ' | ', 2783 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ), 2784 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' ) 2785 ), 'get_topic_approve_link' ); 2786 2787 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2788 2789 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2790 return; 2791 2792 $display = bbp_is_topic_pending( $topic->ID ) ? $r['approve_text'] : $r['unapprove_text']; 2793 $uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_approve', 'topic_id' => $topic->ID ) ); 2794 $uri = wp_nonce_url( $uri, 'approve-topic_' . $topic->ID ); 2795 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-approve-link">' . $display . '</a>' . $r['link_after']; 2796 2797 return apply_filters( 'bbp_get_topic_approve_link', $retval, $r ); 2798 } 2799 2800 /** 2707 2801 * Output the stick link of the topic 2708 2802 * 2709 2803 * @since bbPress (r2754) -
src/templates/default/css/bbpress.css
54 54 background-color: #fdd; 55 55 } 56 56 57 #bbpress-forums .status-pending.even, 58 #bbpress-forums .status-pending.odd, 59 #bbpress-forums ul.status-pending a { 60 background-color: #fef7f1; 61 } 62 57 63 #bbpress-forums ul.status-closed, 58 64 #bbpress-forums ul.status-closed a { 59 65 color: #ccc;