本文整理汇总了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');
}