PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.9
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 4.2.1 All 138 releases
learnpress / inc / admin / class-lp-admin-assets.php

class-lp-admin-assets.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.9, at inc/admin/class-lp-admin-assets.php

676 lines 20.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use LearnPress\Helpers\Config;
4 use LearnPress\Helpers\Template;
5 use LearnPress\Models\CourseModel;
6
7 /**
8 * Class LP_Admin_Assets
9 *
10 * Manage admin assets
11 */
12 class LP_Admin_Assets extends LP_Abstract_Assets {
13 protected static $_instance;
14
15 /**
16 * LP_Admin_Assets constructor.
17 */
18 protected function __construct() {
19 add_action( 'admin_footer', array( $this, 'add_elements_global' ) );
20 add_action( 'admin_print_scripts', array( $this, 'load_scripts_styles_on_head' ), - 1 );
21 parent::__construct();
22 }
23
24 /**
25 * Add javascript to head
26 * Add style to head
27 *
28 * @return void
29 * @version 1.0.0
30 * @since 4.2.5.6
31 */
32 public function load_scripts_styles_on_head() {
33 LP_Helper::print_inline_script_tag( 'lpDataAdmin', $this->localize_data_global(), [ 'id' => 'lpDataAdmin' ] );
34 LP_Helper::print_inline_script_tag( 'lpData', $this->localize_data_global(), [ 'id' => 'lpData' ] );
35 }
36
37 /**
38 * Localize data for all page backend.
39 *
40 * @return array
41 * @since 4.2.5.6
42 * @version 1.0.2
43 */
44 public function localize_data_global(): array {
45 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
46
47 ob_start();
48 Template::instance()->get_admin_template( 'search-author-field.php' );
49 $html_search_author_field = ob_get_clean();
50
51 return apply_filters(
52 'learn-press/admin/localize-data-global',
53 [
54 'site_url' => site_url(),
55 'user_id' => get_current_user_id(),
56 'is_admin' => current_user_can( ADMIN_ROLE ),
57 'theme' => get_stylesheet(),
58 'lp_version' => LP()->version,
59 'lp_rest_url' => get_rest_url(),
60 'lp_rest_load_ajax' => get_rest_url( null, 'lp/v1/load_content_via_ajax/' ), // @deprecated 4.3.0
61 'lpAjaxUrl' => LP_Settings::url_handle_lp_ajax(),
62 'nonce' => wp_create_nonce( 'wp_rest' ),
63 'courses_url' => learn_press_get_page_link( 'courses' ),
64 'urlParams' => lp_archive_skeleton_get_args(),
65 'i18n' => [
66 'select_page' => esc_html__( 'Select page', 'learnpress' ),
67 'yes' => esc_html__( 'Yes' ),
68 'cancel' => esc_html__( 'Cancel' ),
69 'generate_with_ai' => esc_html__( 'Generate with AI', 'learnpress' ),
70 'confirm_close_ai' => esc_html__( 'Are you sure you want to close? Generate data will stop.', 'learnpress' ),
71 ],
72 'current_screen' => $screen ? $screen->id : '',
73 'show_search_author_field' => empty( $html_search_author_field ) ? 0 : $html_search_author_field,
74 'toast' => [
75 'gravity' => 'bottom',
76 'position' => 'center',
77 'duration' => 3000,
78 'close' => 1,
79 'stopOnFocus' => 1,
80 'classPrefix' => 'lp-toast',
81 ],
82 'single_instructor_id' => learn_press_get_page_id( 'single_instructor' ),
83 'lpAi' => [
84 'config' => Config::instance()->get( 'open-ai-modal', 'settings' ),
85 'modelImage' => LP_Settings::get_option( 'open_ai_image_model_type', 'dall-e-3' ),
86 ],
87 'enable_open_ai' => LP_Settings::get_option( 'enable_open_ai', 'no' ) === 'yes'
88 && ! empty( LP_Settings::get_option( 'open_ai_secret_key', '' ) ),
89 ]
90 );
91 }
92
93 /**
94 * Get localize script
95 *
96 * @return array
97 */
98 protected function _get_script_data(): array {
99 $current_screen = get_current_screen();
100
101 return array(
102 'learn-press-global' => learn_press_global_script_params(),
103 'learn-press-meta-box-order' => apply_filters(
104 'learn-press/meta-box-order/script-data',
105 array(
106 'i18n_error' => esc_html__( 'Oops! Error.', 'learnpress' ),
107 'i18n_guest' => esc_html__( 'Guest', 'learnpress' ),
108 )
109 ),
110 'learn-press-update' => apply_filters(
111 'learn-press/upgrade/script-data',
112 array(
113 'i18n_confirm' => esc_html__(
114 'Before taking this action, we strongly recommend you backup your site first before proceeding. If you encounter any problems, please do not hesitate to contact our support team. Are you sure to proceed with the update protocol?',
115 'learnpress'
116 ),
117 )
118 ),
119 'lp-admin' => apply_filters(
120 'learn-press/admin/script-data',
121 array(
122 'ajax' => admin_url( 'admin-ajax.php' ),
123 'questionTypes' => learn_press_question_types(),
124 'supportAnswerOptions' => learn_press_get_question_support_answer_options(),
125 'screen' => $current_screen,
126 )
127 ),
128 'learn-press-admin-course-editor' => $this->get_course_data_for_editor_vue(),
129 );
130 }
131
132 /**
133 * Get default scripts in admin.
134 *
135 * @return mixed
136 */
137 protected function _get_scripts(): array {
138 $lp_admin_js = new LP_Asset_Key(
139 $this->url( 'js/dist/admin/admin' . self::$_min_assets . '.js' ),
140 [ 'wp-i18n', 'lp-utils', 'select2' ],
141 [],
142 0,
143 0,
144 '',
145 [ 'strategy' => 'async' ]
146 );
147 $lp_admin_js->exclude_screen(
148 [
149 'plugin-install',
150 'learnpress_page_learn-press-statistics',
151 'learnpress_page_learn-press-addons',
152 ]
153 );
154
155 $scripts = apply_filters(
156 'learn-press/admin-default-scripts',
157 array(
158 'lp-load-ajax' => new LP_Asset_Key(
159 self::url( 'js/dist/loadAJAX' . self::$_min_assets . '.js' ),
160 [],
161 [],
162 0,
163 0,
164 '',
165 [ 'strategy' => 'async' ]
166 ),
167 // need build if change source vue
168 'vue-libs' => new LP_Asset_Key( $this->url( 'js/vendor/vue/vue_libs.js' ) ),
169 'select2' => new LP_Asset_Key( $this->url( 'src/js/vendor/select2.full.min.js' ) ),
170 'jquery-tipsy' => new LP_Asset_Key( $this->url( 'src/js/vendor/jquery/jquery-tipsy.js' ) ),
171 'html2pdf' => new LP_Asset_Key( $this->url( 'src/js/vendor/html2pdf.bundle.min.js' ) ),
172 'lp-utils' => new LP_Asset_Key(
173 $this->url( 'js/dist/utils' . self::$_min_assets . '.js' ),
174 array(),
175 array(),
176 1
177 ),
178 'dropdown-pages' => new LP_Asset_Key(
179 $this->url( self::$_folder_source . 'js/admin/share/dropdown-pages' . self::$_min_assets . '.js' ),
180 [ 'lp-utils', 'select2' ]
181 ),
182 /*'jquery-ui-timepicker-addon' => new LP_Asset_Key(
183 $this->url( 'src/js/vendor/jquery/jquery-ui-timepicker-addon.js' ),
184 array( 'jquery-ui-datepicker' )
185 ),*/
186 'lp-addons' => new LP_Asset_Key(
187 $this->url( 'js/dist/admin/addons' . self::$_min_assets . '.js' ),
188 [],
189 [ 'learnpress_page_learn-press-addons' ],
190 0,
191 0,
192 '',
193 [ 'strategy' => 'async' ]
194 ),
195 //'advanced-list' => new LP_Asset_Key( $this->url( self::$_folder_source . 'js/admin/share/advanced-list' . self::$_min_assets . '.js' ) ),
196 'learn-press-global' => new LP_Asset_Key(
197 $this->url( self::$_folder_source . 'js/global' . self::$_min_assets . '.js' ),
198 array( 'jquery', 'underscore', 'utils', 'jquery-ui-sortable' )
199 ),
200 'lp-admin' => $lp_admin_js,
201 'lp-admin-mcp-api-keys' => new LP_Asset_Key(
202 $this->url( 'src/js/admin/mcp-api-keys.js' ),
203 [ 'lp-load-ajax' ],
204 [ 'learnpress_page_learn-press-settings' ],
205 0,
206 1,
207 '',
208 [ 'strategy' => 'defer' ]
209 ),
210 'lp-admin-learnpress' => new LP_Asset_Key(
211 $this->url( 'js/dist/admin/learnpress' . self::$_min_assets . '.js' ),
212 array(
213 'learn-press-global',
214 'wp-color-picker',
215 'jquery-tipsy',
216 'dropdown-pages',
217 'wp-api-fetch',
218 //'jquery-ui-timepicker-addon',
219 //'select2'
220 ),
221 array(
222 LP_LESSON_CPT,
223 LP_QUIZ_CPT,
224 LP_COURSE_CPT,
225 //LP_ORDER_CPT,
226 'learnpress_page_learn-press-settings',
227 ),
228 0,
229 1,
230 '',
231 [ 'strategy' => 'defer' ]
232 ),
233 'lp-duplicate-post' => new LP_Asset_Key(
234 $this->url( self::$_folder_source . 'js/admin/lp-duplicate-post' . self::$_min_assets . '.js' ),
235 array( 'jquery' ),
236 array(
237 'edit-' . LP_COURSE_CPT,
238 'edit-' . LP_LESSON_CPT,
239 'edit-' . LP_QUESTION_CPT,
240 'edit-' . LP_QUIZ_CPT,
241 ),
242 0,
243 1
244 ),
245 /*'learn-press-admin-course-editor' => new LP_Asset_Key(
246 $this->url( 'js/dist/admin/editor/course' . self::$_min_assets . '.js' ),
247 array( 'vue-libs', 'lp-utils' ),
248 array( LP_COURSE_CPT ),
249 0,
250 0
251 ),*/
252 'lp-admin-courses' => new LP_Asset_Key(
253 $this->url( 'dist/js/admin/admin-courses' . self::$_min_assets . '.js' ),
254 [ 'lp-load-ajax', 'wp-i18n' ],
255 [ 'edit-' . LP_COURSE_CPT ],
256 0,
257 0,
258 '',
259 [ 'strategy' => 'async' ]
260 ),
261 'lp-edit-course' => new LP_Asset_Key(
262 $this->url( 'dist/js/admin/edit-course' . self::$_min_assets . '.js' ),
263 [ 'lp-load-ajax' ],
264 [],
265 1,
266 0,
267 '',
268 [ 'strategy' => 'async' ]
269 ),
270 'lp-edit-quiz' => new LP_Asset_Key(
271 $this->url( 'dist/js/admin/edit-quiz' . self::$_min_assets . '.js' ),
272 [ 'lp-load-ajax' ],
273 [],
274 1,
275 0,
276 '',
277 [ 'strategy' => 'async' ]
278 ),
279 'lp-edit-question' => new LP_Asset_Key(
280 $this->url( 'dist/js/admin/edit-question' . self::$_min_assets . '.js' ),
281 [ 'lp-load-ajax' ],
282 [],
283 1,
284 0,
285 '',
286 [ 'strategy' => 'async' ]
287 ),
288 /*'learn-press-admin-quiz-editor' => new LP_Asset_Key(
289 $this->url( 'js/dist/admin/editor/quiz' . self::$_min_assets . '.js' ),
290 array( 'vue-libs', 'lp-utils' ),
291 array( LP_QUIZ_CPT ),
292 0,
293 0
294 ),*/
295 /*'learn-press-admin-question-editor' => new LP_Asset_Key(
296 $this->url( 'js/dist/admin/editor/question' . self::$_min_assets . '.js' ),
297 array( 'vue-libs', 'lodash', 'lp-utils' ),
298 array( LP_QUESTION_CPT ),
299 0,
300 0
301 ),*/
302 /*'learn-press-meta-box-order' => new LP_Asset_Key(
303 $this->url( self::$_folder_source . 'js/admin/partial/meta-box-order' . self::$_min_assets . '.js' ),
304 array(
305 'vue-libs',
306 'advanced-list',
307 //'lp-modal-search-courses',
308 //'lp-modal-search-users',
309 ),
310 array( LP_ORDER_CPT ),
311 0,
312 1
313 ),*/
314 'lp-admin-order' => new LP_Asset_Key(
315 $this->url( 'js/dist/admin/admin-order' . self::$_min_assets . '.js' ),
316 array( 'html2pdf' ),
317 array( LP_ORDER_CPT ),
318 0,
319 0,
320 '',
321 [ 'strategy' => 'defer' ]
322 ),
323 'lp-admin-orders' => new LP_Asset_Key(
324 $this->url( 'js/dist/admin/admin-orders' . self::$_min_assets . '.js' ),
325 array(),
326 array( 'edit-' . LP_ORDER_CPT ),
327 0,
328 0,
329 '',
330 [ 'strategy' => 'async' ]
331 ),
332
333 /*'learn-press-sync-data' => new LP_Asset_Key(
334 $this->url( 'js/dist/admin/pages/sync-data' . self::$_min_assets . '.js' ),
335 array(),
336 array( 'learnpress_page_learn-press-tools' ),
337 0,
338 1
339 ),*/
340 /*'lp-setup' => new LP_Asset_Key(
341 $this->url( 'js/dist/admin/pages/setup' . self::$_min_assets . '.js' ),
342 array( 'jquery', 'dropdown-pages' ),
343 array( 'lp-page-setup' ),
344 0,
345 1
346 ),*/
347 /*'learn-press-statistic' => new LP_Asset_Key(
348 $this->url( 'js/dist/admin/pages/statistic' . self::$_min_assets . '.js' ),
349 array( 'jquery', 'jquery-ui-datepicker', 'chart' ),
350 array( 'learnpress_page_learn-press-statistics' ),
351 0,
352 1
353 ),*/
354 /*'lp-modal-search-courses' => new LP_Asset_Key(
355 $this->url( self::$_folder_source . 'js/admin/share/modal-search-courses' . self::$_min_assets . '.js' ),
356 array(
357 'vue-libs',
358 'jquery',
359 ),
360 array( LP_ORDER_CPT ),
361 1,
362 1
363 ),*/
364 /*'lp-modal-search-users' => new LP_Asset_Key(
365 $this->url( self::$_folder_source . 'js/admin/share/modal-search-users' . self::$_min_assets . '.js' ),
366 array( 'jquery' ),
367 array( LP_ORDER_CPT ),
368 1,
369 1
370 ),*/
371 'lp-tools-course-tab' => new LP_Asset_Key(
372 $this->url( 'js/dist/admin/pages/tools' . self::$_min_assets . '.js' ),
373 array(
374 'jquery',
375 'wp-element',
376 'wp-compose',
377 'wp-components',
378 'wp-data',
379 'wp-hooks',
380 'wp-api-fetch',
381 'lodash',
382 'vue-libs',
383
384 ),
385 array( 'learnpress_page_learn-press-tools' ),
386 0,
387 1,
388 '',
389 [ 'strategy' => 'defer' ]
390 ),
391 /*'lp-dashboard' => new LP_Asset_Key(
392 self::url( 'js/dist/admin/pages/dashboard' . self::$_min_assets . '.js' ),
393 [],
394 array( 'dashboard' ),
395 0,
396 1
397 ),*/
398 'lp-widgets-admin' => new LP_Asset_Key(
399 self::url( 'js/dist/admin/pages/widgets' . self::$_min_assets . '.js' ),
400 array(
401 'wp-url',
402 'wp-api-fetch',
403 'lodash',
404 'select2',
405 ),
406 array( 'widgets', 'elementor' ),
407 0,
408 1
409 ),
410 'lp-admin-notices' => new LP_Asset_Key(
411 self::url( 'js/dist/admin/admin-notices' . self::$_min_assets . '.js' ),
412 [],
413 [],
414 1,
415 0,
416 '',
417 [ 'strategy' => 'async' ]
418 ),
419 'lp-material' => new LP_Asset_Key(
420 $this->url( 'js/dist/admin/course-material' . self::$_min_assets . '.js' ),
421 array(),
422 array(
423 LP_COURSE_CPT,
424 LP_LESSON_CPT,
425 ),
426 0,
427 1
428 ),
429 'lp-list-students-enrolled' => new LP_Asset_Key(
430 $this->url( 'dist/js/admin/list-students-enrolled' . self::$_min_assets . '.js' ),
431 array( 'lp-load-ajax' ),
432 array( 'learnpress_page_learn-press-students-enrolled' ),
433 0,
434 0,
435 '',
436 [ 'strategy' => 'async' ]
437 ),
438 'lp-admin-tools' => new LP_Asset_Key(
439 $this->url( 'js/dist/admin/admin-tools' . self::$_min_assets . '.js' ),
440 [],
441 array( 'learnpress_page_learn-press-tools' ),
442 0,
443 1,
444 '',
445 [ 'strategy' => 'defer' ]
446 ),
447 'lp-admin-statistic' => new LP_Asset_Key(
448 $this->url( 'js/dist/admin/admin-statistic' . self::$_min_assets . '.js' ),
449 array( 'wp-api-fetch' ),
450 array( 'learnpress_page_learn-press-statistics' ),
451 0,
452 0,
453 '',
454 [ 'strategy' => 'defer' ]
455 ),
456 )
457 );
458
459 /*$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
460 if ( $screen && $screen->id === 'site-editor' ) {
461 $scripts['editor-check'] = new LP_Asset_Key(
462 self::url( 'js/dist/gutenberg/editor-check' . self::$_min_assets . '.js' ),
463 array(
464 'wp-data',
465 'wp-edit-post',
466 'wp-editor',
467 ),
468 [],
469 0,
470 0,
471 '1.0.0',
472 [ 'strategy' => 'defer' ]
473 );
474 }*/
475
476 return $scripts;
477 }
478
479 /**
480 * Get default styles in admin.
481 *
482 * @return mixed
483 */
484 protected function _get_styles(): array {
485 $is_rtl = is_rtl() ? '-rtl' : '';
486
487 return apply_filters(
488 'learn-press/admin-default-styles',
489 array(
490 'select2' => new LP_Asset_Key(
491 $this->url( 'src/css/vendor/select2.min.css' )
492 ),
493 /*'font-awesome' => new LP_Asset_Key(
494 $this->url( 'src/css/vendor/font-awesome-5.min.css' )
495 ),*/
496 /*'jquery-ui' => new LP_Asset_Key(
497 $this->url( 'src/css/vendor/jquery-ui/jquery-ui.min.css' )
498 ),
499 'jquery-ui-timepicker' => new LP_Asset_Key(
500 $this->url( 'src/css/vendor/jquery-ui-timepicker-addon.css' )
501 ),*/
502 'jquery-tipsy' => new LP_Asset_Key(
503 $this->url( 'src/css/vendor/jquery.tipsy.css' )
504 ),
505 'learn-press-admin' => new LP_Asset_Key(
506 $this->url( 'css/admin/admin' . $is_rtl . self::$_min_assets . '.css' ),
507 array(
508 'wp-color-picker',
509 'wp-components',
510 //'select2',
511 //'jquery-ui',
512 //'jquery-ui-timepicker',
513 //'font-awesome',
514 'jquery-tipsy',
515 ),
516 array(),
517 0
518 ),
519 'lp-edit-curriculum' => new LP_Asset_Key(
520 $this->url( 'css/edit-curriculum' . $is_rtl . self::$_min_assets . '.css' ),
521 [],
522 [],
523 1
524 ),
525 'lp-edit-quiz' => new LP_Asset_Key(
526 $this->url( 'css/edit-quiz' . $is_rtl . self::$_min_assets . '.css' ),
527 [],
528 [],
529 1
530 ),
531 'lp-edit-question' => new LP_Asset_Key(
532 $this->url( 'css/edit-question' . $is_rtl . self::$_min_assets . '.css' ),
533 [],
534 [],
535 1
536 ),
537 'learn-press-statistic' => new LP_Asset_Key(
538 LP_CSS_URL . 'admin/statistic' . $is_rtl . self::$_min_assets . '.css',
539 array(),
540 array( 'learners_page_learn-press-statistics' ),
541 0
542 ),
543 'lp-tom-select' => new LP_Asset_Key(
544 $this->url( 'src/css/vendor/tom-select.min.css' ),
545 [],
546 [],
547 0
548 ),
549 )
550 );
551 }
552
553 /**
554 * Register and enqueue needed js and styles
555 */
556 public function load_scripts() {
557 $screen_id = LP_Admin::instance()->get_screen_id();
558
559 if ( empty( $screen_id ) ) {
560 return;
561 }
562
563 //wp_enqueue_media(); //Todo: tungnx need check why call for that using.
564 $this->handle_js( $screen_id );
565 $this->handle_style( $screen_id );
566
567 do_action( 'learn-press/admin/after-enqueue-scripts' );
568 }
569
570 /**
571 * Show overlay
572 */
573 public function add_elements_global() {
574 echo '<div class="lp-overlay">';
575 apply_filters( 'learnpress/admin/modal-dialog', learn_press_get_template( 'global/lp-modal-overlay' ) );
576 echo '</div>';
577
578 apply_filters( 'learnpress/admin/steps', learn_press_get_template( 'global/lp-group-step' ) );
579
580 // Added notify message when action done.
581 Template::instance()->get_admin_template( 'global/notify-action.php' );
582 }
583
584 /**
585 * Get course data for Vue Editor Course use.
586 *
587 * @return array|mixed|null
588 */
589 public function get_course_data_for_editor_vue() {
590 global $post, $pagenow;
591
592 if ( empty( $post ) || ( get_post_type() !== LP_COURSE_CPT ) || ! in_array(
593 $pagenow,
594 array(
595 'post.php',
596 'post-new.php',
597 )
598 ) ) {
599 return [];
600 }
601
602 $course = CourseModel::find( $post->ID, true );
603 if ( $course ) {
604 $course_section_items = $course->get_section_items();
605 } else { // Code old if not found course on the table learnpress_courses.
606 $course = learn_press_get_course( $post->ID );
607 $course_section_items = $course->get_curriculum_raw();
608 }
609 $hidden_sections = get_post_meta( $post->ID, '_admin_hidden_sections', true );
610
611 return apply_filters(
612 'learn-press/admin-localize-course-editor',
613 array(
614 'root' => array(
615 'course_id' => $post->ID,
616 'auto_draft' => get_post_status( $post->ID ) == 'auto-draft',
617 'ajax' => admin_url( 'index.php' ),
618 'disable_curriculum' => false,
619 'action' => 'admin_course_editor',
620 'nonce' => wp_create_nonce( 'learnpress_update_curriculum' ),
621 ),
622 'chooseItems' => array(
623 'types' => learn_press_course_get_support_item_types(),
624 'open' => false,
625 'addedItems' => array(),
626 'items' => array(),
627 ),
628 'i18n' => array(
629 'item' => __( 'item', 'learnpress' ),
630 'new_section_item' => __( 'Create a new', 'learnpress' ),
631 'back' => __( 'Back', 'learnpress' ),
632 'selected_items' => __( 'Selected items', 'learnpress' ),
633 'confirm_remove_item' => __( 'Do you want to remove the "{{ITEM_NAME}}" item from the course?', 'learnpress' ),
634 'confirm_trash_item' => __( 'Do you want to move the "{{ITEM_NAME}}" item to the trash?', 'learnpress' ),
635 'item_labels' => array(
636 'singular' => __( 'Item', 'learnpress' ),
637 'plural' => __( 'Items', 'learnpress' ),
638 ),
639 'notice_sale_price' => __( 'The course sale price must be less than the regular price', 'learnpress' ),
640 'notice_price' => __( 'The course price must be greater than the sale price', 'learnpress' ),
641 'notice_sale_start_date' => __( 'The sale start date must be before the sale end date', 'learnpress' ),
642 'notice_sale_end_date' => __( 'The sale end date must be after the sale start date', 'learnpress' ),
643 'notice_invalid_date' => __( 'Invalid date', 'learnpress' ),
644 ),
645 'sections' => array(
646 'sections' => $course_section_items,
647 'hidden_sections' => ! empty( $hidden_sections ) ? $hidden_sections : array(),
648 'urlEdit' => admin_url( 'post.php?action=edit&post=' ),
649 ),
650 )
651 );
652 }
653
654 public static function instance() {
655 if ( ! is_admin() ) {
656 return null;
657 }
658
659 if ( ! self::$_instance ) {
660 self::$_instance = new self();
661 }
662
663 return self::$_instance;
664 }
665 }
666
667 /**
668 * Shortcut function to get instance of LP_Admin_Assets
669 *
670 * @return LP_Admin_Assets|null
671 * Addon Certificate, Import/Export is using.
672 */
673 function learn_press_admin_assets() {
674 return LP_Admin_Assets::instance();
675 }
676