Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ?php
- /**
- * A class for managing plugin dependencies and loading the plugin.
- *
- * @package WordPress
- * @subpackage LXB_Boilerplate
- * @since LXB_Boilerplate 0.1
- */
- // This has to occur in the global scope.
- new LXB_BOILERPLATE_Bootstrap;
- class LXB_BOILERPLATE_Bootstrap {
- function __construct() {
- add_action( 'plugins_loaded', array( $this, 'test' ), 1 );
- add_action( 'after_setup_theme', array( $this, 'load' ) );
- add_action( 'admin_notices', array( $this, 'warn' ) );
- add_action( 'network_admin_notices', array( $this, 'warn' ) );
- }
- /**
- * Setup the required components for unit testing.
- */
- function test() {
- // This function is only important during unit tests.
- if( ! defined( 'WP_TESTS_MULTISITE' ) ) { return FALSE; }
- $dm_file = '../../plugins/wordpress-mu-domain-mapping/domain_mapping.php';
- require_once( $dm_file );
- $zd_file = '../../plugins/lxb-zendesk/plugin.php';
- require_once( $zd_file );
- $nsfw_file = realpath( '../../plugins/lxb-network-settings-factory-warehouse/plugin.php' );
- require_once( $nsfw_file );
- $mct_file = realpath( '../../plugins/lxb-mailchimp-tools/lxb-mailchimp-tools.php' );
- require_once( $mct_file );
- $cf_file = realpath( '../../plugins/lxb-cloudflare-toolbar/lxb-cloudflare-toolbar.php' );
- require_once( $cf_file );
- $import_users_file = realpath( '../../plugins/lxb-import-users-from-csv/import-users-from-csv.php' );
- require_once( $import_users_file );
- }
- /**
- * Without all of its dependencies, this plugin throws some admin notices.
- */
- function warn() {
- $out = '';
- $messages = array();
- if( ! defined( 'LXB_ZENDESK' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the LXB ZENDESK plugin for determining the proper email template.', 'lxb-boilerplate' );
- }
- if( ! function_exists( 'dm_text_domain' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the WPMU Domain Mapping plugin for setting the primary domain.', 'lxb-boilerplate' );
- }
- if( ! defined( 'LXB_NSFW' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the LXB Network Settings Factory Warehouse plugin for making calls to the control install.', 'lxb-boilerplate' );
- }
- if( ! is_network_admin() ) {
- if( ! defined( 'LXB_CF_VERSION' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the LXB CloudFlare Tools plugin plugin for making calls to the CloudFlare.com.', 'lxb-boilerplate' );
- }
- if( ! defined( 'LXB_AF' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the Apple Fritter theme.', 'lxb-boilerplate' );
- }
- if( ! class_exists( 'MailChimp' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the LXB MailChimp Tools plugin for making calls to MailChimp.com.', 'lxb-boilerplate' );
- }
- if( ! class_exists( 'IS_IU_Import_Users' ) ) {
- $messages[]= esc_html__( 'LXB Boilerplate requires the LXB Import Users From CSV plugin for importing users.', 'lxb-boilerplate' );
- }
- }
- $message_count = count( $messages );
- if( ! empty( $message_count ) ) {
- foreach( $messages as $message ) {
- $out .= "
- <div class='error notice is-dismissible'><p>$message</p></div>
- ";
- }
- }
- if( empty( $out ) ) { return FALSE; }
- echo $out;
- }
- /**
- * If this plugin does not have all of its dependencies, it refuses to load its files.
- *
- * @return boolean Returns FALSE if it's missing dependencies, else TRUE.
- */
- function load() {
- if( ! defined( 'LXB_ZENDESK' ) ) { return FALSE; }
- if( ! defined( 'LXB_CF_VERSION' ) ) { return FALSE; }
- if( ! defined( 'LXB_NSFW' ) ) { return FALSE; }
- if( ! defined( 'LXB_AF' ) ) { return FALSE; }
- if( ! class_exists( 'MailChimp' ) ) { return FALSE; }
- if( ! class_exists( 'IS_IU_Import_Users' ) ) { return FALSE; }
- // For each php file in the inc/ folder, require it.
- foreach( glob( LXB_BOILERPLATE_PATH . 'inc/*.php' ) as $filename ) {
- require_once( $filename );
- }
- return TRUE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement