这是我在one 我的插件
我从插件复制了此行为Advanced Custom Fields (一些版本之前,donnow它现在是如何进行的)。
1) 调用thickbox时,添加自定义查询变量(mtt_type
在这种情况下):
tb_show(\'{$mtt_title}\', \'media-upload.php?type=image&mtt_type=image&TB_iframe=true\');
2)在中打印脚本
media-upload.php
修改文本。未测试的代码:
add_action(\'admin_head-media-upload-popup\',\'wpse_59984_script_enqueuer\');
function wpse_59984_script_enqueuer() {
if( !isset($_GET[\'mtt_type\'] )
return;
// HIDE MANY ELEMENTS
?>
<style>
#media-upload-header #sidemenu li#tab-type_url, tr.post_excerpt, tr.post_content, tr.url, tr.align, tr.image_alt, tr.post_title.form-required {display: none !important}
}
</style>
<?php
// REFRESH UPLOAD SCREEN EVERY HALF SECOND TO CHANGE THE BUTTON NAMES
// Only happens in the Upload Tab
$tab = isset( $_GET[\'tab\'] ) ? $_GET[\'tab\'] : "type";
if ( \'type\' == $tab )
$refresh = \'var mtt_t = setInterval(function(){
$("#media-items").each(setButtonNames);
$("p.savebutton").css("display", "none");
}, 500);\';
else
$refresh = \'\';
// BUTTON NAME
$select = __("Select Image", \'mtt\');
//CHANGE BUTTON NAMES
?>
<script type="text/javascript">
function setButtonNames() {
jQuery(this).find(\'.savesend .button\').val(\'{$select}\');
}
jQuery(document).ready(function($){
$(\'#media-items\').each(setButtonNames);
<?php echo $refresh; ?>
});
</script>
<?php
}