我为我正在创建的插件定制了一个帖子类型,“添加项目”类型按钮的标签(在列表页面的顶部)需要一个伙伴按钮,上面写着“导入”,另一个写着“导出”,这样我就可以(在简短的确认对话后)允许我的客户端使用JSON文件推拉记录already all set up; 我只需要他们能够触发它,但我不知道如何将按钮添加到列表页面
所以我需要在“添加条目”按钮后添加“导入”和“导出”
Any help is greatly appreciated.
如何在我的“编辑”列表中添加自定义按钮?(edit.php?post_type=)
2 个回复
SO网友:user98239820
我找到了一种方法来完成它,但我对这个过程不是很满意。如果您找到更好的方法,请添加您的答案。同时,这可能会有所帮助。
add_action(\'admin_head-edit.php\',\'addCustomImportButton\'));
我只需要在编辑页面上使用这个,所以我使用admin\\u head-edit。php操作,但您可以使用admin\\u head或其他(不是很具体的要求)/**
* Adds "Import" button on module list page
*/
public function addCustomImportButton()
{
global $current_screen;
// Not our post type, exit earlier
// You can remove this if condition if you don\'t have any specific post type to restrict to.
if (\'module\' != $current_screen->post_type) {
return;
}
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
jQuery(jQuery(".wrap h2")[0]).append("<a id=\'aspose_doc_popup\' class=\'add-new-h2\'>Import</a>");
});
</script>
<?php
}
SO网友:Geza Gog
结束