本文整理匯總了PHP中MS_Model_Addon::_reload_files方法的典型用法代碼示例。如果您正苦於以下問題:PHP MS_Model_Addon::_reload_files方法的具體用法?PHP MS_Model_Addon::_reload_files怎麽用?PHP MS_Model_Addon::_reload_files使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MS_Model_Addon
的用法示例。
在下文中一共展示了MS_Model_Addon::_reload_files方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: load_core_addons
/**
* Checks the /app/addon directory for a list of all addons and loads these
* files.
*
* @since 1.0.0
*/
protected static function load_core_addons()
{
$model = MS_Factory::load('MS_Model_Addon');
$root_path = trailingslashit(dirname(dirname(MS_Plugin::instance()->dir)));
$plugin_dir = substr(MS_Plugin::instance()->dir, strlen($root_path));
$addon_dir = $plugin_dir . 'app/addon/';
if (empty($model->addon_files) || self::$_reload_files) {
// In Admin dashboard we always refresh the addon-list...
self::$_reload_files = false;
$mask = $root_path . $addon_dir . '*/class-ms-addon-*.php';
$addons = glob($mask);
$model->addon_files = array();
foreach ($addons as $file) {
$model->addon_files[] = substr($file, strlen($root_path));
}
/**
* Allow other plugins/themes to register custom addons
*
* @since 1.0.0
*
* @var array
*/
$model->addon_files = apply_filters('ms_model_addon_files', $model->addon_files);
$model->save();
}
// Loop all recignized Add-ons and initialize them.
foreach ($model->addon_files as $file) {
$addon = $root_path . $file;
// Get class-name from file-name
$class = basename($file);
$class = str_replace('.php', '', $class);
$class = implode('_', array_map('ucfirst', explode('-', $class)));
$class = substr($class, 6);
// remove 'Class_' prefix
if (file_exists($addon)) {
if (!class_exists($class)) {
try {
include_once $addon;
} catch (Exception $ex) {
}
}
if (class_exists($class)) {
MS_Factory::load($class);
}
}
}
/**
* Allow custom addon-initialization code to run
*
* @since 1.0.0
*/
do_action('ms_model_addon_load');
}