2

我是 wordpress 开发的新手,我正在编写一个管理插件来处理证书创建。我实现了创建插件,并通过 add_menu_page 在管理菜单中拥有它。

这是插件概念:

  • 我使用 WP_List_Table 来显示用户列表。
  • 我添加了带有一些用户元数据的自定义列。
  • 我添加了一个带有按钮的自定义列。此按钮应显示一个表单(使用正确的项目数据来创建证书。此表单是在文件 test.php 中设计的。(与编辑用户链接的作用方式完全相同)。

我想做的是: 我希望我的按钮打开另一个包含表单并处理该表单的 php 页面。然后返回上一页。用户管理员对 Users-edit.php 页面的处理方式或多或少相同。

我的插件名称是 gbr-certificate。

我的问题:

我不知道如何链接到包含表单 (test.php) 的我的 php 页面。该文件位于我的插件根目录中。我努力了 :

  1. 对 url 进行硬编码:在 column_default 函数中为按钮添加以下代码:
$link = "http://localhost:8888/Standard/wp_content/plugins/gbr-certificate/test.php?user-id=" . $item->ID . "&wp_http_referer=" . urlencode( wp_unslash( $_SERVER['REQUEST_URI']));

$btn = "<button id=\"cert-\" class=\"button\" href=\"" . $link . "\">create cert.</button>";

结果:我的按钮中有正确的链接href

<button id="cert-" class="button" href="http://localhost:8888/Standard/wp_content/plugins/gbr-certificate/test.php?user-id=1&amp;wp_http_referer=%2FStandard%2Fwp-admin%2Fadmin.php%3Fpage%3Duser-cert-manager">create cert.</button>

但是当我点击它=>我得到以下网址:

http://localhost:8888/Standard/wp-admin/admin.php?s=&_wpnonce=feb9b81efe&_wp_http_referer=%2FStandard%2Fwp-admin%2Fadmin.php%3Fpage%3Duser-cert-manager&paged=1

显示空白页。

有人可以帮我实现这一目标吗?

谢谢。纪尧姆 B.

4

0 回答 0