inpsyde / wpml2mlp

Convert posts from an existing WPML multilingual site via WXR Export/Import for MultilingualPress
https://wordpress.org/plugins/wpml-to-multilingualpress/
GNU General Public License v2.0
10 stars 6 forks source link

Prevent double Imports (Implement Import Filters) #49

Open derpixler opened 8 years ago

derpixler commented 8 years ago

When we run the Import more then one time, then we get doublicated data.

981d2d08-c43c-11e5-8a1e-7a4513efe6f0

dnaber-de commented 8 years ago

Sure thing, thats a missing feature. Some thoughts about this…

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 );
}
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 )