From 6df2aff40b637d8c6770af4b6fe4333c31e0b22b Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 11 Sep 2012 00:37:31 +0000 Subject: [PATCH] Turn XML-RPC on and remove the option on the Writing Settings page. props markoheijnen for the initial patch. Introduces a new filter, xmlrpc_enabled. Respects any current callbacks registered to the pre_option_enable_xmlrpc and option_enable_xmlrpc filters, for anyone forcing it off via code. fixes #21509. git-svn-id: https://develop.svn.wordpress.org/trunk@21804 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/schema.php | 3 +-- wp-admin/includes/upgrade.php | 1 - wp-admin/options-writing.php | 8 -------- wp-admin/options.php | 2 +- wp-includes/class-wp-xmlrpc-server.php | 25 +++++++++++++++++++++---- wp-includes/version.php | 2 +- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 8179bb1505..6fb8c1bbd5 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -445,7 +445,6 @@ function populate_options() { // 2.6 'avatar_default' => 'mystery', 'enable_app' => 0, - 'enable_xmlrpc' => 0, // 2.7 'large_size_w' => 1024, @@ -543,7 +542,7 @@ function populate_options() { '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', - 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', + 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', ); foreach ( $unusedoptions as $option ) delete_option($option); diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index d71163ef5c..7278e2a533 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -997,7 +997,6 @@ function upgrade_260() { if ( $wp_current_db_version < 8201 ) { update_option('enable_app', 1); - update_option('enable_xmlrpc', 1); } } diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index cf8439873d..ff87450502 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -179,14 +179,6 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor
- - -
-
-
- diff --git a/wp-admin/options.php b/wp-admin/options.php index 5677251788..ff167011ad 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -64,7 +64,7 @@ $whitelist_options = array( 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ), 'privacy' => array( 'blog_public' ), 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ), - 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ), + 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app' ), 'options' => array( '' ) ); $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index f73acdc8ea..c5eea7915e 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -169,8 +169,17 @@ class wp_xmlrpc_server extends IXR_Server { * @see wp_xmlrpc_server::login */ function login_pass_ok($user_login, $user_pass) { - if ( !get_option( 'enable_xmlrpc' ) ) { - $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); + + // Respect any old filters against get_option() for 'enable_xmlrpc'. + $enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); // Deprecated + if ( false === $enabled ) + $enabled = apply_filters( 'option_enable_xmlrpc', true ); // Deprecated + + // Proper filter for turning off XML-RPC. It is on by default. + $enabled = apply_filters( 'xmlrpc_enabled', $enabled ); + + if ( ! $enabled ) { + $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) ); return false; } @@ -191,8 +200,16 @@ class wp_xmlrpc_server extends IXR_Server { * @return mixed WP_User object if authentication passed, false otherwise */ function login($username, $password) { - if ( !get_option( 'enable_xmlrpc' ) ) { - $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); + // Respect any old filters against get_option() for 'enable_xmlrpc'. + $enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); // Deprecated + if ( false === $enabled ) + $enabled = apply_filters( 'option_enable_xmlrpc', true ); // Deprecated + + // Proper filter for turning off XML-RPC. It is on by default. + $enabled = apply_filters( 'xmlrpc_enabled', $enabled ); + + if ( ! $enabled ) { + $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) ); return false; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 776a5b81aa..a9e7201410 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -11,7 +11,7 @@ $wp_version = '3.5-alpha-21751'; * * @global int $wp_db_version */ -$wp_db_version = 21707; +$wp_db_version = 21804; /** * Holds the TinyMCE version