I've taken much of the code from the wordpress-import.php file so I know I am on the right path. But.. I'm stuck trying to import my Twitter RSS feed and the <twitter:place>..</> fields into custom fields.
For the latest updated code see: http://snipt.org/Zkkl.
Right now this is what I've got (besides the whole rest of the code which works just fine). I am just trying too proccess the extra info from the feed into a custom field(s).
$postmeta = array();
$postmeta[] = preg_match('|<twitter:id>(.*?)</twitter:id>|is', $post, $postmeta);
$postmeta[] = preg_match('|<twitter:name>(.*?)</twitter:name>|is', $post, $postmeta);
$postmeta[] = preg_match('|<twitter:full_name>(.*?)</twitter:full_name>|is', $post, $postmeta);
$postmeta[] = preg_match('|<twitter:place_type>(.*?)</twitter:place_type>|is', $post, $postmeta);
$postmeta[] = preg_match('|<twitter:url>(.*?)</twitter:url>|is', $post, $postmeta);
//$postmeta = $postmeta[1];
if ( $postmeta) { foreach ($postmeta as $p) {
$keys = preg_match('|<twitter:(.*?)>|is', $post, $postmeta);
foreach($keys as $key) {
$key = $this->get_tag( $p, 'twitter:{$k}' ); //how do I get the value after the colon?
}
foreach($values as $value) {
$value = $this->get_tag( $p, 'twitter:' );
}
$this->process_post_meta($post_id, $key, $value);
} }
// Process the custom meta
function process_post_meta($post_id, $key, $value) {
// the filter can return false to skip a particular metadata key
$_key = apply_filters('import_post_meta_key', $key);
if ( $_key ) {
add_post_meta( $post_id, $_key, $value );
do_action('import_post_meta', $post_id, $_key, $value);
}
}
// Get tag function
function get_tag( $string, $tag ) {
global $wpdb;
preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
if ( isset($return[1]) ) {
$return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
$return = $wpdb->escape( trim( $return ) );
} else {
$return = '';
}
return $return;
}