ap_find_duplicate_post( string $content, string $post_type = 'question', integer|false $question_id = false )
Description #
Find duplicate post by content.
Parameters #
- $contentstring (Required) Post content.
- $post_typestring (Optional) Post type. Default value: 'question'
- $question_idinteger | false (Optional) Question ID. Default value: false
Changelog #
Source #
File: includes/functions.php
function ap_find_duplicate_post( $content, $post_type = 'question', $question_id = false ) { global $wpdb; // Return if content is empty. But blank content will be checked. if ( empty( $content ) ) { return false; } $question_q = false !== $question_id ? $wpdb->prepare( ' AND post_parent= %d', $question_id ) : ''; $var = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_content = %s AND post_type = %s {$question_q} LIMIT 1", $content, $post_type ) ); // @codingStandardsIgnoreLine if ( $var > 0 ) { return $var; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/functions.php:1248
Add your comment