Include Minit plugin in theme

Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress.

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 question

I'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 question

I'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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

Well, 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:

  1. Put minit-master directory inside your plugins directory so you can load minit.php like it should be loaded, as a WordPress plugin.

  2. Or you could keep the way you want by changing the source code of minit.php to be loaded within after_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

相关推荐

  • Include Minit plugin in theme

    Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress.

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信