Fix: Failed Remove Media Item
This commit is contained in:
parent
79122e6086
commit
66cfd8dff4
@ -63,7 +63,7 @@
|
||||
initEvents: function(){
|
||||
$('#add_files').bind('click', this.openMediaManager);
|
||||
wp.media.frames.file_frame.on('select',this.mediaSelected, this);
|
||||
$('.delete-att-item').live('click', this.removeMedia);
|
||||
$('.att-info').on('click','.delete-att-item', this.removeMedia);
|
||||
setTimeout(() => { this.map.invalidateSize(); }, 0);
|
||||
},
|
||||
|
||||
@ -90,6 +90,7 @@
|
||||
id: attachment.id
|
||||
});
|
||||
$('#soundmap-attachments-list').append(_o);
|
||||
$('.att-info').on('click','.delete-att-item', this.removeMedia);
|
||||
|
||||
},
|
||||
|
||||
@ -115,7 +116,7 @@
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
console.log($('#map_canvas').width());
|
||||
//console.log($('#map_canvas').width());
|
||||
// Add Timeout for wait load metabox
|
||||
setTimeout(function() {
|
||||
soundmap.initMap();
|
||||
|
53
soundmap.php
53
soundmap.php
@ -81,12 +81,13 @@ 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-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');
|
||||
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');
|
||||
} //metaboxes_register_callback
|
||||
|
||||
function soundmap_email_meta_box(){
|
||||
function email_meta_box(){
|
||||
global $post;
|
||||
$mail = get_post_meta($post->ID, 'EMAIL', TRUE);
|
||||
echo "<p>" . $mail . "</p>";
|
||||
@ -107,22 +108,18 @@ if (!class_exists('Soundmap')){
|
||||
|
||||
$files = get_post_meta($post->ID, 'soundmap_attachments_id', FALSE);
|
||||
echo '<div id="soundmap-attachments">';
|
||||
echo '<div><input type="button" id="add_files" class="button button-primary button-large" value="Add Files"></div>';
|
||||
echo '<div class="add_button_container"><input type="button" id="add_files" class="button button-primary button-large" value="Add Files"></div>';
|
||||
$out = '';
|
||||
if ($files){
|
||||
foreach($files as $file){
|
||||
echo $file;
|
||||
$data = wp_prepare_attachment_for_js( $file );
|
||||
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>";
|
||||
<!-- <div class='att-icon'><img src='{$data['icon']}'/></div> -->
|
||||
<div class='att-info'><a href='{$data['url']}'><strong>{$data['title']}</strong></a><br/>
|
||||
<audio controls>
|
||||
<source src='{$data['url']} type='{$data['mime']}'>
|
||||
</audio><br/>
|
||||
<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>';
|
||||
@ -358,19 +355,15 @@ if (!class_exists('Soundmap')){
|
||||
}
|
||||
|
||||
function register_hooks(){
|
||||
|
||||
add_action('init', array($this, 'init'));
|
||||
add_action('admin_menu', array($this, 'admin_menu'));
|
||||
add_action('save_post', array($this,'save_post'));
|
||||
add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'));
|
||||
|
||||
//add_action('wp_print_footer_scripts', array($this, 'wp_print_footer_scripts'),1);
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
|
||||
add_action('init', array($this, 'add_feed'));
|
||||
/*add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
add_action('admin_init', array($this, 'register_admin_scripts'));*/
|
||||
|
||||
//AJAX ACTIONS
|
||||
add_action('wp_ajax_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
||||
add_action('wp_ajax_nopriv_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
||||
@ -379,42 +372,34 @@ if (!class_exists('Soundmap')){
|
||||
|
||||
add_action('wp_ajax_soundmap-get-markers',array($this, 'soundmap_get_markers'));
|
||||
add_action('wp_ajax_nopriv_soundmap-get-markers',array($this,'soundmap_get_markers'));
|
||||
//add_action('wp_ajax_nopriv_soundmap-get-markers',array($this, 'soundmap_get_markers'));
|
||||
add_action('wp_ajax_soundmap-get-content',array($this, 'soundmap_get_content'));
|
||||
|
||||
|
||||
/* REST API Options */
|
||||
|
||||
|
||||
add_action('rest_api_init','soinumapa_create_marker_georeference');
|
||||
function soinumapa_create_marker_georeference() {
|
||||
add_action('rest_api_init', function() {
|
||||
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() {
|
||||
});
|
||||
add_action('rest_api_init',function() {
|
||||
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() {
|
||||
add_action('rest_api_init', function() {
|
||||
register_rest_field('marker','author',
|
||||
array(
|
||||
'get_callback' => 'marker_get_author',
|
||||
'schema' => null
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function marker_get_georeference ($object, $field_name, $request){
|
||||
//return $object['id'];
|
||||
|
Loading…
Reference in New Issue
Block a user