コード例 #1
0
ファイル: App.php プロジェクト: wells5609/wp-app
 /**
  * Constructor.
  */
 public function __construct(Application\Environment $env)
 {
     if (!isset(static::$instance)) {
         static::$instance = $this;
     }
     $this->environment = $env;
     $this->autoloader = function_exists('composer_autoloader') ? \composer_autoloader() : null;
     $this->events = array((new Action('app.preload'))->bind('muplugins_loaded', PHP_INT_MAX), (new Action('app.load'))->bind('plugins_loaded', PHP_INT_MAX), (new Action('app.init'))->bind('init', -PHP_INT_MAX), (new Action('app.loaded'))->bind('wp_loaded', PHP_INT_MAX), (new Action('app.request'))->bind('parse_request', -PHP_INT_MAX), (new Action('app.ready'))->bind('wp', PHP_INT_MAX));
 }
コード例 #2
0
ファイル: plugin.php プロジェクト: wells5609/wp-app
/**
 * ------------------------------------------------------------
 * 1) Include wp-app functions from the /wp-app/functions directory
 * 2) Include `WordPress` class
 * 3) Add WordPress namespace to autoloader
 * 4) Create the application
 * 5) Set the default services
 * 6) Set the 'app.load' event
 * ----------------------------------------------------------
 */
add_action('muplugins_loaded', function () {
    foreach (glob(__DIR__ . '/functions/*.php') as $__file) {
        require $__file;
    }
    require __DIR__ . '/src/WordPress.php';
    composer_autoloader()->addPsr4('WordPress\\', array(__DIR__ . '/src'));
    /**
     * @var \WordPress\Application\Environment $env
     */
    $env = new Application\Environment(dirname(ABSPATH), dirname(dirname(ABSPATH)));
    /**
     * Get the app class name
     */
    $class = apply_filters('application_class', 'WordPress\\App');
    /**
     * Application instance.
     *
     * @var WordPress\App $app
     */
    \WordPress::init($app = new $class($env));
    $app->set('autoloader', function (App $app) {