【问题标题】:Wordpress with NFS wp-content folder causing pathing issues带有 NFS wp-content 文件夹的 Wordpress 导致路径问题
【发布时间】:2012-10-02 14:34:37
【问题描述】:

NFS 挂载很好并且具有正确的权限,但是我将 Wordpress 中的整个 wp-content 文件夹挂载在 NFS 的 /nfs/blog/ 上。

在分类网址中,有如下代码:

wp_enqueue_style(
            'taxonomy-image-plugin-public',
            taxonomy_image_plugin_url( 'style.css' ),
            array(),
            taxonomy_image_plugin_version(),
            'screen'
            );


function taxonomy_image_plugin_url( $file = '' ) {
    static $path = '';
    if ( empty( $path ) ) {
            $path = plugin_dir_url( __FILE__ );
    }
    return $path . $file;
}

您会注意到 wp_enqueue_style 正在调用函数 taxonomy_image_plugin_url()。是否需要在 wp-config.php 文件中包含一些定义,以防止 Wordpress 打印出我的符号链接?这个问题只在两个插件上是这样的。基本上,CSS 是这样在源代码中出现的:

有什么想法吗?我已经添加了 define('FS_METHOD', 'direct') tp wp-config.php 但我还需要添加任何其他内容,比如此处的任何常量以使 Wordpress 忽略符号链接吗? http://codex.wordpress.org/Determining_Plugin_and_Content_Directories

【问题讨论】:

  • 你设置WP_CONTENT_DIR了吗?所有文件都位于/nfs/blog 还是仅位于wp-content
  • 我没有设置。我希望它看起来像 /wp-content,而不是读取 /nfs/blog。那将在哪里设置以及如何设置?定义()?
  • 那么wp-content 是挂载还是挂载的符号链接?
  • /nfs/blog 是挂载到 nfs 服务器。所以然后在 wordpress 根目录中,我像这样符号链接到 nfs 挂载:wp-content -> /nfs/blog

标签: php wordpress nfs


【解决方案1】:

WordPress 在其代码库中使用 PHP __FILE__ 常量。 __FILE__ 自动解析路径。因此,WordPress 最终会意识到/nfs/blog/

在 wp-config.php 中设置 WP_CONTENT_DIR 应该可以解决问题。

define('WP_CONTENT_DIR', '/nfs/blog');

【讨论】:

  • 完美!像冠军一样工作!
猜你喜欢
  • 2021-11-02
  • 2016-02-29
  • 2020-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-11
  • 1970-01-01
相关资源
最近更新 更多