This commit is contained in:
lrullo 2018-11-12 18:49:28 +01:00
parent 838f90cdf4
commit 91def4dc81

View File

@ -385,13 +385,51 @@ if (!class_exists('Soundmap')){
add_action('wp_ajax_soundmap-get-content',array($this, 'soundmap_get_content'));
/* REST API Options */
add_action('rest_api_init',
register_rest_field('marker','georeference',
array(
'get_callback' => 'marker_get_georeference',
'schema' => null
)
)
);
add_action('rest_api_init',
register_rest_field('marker','media',
array(
'get_callback' => 'marker_get_media',
'schema' => null
)
)
);
function marker_get_georeference ($object, $field_name, $request){
//return $object['id'];
$lat = get_post_meta($object['id'], 'soundmap_marker_lat', true);
$lng = get_post_meta($object['id'], 'soundmap_marker_lng', true);
return [$lng,$lat];
}
function marker_get_media ($object, $field_name, $request) {
$files = get_post_meta($object['id'], 'soundmap_attachments_id', FALSE);
$files_str = [];
if ($files) :
foreach($files as $file){
$data = wp_prepare_attachment_for_js( $file );
array_push($files_str,$data);
}
endif;
return $files_str;
}
/* add_action('wp_ajax_nopriv_soundmap_file_uploaded', array($this, 'ajax_file_uploaded_callback'));
add_action('wp_ajax_nopriv_soundmap_save_public_upload', array($this, 'save_public_upload'));
add_action('wp_ajax_nopriv_soundmap_verify_captcha', array($this, 'verify_captcha'));*/
}
function add_feed(){
global $wp_rewrite;
add_feed('podcast', array($this, 'customfeed'));
@ -630,6 +668,8 @@ if (!class_exists('Soundmap')){
return $result;
}
}
}