【问题标题】:Wordpress paths doesn't contain slashesWordpress 路径不包含斜杠
【发布时间】:2021-12-27 15:52:14
【问题描述】:

我在本地机器上有一个带有 XAMPP 的 wordpress 实例。

我无法将正确的 wordpress 路径传递给我的插件,因为 wordpress 常量在路径中不包含斜杠。 这是我的插件路径和生成的真实路径的示例:

插件路径:

define('__WPPM_ADMIN_CSS__', plugin_dir_path(__FILE__) . 'admin' . '/css');

生成的路径:

https://localhost/wwwebowniaC:xampphtdocswwwebowniawp-contentpluginswp-portfolio-manager/admin/css/admin.css?ver=5.8.2

这是 .htaccess 文件的内容:

# BEGIN WordPress
# Dyrektywy zawarte między "BEGIN WordPress" oraz "END WordPress"
# są generowane dynamicznie i powinny być modyfikowane tylko za pomocą
# filtrów WordPressa. Zmiany dokonane bezpośrednio tutaj będą nadpisywane.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

谁能指出我做错了什么或者我的 xampp localhost 有什么问题?

【问题讨论】:

  • 问题是您试图在实际需要 URL 的地方使用文件系统路径。您需要使用plugin_dir_url
  • @CBroe 你真是太天才了。它就像一个魅力。谢谢你的帮助。 :)
  • 请将您的解决方案添加为“答案”(并接受)。

标签: php wordpress .htaccess xampp


【解决方案1】:

我弄错了函数名。我应该使用 plugin_dir_url 而不是 plugin_dir_path。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 2017-09-29
    • 2021-03-08
    • 1970-01-01
    • 2019-02-16
    • 2018-02-10
    • 1970-01-01
    相关资源
    最近更新 更多