Ticket #34219: 34219.diff
File 34219.diff, 6.5 KB (added by , 9 years ago) |
---|
-
src/wp-includes/default-filters.php
diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php index cfdd709..4df448c 100644
add_filter( 'title_save_pre', 'trim' ); 204 204 205 205 add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); 206 206 207 // REST API filters.208 add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );209 add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 );210 add_action( 'template_redirect', 'rest_output_link_header', 11, 0 );211 add_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' );212 add_action( 'auth_cookie_expired', 'rest_cookie_collect_status' );213 add_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' );214 add_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' );215 add_action( 'auth_cookie_valid', 'rest_cookie_collect_status' );216 add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 );217 218 207 // Actions 219 208 add_action( 'wp_head', '_wp_render_title_tag', 1 ); 220 209 add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); … … add_action( 'after_password_reset', 'wp_password_change_notification' ); 358 347 add_action( 'register_new_user', 'wp_send_new_user_notifications' ); 359 348 add_action( 'edit_user_created_user', 'wp_send_new_user_notifications' ); 360 349 361 // REST API actions. 362 add_action( 'init', 'rest_api_init' ); 363 add_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); 364 add_action( 'parse_request', 'rest_api_loaded' ); 350 /* 351 * REST API actions and filters. 352 */ 353 354 add_action( 'init', 'rest_api_init' ); 355 add_action( 'parse_request', 'rest_api_loaded' ); 356 357 // Deprecated reporting. 358 add_action( 'deprecated_function_run', '_rest_handle_deprecated_function', 10, 3 ); 359 add_filter( 'deprecated_function_trigger_error', '_rest_deprecated_trigger_error' ); 360 add_action( 'deprecated_argument_run', '_rest_handle_deprecated_argument', 10, 3 ); 361 add_filter( 'deprecated_argument_trigger_error', '_rest_deprecated_trigger_error' ); 362 363 // Visibility 364 add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); 365 add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); 366 add_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); 367 368 // Authentication 369 add_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); 370 add_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); 371 add_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); 372 add_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); 373 add_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); 374 add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); 375 376 // Default serving. 377 add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); 378 add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 ); 379 add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 ); 365 380 366 381 /** 367 382 * Filters formerly mixed into wp-includes -
src/wp-includes/rest-api/rest-functions.php
diff --git src/wp-includes/rest-api/rest-functions.php src/wp-includes/rest-api/rest-functions.php index 8a687f7..2ebf10a 100644
function rest_api_register_rewrites() { 129 129 } 130 130 131 131 /** 132 * Registers the default REST API filters.133 *134 * @since 4.4.0135 *136 * @internal This will live in default-filters.php137 */138 function rest_api_default_filters() {139 // Deprecated reporting.140 add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 );141 add_filter( 'deprecated_function_trigger_error', '__return_false' );142 add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 );143 add_filter( 'deprecated_argument_trigger_error', '__return_false' );144 145 // Default serving.146 add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );147 add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 );148 149 add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 );150 }151 152 /**153 132 * Loads the REST API. 154 133 * 155 134 * @since 4.4.0 … … function rest_ensure_response( $response ) { 342 321 * Handles _deprecated_function() errors. 343 322 * 344 323 * @since 4.4.0 324 * @access private 345 325 * 346 326 * @param string $function Function name. 347 327 * @param string $replacement Replacement function name. 348 328 * @param string $version Version. 349 329 */ 350 function rest_handle_deprecated_function( $function, $replacement, $version ) {330 function _rest_handle_deprecated_function( $function, $replacement, $version ) { 351 331 if ( ! empty( $replacement ) ) { 352 332 $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement ); 353 333 } else { 354 334 $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version ); 355 335 } 356 336 357 header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) ); 337 if ( defined( 'REST_REQUEST' ) && ! headers_sent() ) { 338 header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) ); 339 } 358 340 } 359 341 360 342 /** 361 343 * Handles _deprecated_argument() errors. 362 344 * 363 345 * @since 4.4.0 346 * @access private 364 347 * 365 348 * @param string $function Function name. 366 349 * @param string $replacement Replacement function name. 367 350 * @param string $version Version. 368 351 */ 369 function rest_handle_deprecated_argument( $function, $replacement, $version ) {352 function _rest_handle_deprecated_argument( $function, $replacement, $version ) { 370 353 if ( ! empty( $replacement ) ) { 371 354 $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $replacement ); 372 355 } else { 373 356 $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version ); 374 357 } 375 358 376 header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) ); 359 if ( defined( 'REST_REQUEST' ) && ! headers_sent() ) { 360 header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) ); 361 } 362 } 363 364 /** 365 * Filters whether to trigger an error for deprecated functions 366 * and arguments during a REST request. 367 * 368 * @since 4.4.0 369 * @access private 370 * 371 * @param bool $trigger Whether to trigger the error for deprecated functions. 372 * @return bool False when it is a REST Request, `$trigger` otherwise. 373 */ 374 function _rest_deprecated_trigger_error( $trigger ) { 375 if ( defined( 'REST_REQUEST' ) ) { 376 return false; 377 } 378 379 return $trigger; 377 380 } 378 381 379 382 /**