Add RestAPI marker-author field
This commit is contained in:
parent
91def4dc81
commit
5bbfeca36e
13
soundmap.php
13
soundmap.php
@ -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){
|
function marker_get_georeference ($object, $field_name, $request){
|
||||||
//return $object['id'];
|
//return $object['id'];
|
||||||
$lat = get_post_meta($object['id'], 'soundmap_marker_lat', true);
|
$lat = get_post_meta($object['id'], 'soundmap_marker_lat', true);
|
||||||
@ -411,6 +420,10 @@ if (!class_exists('Soundmap')){
|
|||||||
return [$lng,$lat];
|
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) {
|
function marker_get_media ($object, $field_name, $request) {
|
||||||
$files = get_post_meta($object['id'], 'soundmap_attachments_id', FALSE);
|
$files = get_post_meta($object['id'], 'soundmap_attachments_id', FALSE);
|
||||||
$files_str = [];
|
$files_str = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user