From 79122e608661c773c677e680f3a6a8557b85c345 Mon Sep 17 00:00:00 2001 From: Luca Rullo Date: Tue, 13 Dec 2022 01:42:30 +0100 Subject: [PATCH] Fix: Rewrite add_meta_box && rest_init --- soundmap.php | 83 +++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/soundmap.php b/soundmap.php index 118689a..f57e3e8 100644 --- a/soundmap.php +++ b/soundmap.php @@ -81,13 +81,12 @@ if (!class_exists('Soundmap')){ function metaboxes_register_callback(){ add_meta_box('soundmap-map', __("Place the Marker", 'soundmap'), array($this, 'map_meta_box'), 'marker', 'normal', 'high'); - add_meta_box('soundmap-media-info', __("Info", 'soundmap'), array($this,'info_meta_box'), 'marker', 'side', 'high'); - add_meta_box('soundmap-media-attachments', __("Media files attached.", 'soundmap'), array($this, 'attachments_meta_box'), 'marker', 'side', 'high'); - // Ya no es necesario - //add_meta_box('soundmap-email', __("Uploader Mail", 'soundmap'), array($this, 'email_meta_box'), 'marker', 'side', 'low'); + add_meta_box('soundmap-email', __("Uploader Mail", 'soundmap'), array($this,'soundmap_email_meta_box'), 'marker', 'side', 'low'); + add_meta_box('soundmap-sound-info', __("Info", 'soundmap'), array($this,'info_meta_box'), 'marker', 'side', 'high'); + add_meta_box('soundmap-sound-attachments', __("Media files attached.", 'soundmap'), array($this, 'attachments_meta_box'), 'marker', 'side', 'high'); } //metaboxes_register_callback - function email_meta_box(){ + function soundmap_email_meta_box(){ global $post; $mail = get_post_meta($post->ID, 'EMAIL', TRUE); echo "

" . $mail . "

"; @@ -112,11 +111,18 @@ if (!class_exists('Soundmap')){ $out = ''; if ($files){ foreach($files as $file){ + echo $file; $data = wp_prepare_attachment_for_js( $file ); - $out .= "
-
{$data['title']}
+ echo $data; + $out .= "
+
+
+ {$data['title']}
{$data['fileLength']}
- Borrar
"; + Borrar +
+
+
"; } } echo '
' . $out . '
'; @@ -377,33 +383,38 @@ 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 - ) - ) - ); + /* REST API Options */ - add_action('rest_api_init', - register_rest_field('marker','author', - array( - 'get_callback' => 'marker_get_author', - 'schema' => null - ) - ) - ); + + add_action('rest_api_init','soinumapa_create_marker_georeference'); + function soinumapa_create_marker_georeference() { + register_rest_field('marker','georeference', + array( + 'get_callback' => 'marker_get_georeference', + 'schema' => null + ) + ); + } + + add_action('rest_api_init','soinumapa_create_marker_media'); + function soinumapa_create_marker_media() { + register_rest_field('marker','media', + array( + 'get_callback' => 'marker_get_media', + 'schema' => null + ) + ); + } + + add_action('rest_api_init','soinumapa_create_marker_author'); + function soinumapa_create_marker_author() { + register_rest_field('marker','author', + array( + 'get_callback' => 'marker_get_author', + 'schema' => null + ) + ); + } function marker_get_georeference ($object, $field_name, $request){ //return $object['id']; @@ -420,7 +431,7 @@ if (!class_exists('Soundmap')){ $files = get_post_meta($object['id'], 'soundmap_attachments_id', FALSE); $files_str = []; if ($files) : - foreach($files as $file){ + foreach($files as $file){ $data = wp_prepare_attachment_for_js( $file ); array_push($files_str,$data); } @@ -433,7 +444,7 @@ if (!class_exists('Soundmap')){ add_action('wp_ajax_nopriv_soundmap_verify_captcha', array($this, 'verify_captcha'));*/ } - + function add_feed(){ global $wp_rewrite;