Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1425999
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI'm trying to include the Minit plugin in the inc
folder of my WordPress theme and calling it in my functions.php
file:
require get_template_directory() . '/inc/minit-master/minit.php';
However, after its added it doesn't work as it does when it is a plugin and I can't see why.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI'm trying to include the Minit plugin in the inc
folder of my WordPress theme and calling it in my functions.php
file:
require get_template_directory() . '/inc/minit-master/minit.php';
However, after its added it doesn't work as it does when it is a plugin and I can't see why.
Share Improve this question edited May 25, 2019 at 23:22 Troy Templeman asked May 25, 2019 at 23:10 Troy TemplemanTroy Templeman 4217 silver badges24 bronze badges1 Answer
Reset to default 1Well, Minit for WordPress is hooked into the plugins_loaded
action hook (you can see that checking the file minit.php
).
And the thing is you are requiring the file minit.php
in your functions.php
, which is a file loaded after the hook plugins_loaded
is called. This means that Minit is not being initialized the proper way.
So, basically, you have two choices:
Put minit-master directory inside your plugins directory so you can load
minit.php
like it should be loaded, as a WordPress plugin.Or you could keep the way you want by changing the source code of
minit.php
to be loaded withinafter_setup_theme
hook:
<?php
/*
Plugin Name: Minit
Plugin URI: https://github/kasparsd/minit
GitHub URI: https://github/kasparsd/minit
Description: Combine JS and CSS files and serve them from the uploads folder.
Version: 1.4.1
Author: Kaspars Dambis
Author URI: https://kaspars
*/
// Until we add proper autoloading.
include dirname( __FILE__ ) . '/src/minit-assets.php';
include dirname( __FILE__ ) . '/src/minit-asset-cache.php';
include dirname( __FILE__ ) . '/src/minit-js.php';
include dirname( __FILE__ ) . '/src/minit-css.php';
include dirname( __FILE__ ) . '/src/minit-plugin.php';
include dirname( __FILE__ ) . '/src/admin.php';
include dirname( __FILE__ ) . '/src/helpers.php';
// Here we changed from `plugins_loaded` to `after_setup_theme`.
add_action( 'after_setup_theme', array( 'Minit_Plugin', 'instance' ) );
本文标签: Include Minit plugin in theme
版权声明:本文标题:Include Minit plugin in theme 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745463832a2659443.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论