/** * Loads all activated plugin for inclusion. * * @access public * @since 1.0.1 * @param * string (optional) $plugins_dir Loads plugins from specified folder * @return mixed */ public function load_activated_plugins($plugins_dir = '') { $plugin = $this->_app->db->plugin(); $q = $plugin->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($q as $k => $v) { $pluginFile = _h($v['location']); $plugin = str_replace('.plugin.php', '', $pluginFile); if (!file_exists($plugins_dir . $plugin . '/' . $pluginFile)) { $file = $plugins_dir . $pluginFile; } else { $file = $plugins_dir . $plugin . '/' . $pluginFile; } $error = etsis_php_check_syntax($file); if (is_etsis_exception($error)) { $this->deactivate_plugin(_h($v['location'])); $this->_app->flash('error_message', sprintf(_t('The plugin <strong>%s</strong> has been deactivated because your changes resulted in a <strong>fatal error</strong>. <br /><br />') . $error->getMessage(), _h($v['location']))); return false; } if (file_exists($file)) { require_once $file; } else { $this->deactivate_plugin(_h($v['location'])); } } }
/** * Validates a plugin and checks to make sure there are no syntax and/or * parsing errors. * * @since 6.2.0 * @param string $plugin_name * Name of the plugin file (i.e. moodle.plugin.php). */ function etsis_validate_plugin($plugin_name) { $app = \Liten\Liten::getInstance(); $plugin = str_replace('.plugin.php', '', $plugin_name); if (!file_exists(ETSIS_PLUGIN_DIR . $plugin . '/' . $plugin_name)) { $file = ETSIS_PLUGIN_DIR . $plugin_name; } else { $file = ETSIS_PLUGIN_DIR . $plugin . '/' . $plugin_name; } $error = etsis_php_check_syntax($file); if (is_etsis_exception($error)) { $app->flash('error_message', _t('Plugin could not be activated because it triggered a <strong>fatal error</strong>. <br /><br />') . $error->getMessage()); return false; } if (file_exists($file)) { include_once $file; } /** * Fires before a specific plugin is activated. * * $pluginName refers to the plugin's * name (i.e. moodle.plugin.php). * * @since 6.1.00 * @param string $plugin_name * The plugin's base name. */ $app->hook->do_action('activate_plugin', $plugin_name); /** * Fires as a specifig plugin is being activated. * * $pluginName refers to the plugin's * name (i.e. moodle.plugin.php). * * @since 6.1.00 * @param string $plugin_name * The plugin's base name. */ $app->hook->do_action('activate_' . $plugin_name); /** * Activate the plugin if there are no errors. * * @since 5.0.0 * @param string $plugin_name * The plugin's base name. */ activate_plugin($plugin_name); /** * Fires after a plugin has been activated. * * $pluginName refers to the plugin's * name (i.e. moodle.plugin.php). * * @since 6.1.06 * @param string $plugin_name * The plugin's base name. */ $app->hook->do_action('activated_plugin', $plugin_name); }