0
을 포함하여 문제 WordPress 기능을 활용하는 사용자 정의 인터페이스를 만들고 있으며 활용하려는 특정 영역은 WordPress의 미디어 섹션입니다. 내가 먼저 워드 프레스의 핵심 파일을 포함하고있다 : 내가 사용하고 내 미디어 파일 내에서보다wp_enqueue_media - WordPress
$location = $_SERVER['DOCUMENT_ROOT'] . "/wordpress";
include($location.'/wp-config.php');
include($location.'/wp-load.php');
include($location.'/wp-includes/pluggable.php');
global $wpdb;
if(!isset($wpdb))
{
include($location.'/wp-config.php');
include($location.'/wp-includes/wp-db.php');
}
: wp_enqueue_media()
날은 사용자가 자신의 계정에서 미디어를 업로드 할 때의 미디어 뷰어에 액세스 할 수 있도록.
내 나는 다음과 같은 요청이있는 미디어를 실행하는 데 사용하고 JS
스크립트 다음 add-media
이벤트를 실행할 때
$('.add-media').on('click', function(event){
var file_frame;
var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id
event.preventDefault();
// If the media frame already exists, reopen it.
if (file_frame) {
file_frame.open();
return;
}
// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media({
title: jQuery(this).data('uploader_title'),
button: {
text: jQuery(this).data('uploader_button_text'),
},
multiple: true // Set to true to allow multiple files to be selected
});
// When an image is selected, run a callback.
file_frame.on('select', function() {
var selection = file_frame.state().get('selection');
selection.map(function(attachment) {
attachment = attachment.toJSON();
// Do something with attachment.id and/or attachment.url here
$(".load-attachments").append('<div class="singleImg"><a href="'+attachment.url+'" class="shadowbox"><img src="'+attachment.url+'" width="100px" height="100px"/></a><input type="hidden" class="fileURL load-single-attachment" value="'+attachment.id+'"/><span class="removeImg remove"> X </span></div>');
$(".removeImg").bind('click', function(){
$(this).parent().remove();
});
});
});
// Finally, open the modal
file_frame.open();
});
문제, wp
가 정의되어 있지 않습니다. 이제는 왜 그런지 확신 할 수 없습니다. 어떤 생각이나 제안?