Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -52,11 +52,15 @@ abstract class WP_REST_Meta_Fields {
|
|||
* @see register_rest_field()
|
||||
*/
|
||||
public function register_field() {
|
||||
register_rest_field( $this->get_rest_field_type(), 'meta', array(
|
||||
'get_callback' => array( $this, 'get_value' ),
|
||||
'update_callback' => array( $this, 'update_value' ),
|
||||
'schema' => $this->get_field_schema(),
|
||||
));
|
||||
register_rest_field(
|
||||
$this->get_rest_field_type(),
|
||||
'meta',
|
||||
array(
|
||||
'get_callback' => array( $this, 'get_value' ),
|
||||
'update_callback' => array( $this, 'update_value' ),
|
||||
'schema' => $this->get_field_schema(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +77,7 @@ abstract class WP_REST_Meta_Fields {
|
|||
$response = array();
|
||||
|
||||
foreach ( $fields as $meta_key => $args ) {
|
||||
$name = $args['name'];
|
||||
$name = $args['name'];
|
||||
$all_values = get_metadata( $this->get_meta_type(), $object_id, $meta_key, false );
|
||||
if ( $args['single'] ) {
|
||||
if ( empty( $all_values ) ) {
|
||||
|
@ -185,7 +189,10 @@ abstract class WP_REST_Meta_Fields {
|
|||
'rest_cannot_delete',
|
||||
/* translators: %s: custom field key */
|
||||
sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
|
||||
array( 'key' => $name, 'status' => rest_authorization_required_code() )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => rest_authorization_required_code(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -193,7 +200,10 @@ abstract class WP_REST_Meta_Fields {
|
|||
return new WP_Error(
|
||||
'rest_meta_database_error',
|
||||
__( 'Could not delete meta value from database.' ),
|
||||
array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => WP_Http::INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -220,7 +230,10 @@ abstract class WP_REST_Meta_Fields {
|
|||
'rest_cannot_update',
|
||||
/* translators: %s: custom field key */
|
||||
sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
|
||||
array( 'key' => $name, 'status' => rest_authorization_required_code() )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => rest_authorization_required_code(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -255,7 +268,10 @@ abstract class WP_REST_Meta_Fields {
|
|||
return new WP_Error(
|
||||
'rest_meta_database_error',
|
||||
__( 'Could not update meta value in database.' ),
|
||||
array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => WP_Http::INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +281,10 @@ abstract class WP_REST_Meta_Fields {
|
|||
return new WP_Error(
|
||||
'rest_meta_database_error',
|
||||
__( 'Could not update meta value in database.' ),
|
||||
array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => WP_Http::INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -286,12 +305,15 @@ abstract class WP_REST_Meta_Fields {
|
|||
*/
|
||||
protected function update_meta_value( $object_id, $meta_key, $name, $value ) {
|
||||
$meta_type = $this->get_meta_type();
|
||||
if ( ! current_user_can( "edit_{$meta_type}_meta", $object_id, $meta_key ) ) {
|
||||
if ( ! current_user_can( "edit_{$meta_type}_meta", $object_id, $meta_key ) ) {
|
||||
return new WP_Error(
|
||||
'rest_cannot_update',
|
||||
/* translators: %s: custom field key */
|
||||
sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
|
||||
array( 'key' => $name, 'status' => rest_authorization_required_code() )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => rest_authorization_required_code(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -309,7 +331,10 @@ abstract class WP_REST_Meta_Fields {
|
|||
return new WP_Error(
|
||||
'rest_meta_database_error',
|
||||
__( 'Could not update meta value in database.' ),
|
||||
array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
|
||||
array(
|
||||
'key' => $name,
|
||||
'status' => WP_Http::INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -359,7 +384,7 @@ abstract class WP_REST_Meta_Fields {
|
|||
'default' => isset( $args['default'] ) ? $args['default'] : null,
|
||||
);
|
||||
|
||||
$rest_args = array_merge( $default_args, $rest_args );
|
||||
$rest_args = array_merge( $default_args, $rest_args );
|
||||
$rest_args['schema'] = array_merge( $default_schema, $rest_args['schema'] );
|
||||
|
||||
$type = ! empty( $rest_args['type'] ) ? $rest_args['type'] : null;
|
||||
|
@ -373,7 +398,7 @@ abstract class WP_REST_Meta_Fields {
|
|||
$rest_args['schema']['items'] = array(
|
||||
'type' => $rest_args['type'],
|
||||
);
|
||||
$rest_args['schema']['type'] = 'array';
|
||||
$rest_args['schema']['type'] = 'array';
|
||||
}
|
||||
|
||||
$registered[ $name ] = $rest_args;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue