简体   繁体   English

如何在 wordpress 中获得正确的 WordPress 管理员 url

[英]How to get proper WordPress admin url in wordpress

I have the plugin with folder/files and I am using the plugin in admin dashboard.我有带有文件夹/文件的插件,并且我在管理仪表板中使用该插件。

Folder: views
       actions.php
       client_register.php

And I created one menu like this我创建了一个这样的菜单

add_submenu_page("custom", "Client Registration", "New Client Site",'manage_options', "client_register", 'page_client_register');

if ( ! function_exists( 'page_client_register' ) ) {
    function page_client_register(){
        render_page_client_register();
    }
}

And I am able to call the page_client_register function (which is actually a independent php file) like this.我可以像这样调用page_client_register function (实际上是一个独立的 php 文件)。 http://127.0.0.1/wp-admin/admin.php?page=client_register This is possible because I created the menu. http://127.0.0.1/wp-admin/admin.php?page=client_register这是可能的,因为我创建了菜单。

How can I access other files similar to that way?我怎样才能访问与这种方式类似的其他文件? using wp-admin/admin.php url使用wp-admin/admin.php url

If I directly call the files like http://127.0.0.1/wp-content/plugins/<pluginname>/views/actions.php it says Direct PHP ACCESS is not allowed in some cloud sites.如果我直接调用http://127.0.0.1/wp-content/plugins/<pluginname>/views/actions.php之类的文件,它会说不允许在某些 FEC392304A5C23AC138DAESSB284 中使用 Direct Z2FEC392304A5C7777 云站点。

How can I access these files using wp-admin/admin.php ?如何使用wp-admin/admin.php访问这些文件?

You get the concrete URL to admin.php by using the admin_url function:您可以使用admin_url function 将具体的 URL 传递给 admin.php:

admin_url('admin.php'); # http(s)://localhost/wp-admin/admin.php

And in your concrete example you add the page query-info part:在您的具体示例中,您添加了页面查询信息部分:

$url = admin_url('admin.php?page=client_register');
wp_redirect($url); 
exit;

OR或者

admin_url( "client_reg_action.php?page=client_register"] )
admin_url( "admin.php?page=".$_GET["page"] )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM