PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/Widgets/LPWidgetBase.php +67 -67 4.3.9.14.4.8 View file →
@@ -1,67 +1,67 @@
1 -<?php
2 -
3 -namespace LearnPress\Widgets;
4 -
5 -use LearnPress\MetaBox\LPMetaBoxField;
6 -use WP_Widget;
7 -
8 -/**
9 - * Class AbstractWidget
10 - *
11 - * @package LearnPress\Widgets
12 - * @since 4.2.3.2
13 - * @version 1.0.0
14 - */
15 -class LPWidgetBase extends WP_Widget {
16 - protected $prefix = 'learnpress_';
17 - protected $lp_widget_id = '';
18 - protected $lp_widget_name = '';
19 - protected $lp_widget_description = '';
20 - protected $lp_widget_class = '';
21 - protected $lp_widget_options = [];
22 - protected $lp_widget_setting = [];
23 -
24 - public function __construct() {
25 - $id_base = $this->prefix . $this->lp_widget_id;
26 - $name = $this->lp_widget_name;
27 - $widget_options = array_merge(
28 - [
29 - 'description' => $this->lp_widget_description,
30 - 'classname' => $this->lp_widget_class,
31 - 'customize_selective_refresh' => true,
32 - ],
33 - $this->lp_widget_options
34 - );
35 - $control_options = $this->control_options;
36 - parent::__construct( $id_base, $name, $widget_options, $control_options );
37 - }
38 -
39 - public function form( $instance ) {
40 - if ( empty( $this->lp_widget_setting ) ) {
41 - echo '<p>' . esc_html__( 'There are no options for this widget.', 'learnpress' ) . '</p>';
42 - return;
43 - }
44 -
45 - foreach ( $this->lp_widget_setting as $key => $setting ) {
46 - $extra = $setting;
47 - $extra['value'] = $instance[ $key ] ?? '';
48 - $extra['default'] = $setting['std'] ?? '';
49 - $extra['id'] = $this->get_field_id( $key );
50 -
51 - if ( isset( $setting['type'] ) && LPMetaBoxField::CHECKBOX === $setting['type'] ) {
52 - $html_wrapper = [
53 - '<p style="display:flex;flex-direction:row-reverse;justify-content:left;align-items:center">' => '</p>',
54 - '<label for="' . $extra['id'] . '">' . ( $setting['label'] ?? '' ) . '</label>' => '',
55 - ];
56 - } else {
57 - $html_wrapper = [
58 - '<p style="display:flex;flex-direction:column">' => '</p>',
59 - '<label for="' . $extra['id'] . '">' . ( $setting['label'] ?? '' ) . '</label>' => '',
60 - ];
61 - }
62 -
63 - LPMetaBoxField::render( $setting['type'], $this->get_field_name( $key ), $extra, $html_wrapper );
64 - }
65 - }
66 -}
67 -
1 +<?php
2 +
3 +namespace LearnPress\Widgets;
4 +
5 +use LearnPress\MetaBox\LPMetaBoxField;
6 +use WP_Widget;
7 +
8 +/**
9 + * Class AbstractWidget
10 + *
11 + * @package LearnPress\Widgets
12 + * @since 4.2.3.2
13 + * @version 1.0.0
14 + */
15 +class LPWidgetBase extends WP_Widget {
16 + protected $prefix = 'learnpress_';
17 + protected $lp_widget_id = '';
18 + protected $lp_widget_name = '';
19 + protected $lp_widget_description = '';
20 + protected $lp_widget_class = '';
21 + protected $lp_widget_options = [];
22 + protected $lp_widget_setting = [];
23 +
24 + public function __construct() {
25 + $id_base = $this->prefix . $this->lp_widget_id;
26 + $name = $this->lp_widget_name;
27 + $widget_options = array_merge(
28 + [
29 + 'description' => $this->lp_widget_description,
30 + 'classname' => $this->lp_widget_class,
31 + 'customize_selective_refresh' => true,
32 + ],
33 + $this->lp_widget_options
34 + );
35 + $control_options = $this->control_options;
36 + parent::__construct( $id_base, $name, $widget_options, $control_options );
37 + }
38 +
39 + public function form( $instance ) {
40 + if ( empty( $this->lp_widget_setting ) ) {
41 + echo '<p>' . esc_html__( 'There are no options for this widget.', 'learnpress' ) . '</p>';
42 + return;
43 + }
44 +
45 + foreach ( $this->lp_widget_setting as $key => $setting ) {
46 + $extra = $setting;
47 + $extra['value'] = $instance[ $key ] ?? '';
48 + $extra['default'] = $setting['std'] ?? '';
49 + $extra['id'] = $this->get_field_id( $key );
50 +
51 + if ( isset( $setting['type'] ) && LPMetaBoxField::CHECKBOX === $setting['type'] ) {
52 + $html_wrapper = [
53 + '<p style="display:flex;flex-direction:row-reverse;justify-content:left;align-items:center">' => '</p>',
54 + '<label for="' . $extra['id'] . '">' . ( $setting['label'] ?? '' ) . '</label>' => '',
55 + ];
56 + } else {
57 + $html_wrapper = [
58 + '<p style="display:flex;flex-direction:column">' => '</p>',
59 + '<label for="' . $extra['id'] . '">' . ( $setting['label'] ?? '' ) . '</label>' => '',
60 + ];
61 + }
62 +
63 + LPMetaBoxField::render( $setting['type'], $this->get_field_name( $key ), $extra, $html_wrapper );
64 + }
65 + }
66 +}
67 +