/** * Loads template for the admin page. * * Stores several variables and includes template for the settings page * * @since 0.1.0 * * @see Me::get_all_modules * */ function create_admin_page() { $modules = Me_Utils::get_all_modules(); $activate_nonce = wp_create_nonce('me_module_activate'); $deactivate_nonce = wp_create_nonce('me_module_deactivate'); include ME__PLUGIN_DIR . 'admin/template.php'; }
/** * Gets a list of modules for our API endpoint * * Callback for the GET method of the "modules" endpoint * * @since 0.1.1 * * */ function me_get_modules() { $return = Me_Utils::get_all_modules(); $response = new WP_REST_Response($return); $response->header('Access-Control-Allow-Origin', apply_filters('giar_access_control_allow_origin', '*')); return $response; }
/** * Load the files for each module that is active. * * Sorts through a list of active modules and includes the file * for each one from the /modules folder. * * @since 0.1.0 * * @see Me_Utils::get_active_modules() * @see Me_Utils::get_module_path() * */ private function load_modules() { $modules = Me_Utils::get_active_modules(); foreach ($modules as $module) { if (did_action('me_module_loaded' . $module)) { continue; } require Me_Utils::get_module_path($module); do_action('me_module_loaded' . $module); } }
/** * Deactivate a module. * * Removes the module from the active_modules option * * @since 0.1.0 * * @see get_active_modules * * @param string $module The slug of the module to deactivate * */ public static function deactivate_module($module) { $active = Me_Utils::get_active_modules(); $new = array_filter(array_diff($active, (array) $module)); Me_Utils::update_option('active_modules', $new); return true; }