[wp-trac] [WordPress Trac] #33721: Add filter to customize result of post_exists()

WordPress Trac noreply at wordpress.org
Mon Sep 7 05:02:43 UTC 2015


#33721: Add filter to customize result of post_exists()
-------------------------+----------------------------
 Reporter:  westonruter  |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  WordPress.org
Component:  Import       |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+----------------------------

Comment (by westonruter):

 @swissspidy Good catch! Patch amended.

 With this change, a plugin can do the (right thing) and use the GUID as
 the determination if the post actually already exists, using a plugin like
 this:

 {{{#!php
 <?php
 add_filter( 'wp_import_existing_post', function( $post_exists, $post ) {
         if ( $post_exists ) {
                 $existing_post = get_post( $post_exists );
                 if ( $existing_post->guid !== $post['guid'] ) {
                         $post_exists = 0;
                 }
         }
         return $post_exists;
 }, 10, 2 );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33721#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list