Ticket #37406: 37406.patch
File 37406.patch, 1.4 KB (added by , 8 years ago) |
---|
-
wp-admin/includes/post.php
664 664 } 665 665 666 666 /** 667 * Determine if a post exists based on title, content, and date667 * Determine if a post exists based on title, content, date and type. 668 668 * 669 669 * @since 2.0.0 670 670 * … … 673 673 * @param string $title Post title 674 674 * @param string $content Optional post content 675 675 * @param string $date Optional post date 676 * @param string type Optional post type 676 677 * @return int Post ID if post exists, 0 otherwise. 677 678 */ 678 function post_exists( $title, $content = '', $date = '') {679 function post_exists( $title, $content = '', $date = '', $type = '' ) { 679 680 global $wpdb; 680 681 681 682 $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); 682 683 $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); 683 684 $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); 685 $post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) ); 684 686 685 687 $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; 686 688 $args = array(); … … 699 701 $query .= ' AND post_content = %s'; 700 702 $args[] = $post_content; 701 703 } 704 705 if ( !empty ( $type ) ) { 706 $query .= ' AND post_type = %s'; 707 $args[] = $post_type; 708 } 702 709 703 710 if ( !empty ( $args ) ) 704 711 return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );