add can_delete flag to entities in the API

This commit is contained in:
Leo Germani 2019-03-21 10:46:52 -03:00
parent 9391f2da7e
commit d5fa3b7326
7 changed files with 9 additions and 0 deletions

View File

@ -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'] );

View File

@ -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();
}

View File

@ -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;

View File

@ -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'] );

View File

@ -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();

View File

@ -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) {

View File

@ -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([