将wordpress媒体上传器集成到插件中
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将wordpress媒体上传器集成到插件中相关的知识,希望对你有一定的参考价值。
It's a 3 part process, first is the php that you need to run, which includes the appropriate scripts and styles into the admin header, then you need an html button and input field to put the stored value in, then you need some jQuery to open the popup and get the appropriate information from it (then close it again).There more information on implementation at the URL.
// PHP, adds the appropriate scripts and styles in admin add_action('admin_print_scripts',array(&$this,'uploader_scripts')); add_action('admin_print_styles',array(&$this,'uploader_styles')); public function uploader_scripts(){ wp_enqueue_script('media-upload'); wp_enqueue_script('thinkbox'); } public function uploader_styles(){ wp_enqueue_style('thickbox'); } // The html for the button and hidden input for result (super simple) <input id="backdrop_upload_button" value="Upload/Select Image" type="button" class="button" /> <input type="hidden" name="the_image" id="the_image" value="<?= $settings['the_image'] ?>" /> // The jQuery to open the media uploader and get the response var $ = jQuery; // Handels image uploading $(document).ready(function(){ $("input#upload_button").click(function(){ tb_show('','media-upload.php?type=image&post_id=1&TB_iframe=true&flash=0&backdrop=true'); return false; }) window.send_to_editor=function(html){ var img = $('<div>'+html+'</div>').find('img').attr('src'); $('#the_image').val(img); tb_remove(); }; });
以上是关于将wordpress媒体上传器集成到插件中的主要内容,如果未能解决你的问题,请参考以下文章
php 将复选框自定义元字段添加到媒体上传器wordpress
需要一种方法来更改 wordpress 媒体上传器 div TB_window css