Created
May 7, 2011 18:10
-
-
Save ankit/960702 to your computer and use it in GitHub Desktop.
Enabling editing Wordpress pages using Textmate Blogging Bundle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** Edits to wp-includes/post.php ***/ | |
// Add this method | |
// | |
function wp_get_pages( $args = array(), $output = ARRAY_A ) { | |
if ( is_numeric( $args ) ) { | |
_deprecated_argument( __FUNCTION__, '3.1', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) ); | |
$args = array( 'numberposts' => absint( $args ) ); | |
} | |
// Set default arguments | |
$defaults = array( | |
'numberposts' => 10, 'offset' => 0, | |
'category' => 0, 'orderby' => 'post_date', | |
'order' => 'DESC', 'include' => '', | |
'exclude' => '', 'meta_key' => '', | |
'meta_value' =>'', 'post_type' => 'page', 'post_status' => 'draft, publish, future, pending, private', | |
'suppress_filters' => true | |
); | |
$r = wp_parse_args( $args, $defaults ); | |
$results = get_posts( $r ); | |
// Backward compatibility. Prior to 3.1 expected posts to be returned in array | |
if ( ARRAY_A == $output ){ | |
foreach( $results as $key => $result ) { | |
$results[$key] = get_object_vars( $result ); | |
} | |
return $results ? $results : array(); | |
} | |
return $results ? $results : false; | |
} | |
/*** End of edits to wp-includes/post.php ***/ | |
/*** Edits to wp-includes/class-wp-xmlrpc-server.php ***/ | |
// Edit the method mw_getRecentPosts | |
// This is the XMLRPC endpoint used by Textmate Blogging Bundle | |
// | |
// Immediately after '$posts_list = wp_get_recent_posts( $query );', get the pages and push them | |
// into the posts_list array | |
// | |
// get the pages | |
$pages_list = wp_get_pages( $query ); | |
// merge the pages into the posts_list array | |
$posts_list = array_merge($posts_list, $pages_list); | |
/*** End of edits to wp-includes/class-wp-xmlrpc-server.php ***/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment