184 * @since 5.7.3 |
184 * @since 5.7.3 |
185 */ |
185 */ |
186 private function set_is_enabled() { |
186 private function set_is_enabled() { |
187 /* |
187 /* |
188 * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc' |
188 * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc' |
189 * option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead. |
189 * option was deprecated in 3.5.0. Use the {@see 'xmlrpc_enabled'} hook instead. |
190 */ |
190 */ |
191 $is_enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); |
191 $is_enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); |
192 if ( false === $is_enabled ) { |
192 if ( false === $is_enabled ) { |
193 $is_enabled = apply_filters( 'option_enable_xmlrpc', true ); |
193 $is_enabled = apply_filters( 'option_enable_xmlrpc', true ); |
194 } |
194 } |
2269 * @see wp_delete_term() |
2269 * @see wp_delete_term() |
2270 * |
2270 * |
2271 * @param array $args { |
2271 * @param array $args { |
2272 * Method arguments. Note: arguments must be ordered as documented. |
2272 * Method arguments. Note: arguments must be ordered as documented. |
2273 * |
2273 * |
2274 * @type int $blog_id Blog ID (unused). |
2274 * @type int $blog_id Blog ID (unused). |
2275 * @type string $username Username. |
2275 * @type string $username Username. |
2276 * @type string $password Password. |
2276 * @type string $password Password. |
2277 * @type string $taxnomy_name Taxonomy name. |
2277 * @type string $taxonomy_name Taxonomy name. |
2278 * @type int $term_id Term ID. |
2278 * @type int $term_id Term ID. |
2279 * } |
2279 * } |
2280 * @return true|IXR_Error True on success, IXR_Error instance on failure. |
2280 * @return true|IXR_Error True on success, IXR_Error instance on failure. |
2281 */ |
2281 */ |
2282 public function wp_deleteTerm( $args ) { |
2282 public function wp_deleteTerm( $args ) { |
2283 if ( ! $this->minimum_args( $args, 5 ) ) { |
2283 if ( ! $this->minimum_args( $args, 5 ) ) { |
2342 * Method arguments. Note: arguments must be ordered as documented. |
2342 * Method arguments. Note: arguments must be ordered as documented. |
2343 * |
2343 * |
2344 * @type int $blog_id Blog ID (unused). |
2344 * @type int $blog_id Blog ID (unused). |
2345 * @type string $username Username. |
2345 * @type string $username Username. |
2346 * @type string $password Password. |
2346 * @type string $password Password. |
2347 * @type string $taxnomy Taxonomy name. |
2347 * @type string $taxonomy Taxonomy name. |
2348 * @type string $term_id Term ID. |
2348 * @type string $term_id Term ID. |
2349 * } |
2349 * } |
2350 * @return array|IXR_Error IXR_Error on failure, array on success, containing: |
2350 * @return array|IXR_Error IXR_Error on failure, array on success, containing: |
2351 * - 'term_id' |
2351 * - 'term_id' |
2352 * - 'name' |
2352 * - 'name' |
2415 * Method arguments. Note: arguments must be ordered as documented. |
2415 * Method arguments. Note: arguments must be ordered as documented. |
2416 * |
2416 * |
2417 * @type int $blog_id Blog ID (unused). |
2417 * @type int $blog_id Blog ID (unused). |
2418 * @type string $username Username. |
2418 * @type string $username Username. |
2419 * @type string $password Password. |
2419 * @type string $password Password. |
2420 * @type string $taxnomy Taxonomy name. |
2420 * @type string $taxonomy Taxonomy name. |
2421 * @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'number', |
2421 * @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'number', |
2422 * 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array. |
2422 * 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array. |
2423 * } |
2423 * } |
2424 * @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise. |
2424 * @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise. |
2425 */ |
2425 */ |
2507 * Method arguments. Note: arguments must be ordered as documented. |
2507 * Method arguments. Note: arguments must be ordered as documented. |
2508 * |
2508 * |
2509 * @type int $blog_id Blog ID (unused). |
2509 * @type int $blog_id Blog ID (unused). |
2510 * @type string $username Username. |
2510 * @type string $username Username. |
2511 * @type string $password Password. |
2511 * @type string $password Password. |
2512 * @type string $taxnomy Taxonomy name. |
2512 * @type string $taxonomy Taxonomy name. |
2513 * @type array $fields Optional. Array of taxonomy fields to limit to in the return. |
2513 * @type array $fields Optional. Array of taxonomy fields to limit to in the return. |
2514 * Accepts 'labels', 'cap', 'menu', and 'object_type'. |
2514 * Accepts 'labels', 'cap', 'menu', and 'object_type'. |
2515 * Default empty array. |
2515 * Default empty array. |
2516 * } |
2516 * } |
2517 * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise. |
2517 * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise. |
6397 } |
6397 } |
6398 |
6398 |
6399 /** |
6399 /** |
6400 * Filters whether to preempt the XML-RPC media upload. |
6400 * Filters whether to preempt the XML-RPC media upload. |
6401 * |
6401 * |
6402 * Passing a truthy value will effectively short-circuit the media upload, |
6402 * Returning a truthy value will effectively short-circuit the media upload, |
6403 * returning that value as a 500 error instead. |
6403 * returning that value as a 500 error instead. |
6404 * |
6404 * |
6405 * @since 2.1.0 |
6405 * @since 2.1.0 |
6406 * |
6406 * |
6407 * @param bool $error Whether to pre-empt the media upload. Default false. |
6407 * @param bool $error Whether to pre-empt the media upload. Default false. |
6892 return $this->pingback_error( 0, '' ); |
6892 return $this->pingback_error( 0, '' ); |
6893 } |
6893 } |
6894 } |
6894 } |
6895 } else { |
6895 } else { |
6896 // TODO: Attempt to extract a post ID from the given URL. |
6896 // TODO: Attempt to extract a post ID from the given URL. |
6897 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); |
6897 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); |
6898 } |
6898 } |
6899 $post_ID = (int) $post_ID; |
6899 $post_ID = (int) $post_ID; |
6900 |
6900 |
6901 $post = get_post( $post_ID ); |
6901 $post = get_post( $post_ID ); |
6902 |
6902 |
6903 if ( ! $post ) { // Post not found. |
6903 if ( ! $post ) { // Post not found. |
6904 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); |
6904 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); |
6905 } |
6905 } |
6906 |
6906 |
6907 if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) { |
6907 if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) { |
6908 return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); |
6908 return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); |
6909 } |
6909 } |
6910 |
6910 |
6911 // Check if pings are on. |
6911 // Check if pings are on. |
6912 if ( ! pings_open( $post ) ) { |
6912 if ( ! pings_open( $post ) ) { |
6913 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); |
6913 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); |
6914 } |
6914 } |
6915 |
6915 |
6916 // Let's check that the remote site didn't already pingback this entry. |
6916 // Let's check that the remote site didn't already pingback this entry. |
6917 if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom ) ) ) { |
6917 if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom ) ) ) { |
6918 return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); |
6918 return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); |
6921 // Very stupid, but gives time to the 'from' server to publish! |
6921 // Very stupid, but gives time to the 'from' server to publish! |
6922 sleep( 1 ); |
6922 sleep( 1 ); |
6923 |
6923 |
6924 $remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ); |
6924 $remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ); |
6925 |
6925 |
6926 /** This filter is documented in wp-includes/class-http.php */ |
6926 /** This filter is documented in wp-includes/class-wp-http.php */ |
6927 $user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $pagelinkedfrom ); |
6927 $user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $pagelinkedfrom ); |
6928 |
6928 |
6929 // Let's check the remote site. |
6929 // Let's check the remote site. |
6930 $http_api_args = array( |
6930 $http_api_args = array( |
6931 'timeout' => 10, |
6931 'timeout' => 10, |
6961 $remote_source = preg_replace( '/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/', "\n\n", $remote_source ); |
6961 $remote_source = preg_replace( '/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/', "\n\n", $remote_source ); |
6962 |
6962 |
6963 preg_match( '|<title>([^<]*?)</title>|is', $remote_source, $matchtitle ); |
6963 preg_match( '|<title>([^<]*?)</title>|is', $remote_source, $matchtitle ); |
6964 $title = isset( $matchtitle[1] ) ? $matchtitle[1] : ''; |
6964 $title = isset( $matchtitle[1] ) ? $matchtitle[1] : ''; |
6965 if ( empty( $title ) ) { |
6965 if ( empty( $title ) ) { |
6966 return $this->pingback_error( 32, __( 'We cannot find a title on that page.' ) ); |
6966 return $this->pingback_error( 32, __( 'A title on that page cannot be found.' ) ); |
6967 } |
6967 } |
6968 |
6968 |
6969 // Remove all script and style tags including their content. |
6969 // Remove all script and style tags including their content. |
6970 $remote_source = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $remote_source ); |
6970 $remote_source = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $remote_source ); |
6971 // Just keep the tag we need. |
6971 // Just keep the tag we need. |
7073 $url = $this->escape( $url ); |
7073 $url = $this->escape( $url ); |
7074 |
7074 |
7075 $post_ID = url_to_postid( $url ); |
7075 $post_ID = url_to_postid( $url ); |
7076 if ( ! $post_ID ) { |
7076 if ( ! $post_ID ) { |
7077 // We aren't sure that the resource is available and/or pingback enabled. |
7077 // We aren't sure that the resource is available and/or pingback enabled. |
7078 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); |
7078 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); |
7079 } |
7079 } |
7080 |
7080 |
7081 $actual_post = get_post( $post_ID, ARRAY_A ); |
7081 $actual_post = get_post( $post_ID, ARRAY_A ); |
7082 |
7082 |
7083 if ( ! $actual_post ) { |
7083 if ( ! $actual_post ) { |