不知道这是否可以帮助您,我使用它来管理post admin页面中元框中的图像字段:
add_action( \'load-post.php\', \'ImageOnSlider_scripts\' );
add_action( \'load-post-new.php\', \'ImageOnSlider_scripts\' );
function ImageOnSlider_scripts() {
wp_enqueue_script(\'media-upload\');
wp_enqueue_script(\'thickbox\');
wp_register_script(\'my-upload\', WP_THEME_URL.\'/js/name_of_script.js\', array(\'jquery\',\'media-upload\',\'thickbox\'));
wp_enqueue_script(\'my-upload\');
wp_enqueue_style(\'thickbox\');
}
和JS:
jQuery(document).ready(function() {
jQuery(\'#upload_image_button\').click(function() {
formfield = jQuery(\'#input-ImageOnSlider\').attr(\'name\');
tb_show(\'\', \'media-upload.php?type=image&TB_iframe=true\');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery(\'img\',html).attr(\'src\');
jQuery(\'#input-ImageOnSlider\').val(imgurl);
tb_remove();
}
});
(根据js命名按钮或链接,或修改js)