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/class-lp-assets.php +344 -64 4.2.04.4.8 View file →
@@ -6,8 +6,10 @@
6 6 * @package LearnPress/Classes
7 7 * @version 4.0.1
8 8 */
9 9
10 +use LearnPress\Services\OpenAiService;
11 +
10 12 defined( 'ABSPATH' ) || exit;
11 13
12 14 class LP_Assets extends LP_Abstract_Assets {
13 15 protected static $_instance;
@@ -18,8 +20,10 @@
18 20 protected function __construct() {
19 21 parent::__construct();
20 22
21 23 add_action( 'wp_print_footer_scripts', array( $this, 'show_overlay' ) );
24 + //Note: hook wp_head load before hook wp_enqueue_scripts
25 + add_action( 'wp_head', [ $this, 'load_scripts_styles_on_head' ], - 1 );
22 26 }
23 27
24 28 /**
25 29 * Get default styles in frontend.
@@ -28,22 +32,54 @@
28 32 */
29 33 protected function _get_styles(): array {
30 34 $is_rtl = is_rtl() ? '-rtl' : '';
31 35
32 - return apply_filters(
36 + $only_register_css_learnpress = false;
37 + if ( wp_is_block_theme() ) {
38 + if ( LP_Page_Controller::is_page_courses() ) {
39 + $only_register_css_learnpress = true;
40 + }
41 +
42 + if ( LP_Page_Controller::is_page_single_course() ) {
43 + global $post;
44 + setup_postdata( $post );
45 + $course_item = LP_Global::course_item();
46 + if ( ! $course_item ) {
47 + $only_register_css_learnpress = true;
48 + }
49 + }
50 + }
51 +
52 + $styles = apply_filters(
33 53 'learn-press/frontend-default-styles',
34 54 array(
35 - 'font-awesome-5-all' => new LP_Asset_Key(
36 - self::url( 'src/css/vendor/font-awesome-5.min.css' ),
55 + 'learnpress' => new LP_Asset_Key(
56 + self::url( 'css/learnpress' . $is_rtl . self::$_min_assets . '.css' ),
37 57 array(),
38 - array()
58 + array(
59 + LP_PAGE_COURSES,
60 + LP_PAGE_SINGLE_COURSE,
61 + LP_PAGE_SINGLE_COURSE_CURRICULUM,
62 + LP_PAGE_QUIZ,
63 + LP_PAGE_QUESTION,
64 + LP_PAGE_CHECKOUT,
65 + LP_PAGE_BECOME_A_TEACHER,
66 + LP_PAGE_PROFILE,
67 + ),
68 + $only_register_css_learnpress
39 69 ),
40 - 'learnpress' => new LP_Asset_Key(
41 - self::url( 'css/learnpress' . $is_rtl . self::$_min_assets . '.css' ),
42 - array( 'font-awesome-5-all' ),
43 - array( LP_PAGE_COURSES, LP_PAGE_SINGLE_COURSE, LP_PAGE_SINGLE_COURSE_CURRICULUM, LP_PAGE_QUIZ, LP_PAGE_QUESTION, LP_PAGE_CHECKOUT, LP_PAGE_BECOME_A_TEACHER, LP_PAGE_PROFILE ),
44 - 0
70 + 'lp-instructor' => new LP_Asset_Key(
71 + self::url( 'css/instructor' . $is_rtl . self::$_min_assets . '.css' ),
72 + array(),
73 + array(),
74 + 1
45 75 ),
76 + 'lp-instructors' => new LP_Asset_Key(
77 + self::url( 'css/instructors' . $is_rtl . self::$_min_assets . '.css' ),
78 + [],
79 + [],
80 + 1
81 + ),
46 82 'learnpress-widgets' => new LP_Asset_Key(
47 83 self::url( 'css/widgets' . $is_rtl . self::$_min_assets . '.css' ),
48 84 array(),
49 85 array(),
@@ -48,10 +84,57 @@
48 84 array(),
49 85 array(),
50 86 0
51 87 ),
88 + 'lp-edit-curriculum' => new LP_Asset_Key(
89 + $this->url( 'css/edit-curriculum' . $is_rtl . self::$_min_assets . '.css' ),
90 + [],
91 + [],
92 + 1
93 + ),
94 + 'lp-edit-quiz' => new LP_Asset_Key(
95 + $this->url( 'css/edit-quiz' . $is_rtl . self::$_min_assets . '.css' ),
96 + [],
97 + [],
98 + 1
99 + ),
100 + 'lp-edit-question' => new LP_Asset_Key(
101 + $this->url( 'css/edit-question' . $is_rtl . self::$_min_assets . '.css' ),
102 + [],
103 + [],
104 + 1
105 + ),
106 + 'lp-course-builder' => new LP_Asset_Key(
107 + self::url( 'css/course-builder' . $is_rtl . self::$_min_assets . '.css' ),
108 + array(),
109 + array( LP_PAGE_COURSE_BUILDER ),
110 + 0
111 + ),
112 + 'lp-tom-select' => new LP_Asset_Key(
113 + self::url( 'src/css/vendor/tom-select.min.css' ),
114 + [],
115 + [],
116 + 0
117 + ),
118 + 'lp-ai-assistant' => new LP_Asset_Key(
119 + self::url( 'css/frontend/ai-assistant' . self::$_min_assets . '.css' ),
120 + array(),
121 + array( LP_PAGE_SINGLE_COURSE_CURRICULUM ),
122 + 1
123 + ),
52 124 )
53 125 );
126 +
127 + if ( wp_is_block_theme() ) {
128 + $styles['learnpress-block'] = new LP_Asset_Key(
129 + self::url( 'css/learnpress-block' . $is_rtl . self::$_min_assets . '.css' ),
130 + array(),
131 + array(),
132 + 0
133 + );
134 + }
135 +
136 + return $styles;
54 137 }
55 138
56 139 /**
57 140 * Set localize script data
@@ -59,15 +142,15 @@
59 142 * @return array
60 143 */
61 144 public function _get_script_data(): array {
62 145 $localize_script = [
63 - 'lp-global' => array(
64 - 'url' => learn_press_get_current_url(),
146 + 'lp-global' => array(
147 + //'url' => learn_press_get_current_url(),
65 148 'siteurl' => site_url(),
66 149 'ajax' => admin_url( 'admin-ajax.php' ),
67 150 'courses_url' => learn_press_get_page_link( 'courses' ),
68 151 'post_id' => get_the_ID(),
69 - 'user_id' => get_current_user_id(), // use: course-progress.
152 + 'user_id' => get_current_user_id(),
70 153 'theme' => get_stylesheet(),
71 154 'localize' => array(
72 155 'button_ok' => esc_html__( 'OK', 'learnpress' ),
73 156 'button_cancel' => esc_html__( 'Cancel', 'learnpress' ),
@@ -74,16 +157,21 @@
74 157 'button_yes' => esc_html__( 'Yes', 'learnpress' ),
75 158 'button_no' => esc_html__( 'No', 'learnpress' ),
76 159 ),
77 160 'lp_rest_url' => get_rest_url(),
161 + //Todo: should create nonce for guest and user separation
78 162 'nonce' => wp_create_nonce( 'wp_rest' ),
79 163 'option_enable_popup_confirm_finish' => LP_Settings::get_option( 'enable_popup_confirm_finish', 'yes' ),
80 - 'is_course_archive' => learn_press_is_courses(),
164 + 'is_course_archive' => LP_Page_Controller::is_page_courses(),
81 165 'lpArchiveSkeleton' => lp_archive_skeleton_get_args(),
166 + 'lpArchiveLoadAjax' => LP_Settings_Courses::is_ajax_load_courses() ? 1 : 0,
167 + 'lpArchiveNoLoadAjaxFirst' => LP_Settings_Courses::is_ajax_load_courses() && LP_Settings_Courses::is_no_load_ajax_first_courses() ? 1 : 0,
168 + 'lpArchivePaginationType' => LP_Settings::get_option( 'course_pagination_type' ),
169 + 'noLoadCoursesJs' => LP_Settings::theme_no_support_load_courses_ajax() ? 1 : 0,
82 170 ),
83 - 'lp-checkout' => array(
171 + 'lp-checkout' => array(
84 172 'ajaxurl' => home_url( '/' ),
85 - 'user_checkout' => LearnPress::instance()->checkout()->get_checkout_email(),
173 + //'user_checkout' => LP_Checkout::instance()->get_checkout_email(),
86 174 'i18n_processing' => esc_html__( 'Processing', 'learnpress' ),
87 175 'i18n_redirecting' => esc_html__( 'Redirecting', 'learnpress' ),
88 176 'i18n_invalid_field' => esc_html__( 'Invalid field', 'learnpress' ),
89 177 'i18n_unknown_error' => esc_html__( 'Unknown error', 'learnpress' ),
@@ -88,22 +176,91 @@
88 176 'i18n_invalid_field' => esc_html__( 'Invalid field', 'learnpress' ),
89 177 'i18n_unknown_error' => esc_html__( 'Unknown error', 'learnpress' ),
90 178 'i18n_place_order' => esc_html__( 'Place order', 'learnpress' ),
91 179 ),
92 - 'lp-profile-user' => array(
93 - 'processing' => esc_html__( 'Processing', 'learnpress' ),
94 - 'redirecting' => esc_html__( 'Redirecting', 'learnpress' ),
95 - 'avatar_size' => learn_press_get_avatar_thumb_size(),
180 + 'lp-profile' => array(
181 + 'text_upload' => __( 'Upload', 'learnpress' ),
182 + 'text_replace' => __( 'Replace', 'learnpress' ),
183 + 'text_remove' => __( 'Remove', 'learnpress' ),
184 + 'text_save' => __( 'Save', 'learnpress' ),
185 + 'avatar_dimensions' => learn_press_get_avatar_thumb_size(),
186 + 'default_avatar' => get_avatar_url( get_current_user_id() ),
96 187 ),
97 - //'lp-course' => learn_press_single_course_args(),
98 - 'lp-quiz' => learn_press_single_quiz_args(),
188 + 'lp-quiz' => learn_press_single_quiz_args(),
99 189 ];
100 190
101 191 return apply_filters( 'learnpress/frontend/localize_script', $localize_script );
192 + }
102 193
194 + /**
195 + * Localize data for all page frontend.
196 + *
197 + * @return array
198 + */
199 + public function localize_data_global(): array {
200 + $cover_image_dimensions = LP_Settings::get_option(
201 + 'cover_image_dimensions',
202 + array(
203 + 'width' => 1290,
204 + 'height' => 250,
205 + )
206 + );
207 + $aspectRatio = $cover_image_dimensions['width'] / $cover_image_dimensions['height'];
208 +
209 + return apply_filters(
210 + 'learn-press/frontend/localize-data-global',
211 + [
212 + 'site_url' => site_url(),
213 + 'user_id' => get_current_user_id(),
214 + 'theme' => get_stylesheet(),
215 + 'lp_rest_url' => get_rest_url(),
216 + 'nonce' => wp_create_nonce( 'wp_rest' ),
217 + 'is_course_archive' => LP_Page_Controller::is_page_courses(),
218 + 'courses_url' => learn_press_get_page_link( 'courses' ),
219 + 'urlParams' => lp_archive_skeleton_get_args(),
220 + 'lp_version' => LearnPress::instance()->version,
221 + 'lp_rest_load_ajax' => get_rest_url( null, 'lp/v1/load_content_via_ajax/' ), // @deprecated 4.3.0
222 + 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
223 + 'lpAjaxUrl' => LP_Settings::url_handle_lp_ajax(),
224 + 'coverImageRatio' => $aspectRatio,
225 + 'toast' => [
226 + 'gravity' => 'bottom',
227 + 'position' => 'center',
228 + 'duration' => 3000,
229 + 'close' => 1,
230 + 'stopOnFocus' => 1,
231 + 'classPrefix' => 'lp-toast',
232 + ],
233 + 'i18n' => [
234 + 'yes' => esc_html__( 'Yes' ),
235 + 'cancel' => esc_html__( 'Cancel' ),
236 + 'generate_with_ai' => esc_html__( 'Generate with AI', 'learnpress' ),
237 + 'confirm_close_ai' => esc_html__( 'Are you sure you want to close? Generate data will stop.', 'learnpress' ),
238 + ],
239 + 'enable_open_ai' => OpenAiService::instance()->is_enable()
240 + && ! empty( LP_Settings::get_option( 'open_ai_secret_key', '' ) ),
241 + ]
242 + );
103 243 }
104 244
105 245 /**
246 + * Localize data for all page frontend.
247 + *
248 + * @return array
249 + */
250 + public function localize_data_courses(): array {
251 + return apply_filters(
252 + 'learn-press/frontend/localize-script/courses',
253 + [
254 + 'lpArchiveLoadAjax' => LP_Settings_Courses::is_ajax_load_courses() ? 1 : 0,
255 + 'lpArchiveNoLoadAjaxFirst' => LP_Settings_Courses::is_ajax_load_courses() && LP_Settings_Courses::is_no_load_ajax_first_courses() ? 1 : 0,
256 + 'lpArchivePaginationType' => LP_Settings::get_option( 'course_pagination_type' ),
257 + 'noLoadCoursesJs' => LP_Settings::theme_no_support_load_courses_ajax() ? 1 : 0,
258 + ]
259 + );
260 + }
261 +
262 + /**
106 263 * Config load scripts
107 264 *
108 265 * @return array
109 266 */
@@ -120,42 +277,53 @@
120 277
121 278 $scripts = apply_filters(
122 279 'learn-press/frontend-default-scripts',
123 280 array(
124 - 'vue-libs' => new LP_Asset_Key(
281 + /*'vue-libs' => new LP_Asset_Key(
125 282 self::url( 'src/js/vendor/vue/vue_libs_special.min.js' )
126 - ),
127 - 'lp-modal' => new LP_Asset_Key(
283 + ),*/
284 + 'lp-modal' => new LP_Asset_Key(
128 285 self::url( 'js/dist/frontend/modal' . self::$_min_assets . '.js' ),
129 286 array( 'jquery' )
130 287 ),
131 288 // lp-plugins-all use only for FE, when FE 2 release will remove it.
132 - 'lp-plugins-all' => new LP_Asset_Key( self::url( 'js/vendor/plugins.all.min.js' ) ),
133 - 'lp-global' => new LP_Asset_Key(
289 + //'lp-plugins-all' => new LP_Asset_Key( self::url( 'js/vendor/plugins.all.min.js' ) ),
290 + 'lp-global' => new LP_Asset_Key(
134 291 self::url( self::$_folder_source . 'js/global' . self::$_min_assets . '.js' ),
135 292 array( 'jquery', 'underscore', 'utils' )
136 293 ),
137 - 'lp-utils' => new LP_Asset_Key(
294 + 'lp-utils' => new LP_Asset_Key(
138 295 self::url( 'js/dist/utils' . self::$_min_assets . '.js' ),
139 296 array( 'jquery' )
140 297 ),
141 - 'lp-checkout' => new LP_Asset_Key(
298 + 'lp-load-ajax' => new LP_Asset_Key(
299 + self::url( 'js/dist/loadAJAX' . self::$_min_assets . '.js' ),
300 + [ 'wp-hooks' ],
301 + [],
302 + 0,
303 + 0,
304 + '',
305 + [ 'strategy' => 'async' ]
306 + ),
307 + 'lp-checkout' => new LP_Asset_Key(
142 308 self::url( 'js/dist/frontend/checkout' . self::$_min_assets . '.js' ),
143 - array( 'lp-global', 'lp-utils', 'wp-api-fetch', 'jquery' ),
144 - array( LP_PAGE_CHECKOUT ),
309 + [],
310 + [ LP_PAGE_CHECKOUT ],
145 311 0,
146 - 1
312 + 0,
313 + '',
314 + [ 'strategy' => 'async' ]
147 315 ),
148 - 'lp-data-controls' => new LP_Asset_Key(
316 + 'lp-data-controls' => new LP_Asset_Key(
149 317 self::url( 'js/dist/js/data-controls' . self::$_min_assets . '.js' ),
150 318 array_merge( $wp_js, array( 'lp-global' ) )
151 319 ),
152 - 'lp-config' => new LP_Asset_Key(
320 + 'lp-config' => new LP_Asset_Key(
153 321 self::url( 'js/dist/frontend/lp-configs' . self::$_min_assets . '.js' ),
154 322 array_merge( $wp_js, array( 'lp-global' ) )
155 323 ),
156 324 // 'lp-lesson' => new LP_Asset_Key( self::url( self::$_folder_source .'js/frontend/lesson' . self::$_min_assets . '.js' ) ),
157 - 'lp-question-types' => new LP_Asset_Key(
325 + 'lp-question-types' => new LP_Asset_Key(
158 326 self::url( 'js/dist/frontend/question-types' . self::$_min_assets . '.js' ),
159 327 array_merge( $wp_js, array( 'lp-global' ) ),
160 328 array(),
161 329 1,
@@ -160,9 +328,9 @@
160 328 array(),
161 329 1,
162 330 1
163 331 ),
164 - 'lp-single-curriculum' => new LP_Asset_Key(
332 + 'lp-single-curriculum' => new LP_Asset_Key(
165 333 self::url( 'js/dist/frontend/single-curriculum' . self::$_min_assets . '.js' ),
166 334 array_merge(
167 335 $wp_js,
168 336 array(
@@ -171,11 +339,22 @@
171 339 )
172 340 ),
173 341 array( LP_PAGE_SINGLE_COURSE_CURRICULUM ),
174 342 0,
175 - 1
343 + 1,
344 + '',
345 + [ 'strategy' => 'defer' ]
176 346 ),
177 - 'lp-quiz' => new LP_Asset_Key(
347 + 'lp-curriculum' => new LP_Asset_Key(
348 + self::url( 'js/dist/frontend/curriculum' . self::$_min_assets . '.js' ),
349 + [],
350 + array( LP_PAGE_SINGLE_COURSE_CURRICULUM, LP_PAGE_SINGLE_COURSE ),
351 + 0,
352 + 0,
353 + '',
354 + [ 'strategy' => 'async' ]
355 + ),
356 + 'lp-quiz' => new LP_Asset_Key(
178 357 self::url( 'js/dist/frontend/quiz' . self::$_min_assets . '.js' ),
179 358 array_merge(
180 359 $wp_js,
181 360 array(
@@ -190,11 +369,13 @@
190 369 )
191 370 ),
192 371 array( LP_PAGE_QUIZ ),
193 372 0,
194 - 1
373 + 1,
374 + '',
375 + [ 'strategy' => 'defer' ]
195 376 ),
196 - 'lp-single-course' => new LP_Asset_Key(
377 + 'lp-single-course' => new LP_Asset_Key(
197 378 self::url( 'js/dist/frontend/single-course' . self::$_min_assets . '.js' ),
198 379 array_merge(
199 380 $wp_js,
200 381 array(
@@ -203,51 +384,110 @@
203 384 )
204 385 ),
205 386 array( LP_PAGE_SINGLE_COURSE ),
206 387 0,
207 - 1
388 + 0,
389 + '',
390 + [ 'strategy' => 'defer' ]
208 391 ),
209 - 'lp-courses' => new LP_Asset_Key(
392 + /*'lp-courses' => new LP_Asset_Key(
210 393 self::url( 'js/dist/frontend/courses' . self::$_min_assets . '.js' ),
211 - array( 'lp-global', 'lp-utils', 'wp-hooks' ),
212 - array( LP_PAGE_COURSES ),
394 + array(
395 + 'lp-global',
396 + 'wp-hooks',
397 + ), // when Eduma v5.3.6 release a long time, will be remove lp-global.
398 + array(),
399 + 1,
213 400 0,
214 - 0
401 + '',
402 + [ 'strategy' => 'defer' ]
403 + ),*/
404 + 'lp-courses-v2' => new LP_Asset_Key(
405 + self::url( 'js/dist/frontend/courses-v2' . self::$_min_assets . '.js' ),
406 + [ 'utils', 'wp-hooks' ], // dependency utils of wp, because js is using wpCookies
407 + [ LP_PAGE_COURSES ],
408 + 0,
409 + 0,
410 + '',
411 + [ 'strategy' => 'async' ]
215 412 ),
216 - 'lp-profile' => new LP_Asset_Key(
413 + 'lp-instructors' => new LP_Asset_Key(
414 + self::url( 'js/dist/frontend/instructors' . self::$_min_assets . '.js' ),
415 + [ 'lp-global' ],
416 + [],
417 + 1,
418 + 0,
419 + '',
420 + [ 'strategy' => 'defer' ]
421 + ),
422 + 'lp-profile' => new LP_Asset_Key(
217 423 self::url( 'js/dist/frontend/profile' . self::$_min_assets . '.js' ),
218 - array_merge(
219 - $wp_js,
220 - array( 'wp-i18n', 'lp-utils' )
221 - ),
424 + [ 'lp-load-ajax', 'wp-i18n' ],
222 425 array( LP_PAGE_PROFILE ),
223 426 0,
224 - 1
427 + 0,
428 + '',
429 + [ 'strategy' => 'defer' ]
225 430 ),
226 - 'lp-widgets' => new LP_Asset_Key(
431 + 'lp-list-students-enrolled' => new LP_Asset_Key(
432 + self::url( 'dist/js/admin/list-students-enrolled' . self::$_min_assets . '.js' ),
433 + [ 'lp-load-ajax' ],
434 + [ LP_PAGE_PROFILE ],
435 + 0,
436 + 0,
437 + '',
438 + [ 'strategy' => 'async' ]
439 + ),
440 + 'lp-widgets' => new LP_Asset_Key(
227 441 self::url( 'js/dist/frontend/widgets' . self::$_min_assets . '.js' ),
228 - array_merge(
229 - $wp_js,
230 - array( 'wp-i18n' )
231 - ),
442 + [ 'lp-course-filter' ],
232 443 array(),
233 444 1,
234 - 1
445 + 0,
446 + '',
447 + [ 'strategy' => 'async' ]
235 448 ),
236 - 'lp-become-a-teacher' => new LP_Asset_Key(
449 + 'lp-become-a-teacher' => new LP_Asset_Key(
237 450 self::url( 'js/dist/frontend/become-teacher' . self::$_min_assets . '.js' ),
238 - array( 'jquery', 'lp-utils' ),
451 + array( 'jquery' ),
239 452 array( LP_PAGE_BECOME_A_TEACHER ),
240 453 0,
241 - 1
454 + 1,
455 + '',
456 + [ 'strategy' => 'defer' ]
242 457 ),
458 + 'lp-course-filter' => new LP_Asset_Key(
459 + self::url( 'js/dist/frontend/course-filter' . self::$_min_assets . '.js' ),
460 + array(),
461 + array(),
462 + 1,
463 + 0,
464 + '',
465 + [ 'strategy' => 'async' ]
466 + ),
467 + 'lp-course-builder' => new LP_Asset_Key(
468 + self::url( 'dist/js/frontend/course-builder' . self::$_min_assets . '.js' ),
469 + array( 'wp-tinymce', 'editor', 'lp-load-ajax' ),
470 + array( LP_PAGE_COURSE_BUILDER ),
471 + 0,
472 + 0,
473 + '',
474 + [ 'strategy' => 'defer' ]
475 + ),
476 + 'lp-ai-assistant' => new LP_Asset_Key(
477 + self::url( 'js/dist/frontend/ai-assistant' . self::$_min_assets . '.js' ),
478 + array(),
479 + array( LP_PAGE_SINGLE_COURSE_CURRICULUM ),
480 + 1,
481 + 1,
482 + ),
243 483 )
244 484 );
245 485
246 486 // Dequeue script 'smoothPageScroll' on item details, it makes can't scroll, when rewrite page item detail, can check to remove.
247 487 if ( LP_PAGE_SINGLE_COURSE_CURRICULUM === LP_Page_Controller::page_current() ||
248 - LP_PAGE_QUIZ === LP_Page_Controller::page_current() ||
249 - LP_PAGE_QUESTION === LP_Page_Controller::page_current() ) {
488 + LP_PAGE_QUIZ === LP_Page_Controller::page_current() ||
489 + LP_PAGE_QUESTION === LP_Page_Controller::page_current() ) {
250 490 wp_dequeue_script( 'smoothPageScroll' );
251 491 }
252 492
253 493 return $scripts;
@@ -268,8 +508,49 @@
268 508 do_action( 'learn-press/after-enqueue-scripts' );
269 509 }
270 510
271 511 /**
512 + * Add javascript to head
513 + * Add style to head
514 + *
515 + * @return void
516 + */
517 + public function load_scripts_styles_on_head() {
518 + $this->load_scripts_on_head();
519 + $this->load_styles_on_head();
520 + }
521 +
522 + /**
523 + * Load scripts on head
524 + * @return void
525 + */
526 + public function load_scripts_on_head() {
527 + LP_Helper::print_inline_script_tag( 'lpData', $this->localize_data_global(), [ 'id' => 'lpData' ] );
528 + LP_Helper::print_inline_script_tag( 'lpSettingCourses', $this->localize_data_courses(), [ 'id' => 'lpSettingCourses' ] );
529 + }
530 +
531 + /**
532 + * Load styles on head
533 + * @return void
534 + */
535 + public function load_styles_on_head() {
536 + $max_width = esc_html( LP_Settings::get_option( 'width_container', '1290px' ) );
537 + $padding_container = apply_filters( 'learn-press/container-padding-width', '1rem' );
538 + $primary_color = esc_html( LP_Settings::get_option( 'primary_color' ) );
539 + $secondary_color = esc_html( LP_Settings::get_option( 'secondary_color' ) );
540 + ?>
541 + <style id="learn-press-custom-css">
542 + :root {
543 + --lp-container-max-width: <?php echo $max_width; ?>;
544 + --lp-cotainer-padding: <?php echo $padding_container; ?>;
545 + --lp-primary-color: <?php echo ! empty( $primary_color ) ? $primary_color : '#ffb606'; ?>;
546 + --lp-secondary-color: <?php echo ! empty( $secondary_color ) ? $secondary_color : '#442e66'; ?>;
547 + }
548 + </style>
549 + <?php
550 + }
551 +
552 + /**
272 553 * Add lp overlay
273 554 *
274 555 * @since 3.2.8
275 556 * @version 1.0.1
@@ -287,10 +568,10 @@
287 568 if ( 'yes' !== LP_Settings::get_option( 'enable_popup_confirm_finish', 'yes' ) ) {
288 569 return;
289 570 }
290 571
291 - echo '<div class="lp-overlay">';
292 - apply_filters( 'learnpress/modal-dialog', learn_press_get_template( 'global/lp-modal-overlay' ) );
572 + echo '<div class="lp-overlay" style="display: none">';
573 + learn_press_get_template( 'global/lp-modal-overlay' );
293 574 echo '</div>';
294 575 }
295 576
296 577 public static function instance() {
@@ -315,5 +596,4 @@
315 596 return LP_Assets::instance();
316 597 }
317 598
318 599 learn_press_assets();
319 -