From 5bbfeca36e253f7085a82539c14258d6da9348f6 Mon Sep 17 00:00:00 2001 From: lrullo Date: Mon, 17 Dec 2018 13:32:24 +0100 Subject: [PATCH] Add RestAPI marker-author field --- soundmap.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/soundmap.php b/soundmap.php index 8a9631a..37fe978 100644 --- a/soundmap.php +++ b/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){ //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 = [];