Changeset 51278
- Timestamp:
- 06/30/2021 12:33:43 PM (3 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r51021 r51278 119 119 * by object type. 120 120 * 121 * @param string|array $object_type Object(s) the field is being registered 122 * to,"post"|"term"|"comment" etc.121 * @param string|array $object_type Object(s) the field is being registered to, 122 * "post"|"term"|"comment" etc. 123 123 * @param string $attribute The attribute name. 124 124 * @param array $args { … … 136 136 */ 137 137 function register_rest_field( $object_type, $attribute, $args = array() ) { 138 global $wp_rest_additional_fields; 139 138 140 $defaults = array( 139 141 'get_callback' => null, … … 143 145 144 146 $args = wp_parse_args( $args, $defaults ); 145 146 global $wp_rest_additional_fields;147 147 148 148 $object_types = (array) $object_type; -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php
r49108 r51278 104 104 * @since 5.0.0 105 105 * 106 * @global WP_Post $post Global post object. 107 * 106 108 * @param WP_REST_Request $request Request. 107 109 * @return true|WP_Error True if the request has read access, WP_Error object otherwise. … … 112 114 $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0; 113 115 114 if ( 0 < $post_id) {116 if ( $post_id > 0 ) { 115 117 $post = get_post( $post_id ); 116 118 … … 144 146 * @since 5.0.0 145 147 * 148 * @global WP_Post $post Global post object. 149 * 146 150 * @param WP_REST_Request $request Full details about the request. 147 151 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. … … 152 156 $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0; 153 157 154 if ( 0 < $post_id) {158 if ( $post_id > 0 ) { 155 159 $post = get_post( $post_id ); 156 160 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
r50952 r51278 505 505 * @since 4.7.0 506 506 * 507 * @global array $wp_rest_additional_fields Holds registered fields, organized by object type. 508 * 507 509 * @param string $object_type Optional. The object type. 508 * @return array Registered additional fields (if any), empty array if none or if the object type could509 * not be inferred.510 * @return array Registered additional fields (if any), empty array if none or if the object type 511 * could not be inferred. 510 512 */ 511 513 protected function get_additional_fields( $object_type = null ) { 514 global $wp_rest_additional_fields; 512 515 513 516 if ( ! $object_type ) { … … 518 521 return array(); 519 522 } 520 521 global $wp_rest_additional_fields;522 523 523 524 if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) { -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php
r49955 r51278 266 266 * @since 5.5.0 267 267 * 268 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. 269 * 268 270 * @param WP_REST_Request $request Full details about the request. 269 271 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. 270 272 */ 271 273 public function create_item( $request ) { 274 global $wp_filesystem; 275 272 276 require_once ABSPATH . 'wp-admin/includes/file.php'; 273 277 require_once ABSPATH . 'wp-admin/includes/plugin.php'; … … 330 334 331 335 if ( is_null( $result ) ) { 332 global $wp_filesystem;333 336 // Pass through the error from WP_Filesystem if one was raised. 334 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 335 return new WP_Error( 'unable_to_connect_to_filesystem', $wp_filesystem->errors->get_error_message(), array( 'status' => 500 ) ); 336 } 337 338 return new WP_Error( 'unable_to_connect_to_filesystem', __( 'Unable to connect to the filesystem. Please confirm your credentials.' ), array( 'status' => 500 ) ); 337 if ( $wp_filesystem instanceof WP_Filesystem_Base 338 && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() 339 ) { 340 return new WP_Error( 341 'unable_to_connect_to_filesystem', 342 $wp_filesystem->errors->get_error_message(), 343 array( 'status' => 500 ) 344 ); 345 } 346 347 return new WP_Error( 348 'unable_to_connect_to_filesystem', 349 __( 'Unable to connect to the filesystem. Please confirm your credentials.' ), 350 array( 'status' => 500 ) 351 ); 339 352 } 340 353 … … 342 355 343 356 if ( ! $file ) { 344 return new WP_Error( 'unable_to_determine_installed_plugin', __( 'Unable to determine what plugin was installed.' ), array( 'status' => 500 ) ); 357 return new WP_Error( 358 'unable_to_determine_installed_plugin', 359 __( 'Unable to determine what plugin was installed.' ), 360 array( 'status' => 500 ) 361 ); 345 362 } 346 363 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r51000 r51278 1174 1174 * @since 4.7.0 1175 1175 * 1176 * @global WP_Roles $wp_roles WordPress role management object. 1177 * 1176 1178 * @param int $user_id User ID. 1177 1179 * @param array $roles New user roles.
Note: See TracChangeset
for help on using the changeset viewer.