[wp-hackers] command line script to add "pending" item with podcast attachment?

Chris Dawson xrdawson at gmail.com
Sat Oct 31 07:41:27 UTC 2009


I'm trying to write a plugin or command-line script that will allow an
external process to create a new post in my wordpress blog and have the new
item marked as pending.  I want to have this process create the post for a
user in the system, and then let the user review the post before it is
published.  I'm reviewing the Wordpress API, but am not sure where I should
start looking on design choices for implementing this.  Does anyone have a
suggestion on how I should implement this, or what pitfalls to avoid?

Truth be told, I'd prefer to write a script that publishes using ATOM.  And,
I think I have this working.  However, I need to modify the attachments as
stored by the powerpress podcast plugin, and am not sure how to make the
wordpress API work within that.  Perhaps I should modify the database by
hand?  Or, should I do this another way?

I've got a plugin like this so far:

<?php
function update_title_for_podcast($title) {
/* determine the podcast id */
  $postid = get_the_ID();
  $matches;
  if( preg_match( "/podcast=(.*)/", $title, $matches ) ) {
    $podcast_id = $matches[0];
    }
  $filename = "http://www.blahblah.com/podcasts/" . $podcast_id .
".wav.mp3";
  $attachment = array( 'post_title' => 'New podcast', 'post_content' => '',
'post_status' => '' );
  $attach_id = wp_insert_attachment( $attachment, $filename, $postid );
  $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
  $foo = wp_update_attachment_metadata( $attach_id,  $attach_data );
  return "Now with podcast: $title";
}

add_filter('the_title', 'update_title_for_podcast');
?>

Thanks,
Chris

-- 
Chris Dawson
971-533-8335


More information about the wp-hackers mailing list