Changeset 4499
- Timestamp:
- 11/24/2012 06:52:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/common/functions.php
r4492 r4499 643 643 * @return bool True if it is not a duplicate, false if it is 644 644 */ 645 function bbp_check_for_duplicate( $post_data ) {645 function bbp_check_for_duplicate( $post_data = array() ) { 646 646 647 647 // No duplicate checks for those who can throttle … … 649 649 return true; 650 650 651 global $wpdb; 652 653 extract( $post_data, EXTR_SKIP ); 651 $r = bbp_parse_args( $post_data, array( 652 'post_author' => 0, 653 'post_type' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ), 654 'post_parent' => 0, 655 'post_content' => '', 656 'post_status' => bbp_get_trash_status_id(), 657 'anonymous_data' => false 658 ), 'check_for_duplicate' ); 654 659 655 660 // Check for anonymous post 656 if ( empty( $ post_author ) && ( isset( $anonymous_data ) && !empty( $anonymous_data['bbp_anonymous_email'] ) ) ) {661 if ( empty( $r['post_author'] ) && ( !empty( $r['anonymous_data'] ) && !empty( $r['anonymous_data']['bbp_anonymous_email'] ) ) ) { 657 662 $clauses = get_meta_sql( array( array( 658 663 'key' => '_bbp_anonymous_email', 659 'value' => $ anonymous_data['bbp_anonymous_email']664 'value' => $r['anonymous_data']['bbp_anonymous_email'] 660 665 ) ), 'post', $wpdb->posts, 'ID' ); 661 666 … … 668 673 // Simple duplicate check 669 674 // Expected slashed ($post_type, $post_parent, $post_author, $post_content, $anonymous_data) 670 $status = bbp_get_trash_status_id(); 671 $dupe = "SELECT ID FROM {$wpdb->posts} {$join} WHERE post_type = '{$post_type}' AND post_status != '{$status}' AND post_author = {$post_author} AND post_content = '{$post_content}' {$where}"; 672 $dupe .= !empty( $post_parent ) ? " AND post_parent = '{$post_parent}'" : ''; 673 $dupe .= " LIMIT 1"; 674 $dupe = apply_filters( 'bbp_check_for_duplicate_query', $dupe, $post_data ); 675 $query = "SELECT ID FROM {$wpdb->posts} {$join} WHERE post_type = '{$r['post_type']}' AND post_status != '{$r['post_status']}' AND post_author = {$r['post_author']} AND post_content = '{$r['post_content']}' {$where}"; 676 $query .= !empty( $r['post_parent'] ) ? " AND post_parent = '{$r['post_parent']}'" : ''; 677 $query .= " LIMIT 1"; 678 $dupe = apply_filters( 'bbp_check_for_duplicate_query', $query, $r ); 679 680 global $wpdb; 675 681 676 682 if ( $wpdb->get_var( $dupe ) ) {
Note: See TracChangeset
for help on using the changeset viewer.