| Server IP : 172.67.147.195 / Your IP : 216.73.216.142 Web Server : Apache/2 System : Linux hosting8537.lvs 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : mienphi ( 1014) PHP Version : 8.2.14 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/mienphi/public_html/wp-content/plugins/learnpress/inc/Widgets/ |
Upload File : |
<?php
namespace LearnPress\Widgets;
use LearnPress\MetaBox\LPMetaBoxField;
use WP_Widget;
/**
* Class AbstractWidget
*
* @package LearnPress\Widgets
* @since 4.2.3.2
* @version 1.0.0
*/
class LPWidgetBase extends WP_Widget {
protected $prefix = 'learnpress_';
protected $lp_widget_id = '';
protected $lp_widget_name = '';
protected $lp_widget_description = '';
protected $lp_widget_class = '';
protected $lp_widget_options = [];
protected $lp_widget_setting = [];
public function __construct() {
$id_base = $this->prefix . $this->lp_widget_id;
$name = $this->lp_widget_name;
$widget_options = array_merge(
[
'description' => $this->lp_widget_description,
'classname' => $this->lp_widget_class,
'customize_selective_refresh' => true,
],
$this->lp_widget_options
);
$control_options = $this->control_options;
parent::__construct( $id_base, $name, $widget_options, $control_options );
}
public function form( $instance ) {
if ( empty( $this->lp_widget_setting ) ) {
echo '<p>' . esc_html_e( 'There are no options for this widget.', 'learnpress' ) . '</p>';
return;
}
foreach ( $this->lp_widget_setting as $key => $setting ) {
$extra = $setting;
$extra['value'] = $instance[ $key ] ?? '';
$extra['default'] = $setting['std'] ?? '';
$extra['id'] = $this->get_field_id( $key );
if ( isset( $setting['type'] ) && LPMetaBoxField::CHECKBOX === $setting['type'] ) {
$html_wrapper = [
'<p style="display:flex;flex-direction:row-reverse;justify-content:left;align-items:center">' => '</p>',
'<label for="' . $extra['id'] . '">' . ( $setting['label'] ?? '' ) . '</label>' => '',
];
} else {
$html_wrapper = [
'<p style="display:flex;flex-direction:column">' => '</p>',
'<label for="' . $extra['id'] . '">' . ( $setting['label'] ?? '' ) . '</label>' => '',
];
}
LPMetaBoxField::render( $setting['type'], $this->get_field_name( $key ), $extra, $html_wrapper );
}
}
}