了解WordPress(框架?)Web开发

时间:2020-11-26 作者:Anuj Kaithwas

我遇到了一个很棒的投资组合网站https://dogstudio.co/ 当我在寻找设计的例子时。在探索源代码后,很明显这毕竟是一个wordpress网站。

我不明白的是,它如何以及为什么没有典型的wordpress目录层次结构。例如,这是他们的CSS文件的URL,https://dogstudio.co/app/themes/portfolio-2018/static/css/main.css.

一个典型的wordpress网站会有这样的内容,https://www.example.com/wp-content/themes/theme_name/style.css (thewp-contentwp- 作为制作wordpress主题的一般经验法则。

那么,它是使用框架制作的吗?我真的需要理解这一点。

2 个回复
最合适的回答,由SO网友:Tom J Nowell 整理而成

That site probably uses the Roots Bedrock framework, which moves the theme/plugin folders around into an app subfolder. This is mainly due to the preference of that framework though, rather than for any structural benefit.

It\'s also possible they use standard WordPress but have renamed wp-content using constants in wp-config.php , e.g.

define(\'WP_CONTENT_URL\', \'https://example.com/app\');
define(\'WP_CONTENT_DIR\', \'/var/www/example.com/public_html/app/\');

Why Change the wp-content directory location?

If you want to use a git submodule to install WordPress, or a package manager such as composer, having WordPress in a subfolder on its own makes it easier to update and install.

This necessitates moving wp-content out of that folder though to avoid nested folders. E.g composer updates packages by deleting them and installing the new version, which would destroy all uploaded files, plugins, and themes.

So instead, you might have a folder structure like this:

 - wordpress ( sometimes wp )
 - wp-content
   - themes
   - plugins
   - etc..
 - wp-config.php
 - index.php

Such a setup requires more steps to set up than a normal WordPress install however, and isn\'t well suited for most use cases and hosts. If you\'re using the auto-updater to keep WordPress up to date and don\'t use a site-wide version control, or use WP CLI to update WordPress, then you won\'t see many benefits by moving to this setup.

As for why Bedrock does it that way, the answer is simple, the maintainers prefer those folder names and organisation. Other than that Bedrock provides a local environment, but not much else. It\'s a boilerplate for setting up WordPress. For more info or if you have questions about Bedrock, you should visit https://roots.io/bedrock/ and ask in their community

SO网友:Brian Burton

您可以将WordPress静态资产存储在任何地方,甚至可以存储在与网站托管服务器完全分离的CDN上。他们在这里所做的很可能是利用服务器重写该点/应用程序/主题->/wp内容/主题。

还可以使用register_theme_directory(ABSPATH . \'app/themes\') 作用

如果你问他们为什么这样做,可以简单到代码美学,也可以复杂到使用曾经集中的WordPress代码库进行定制的多站点安装。

相关推荐