PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 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 All 140 releases
← All changes | inc/class-lp-assets.php +346 -64 4.1.6.9.2 → 4.4.9 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,15 +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(),
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,
81 170 ),
82 - 'lp-checkout' => array(
171 + 'lp-checkout' => array(
83 172 'ajaxurl' => home_url( '/' ),
84 - 'user_checkout' => LP()->checkout()->get_checkout_email(),
173 + //'user_checkout' => LP_Checkout::instance()->get_checkout_email(),
85 174 'i18n_processing' => esc_html__( 'Processing', 'learnpress' ),
86 175 'i18n_redirecting' => esc_html__( 'Redirecting', 'learnpress' ),
87 176 'i18n_invalid_field' => esc_html__( 'Invalid field', 'learnpress' ),
88 177 'i18n_unknown_error' => esc_html__( 'Unknown error', 'learnpress' ),
@@ -87,22 +176,91 @@
87 176 'i18n_invalid_field' => esc_html__( 'Invalid field', 'learnpress' ),
88 177 'i18n_unknown_error' => esc_html__( 'Unknown error', 'learnpress' ),
89 178 'i18n_place_order' => esc_html__( 'Place order', 'learnpress' ),
90 179 ),
91 - 'lp-profile-user' => array(
92 - 'processing' => esc_html__( 'Processing', 'learnpress' ),
93 - 'redirecting' => esc_html__( 'Redirecting', 'learnpress' ),
94 - '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() ),
95 187 ),
96 - //'lp-course' => learn_press_single_course_args(),
97 - 'lp-quiz' => learn_press_single_quiz_args(),
188 + 'lp-quiz' => learn_press_single_quiz_args(),
98 189 ];
99 190
100 191 return apply_filters( 'learnpress/frontend/localize_script', $localize_script );
192 + }
101 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 + );
102 243 }
103 244
104 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 + /**
105 263 * Config load scripts
106 264 *
107 265 * @return array
108 266 */
@@ -119,41 +277,53 @@
119 277
120 278 $scripts = apply_filters(
121 279 'learn-press/frontend-default-scripts',
122 280 array(
123 - 'vue-libs' => new LP_Asset_Key(
281 + /*'vue-libs' => new LP_Asset_Key(
124 282 self::url( 'src/js/vendor/vue/vue_libs_special.min.js' )
125 - ),
126 - 'lp-modal' => new LP_Asset_Key(
283 + ),*/
284 + 'lp-modal' => new LP_Asset_Key(
127 285 self::url( 'js/dist/frontend/modal' . self::$_min_assets . '.js' ),
128 286 array( 'jquery' )
129 287 ),
130 - 'lp-plugins-all' => new LP_Asset_Key( self::url( 'js/vendor/plugins.all.min.js' ) ),
131 - 'lp-global' => new LP_Asset_Key(
288 + // lp-plugins-all use only for FE, when FE 2 release will remove it.
289 + //'lp-plugins-all' => new LP_Asset_Key( self::url( 'js/vendor/plugins.all.min.js' ) ),
290 + 'lp-global' => new LP_Asset_Key(
132 291 self::url( self::$_folder_source . 'js/global' . self::$_min_assets . '.js' ),
133 292 array( 'jquery', 'underscore', 'utils' )
134 293 ),
135 - 'lp-utils' => new LP_Asset_Key(
294 + 'lp-utils' => new LP_Asset_Key(
136 295 self::url( 'js/dist/utils' . self::$_min_assets . '.js' ),
137 296 array( 'jquery' )
138 297 ),
139 - '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(
140 308 self::url( 'js/dist/frontend/checkout' . self::$_min_assets . '.js' ),
141 - array( 'lp-global', 'lp-utils', 'wp-api-fetch', 'jquery' ),
142 - array( LP_PAGE_CHECKOUT ),
309 + [],
310 + [ LP_PAGE_CHECKOUT ],
143 311 0,
144 - 1
312 + 0,
313 + '',
314 + [ 'strategy' => 'async' ]
145 315 ),
146 - 'lp-data-controls' => new LP_Asset_Key(
316 + 'lp-data-controls' => new LP_Asset_Key(
147 317 self::url( 'js/dist/js/data-controls' . self::$_min_assets . '.js' ),
148 318 array_merge( $wp_js, array( 'lp-global' ) )
149 319 ),
150 - 'lp-config' => new LP_Asset_Key(
320 + 'lp-config' => new LP_Asset_Key(
151 321 self::url( 'js/dist/frontend/lp-configs' . self::$_min_assets . '.js' ),
152 322 array_merge( $wp_js, array( 'lp-global' ) )
153 323 ),
154 324 // 'lp-lesson' => new LP_Asset_Key( self::url( self::$_folder_source .'js/frontend/lesson' . self::$_min_assets . '.js' ) ),
155 - 'lp-question-types' => new LP_Asset_Key(
325 + 'lp-question-types' => new LP_Asset_Key(
156 326 self::url( 'js/dist/frontend/question-types' . self::$_min_assets . '.js' ),
157 327 array_merge( $wp_js, array( 'lp-global' ) ),
158 328 array(),
159 329 1,
@@ -158,9 +328,9 @@
158 328 array(),
159 329 1,
160 330 1
161 331 ),
162 - 'lp-single-curriculum' => new LP_Asset_Key(
332 + 'lp-single-curriculum' => new LP_Asset_Key(
163 333 self::url( 'js/dist/frontend/single-curriculum' . self::$_min_assets . '.js' ),
164 334 array_merge(
165 335 $wp_js,
166 336 array(
@@ -169,11 +339,22 @@
169 339 )
170 340 ),
171 341 array( LP_PAGE_SINGLE_COURSE_CURRICULUM ),
172 342 0,
173 - 1
343 + 1,
344 + '',
345 + [ 'strategy' => 'defer' ]
174 346 ),
175 - '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(
176 357 self::url( 'js/dist/frontend/quiz' . self::$_min_assets . '.js' ),
177 358 array_merge(
178 359 $wp_js,
179 360 array(
@@ -188,11 +369,13 @@
188 369 )
189 370 ),
190 371 array( LP_PAGE_QUIZ ),
191 372 0,
192 - 1
373 + 1,
374 + '',
375 + [ 'strategy' => 'defer' ]
193 376 ),
194 - 'lp-single-course' => new LP_Asset_Key(
377 + 'lp-single-course' => new LP_Asset_Key(
195 378 self::url( 'js/dist/frontend/single-course' . self::$_min_assets . '.js' ),
196 379 array_merge(
197 380 $wp_js,
198 381 array(
@@ -201,51 +384,110 @@
201 384 )
202 385 ),
203 386 array( LP_PAGE_SINGLE_COURSE ),
204 387 0,
205 - 1
388 + 0,
389 + '',
390 + [ 'strategy' => 'defer' ]
206 391 ),
207 - 'lp-courses' => new LP_Asset_Key(
392 + /*'lp-courses' => new LP_Asset_Key(
208 393 self::url( 'js/dist/frontend/courses' . self::$_min_assets . '.js' ),
209 - array( 'lp-global', 'lp-utils', 'wp-api-fetch', 'wp-hooks' ),
210 - 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,
211 400 0,
212 - 1
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' ]
213 412 ),
214 - '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(
215 423 self::url( 'js/dist/frontend/profile' . self::$_min_assets . '.js' ),
216 - array_merge(
217 - $wp_js,
218 - array( 'wp-i18n', 'lp-utils' )
219 - ),
424 + [ 'lp-load-ajax', 'wp-i18n' ],
220 425 array( LP_PAGE_PROFILE ),
221 426 0,
222 - 1
427 + 0,
428 + '',
429 + [ 'strategy' => 'defer' ]
223 430 ),
224 - '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(
225 441 self::url( 'js/dist/frontend/widgets' . self::$_min_assets . '.js' ),
226 - array_merge(
227 - $wp_js,
228 - array( 'wp-i18n' )
229 - ),
442 + [ 'lp-course-filter' ],
230 443 array(),
231 444 1,
232 - 1
445 + 0,
446 + '',
447 + [ 'strategy' => 'async' ]
233 448 ),
234 - 'lp-become-a-teacher' => new LP_Asset_Key(
449 + 'lp-become-a-teacher' => new LP_Asset_Key(
235 450 self::url( 'js/dist/frontend/become-teacher' . self::$_min_assets . '.js' ),
236 - array( 'jquery', 'lp-utils' ),
451 + array( 'jquery' ),
237 452 array( LP_PAGE_BECOME_A_TEACHER ),
238 453 0,
239 - 1
454 + 1,
455 + '',
456 + [ 'strategy' => 'defer' ]
240 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 + ),
241 483 )
242 484 );
243 485
244 486 // Dequeue script 'smoothPageScroll' on item details, it makes can't scroll, when rewrite page item detail, can check to remove.
245 487 if ( LP_PAGE_SINGLE_COURSE_CURRICULUM === LP_Page_Controller::page_current() ||
246 - LP_PAGE_QUIZ === LP_Page_Controller::page_current() ||
247 - 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() ) {
248 490 wp_dequeue_script( 'smoothPageScroll' );
249 491 }
250 492
251 493 return $scripts;
@@ -266,8 +508,49 @@
266 508 do_action( 'learn-press/after-enqueue-scripts' );
267 509 }
268 510
269 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 + /**
270 553 * Add lp overlay
271 554 *
272 555 * @since 3.2.8
273 556 * @version 1.0.1
@@ -285,10 +568,10 @@
285 568 if ( 'yes' !== LP_Settings::get_option( 'enable_popup_confirm_finish', 'yes' ) ) {
286 569 return;
287 570 }
288 571
289 - echo '<div class="lp-overlay">';
290 - 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' );
291 574 echo '</div>';
292 575 }
293 576
294 577 public static function instance() {
@@ -313,5 +596,4 @@
313 596 return LP_Assets::instance();
314 597 }
315 598
316 599 learn_press_assets();
317 -