[wp-xmlrpc] Handling Custom Post Types in WP 3.0 via XMLRPC

David Weiss dave at daveweiss.net
Thu Jul 8 04:43:56 UTC 2010


It's really just a total hack - I added elseif statements and hard-coded
post types, assigning them to $post_type.

I suppose the right thing to do is take the
$content_struct<http://_variables/content_struct.html>['post_type']
and test it against registered post types, test for permission, and assign
it to the $post_type or return the error.

If I get around to doing that some time soon, I'll send it along.



On Wed, Jul 7, 2010 at 10:42 PM, Eric Mann <eric at eamann.com> wrote:

>  David,
>
>
>
> Any chance you can post a snippet (better yet a diff) showing what exactly
> you changed to support your custom post types?  If possible, I’d like to
> generalize it and submit a formal patch …
>
>
>
> *From:* wp-xmlrpc-bounces at lists.automattic.com [mailto:
> wp-xmlrpc-bounces at lists.automattic.com] *On Behalf Of *David Weiss
> *Sent:* Wednesday, July 07, 2010 6:07 PM
> *To:* wp-xmlrpc at lists.automattic.com
> *Subject:* [wp-xmlrpc] Handling Custom Post Types in WP 3.0 via XMLRPC
>
>
>
> FYI, I wanted to use Custom Post Types and WP 3.0 in a new blog and manage
> content via XMLRPC.
>
>
>
> XMLRPC.php isn't updated to handle this, it seems.
>
>
>
> mw_NewPost just needs a tweak to get it to work.
>
>
>
> 1993          $post_type <http://_variables/post_type.html> = 'post';
>
> 1994          $page_template <http://_variables/page_template.html> = '';
>
> 1995          if ( !empty <http://_functions/empty.html>( $content_struct <http://_variables/content_struct.html>['post_type'] ) ) {
>
> 1996              if ( $content_struct <http://_variables/content_struct.html>['post_type'] == 'page' ) {
>
> 1997                  $cap <http://_variables/cap.html> = ( $publish <http://_variables/publish.html> ) ? 'publish_pages' : 'edit_pages';
>
> 1998                  $error_message <http://_variables/error_message.html> = __ <http://_functions/__.html>( 'Sorry, you are not allowed to publish pages on this site.' );
>
> 1999                  $post_type <http://_variables/post_type.html> = 'page';
>
> 2000                  if ( !empty <http://_functions/empty.html>( $content_struct <http://_variables/content_struct.html>['wp_page_template'] ) )
>
> 2001                      $page_template <http://_variables/page_template.html> = $content_struct <http://_variables/content_struct.html>['wp_page_template'];
>
> 2002              } elseif ( $content_struct <http://_variables/content_struct.html>['post_type'] == 'post' ) {
>
> 2003  *                // This is the default, no changes needed*
>
> 2004              } else {
>
> 2005  *                // No other post_type values are allowed here*
>
> 2006                  return *new *IXR_Error <http://_classes/ixr_error.html>( 401, __ <http://_functions/__.html>( 'Invalid post type.' ) );
>
> 2007              }
>
> 2008          }
>
>
>
> I just edited up the if/elseif/else to take into account my custom post type names, and set the post_type key/value to the appropriate post type in my client.
>
> Works fine so far.
>
>
> _______________________________________________
> wp-xmlrpc mailing list
> wp-xmlrpc at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-xmlrpc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.automattic.com/pipermail/wp-xmlrpc/attachments/20100707/5b9e35f9/attachment-0001.htm>


More information about the wp-xmlrpc mailing list