Fix: Failed Remove Media Item
This commit is contained in:
parent
79122e6086
commit
66cfd8dff4
@ -63,15 +63,15 @@
|
|||||||
initEvents: function(){
|
initEvents: function(){
|
||||||
$('#add_files').bind('click', this.openMediaManager);
|
$('#add_files').bind('click', this.openMediaManager);
|
||||||
wp.media.frames.file_frame.on('select',this.mediaSelected, this);
|
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);
|
setTimeout(() => { this.map.invalidateSize(); }, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeMedia: function(event){
|
removeMedia: function(event){
|
||||||
$(event.currentTarget).parents('.soundmap-attach-item').remove();
|
$(event.currentTarget).parents('.soundmap-attach-item').remove();
|
||||||
},
|
},
|
||||||
openMediaManager: function(event){
|
openMediaManager: function(event){
|
||||||
this.file_frame = wp.media.frames.file_frame
|
this.file_frame = wp.media.frames.file_frame
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if ( this.file_frame ){
|
if ( this.file_frame ){
|
||||||
this.file_frame.open();
|
this.file_frame.open();
|
||||||
@ -90,6 +90,7 @@
|
|||||||
id: attachment.id
|
id: attachment.id
|
||||||
});
|
});
|
||||||
$('#soundmap-attachments-list').append(_o);
|
$('#soundmap-attachments-list').append(_o);
|
||||||
|
$('.att-info').on('click','.delete-att-item', this.removeMedia);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -115,7 +116,7 @@
|
|||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
console.log($('#map_canvas').width());
|
//console.log($('#map_canvas').width());
|
||||||
// Add Timeout for wait load metabox
|
// Add Timeout for wait load metabox
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
soundmap.initMap();
|
soundmap.initMap();
|
||||||
|
101
soundmap.php
101
soundmap.php
@ -81,12 +81,13 @@ if (!class_exists('Soundmap')){
|
|||||||
|
|
||||||
function metaboxes_register_callback(){
|
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-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-media-info', __("Info", 'soundmap'), array($this,'info_meta_box'), 'marker', 'side', 'high');
|
||||||
add_meta_box('soundmap-sound-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');
|
||||||
add_meta_box('soundmap-sound-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
|
} //metaboxes_register_callback
|
||||||
|
|
||||||
function soundmap_email_meta_box(){
|
function email_meta_box(){
|
||||||
global $post;
|
global $post;
|
||||||
$mail = get_post_meta($post->ID, 'EMAIL', TRUE);
|
$mail = get_post_meta($post->ID, 'EMAIL', TRUE);
|
||||||
echo "<p>" . $mail . "</p>";
|
echo "<p>" . $mail . "</p>";
|
||||||
@ -106,23 +107,19 @@ if (!class_exists('Soundmap')){
|
|||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
$files = get_post_meta($post->ID, 'soundmap_attachments_id', FALSE);
|
$files = get_post_meta($post->ID, 'soundmap_attachments_id', FALSE);
|
||||||
echo '<div id="soundmap-attachments">';
|
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 = '';
|
$out = '';
|
||||||
if ($files){
|
if ($files){
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
echo $file;
|
$data = wp_prepare_attachment_for_js( $file );
|
||||||
$data = wp_prepare_attachment_for_js( $file );
|
$out .= "<div class='soundmap-attach-item'>
|
||||||
echo $data;
|
<!-- <div class='att-icon'><img src='{$data['icon']}'/></div> -->
|
||||||
$out .= "<div class='soundmap-attach-item'>
|
<div class='att-info'><a href='{$data['url']}'><strong>{$data['title']}</strong></a><br/>
|
||||||
<div class='att-icon'><img src='{$data['icon']}'/></div>
|
<audio controls>
|
||||||
<div class='att-info'>
|
<source src='{$data['url']} type='{$data['mime']}'>
|
||||||
<a href='{$data['url']}'><strong>{$data['title']}</strong></a><br/>
|
</audio><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>';
|
echo '<div id="soundmap-attachments-list">' . $out . '</div>';
|
||||||
@ -357,21 +354,17 @@ if (!class_exists('Soundmap')){
|
|||||||
wp_localize_script( 'soundmap', 'WP_Soundmap', $params);
|
wp_localize_script( 'soundmap', 'WP_Soundmap', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function register_hooks(){
|
function register_hooks(){
|
||||||
|
|
||||||
add_action('init', array($this, 'init'));
|
add_action('init', array($this, 'init'));
|
||||||
add_action('admin_menu', array($this, 'admin_menu'));
|
add_action('admin_menu', array($this, 'admin_menu'));
|
||||||
add_action('save_post', array($this,'save_post'));
|
add_action('save_post', array($this,'save_post'));
|
||||||
add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'));
|
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('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||||
|
|
||||||
add_action('init', array($this, 'add_feed'));
|
add_action('init', array($this, 'add_feed'));
|
||||||
/*add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
//AJAX ACTIONS
|
||||||
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_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
||||||
add_action('wp_ajax_nopriv_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
add_action('wp_ajax_nopriv_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
||||||
add_action('wp_ajax_nopriv_soundmap_load_infowindow', array($this, 'load_infowindow'));
|
add_action('wp_ajax_nopriv_soundmap_load_infowindow', array($this, 'load_infowindow'));
|
||||||
@ -379,42 +372,34 @@ if (!class_exists('Soundmap')){
|
|||||||
|
|
||||||
add_action('wp_ajax_soundmap-get-markers',array($this, 'soundmap_get_markers'));
|
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_nopriv_soundmap-get-markers',array($this, 'soundmap_get_markers'));
|
|
||||||
add_action('wp_ajax_soundmap-get-content',array($this, 'soundmap_get_content'));
|
add_action('wp_ajax_soundmap-get-content',array($this, 'soundmap_get_content'));
|
||||||
|
|
||||||
|
/* REST API Options */
|
||||||
|
add_action('rest_api_init', function() {
|
||||||
|
register_rest_field('marker','georeference',
|
||||||
|
array(
|
||||||
|
'get_callback' => 'marker_get_georeference',
|
||||||
|
'schema' => null
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
add_action('rest_api_init',function() {
|
||||||
|
register_rest_field('marker','media',
|
||||||
|
array(
|
||||||
|
'get_callback' => 'marker_get_media',
|
||||||
|
'schema' => null
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/* REST API Options */
|
add_action('rest_api_init', function() {
|
||||||
|
register_rest_field('marker','author',
|
||||||
|
array(
|
||||||
add_action('rest_api_init','soinumapa_create_marker_georeference');
|
'get_callback' => 'marker_get_author',
|
||||||
function soinumapa_create_marker_georeference() {
|
'schema' => null
|
||||||
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){
|
function marker_get_georeference ($object, $field_name, $request){
|
||||||
//return $object['id'];
|
//return $object['id'];
|
||||||
|
Loading…
Reference in New Issue
Block a user