Posts_Import::get_duplicate_posts( array $raw_feed, $post_type )
Parameters
- $raw_feed
-
(Required)
- $post_type
-
(Required)
Return
(array)
Source
File: includes/libs/posts-import.class.php
public function get_duplicate_posts( $raw_feed, $post_type ){ if( !$raw_feed ){ return []; } $video_ids = []; foreach( $raw_feed as $video ){ $video_ids[] = $video['video_id']; } /** * @var \WP_Query */ global $wpdb; $query = $wpdb->prepare( " SELECT {$wpdb->postmeta}.post_id, {$wpdb->postmeta}.meta_value FROM {$wpdb->postmeta} LEFT JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type LIKE '%s' AND meta_value IN(" . implode( ',', $video_ids ) . ") ", $post_type ); $existing = $wpdb->get_results( $query ); $_result = []; if( $existing ){ foreach( $existing as $r ){ $_result[ $r->meta_value ][] = $r->post_id; } } /** * Filter the duplicate posts found by the plugin. * When perfoming imports, the filter runs when duplicate imports are detected. * * @param array $_result The post IDs found as duplicates. */ $result = apply_filters( 'vimeotheque\duplicate_posts_found', $_result ); if( $_result !== $result ){ Helper::debug_message( sprintf( 'Detected duplicate posts override by filter "%s".', 'vimeotheque\duplicate_posts_found' ) ); } return $result; }