Open derpixler opened 8 years ago
Sure thing, thats a missing feature. Some thoughts about this…
PostImporterInterface
structure. So it wont go into WpPostImporter
ImportFilterInterface
which checks each Type\ImportPostInterface
whether it should be imported or not: namespace W2M\Import\Filter;
use
W2M\Import\Type;
interface PostImportFilterInterface {
/**
* Checks if a post should be imported or not
*
* @param Type\ImportPostInterface $import_post
*
* @return bool
*/
public function post_to_import( Type\ImportPostInterface $import_post );
}
Import\Service\PostProcessor
depends additionaly on the Filter, and asks for each post before passing it to the importer.PostFilterInterface
has two tasks: Of course it implements post_to_import()
method. Furthermore it listens to the w2m_post_imported
action with a second method. The strategy to identify already imported posts could be to save post_guids/namespace W2M\Import\Filter;
use
W2M\Import\Type,
WP_Post;
class DuplicatePostFilter implements PostFilterInterface {
/**
* Checks if a post should be imported or not
*
* @param Type\ImportPostInterface $import_post
*
* @return bool
*/
public function post_to_import( Type\ImportPostInterface $import_post ) {
// check for existing post here
}
/**
* Records new imported post
*
* @wp-hook w2m_post_imported
*
* @param WP_Post $wp_post
* @param Type\ImportPostInterface $import_post
*/
public function mark_imported_post( WP_Post $wp_post, Type\ImportPostInterface $import_post ) {
// save post meta to identify the post here
}
}
Update
It's important to have a separate Interface for the w2m_{TYPE}_imported
action listeners ( #54 )
When we run the Import more then one time, then we get doublicated data.