/** * */ static function on_load() { if (defined('WPLIB_RUNMODE')) { $runmode = strtoupper(WPLIB_RUNMODE); if (is_string($runmode) && defined("self::{$runmode}")) { $runmode = intval(self::get_constant(strtoupper($runmode))); } if (is_int($runmode) && self::DEVELOPMENT <= $runmode && self::PRODUCTION >= $runmode) { self::set_runmode($runmode); } } else { self::set_runmode(self::PRODUCTION); } spl_autoload_register(array(__CLASS__, '_autoloader')); self::register_module('posts', 0); self::register_module('terms', 0); self::register_module('users', 0); self::register_module('post-type-post', 0); self::register_module('post-type-page', 0); self::register_module('taxonomy-categories', 0); self::register_module('taxonomy-post-tags', 0); self::register_module('helpers-html', 0); self::register_module('helpers-wp', 0); self::register_module('theme', 0); /** * Register default User Roles */ self::register_module('user-role-administrator', 4); self::register_module('user-role-contributor', 4); self::register_module('user-role-subscriber', 4); self::register_module('user-role-editor', 4); self::register_module('user-role-author', 4); self::add_class_action('init', 9); self::add_class_action('plugins_loaded', 11); self::add_class_action('after_setup_theme'); self::add_class_action('after_setup_theme', 11); self::add_class_action('xmlrpc_call'); self::add_class_action('shutdown'); /** * Set a marker to ignore classes declared before this class. */ self::$_non_app_class_count = count(get_declared_classes()) - 1; }
/** * */ static function on_load() { /** * @var bool Flag to ensure this method is only ever called once. */ static $done_once = false; if (!$done_once) { $done_once = true; } else { $err_msg = __('The %s::on_load() method should not call its parent class, e.g. remove parent::on_load(). Report generated ', 'wplib'); self::trigger_error(sprintf($err_msg, get_called_class()), E_USER_ERROR); } if (!class_exists('WPLib_Enum', false)) { /** * defines.php can be included in local-config.php, but if * not then we need to include it here. */ require __DIR__ . '/defines.php'; } if (!defined('WPLIB_STABILITY')) { /* @note THIS IS NOT WIDELY IMPLEMENTED YET. * * WPLib follows the convention of Node.js in having a Stability Index. * Every class, property, method, constant, etc. will have a Stability value, * except for those that do not (yet.) * * The stability will be specified by an @stability PHPDoc comment with one * of the following values: * * Stability: 0 - Deprecated * Stability: 1 - Experimental * Stability: 2 - Stable * Stability: 3 - Locked * * The default stability is 2 - Stable. However you can set the stability * you want in your wp-local-config.php file using the WPLIB_STABILITY constant. * * You can check (for example) for EXPERIMENTAL stability in a method using: * * self::stability()->check_method( __METHOD__, WPLib::EXPERIMENTAL ); * * Internal methods -- ones with a leading underscore -- will not be marked with * a stability level. * * To read more about the concept of stability: * * @see https://nodejs.org/api/documentation.html#documentation_stability_index */ define('WPLIB_STABILITY', is_null(self::stability()) ? WPLib_Stability::__default : self::stability()->get_value()); } if (is_null(self::stability())) { self::set_stability(new WPLib_Stability(WPLIB_STABILITY)); } if (!defined('WPLIB_RUNMODE')) { define('WPLIB_RUNMODE', is_null(self::runmode()) ? WPLib_Runmode::__default : self::runmode()->get_value()); } if (is_null(self::runmode())) { self::set_runmode(new WPLib_Runmode(WPLIB_RUNMODE)); } spl_autoload_register(array(__CLASS__, '_autoloader'), true, true); /** * Set a marker to ignore classes declared before this class. */ self::$_non_app_class_count = count(get_declared_classes()) - 1; self::register_module('posts', 0); self::register_module('terms', 0); self::register_module('roles', 0); self::register_module('users', 0); self::register_module('post-type-post', 0); self::register_module('post-type-page', 0); self::register_module('taxonomy-categories', 0); self::register_module('taxonomy-post-tags', 0); self::register_module('helpers-html', 0); self::register_module('helpers-wp', 0); self::register_module('theme', 0); self::register_module('commit-reviser', 0); /** * Register default User Roles */ self::register_module('role-administrator', 4); self::register_module('role-contributor', 4); self::register_module('role-subscriber', 4); self::register_module('role-editor', 4); self::register_module('role-author', 4); self::add_class_action('init', 9); self::add_class_action('plugins_loaded', 11); self::add_class_action('after_setup_theme'); self::add_class_action('after_setup_theme', 11); self::add_class_action('xmlrpc_call'); self::add_class_action('shutdown'); }