Jetpack::get_module_path PHP Method

get_module_path() public static method

Generate a module's path from its slug.
public static get_module_path ( $slug )
    public static function get_module_path($slug)
    {
        return JETPACK__PLUGIN_DIR . "modules/{$slug}.php";
    }

Usage Example

 public static function activate_module($module, $exit = true, $redirect = true)
 {
     do_action('jetpack_pre_activate_module', $module, $exit);
     $jetpack = Jetpack::init();
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     $module_data = Jetpack::get_module($module);
     if (!Jetpack::is_active()) {
         if (!Jetpack::is_development_mode()) {
             return false;
         }
         // If we're not connected but in development mode, make sure the module doesn't require a connection
         if (Jetpack::is_development_mode() && $module_data['requires_connection']) {
             return false;
         }
     }
     // Check and see if the old plugin is active
     if (isset($jetpack->plugins_to_deactivate[$module])) {
         // Deactivate the old plugin
         if (Jetpack_Client_Server::deactivate_plugin($jetpack->plugins_to_deactivate[$module][0], $jetpack->plugins_to_deactivate[$module][1])) {
             // If we deactivated the old plugin, remembere that with ::state() and redirect back to this page to activate the module
             // We can't activate the module on this page load since the newly deactivated old plugin is still loaded on this page load.
             Jetpack::state('deactivated_plugins', $module);
             wp_safe_redirect(add_query_arg('jetpack_restate', 1));
             exit;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     do_action('jetpack_activate_module', $module);
     $active[] = $module;
     Jetpack_Options::update_option('active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     if ($redirect) {
         wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
     }
     if ($exit) {
         exit;
     }
 }
All Usage Examples Of Jetpack::get_module_path
Jetpack