是否可以将插件文件放置在 WordPress 主题中?

发布于 2024-10-08 14:58:22 字数 175 浏览 1 评论 0原文

我正在构建一个 Wordpress 主题,我希望它能够工作而无需单独下载它使用的插件(例如内部化、联系表单和灯箱)。

是否可以将插件文件放置在 WordPress 主题中(或者是否有其他方法来解决这个问题)?

例如:wp-content/themes/my-wordpress-theme/plugins

I'm building a Wordpress theme, and I would like it to work without having to separately download the plugins it uses (e.g. internalization, contact form and lightbox).

Is it possible to place plugin files inside a Wordpress theme (or is there another way of solving this)?

e.g: wp-content/themes/my-wordpress-theme/plugins

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉墨 2024-10-15 14:58:22

当主题与自己的插件打包在一起时,最终用户会被指示将其安装在 /wpcontent 中,而不是正常的 /wp-content/themes 目录中,以便插件和主题文件安装在适当的位置。你想要形式和功能之间的分离。

主题应包含这些插件的挂钩,然后管理员必须在安装后激活它们。

像这样包装你的主题实际上就是你想要做的事情;我们只是稍微扩大了主题的定义以包括其插件目录。

如果您确定让插件目录成为主题的子目录,我不确定这是否可行或如何可行,但这是不好的做法,因为它不能保持形式和功能之间的分离。

When a theme comes packaged with its own plugins, the end user is instructed to install it in /wpcontent as opposed to the normal /wp-content/themes directory so that plugins and theme files are installed in their appropriate places. You want that separation between form and function.

The theme should include hooks to those plugins, and then the administrator has to activate them after installation.

Packaging your theme like this is effectively what you are trying to do; we are just broadening the definition of a theme a bit to include its plugin directory.

If you are determined to have the plugin directory be a subdirectory of the theme, I'm not sure if or how that's doable, but it is bad practice because it doesn't maintain the separation between form and function.

夏尔 2024-10-15 14:58:22

如果插件很大,则必须将其放入单独的插件中。否则人们会对你很生气:)

如果你的“插件”包含一些 PHP 函数,你可以将它们放在functions.php 中。

但是,最好将其放在单独的插件中。
还有一个额外的好处:将您的插件放在 http://wordpress.org/extend/plugins/ 上,并且其他人可以使用和扩展您的工作。

If the plugin is large, you have to put it into a separate plugin. Otherwise people will be very angry with you :)

If your 'plugin' consists of a few PHP functions you can put them in functions.php.

But, it's better to put it in a separate plugin.
With an added bonus: Put your plugin on http://wordpress.org/extend/plugins/ and other people can use and extend your work.

赏烟花じ飞满天 2024-10-15 14:58:22

如果您想将所有插件捆绑到您的主题中。那么你会取得什么成就呢?
你将冻结时间。插件开发人员不断更新它们。并且并非每个 WordPress 实现都需要所有这些功能。
当用户直接从 Codex 使用插件时,他们可以随时更新它们。

此外,您选择的插件集合及其功能很可能与其他人的不匹配。因此,最好保持它们原样。相反,当你的轮子并不比现有的更好时,最好开发自己的东西,而不是总是重新发明轮子。

If you want to put all the plugins bundled into your theme. Then what would you achieve?
You will freeze the time. The plugin developers continuously update them. And the functionalities of all these functions are not needed in every wordpress implementation.
When users use the plugins right from codex, they can update them anytime they want.

Also, your choice of collection of plugins and their functionalities most likely wont match evryone else's. So, its better to keep them as they are. Rather it better idea to develop your own things while not always re-inventing the wheel when your wheel is not better than existing ones.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文