Advanced developers can create custom modules that integrate seamlessly with MagicWP.
Module Structure
Create a new directory in wp-content/plugins/magicwp/modules/:
Directory Structure
modules/
└── my-custom-module/
├── class-module.php
├── assets/
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── script.js
└── includes/
Module Template
class-module.php
<?php
namespace MagicWP\Modules\My_Custom_Module;
class Module extends \MagicWP\Core\Module_Base {
protected $module_id = 'my-custom-module';
protected $module_name = 'My Custom Module';
protected $module_description = 'Description of my module';
protected $module_version = '1.0.0';
public function init() {
$this->register_hooks();
}
public function register_hooks() {
add_action( 'wp_footer', [ $this, 'render_output' ] );
}
public function get_settings_schema() {
return array(
'my_setting' => array(
'type' => 'text',
'label' => __( 'My Setting', 'magicwp' ),
'default' => 'Default value',
),
);
}
public function enqueue_frontend_assets() {
wp_enqueue_style(
'magicwp-my-module',
$this->module_url . 'assets/css/style.css',
array(),
$this->module_version
);
wp_enqueue_script(
'magicwp-my-module',
$this->module_url . 'assets/js/script.js',
array(),
$this->module_version,
true
);
}
public function render_output() {
$settings = $this->get_settings();
}
}
Custom modules added directly to the plugin directory will be lost during updates. Consider creating modules as separate plugins or use a child plugin approach.