fix: test if compound metadata child is trashed
This commit is contained in:
parent
2c61ce2338
commit
7d97c3ef1e
|
@ -42,6 +42,11 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
public function register_routes() {
|
||||
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)',
|
||||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => array($this, 'get_item_metadatum_value'),
|
||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||
),
|
||||
array(
|
||||
'methods' => \WP_REST_Server::EDITABLE,
|
||||
'callback' => array($this, 'update_item'),
|
||||
|
@ -55,7 +60,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
),
|
||||
)
|
||||
);
|
||||
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/'. $this->rest_base,
|
||||
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
|
@ -65,15 +70,6 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
)
|
||||
)
|
||||
);
|
||||
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/'. $this->rest_base. '/(?P<metadatum_id>[\d]+)',
|
||||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => array($this, 'get_item_metadatum_value'),
|
||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -437,7 +437,7 @@ class Item_Metadata extends Repository {
|
|||
if ( is_array( $ids ) ) {
|
||||
foreach ( $ids as $id ) {
|
||||
$post_meta_object = get_metadata_by_mid( 'post', $id );
|
||||
if ( is_object( $post_meta_object ) && get_post($post_meta_object->meta_key) !== null ) {
|
||||
if ( is_object( $post_meta_object ) && get_post($post_meta_object->meta_key) !== null && get_post_status($post_meta_object->meta_key) !== 'trash' ) {
|
||||
$metadatum = new Entities\Metadatum( $post_meta_object->meta_key );
|
||||
$return_value[ $metadatum->get_id() ] = new Entities\Item_Metadata_Entity( $item, $metadatum, $id, (int)$compound_meta_id );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue