3 replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
source | link

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function nc_getPost( $args ) {
    global $wp_xmlrpc_server;
    $post_obj = $wp_xmlrpc_server->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this postthis post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function nc_getPost( $args ) {
    global $wp_xmlrpc_server;
    $post_obj = $wp_xmlrpc_server->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function nc_getPost( $args ) {
    global $wp_xmlrpc_server;
    $post_obj = $wp_xmlrpc_server->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?

2 added 44 characters in body
source | link

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function my_getPostnc_getPost( $args ) {
    global $wp_xmlrpc_server;
    $post_obj = $wp_xmlrpc_server->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function my_getPost( $args ) {

    $post_obj->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function nc_getPost( $args ) {
    global $wp_xmlrpc_server;
    $post_obj = $wp_xmlrpc_server->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?

1
source | link

Modifying Wordpress XML-RPC Built-Ins

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (wp_getPost):

add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );

function nc_xmlrpc_methods( $methods ) {
    $methods['wp.getPost'] = 'my_getPost';
    return $methods;
}

function my_getPost( $args ) {

    $post_obj->wp_getPost( $args );
    $post = $post_obj->to_array();

    $post['permalink'] = get_permalink( $post_obj->ID );

    return $post;
}

Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path.

I saw this post and it suggests extending wp_xmlrpc_server. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?