Changeset 44959 for trunk/src/wp-admin/includes/post.php
- Timestamp:
- 03/21/2019 12:43:48 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/post.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r44938 r44959 732 732 733 733 /** 734 * Determine if a post exists based on title, content, and date734 * Determines if a post exists based on title, content, date and type. 735 735 * 736 736 * @since 2.0.0 737 * @since 5.2.0 Added the `$type` parameter. 737 738 * 738 739 * @global wpdb $wpdb WordPress database abstraction object. 739 740 * 740 * @param string $title Post title 741 * @param string $content Optional post content 742 * @param string $date Optional post date 741 * @param string $title Post title. 742 * @param string $content Optional post content. 743 * @param string $date Optional post date. 744 * @param string $type Optional post type. 743 745 * @return int Post ID if post exists, 0 otherwise. 744 746 */ 745 function post_exists( $title, $content = '', $date = '' ) {747 function post_exists( $title, $content = '', $date = '', $type = '' ) { 746 748 global $wpdb; 747 749 … … 749 751 $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); 750 752 $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); 753 $post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) ); 751 754 752 755 $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; … … 766 769 $query .= ' AND post_content = %s'; 767 770 $args[] = $post_content; 771 } 772 773 if ( ! empty( $type ) ) { 774 $query .= ' AND post_type = %s'; 775 $args[] = $post_type; 768 776 } 769 777
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)