HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux newsites.squeezer-software.com 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 14:14:30 UTC 2025 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/sites/ileskneiss/wp-content/plugins/learnpress/inc/Widgets/LPWidgetBase.php
<?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 );
		}
	}
}