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' ) );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745463833a4628827.html
评论列表(0条)