我发现了问题。
指向网络管理员的链接不正确。例如,网络用户具有:
http://my-local-cms.dev/wp-admin/network/
应该是(如果wordpress core位于后端/)
http://my-local-cms.dev/backend/wp-admin/network/
如果访问第一个链接并在浏览器中添加/后端/在wp admin之前,则网络管理员将正常工作。
Fix
编辑2017-08-30新解决方案:
public function fix_network_admin_url($path, $scheme) {
$path = ltrim($path, \'/\');
return str_replace(\'/wp-admin/network\', \'/backend/wp-admin/network\', $path);
}
add_filter(\'network_admin_url\',\'fix_network_admin_url\', 10, 3);
2017-08-30年末编辑
我选择的解决方法是制作一个带有正确链接的单独网络管理菜单。这不是一个优雅的解决方案,但我不知道如何只修复本机网络管理菜单的URL,而保持其余链接不变(请参阅“其他可能的解决方案”)。
我的解决方案类似于此(添加到主题中的function.php或创建插件):
add_action(\'admin_head\', \'admin_head_network_menu\');
add_action(\'admin_bar_menu\', \'custom_network_admin_bar_menu\', 20);
function admin_head_network_menu()
{
echo \'<style type="text/css">#wp-admin-bar-my-sites-super-admin {display: none}</style>\';
}
function custom_network_admin_bar_menu($adminBar)
{
// Don\'t add network admin bar for non super admins
if (!current_user_can(\'manage_network\')) {
return;
}
$mainMenuID = \'my-new-network-admin-menu\';
$adminBar->add_menu([
\'id\' => $mainMenuID,
\'title\' => __(\'Network Admin\'),
\'href\' => new_admin_url(),
]);
$adminBar->add_menu([
\'id\' => $mainMenuID.\'-sites\',
\'parent\' => $mainMenuID,
\'title\' => __(\'Network Sites\'),
\'href\' => new_admin_url(\'sites.php\'),
]);
$adminBar->add_menu([
\'id\' => $mainMenuID.\'-users\',
\'parent\' => $mainMenuID,
\'title\' => __(\'Network Users\'),
\'href\' => new_admin_url(\'users.php\'),
]);
$adminBar->add_menu([
\'id\' => $mainMenuID.\'-plugins\',
\'parent\' => $mainMenuID,
\'title\' => __(\'Network Plugins\'),
\'href\' => new_admin_url(\'plugins.php\'),
]);
$adminBar->add_menu([
\'id\' => $mainMenuID.\'-settings\',
\'parent\' => $mainMenuID,
\'title\' => __(\'Network Settings\'),
\'href\' => new_admin_url(\'settings.php\'),
]);
}
function new_admin_url($path = \'\')
{
$url = network_admin_url($path);
return str_replace(\'/wp-admin/network\', \'/backend/wp-admin/network\', $url);
}
Other potential solutions
如果您有(子)域多站点安装,请在Github(mu-plugins/wpms-site-url-fixer.php)上签出“felixarntz/multisite-fixes”。
我想也许这可以通过改变来解决。htaccess。出于许多原因,这不是我的项目的一个选项。但如果其他人想尝试一下,这里有一个例子。基岩htaccess:
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
RewriteRule . index.php [L]