Wordpress插件中没有AdminMenu
我正在创建一个插件,插件中有一个显示注册列表的页面 在那个页面上,我想做一个按钮来打印注册列表 单击该按钮时,将打开一个新页面,其中显示一个窗口。打印;在body标签中。这一页已经印好了 但是,Wordpress将管理菜单放在页脚,也会打印出来 我想打印没有管理员菜单页脚的页面。所以我的问题是:如何在我自己的插件中创建一个页面,它不显示Wordpress菜单,而只是基于。我们可以在Thickbox中打开一个管理页面,防止WP呈现其元素 诀窍是用钩子加载截获子菜单页-$our_hidden_page_slug,并在加载其余WP之前退出其执行Wordpress插件中没有AdminMenu,wordpress,Wordpress,我正在创建一个插件,插件中有一个显示注册列表的页面 在那个页面上,我想做一个按钮来打印注册列表 单击该按钮时,将打开一个新页面,其中显示一个窗口。打印;在body标签中。这一页已经印好了 但是,Wordpress将管理菜单放在页脚,也会打印出来 我想打印没有管理员菜单页脚的页面。所以我的问题是:如何在我自己的插件中创建一个页面,它不显示Wordpress菜单,而只是基于。我们可以在Thickbox中打开一个管理页面,防止WP呈现其元素 诀窍是用钩子加载截获子菜单页-$our_hidden_pag
add_action('admin_menu', 'admin_menu_wpse_71437');
add_action( 'load-dashboard_page_my_hidden_page', 'intercept_thickbox_wpse_71437' );
/**
* Add plugin page and a hidden and empty submenu page
*/
function admin_menu_wpse_71437()
{
add_menu_page(
'TB',
'<span style="color:#e57300;">Thickbox</span>',
'edit_pages',
'open_hidden_page_in_thickbox',
'menu_page_wpse_71437',
'', // no icon
1 // create before Dashboard menu item
);
add_submenu_page(
null, // doesn't shows up in the menu, attached to "index.php"
'Hidden',
'Hidden',
'edit_pages',
'my_hidden_page',
'submenu_page_wpse_71437'
);
}
/**
* Main page
*/
function menu_page_wpse_71437()
{
wp_enqueue_style('thickbox');
wp_enqueue_script('thickbox');
?>
<h2>Print without menu and footer</h2>
<a href="#" id="open-tb"><strong>Print table</strong></a>
<?php print_table_so_24054478(); ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#open-tb").click(function() {
tb_show("", "index.php?page=my_hidden_page&TB_iframe=true");
return false;
});
});
</script>
<?php
}
/**
* Submenu page
*/
function submenu_page_wpse_71437() { /* Do nothing */ }
/**
* Intercept our hidden/empty page and print the Thickbox content
*/
function intercept_thickbox_wpse_71437()
{
iframe_header();
echo '<script>window.print();</script>';
print_table_so_24054478();
exit; // Exit to prevent the page continueing loading and adding the admin menu's etc.
}
/**
* Aux function to echo a table
* from https://github.com/bueltge/WordPress-Admin-Style
*/
function print_table_so_24054478()
{
echo <<<HTML
<table class="widefat">
<thead>
<tr>
<th class="row-title">Table header cell #1</th>
<th>Table header cell #2</th>
</tr>
</thead>
<tbody>
<tr>
<td class="row-title"><label for="tablecell">Table Cell #1, with label</label></td>
<td>Table Cell #2</td>
</tr>
<tr class="alternate">
<td class="row-title"><label for="tablecell">Table Cell #3, with label and class <code>alternate</code></label></td>
<td>Table Cell #4</td>
</tr>
<tr>
<td class="row-title">Table Cell #5, without label</td>
<td>Table Cell #6</td>
</tr>
<tr class="alt">
<td class="row-title">Table Cell #7, without label and with class <code>alt</code></td>
<td>Table Cell #8</td>
</tr>
<tr class="form-invalid">
<td class="row-title">Table Cell #9, without label and with class <code>form-invalid</code></td>
<td>Table Cell #10</td>
</tr>
</tbody>
<tfoot>
<tr>
<th class="row-title">Table header cell #1</th>
<th>Table header cell #2</th>
</tr>
</tfoot>
</table>
HTML;
}
基于。我们可以在Thickbox中打开一个管理页面,防止WP呈现其元素
诀窍是用钩子加载截获子菜单页-$our_hidden_page_slug,并在加载其余WP之前退出其执行
add_action('admin_menu', 'admin_menu_wpse_71437');
add_action( 'load-dashboard_page_my_hidden_page', 'intercept_thickbox_wpse_71437' );
/**
* Add plugin page and a hidden and empty submenu page
*/
function admin_menu_wpse_71437()
{
add_menu_page(
'TB',
'<span style="color:#e57300;">Thickbox</span>',
'edit_pages',
'open_hidden_page_in_thickbox',
'menu_page_wpse_71437',
'', // no icon
1 // create before Dashboard menu item
);
add_submenu_page(
null, // doesn't shows up in the menu, attached to "index.php"
'Hidden',
'Hidden',
'edit_pages',
'my_hidden_page',
'submenu_page_wpse_71437'
);
}
/**
* Main page
*/
function menu_page_wpse_71437()
{
wp_enqueue_style('thickbox');
wp_enqueue_script('thickbox');
?>
<h2>Print without menu and footer</h2>
<a href="#" id="open-tb"><strong>Print table</strong></a>
<?php print_table_so_24054478(); ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#open-tb").click(function() {
tb_show("", "index.php?page=my_hidden_page&TB_iframe=true");
return false;
});
});
</script>
<?php
}
/**
* Submenu page
*/
function submenu_page_wpse_71437() { /* Do nothing */ }
/**
* Intercept our hidden/empty page and print the Thickbox content
*/
function intercept_thickbox_wpse_71437()
{
iframe_header();
echo '<script>window.print();</script>';
print_table_so_24054478();
exit; // Exit to prevent the page continueing loading and adding the admin menu's etc.
}
/**
* Aux function to echo a table
* from https://github.com/bueltge/WordPress-Admin-Style
*/
function print_table_so_24054478()
{
echo <<<HTML
<table class="widefat">
<thead>
<tr>
<th class="row-title">Table header cell #1</th>
<th>Table header cell #2</th>
</tr>
</thead>
<tbody>
<tr>
<td class="row-title"><label for="tablecell">Table Cell #1, with label</label></td>
<td>Table Cell #2</td>
</tr>
<tr class="alternate">
<td class="row-title"><label for="tablecell">Table Cell #3, with label and class <code>alternate</code></label></td>
<td>Table Cell #4</td>
</tr>
<tr>
<td class="row-title">Table Cell #5, without label</td>
<td>Table Cell #6</td>
</tr>
<tr class="alt">
<td class="row-title">Table Cell #7, without label and with class <code>alt</code></td>
<td>Table Cell #8</td>
</tr>
<tr class="form-invalid">
<td class="row-title">Table Cell #9, without label and with class <code>form-invalid</code></td>
<td>Table Cell #10</td>
</tr>
</tbody>
<tfoot>
<tr>
<th class="row-title">Table header cell #1</th>
<th>Table header cell #2</th>
</tr>
</tfoot>
</table>
HTML;
}
在寻找brasofilo的解决方案以开始工作时,我发现了
这很有效。只需将&noheader添加到您的URL,您就没有菜单。在搜索brasofilo的解决方案以开始工作时,我发现了使用
这很有效。只需将&noheader添加到您的URL,您就没有菜单。请解释如何在插件中加载页面。这个按钮在哪里?有相关的示例代码吗?更改了问题,希望现在更清楚一点是的,目标是明确的,但我希望看到您当前的新页面实现被打开,这是哪一页,您是如何制作的?它是添加子菜单吗;?是的,它是添加子菜单\u pagenull、/*等*/;请解释在插件中加载页面。这个按钮在哪里?有相关的示例代码吗?更改了问题,希望现在更清楚一点是的,目标是明确的,但我希望看到您当前的新页面实现被打开,这是哪一页,您是如何制作的?它是添加子菜单吗;?是的,它是添加子菜单\u pagenull、/*等*/;