PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.2.10
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.2.10
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
notificationx / includes / Types / ELearning.php

ELearning.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.2.10, at includes/Types/ELearning.php

306 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Extension Abstract
4 *
5 * @package NotificationX\Extensions
6 */
7
8 namespace NotificationX\Types;
9
10 use NotificationX\Core\Rules;
11 use NotificationX\Extensions\GlobalFields;
12 use NotificationX\GetInstance;
13 use NotificationX\Modules;
14 use NotificationX\NotificationX;
15
16 /**
17 * Extension Abstract for all Extension.
18 * @method static ELearning get_instance($args = null)
19 */
20 class ELearning extends Types {
21 /**
22 * Instance of Admin
23 *
24 * @var Admin
25 */
26 use GetInstance;
27
28 public $priority = 10;
29 public $themes = [];
30 public $module = [
31 'modules_tutor',
32 'modules_learndash',
33 ];
34 public $default_source = 'tutor';
35 public $default_theme = 'elearning_theme-one';
36 public $link_type = 'course_page';
37
38
39 /**
40 * Initially Invoked when initialized.
41 */
42 public function __construct(){
43 parent::__construct();
44 $this->id = 'elearning';
45 add_filter("nx_filtered_entry_{$this->id}", array($this, 'conversion_data'), 10, 2);
46 }
47
48 public function init()
49 {
50 parent::init();
51 $this->title = __('eLearning', 'notificationx');
52 $this->themes = [
53 'theme-one' => [
54 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-1.jpg',
55 'image_shape' => 'circle',
56 'template' => [
57 'first_param' => 'tag_name',
58 'custom_first_param' => __('Someone' , 'notificationx'),
59 'second_param' => __('just enrolled', 'notificationx'),
60 'third_param' => 'tag_course_title',
61 'custom_third_param' => __('Anonymous Course' , 'notificationx'),
62 'fourth_param' => 'tag_time',
63 'custom_fourth_param' => __( 'Some time ago', 'notificationx' ),
64 ],
65 ],
66 'theme-two' => [
67 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-2.jpg',
68 'image_shape' => 'circle',
69 'template' => [
70 'first_param' => 'tag_name',
71 'custom_first_param' => __('Someone' , 'notificationx'),
72 'second_param' => __('recently enrolled' , 'notificationx'),
73 'third_param' => 'tag_course_title',
74 'custom_third_param' => __('Anonymous Course' , 'notificationx'),
75 'fourth_param' => 'tag_time',
76 'custom_fourth_param' => __( 'Some time ago', 'notificationx' ),
77 ],
78 ],
79 'theme-three' => [
80 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-3.jpg',
81 'image_shape' => 'square',
82 'template' => [
83 'first_param' => 'tag_name',
84 'custom_first_param' => __('Someone' , 'notificationx'),
85 'second_param' => __('recently enrolled' , 'notificationx'),
86 'third_param' => 'tag_course_title',
87 'custom_third_param' => __('Anonymous Course' , 'notificationx'),
88 'fourth_param' => 'tag_time',
89 'custom_fourth_param' => __( 'Some time ago', 'notificationx' ),
90 ],
91 ],
92 'theme-four' => array(
93 'is_pro' => true,
94 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-4.png',
95 'image_shape' => 'circle',
96 ),
97 'theme-five' => array(
98 'is_pro' => true,
99 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-5.png',
100 'image_shape' => 'circle',
101 ),
102 'conv-theme-six' => array(
103 'is_pro' => true,
104 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-6.png',
105 'image_shape' => 'circle',
106 ),
107 'conv-theme-seven' => array(
108 'is_pro' => true,
109 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-7.png',
110 'image_shape' => 'rounded',
111 ),
112 'conv-theme-eight' => array(
113 'is_pro' => true,
114 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-8.png',
115 'image_shape' => 'circle',
116 ),
117 'conv-theme-nine' => array(
118 'is_pro' => true,
119 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/elearning-theme-9.png',
120 'image_shape' => 'circle',
121 ),
122 'maps_theme' => array(
123 'is_pro' => true,
124 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/elearning/maps-theme.png',
125 'image_shape' => 'square',
126 'show_notification_image' => 'maps_image',
127 ),
128 ];
129 $this->res_themes = [
130 'res-theme-one' => array(
131 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-1.png',
132 '_template' => 'elearning_template_new',
133 'is_pro' => true,
134 ),
135 'res-theme-two' => array(
136 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-2.png',
137 '_template' => 'elearning_template_new',
138 'is_pro' => true,
139 ),
140 'res-theme-three' => array(
141 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-3.png',
142 '_template' => 'elearning_template_new',
143 'is_pro' => true,
144 ),
145 'res-theme-four' => array(
146 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-4.png',
147 '_template' => 'elearning_template_new',
148 'is_pro' => true,
149 ),
150 'elearning-res-theme-five' => array(
151 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-5.png',
152 '_template' => 'elearning_template_new',
153 'is_pro' => true,
154 ),
155 'elearning-res-theme-six' => array(
156 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-6.png',
157 '_template' => 'maps_template_new',
158 'is_pro' => true,
159 ),
160 'elearning-res-theme-seven' => array(
161 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-7.png',
162 '_template' => 'elearning_template_sales_count',
163 'is_pro' => true,
164 ),
165 'elearning-res-theme-eight' => array(
166 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-8.png',
167 '_template' => 'elearning_template_sales_count',
168 'is_pro' => true,
169 ),
170 'res-theme-nine' => array(
171 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-9.png',
172 '_template' => 'elearning_template_sales_count',
173 'is_pro' => true,
174 ),
175 'elearning-res-theme-ten' => array(
176 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_elearning/elearning-res-theme-10.png',
177 '_template' => 'maps_template_new',
178 'is_pro' => true,
179 ),
180 ];
181 $this->templates = [
182 'elearning_template_new' => [
183 'first_param' => GlobalFields::get_instance()->common_name_fields(),
184 'third_param' => [
185 'tag_course_title' => __('Course Title', 'notificationx'),
186 ],
187 'fourth_param' => [
188 'tag_time' => __('Definite Time', 'notificationx'),
189 ],
190 '_themes' => [
191 'elearning_theme-one',
192 'elearning_theme-two',
193 'elearning_theme-three',
194 'elearning_theme-four',
195 'elearning_theme-five',
196 ]
197 ],
198 'elearning_template_sales_count' => [
199 'first_param' => GlobalFields::get_instance()->common_name_fields(),
200 'third_param' => [
201 'tag_course_title' => __('Course Title', 'notificationx'),
202 ],
203 'fourth_param' => [
204 // 'tag_time' => __('Definite Time', 'notificationx'),
205 ],
206 '_themes' => [
207 'elearning_conv-theme-seven',
208 'elearning_conv-theme-eight',
209 'elearning_conv-theme-nine',
210 ]
211 ],
212 ];
213 }
214
215
216 /**
217 * Hooked to nx_before_metabox_load action.
218 *
219 * @return void
220 */
221 public function init_fields() {
222 parent::init_fields();
223 add_filter('nx_link_types', [$this, 'link_types']);
224 add_filter('nx_content_fields', [$this, 'content_fields']);
225 }
226
227 /**
228 * Needed content fields
229 * @return array
230 */
231 public function content_fields($fields) {
232 $content_fields = &$fields['content']['fields'];
233 $content_fields['ld_product_control'] = array(
234 'name' => 'ld_product_control',
235 'label' => __('Show Notification Of', 'notificationx'),
236 'type' => 'select',
237 'priority' => 200,
238 'default' => 'none',
239 'options' => GlobalFields::get_instance()->normalize_fields(array(
240 'none' => __('All', 'notificationx'),
241 'ld_course' => __('By Course', 'notificationx'),
242 )),
243 'rules' => Rules::is('type', $this->id),
244 );
245
246 $content_fields['ld_course_list'] = array(
247 'name' => 'ld_course_list',
248 'label' => __('Select Course', 'notificationx'),
249 'type' => 'select-async',
250 'multiple' => true,
251 'priority' => 201,
252 'options' => apply_filters('nx_elearning_course_list', [
253 [
254 'label' => "Type for more result...",
255 'value' => null,
256 'disabled' => true,
257 ],
258 ]),
259 'rules' => Rules::logicalRule([
260 Rules::is('type', $this->id),
261 Rules::is('ld_product_control', 'ld_course'),
262 ]),
263 'ajax' => [
264 'api' => "/notificationx/v1/get-data",
265 'data' => [
266 'type' => "@type",
267 'source' => "@source",
268 'field' => "ld_course_list",
269 ],
270 ],
271 );
272
273 return $fields;
274 }
275
276
277 /**
278 * Adds option to Link Type field in Content tab.
279 *
280 * @param array $options
281 * @return array
282 */
283 public function link_types($options) {
284 $_options = GlobalFields::get_instance()->normalize_fields([
285 'course_page' => __('Course Page', 'notificationx'),
286 ], 'type', $this->id);
287
288 return array_merge($options, $_options);
289 }
290
291 public function conversion_data($saved_data, $settings) {
292 if ( ! empty( $saved_data['course_title'] ) ) {
293 $saved_data['course_title'] = strip_tags( html_entity_decode( $saved_data['course_title'] ) );
294 }
295 return $saved_data;
296 }
297
298 public function preview_entry($entry, $settings){
299 $entry = array_merge($entry, [
300 "title" => "PHP Beginners – Become a PHP Master",
301
302 ]);
303 return $entry;
304 }
305 }
306