Add RestAPI marker-author field

This commit is contained in:
lrullo 2018-12-17 13:32:24 +01:00
parent 91def4dc81
commit 5bbfeca36e

View File

@ -404,6 +404,15 @@ if (!class_exists('Soundmap')){
)
);
add_action('rest_api_init',
register_rest_field('marker','author',
array(
'get_callback' => 'marker_get_author',
'schema' => null
)
)
);
function marker_get_georeference ($object, $field_name, $request){
//return $object['id'];
$lat = get_post_meta($object['id'], 'soundmap_marker_lat', true);
@ -411,6 +420,10 @@ if (!class_exists('Soundmap')){
return [$lng,$lat];
}
function marker_get_author ($object,$field_name, $request) {
return get_post_meta($object['id'],'soundmap_marker_author',true);
}
function marker_get_media ($object, $field_name, $request) {
$files = get_post_meta($object['id'], 'soundmap_attachments_id', FALSE);
$files_str = [];