The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WordPress::Post

SYNOPSIS

NEW POST EXAMPLE

   use WordPress::API::Post;

   my $p = WordPress::API::Post->new({
      username => 'jim',
      password => 'pazz',
      proxy => 'http://site/xmlrpc.php',
   });   

   $p->title('Wonderful Thing');
   $p->description('This is the main page content');  

   $p->dateCreated('20060731'); # set the date for the post
   
   $p->save; # save to wordpress

   $p->id; # what is the id for this?   
   $p->url; # how would we access this page via http?

GET POST EXAMPLE

  use WordPress::API::Post;

   my $p = WordPress::Post({
      username => 'jim',
      password => 'pass',
      proxy => 'http://site/xmlrpc.php',
   });

   $p-id(35);  # what page do we want to get from wordpress
   $p->load; # from server
   print $p->title;
   print $p->description;

METHODS

new()

Arg is hashref. Requires 'proxy', 'username', and 'password' keys. See WordPress::XMLRPC

   new({ 
      proxy    => $proxy, 
      username => $username, 
      password => $password, 
   });

save()

No argument. If id is set, will edit.

Returns post id.

load()

Get object data from server using xmlrpc.

You must have id() set. If you called via load, id is set for you. If you upload, id is also set automatically.

delete()

Deletes the post from server. Returns boolean.

   $o->delete
      or die( $o->errstr );

abs_path()

Setget method. Argument is path string. (We can use this module to save the "struct" to a YAML file for editing.)

abs_path_resolve()

Optional argument is abs path- If not, expects abs_path() to have been set already. Attempts to resolve to disk. Returns abs path resolved. Subsequent calls to abs_path() will also return this value.

save_file()

Dumps data structure to abs_path(), as YAML conf file.

Imagine you want to save a post from your blog to a text file on your machine:

   $o->id(43);
   $o->abs_path('/home/myself/posts/43.yml');
   $o->save_file or die($o->errstr);

Don't confuse this with save(), which saves to the blog.

errstr()

   $o->save
      or die($o->errstr);

Or

   $o->load
      or die($o->errstr);

STRUCTURE DATA SETGET METHODS

These are all inherited from WordPress::Base::Data::Post

dateCreated()

Setget perl method. Argument is string. Argument is checked by Date::Manip

date_created_gmt()

returns date_created_gmt value as a unix timestamp. If you call dateCreated(0 with an argument, this is reset.

permaLink()

Setget perl method. argument is url

wp_password()

Setget perl method. Argument is string.

userid()

Setget perl method. Argument is number.

mt_allow_pings()

Setget perl method. argument is boolean

mt_excerpt()

Setget perl method. Argument is string.

wp_author_display_name()

Setget perl method. Argument is string.

link()

Setget perl method. argument is url

wp_slug()

Setget perl method. Argument is string.

mt_allow_comments()

Setget perl method. argument is boolean

categories()

Setget perl method. argument is array ref

description()

Setget perl method. Argument is string.

postid() and post_id()

Setget perl method. Argument is number.

wp_author_id()

Setget perl method. Argument is number.

mt_keywords()

Setget perl method. Argument is string.

title()

Setget perl method. Argument is string.

mt_text_more()

Setget perl method. Argument is string.

object_type()

Returns 'Post'.

structure_data()

Perl serget method. Argument is hashref, represents the struct as per wordpress. It is rare that this method should be called by your code.

Returns the data structure as you would present to a WordPress::XMLRPC set call.

If you made a WordPress::XMLRPC get call, that return hash ref should be an argument here.

THE POST DATA

To get the data in one hashref (or struct as wordpress expects it), call structure_data()

POST STRUCT EXAMPLE

    $struct: {
               categories => [
                               'Uncategorized'
                             ],
               dateCreated => '20080205T14:55:30',
               date_created_gmt => '20080205T22:55:30',
               description => 'this is test content',
               link => 'http://leocharre.com/articles/this-is-ok1202252126/',
               mt_allow_comments => '1',
               mt_allow_pings => '1',
               mt_excerpt => '',
               mt_keywords => '',
               mt_text_more => '',
               permaLink => 'http://leocharre.com/articles/this-is-ok1202252126/',
               postid => '174',
               title => 'This is ok1202252126',
               userid => '2',
               wp_author_display_name => 'leocharre',
               wp_author_id => '2',
               wp_password => '',
               wp_slug => 'this-is-ok1202252126'
             }

PAGE STRUCT EXAMPLE

    $struct: {
               categories => [
                               'Uncategorized'
                             ],
               dateCreated => '20080205T14:51:28',
               date_created_gmt => '20080205T22:51:28',
               description => 'this is test content',
               excerpt => '',
               link => 'http://leocharre.com/this-is-ok1202251882/',
               mt_allow_comments => '1',
               mt_allow_pings => '1',
               page_id => '173',
               page_status => 'publish',
               permaLink => 'http://leocharre.com/this-is-ok1202251882/',
               text_more => '',
               title => 'This is ok1202251882',
               userid => '2',
               wp_author => 'leocharre',
               wp_author_display_name => 'leocharre',
               wp_author_id => '2',
               wp_page_order => '0',
               wp_page_parent_id => '0',
               wp_page_parent_title => '',
               wp_password => '',
               wp_slug => 'this-is-ok1202251882'
             }

WHY ARE THERE PATH METHODS

Part of the usefulness of these modules is that you can work with text files as the posts, locally. And then you can upload to server.

SEE ALSO

WordPress::Base::Date Date::Manip WordPress::API WordPress::XMLRPC YAML

AUTHOR

Leo Charre leocharre at cpan dot org

CAVEATS

This module is in development. Please contact the AUTHOR.