Fix: Rewrite add_meta_box && rest_init
This commit is contained in:
parent
f11d466ff0
commit
79122e6086
83
soundmap.php
83
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 "<p>" . $mail . "</p>";
|
||||
@ -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 .= "<div class='soundmap-attach-item'><div class='att-icon'><img src='{$data['icon']}'/></div>
|
||||
<div class='att-info'><a href='{$data['url']}'><strong>{$data['title']}</strong></a><br/>
|
||||
echo $data;
|
||||
$out .= "<div class='soundmap-attach-item'>
|
||||
<div class='att-icon'><img src='{$data['icon']}'/></div>
|
||||
<div class='att-info'>
|
||||
<a href='{$data['url']}'><strong>{$data['title']}</strong></a><br/>
|
||||
<span class='att-length'>{$data['fileLength']}</span><br/>
|
||||
<a href='#' class='delete-att-item'>Borrar</a></div><div class='clear'></div><input type='hidden' name='soundmap-att-ids[]' value='{$file}' /></div>";
|
||||
<a href='#' class='delete-att-item'>Borrar</a>
|
||||
</div>
|
||||
<div class='clear'></div>
|
||||
<input type='hidden' name='soundmap-att-ids[]' value='{$file}' /></div>";
|
||||
}
|
||||
}
|
||||
echo '<div id="soundmap-attachments-list">' . $out . '</div>';
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user