| Server IP : 47.82.179.145 / Your IP : 216.73.217.129 Web Server : nginx/1.26.3 System : Linux iZt4n9czhka2zvqfajdlr2Z 6.8.0-63-generic #66-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 13 20:25:30 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.3.30 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/scuipturepactory.com/wp-content/themes/plover/core/src/Services/Settings/ |
Upload File : |
<?php
namespace Plover\Core\Services\Settings;
use Plover\Core\Plover;
/**
* @since 1.0.0
*/
class Modules {
/**
* All registered modules.
*
* @var array
*/
protected $modules = [];
/**
* All registered module groups.
*
* @var array
*/
protected $groups = [];
/**
* @var Plover
*/
protected $core;
/**
* @var Settings
*/
protected $settings;
/**
* Create modules instance.
*
* @param Plover $core
*/
public function __construct( Plover $core, Settings $settings ) {
$this->core = $core;
$this->settings = $settings;
$this->register_group( 'theme', array(
'label' => __( 'Theme', 'plover' ),
'description' => __( 'Extensions provided by the active theme.', 'plover' ),
) );
$this->register_group( 'default', array(
'label' => __( 'Modules', 'plover' ),
'description' => __( 'Standalone feature, similar to a WordPress plugin.', 'plover' ),
) );
$this->register_group( 'motion-effects', array(
'label' => __( 'Motion Effects', 'plover' ),
'description' => __( 'Bring your website to life with dynamic motion effects!', 'plover' ),
) );
$this->register_group( 'blocks', array(
'label' => __( 'Blocks', 'plover' ),
'description' => __( 'Blocks or block variations provided by this plugin.', 'plover' ),
) );
$this->register_group( 'extensions', array(
'label' => __( 'Block Extensions', 'plover' ),
'description' => __( 'Take your WordPress editing experience to the next level!', 'plover' ),
) );
$this->register_group( 'supports', array(
'label' => __( 'Block Styles', 'plover' ),
'description' => __( 'Empower your creativity: visual CSS tools for your design!', 'plover' ),
) );
add_filter( 'plover_core_dashboard_data', function ( $data ) {
$data['modules'] = array_map( function ( $module ) {
$module['label'] = esc_html( $module['label'] );
$module['excerpt'] = esc_html( $module['excerpt'] );
$module['order'] = absint( $module['order'] );
$module['description'] = wp_kses_post( $module['description'] );
return $module;
}, $this->modules );
$data['module_groups'] = $this->groups;
return $data;
} );
}
/**
* Register a module group.
*
* @param $slug
* @param array $args
*
* @return void
*/
public function register_group( $slug, $args = array() ) {
static $order = 0;
$args = wp_parse_args( $args, array(
'label' => '',
'description' => '',
'order' => $order ++,
) );
if ( ! empty( $args['label'] ) ) {
$this->groups[ $slug ] = array(
'label' => esc_html( $args['label'] ),
'description' => esc_html( $args['description'] ),
'order' => absint( $args['order'] ),
);
}
}
/**
* Register module.
*
* @param $id
* @param $args
*
* @return void
* @throws \Exception
*/
public function register( $id, $args = array() ) {
if ( isset( $this->modules[ $id ] ) ) {
return;
}
static $order = 0;
$args = wp_parse_args( $args, array(
'recent' => false,
'premium' => false,
'group' => 'default',
'label' => '',
'enabled' => 'yes',
'excerpt' => '',
'icon' => '',
'description' => '',
'fields' => array(),
'order' => $order ++,
) );
$this->settings->add_group( $id, array(
'default' => $args['enabled'],
) );
$fields = $args['fields'] ?? array();
$args['enabled'] = $this->settings->get( $id );
$args['fields'] = array();
$this->modules[ $id ] = $args;
foreach ( $fields as $field => $field_args ) {
$this->add_field( $id, $field, $field_args );
}
}
/**
* Add a field to exists module.
*
* @param $module
* @param $field
* @param $args
*
* @return void
*/
public function add_field( $module, $field, $args = array() ) {
if ( ! isset( $this->modules[ $module ] ) ) {
return;
}
$field_args = wp_parse_args( $args, array(
'label' => '',
'default' => '',
'control' => Control::T_TEXT,
) );
$this->settings->add_field( $module, $field, array(
'default' => $field_args['default'],
'sanitize' => Control::sanitize(
$field_args['control'],
array_merge(
$field_args['control_args'] ?? array(),
array( 'default' => $field_args['default'] )
)
),
) );
$field_args['value'] = $this->settings->get( $module, $field );
$this->modules[ $module ]['fields'][ $field ] = $field_args;
}
/**
* Get registered field args
*
* @param $module
* @param $field
*
* @return mixed|null
*/
public function get_field( $module, $field ) {
return $this->modules[ $module ]['fields'][ $field ] ?? null;
}
/**
* Unregister exists module.
*
* @param $slug
*
* @return void
*/
public function unregister( $slug ) {
unset( $this->modules[ $slug ] );
}
}