/** * Renders the markup for the given module. * * @param Module $module Module object. * * @return void */ private function render_module(Module $module) { $is_active = $module->is_active(); $id = 'multilingualpress-module-' . $module->id(); ?> <tr class="<?php echo esc_attr($is_active ? 'active' : 'inactive'); ?> "> <td class="check-column"> <input type="checkbox" name="<?php echo esc_attr('multilingualpress_modules[' . $module->id() . ']'); ?> " value="1" id="<?php echo esc_attr($id); ?> "<?php checked($is_active); ?> > </td> <td> <label for="<?php echo esc_attr($id); ?> " class="mlp-block-label"> <strong><?php echo esc_html($module->name()); ?> </strong> <?php echo wpautop(esc_html($module->description())); ?> </label> </td> </tr> <?php }
/** * 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]; }