如何在自定义管理子菜单页面中打开目标空白? [英] How to open target blank in a custom admin sub menu page?
本文介绍了如何在自定义管理子菜单页面中打开目标空白?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的管理区域的外部链接菜单功能:
Here is my external link menu function for admin area:
##CACHE MENU
add_action('admin_menu', 'mariCacheDel');
function mariCacheDel() {
global $submenu;
$url = get_bloginfo('wpurl').'/cache/?do=deleteAll';
$submenu['themes.php'][] = array('MARIA CACHE', 'manage_options', $url);
}
我们如何使用此链接打开 _blank
浏览器窗口?
How can we open a _blank
browser window with this link?
推荐答案
必须使用 jQuery 并在 admin_menu
中使用一个小技巧来插入带有 ID 的目标 div:
It has to be with jQuery and using a small trick in the admin_menu
to insert a target div with an ID:
add_action('admin_menu', 'mariCacheDel');
function mariCacheDel() {
global $submenu;
$submenu['themes.php'][] = array(
'<div id="maricache">MARIA CACHE</div>', // <-- trick
'manage_options',
site_url( '/cache/?do=deleteAll' )
);
}
add_action( 'admin_footer', 'make_maricache_blank' );
function make_maricache_blank()
{
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#maricache').parent().attr('target','_blank');
});
</script>
<?php
}
这篇关于如何在自定义管理子菜单页面中打开目标空白?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文