[wp-trac] [WordPress Trac] #21710: More hooks for WordPress Importer
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 28 04:52:18 UTC 2012
#21710: More hooks for WordPress Importer
-------------------------+------------------------------
Reporter: batmoo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Import | Version: 3.4.1
Severity: normal | Resolution:
Keywords: |
-------------------------+------------------------------
Comment (by batmoo):
Sample code that hooks in to these filters (excuse the PHP 5.3-ness).
Make the import more verbose:
{{{
add_action( 'wp_import_insert_post', function( $post_id,
$original_post_ID, $postdata, $post ) {
if ( is_wp_error( $post_id ) )
echo "-- Error importing post: " .
$post_id->get_error_code() . PHP_EOL;
else
echo "-- Imported post as post_id #{$post_id}" . PHP_EOL;
}, 10, 4 );
}}}
Modify post data on the fly:
{{{
add_filter( 'wp_import_post_meta', function( $postmeta, $post_id, $post )
{
$postmeta[] = array(
'key' => '_imported_author',
'value' => sanitize_user( $post['post_author'], true ),
);
return $postmeta;
}, 10, 3 );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21710#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list