add can_delete flag to entities in the API
This commit is contained in:
parent
9391f2da7e
commit
d5fa3b7326
|
@ -181,6 +181,7 @@ class REST_Collections_Controller extends REST_Controller {
|
|||
$item_arr['moderators'] = $moderators;
|
||||
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
}
|
||||
|
||||
unset($item_arr['moderators_ids']);
|
||||
|
@ -200,6 +201,7 @@ class REST_Collections_Controller extends REST_Controller {
|
|||
|
||||
if ( $request['context'] === 'edit' ) {
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
}
|
||||
|
||||
$item_arr['url'] = get_permalink( $item_arr['id'] );
|
||||
|
|
|
@ -326,6 +326,7 @@ class REST_Filters_Controller extends REST_Controller {
|
|||
|
||||
if($request['context'] === 'edit'){
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
$item_arr['enabled'] = $item->get_enabled_for_collection();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
|
||||
if($request['context'] === 'edit'){
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
}
|
||||
|
||||
return $item_arr;
|
||||
|
|
|
@ -161,6 +161,7 @@ class REST_Items_Controller extends REST_Controller {
|
|||
|
||||
if ( $request['context'] === 'edit' ) {
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
}
|
||||
|
||||
$img_size = 'large';
|
||||
|
@ -206,6 +207,7 @@ class REST_Items_Controller extends REST_Controller {
|
|||
|
||||
if ( $request['context'] === 'edit' ) {
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
}
|
||||
|
||||
$item_arr['url'] = get_permalink( $item_arr['id'] );
|
||||
|
|
|
@ -295,6 +295,7 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
|
||||
if($request['context'] === 'edit'){
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
ob_start();
|
||||
$item->get_metadata_type_object()->form();
|
||||
$form = ob_get_clean();
|
||||
|
|
|
@ -100,6 +100,7 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
|||
|
||||
if ( $request['context'] === 'edit' ) {
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
$item_arr['collections'] = [];
|
||||
if ( is_array($tax_collections = $item->get_collections()) ) {
|
||||
foreach ($tax_collections as $tax_collection) {
|
||||
|
|
|
@ -261,6 +261,7 @@ class REST_Terms_Controller extends REST_Controller {
|
|||
|
||||
if ( $request['context'] === 'edit' ) {
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
}
|
||||
|
||||
$children = get_terms([
|
||||
|
|
Loading…
Reference in New Issue