Inpsyde\MultilingualPress\Module\Module::activate PHP Method

activate() public method

Activates the module.
Since: 3.0.0
public activate ( ) : static
return static Module instance.
    public function activate()
    {
        $this->is_active = true;
        return $this;
    }

Usage Example

 /**
  * Registers the given module.
  *
  * @since 3.0.0
  *
  * @param Module $module Module object.
  *
  * @return bool Whether or not the module is active.
  *
  * @throws ModuleAlreadyRegisteredException if a module with the ID of the given module already has been registered.
  */
 public function register_module(Module $module)
 {
     $id = $module->id();
     if ($this->has_module($id)) {
         throw ModuleAlreadyRegisteredException::for_id($id, 'register');
     }
     if (isset($this->states[$id])) {
         if ($this->states[$id]) {
             $module->activate();
         } else {
             $module->deactivate();
         }
     } else {
         $this->states[$id] = $module->is_active();
         $this->save_modules();
     }
     $this->modules[$id] = $module;
     return $this->states[$id];
 }