PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 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 All 142 releases
← All changes | inc/admin/class-lp-admin-assets.php +205 -35 4.4.2 → 4.4.10 View file →
@@ -2,8 +2,9 @@
2 2
3 3 use LearnPress\Helpers\Config;
4 4 use LearnPress\Helpers\Template;
5 5 use LearnPress\Models\CourseModel;
6 +use LearnPress\Statistics\PeriodResolver;
6 7
7 8 /**
8 9 * Class LP_Admin_Assets
9 10 *
@@ -67,8 +68,9 @@
67 68 'yes' => esc_html__( 'Yes' ),
68 69 'cancel' => esc_html__( 'Cancel' ),
69 70 'generate_with_ai' => esc_html__( 'Generate with AI', 'learnpress' ),
70 71 'confirm_close_ai' => esc_html__( 'Are you sure you want to close? Generate data will stop.', 'learnpress' ),
72 + 'select_user' => esc_html__( 'Select users', 'learnpress' ),
71 73 ),
72 74 'current_screen' => $screen ? $screen->id : '',
73 75 'show_search_author_field' => empty( $html_search_author_field ) ? 0 : $html_search_author_field,
74 76 'toast' => array(
@@ -81,9 +83,9 @@
81 83 ),
82 84 'single_instructor_id' => learn_press_get_page_id( 'single_instructor' ),
83 85 'lpAi' => array(
84 86 'config' => Config::instance()->get( 'open-ai-modal', 'settings' ),
85 - 'modelImage' => LP_Settings::get_option( 'open_ai_image_model_type', 'dall-e-3' ),
87 + 'modelImage' => LP_Settings::get_option( 'open_ai_image_model_type', 'gpt-image-1' ),
86 88 ),
87 89 'enable_open_ai' => LP_Settings::get_option( 'enable_open_ai', 'no' ) === 'yes'
88 90 && ! empty( LP_Settings::get_option( 'open_ai_secret_key', '' ) ),
89 91 )
@@ -99,9 +101,10 @@
99 101 $current_screen = get_current_screen();
100 102
101 103 return array(
102 104 'learn-press-global' => learn_press_global_script_params(),
103 - /*'learn-press-meta-box-order' => apply_filters(
105 + /*
106 + 'learn-press-meta-box-order' => apply_filters(
104 107 'learn-press/meta-box-order/script-data',
105 108 array(
106 109 'i18n_error' => esc_html__( 'Oops! Error.', 'learnpress' ),
107 110 'i18n_guest' => esc_html__( 'Guest', 'learnpress' ),
@@ -106,9 +109,10 @@
106 109 'i18n_error' => esc_html__( 'Oops! Error.', 'learnpress' ),
107 110 'i18n_guest' => esc_html__( 'Guest', 'learnpress' ),
108 111 )
109 112 ),*/
110 - /*'learn-press-update' => apply_filters(
113 + /*
114 + 'learn-press-update' => apply_filters(
111 115 'learn-press/upgrade/script-data',
112 116 array(
113 117 'i18n_confirm' => esc_html__(
114 118 '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?',
@@ -124,14 +128,165 @@
124 128 'supportAnswerOptions' => learn_press_get_question_support_answer_options(),
125 129 'screen' => $current_screen,
126 130 )
127 131 ),
132 + // Statistics dashboard config → JS global lpAdminStatisticSettings.
133 + // REST root + nonce come from lpDataAdmin (already on every admin page).
134 + 'lp-admin-statistic' => apply_filters(
135 + 'learn-press/admin/statistics/script-data',
136 + array(
137 + 'restNamespace' => 'lp/v1/statistics',
138 + 'adminUrl' => admin_url(),
139 + // decode: JS renders via textContent, entities would show literally.
140 + 'currencySymbol' => html_entity_decode( learn_press_get_currency_symbol() ),
141 + 'completionTarget' => (int) apply_filters( 'learn-press/statistics/completion-target', 70 ),
142 + // Completion badge bands: >= green is green, >= yellow is yellow, below is red.
143 + 'completionBadge' => apply_filters(
144 + 'learn-press/statistics/completion-badge-thresholds',
145 + array(
146 + 'green' => 60,
147 + 'yellow' => 40,
148 + )
149 + ),
150 + // Date-range dropdown: per-preset resolved labels ( the server is the
151 + // single source of calendar logic — JS never re-derives windows ).
152 + 'dateRange' => array(
153 + 'presets' => self::statistics_date_range_presets(),
154 + 'startOfWeek' => (int) get_option( 'start_of_week', 1 ),
155 + 'dateFormat' => (string) get_option( 'date_format', 'F j, Y' ),
156 + ),
157 + 'i18n' => array(
158 + 'loadError' => esc_html__( 'Failed to load statistics data.', 'learnpress' ),
159 + 'noData' => esc_html__( 'No data for this period.', 'learnpress' ),
160 + // Date-range dropdown.
161 + 'presets' => esc_html__( 'Presets', 'learnpress' ),
162 + 'custom' => esc_html__( 'Custom', 'learnpress' ),
163 + 'compareTo' => esc_html__( 'Compare to', 'learnpress' ),
164 + 'previousPeriod' => esc_html__( 'Previous period', 'learnpress' ),
165 + 'previousYear' => esc_html__( 'Previous year', 'learnpress' ),
166 + 'update' => esc_html__( 'Update', 'learnpress' ),
167 + 'from' => esc_html__( 'From', 'learnpress' ),
168 + 'to' => esc_html__( 'To', 'learnpress' ),
169 + 'selectDateRange' => esc_html__( 'Select a date range', 'learnpress' ),
170 + 'itemsCount' => esc_html__( '%d items', 'learnpress' ),
171 + 'cappedNotice' => esc_html__( 'Showing the first %d rows. Narrow the period or filters to see the rest.', 'learnpress' ),
172 + 'vsPrevPeriod' => esc_html__( 'vs previous period', 'learnpress' ),
173 + 'revenue' => esc_html__( 'Revenue', 'learnpress' ),
174 + 'enrollments' => esc_html__( 'Enrollments', 'learnpress' ),
175 + 'aov' => esc_html__( 'Avg. order value: %s', 'learnpress' ),
176 + 'belowTarget' => esc_html__( '%d below completion target', 'learnpress' ),
177 + 'failRate' => esc_html__( '%s%% of all orders', 'learnpress' ),
178 + 'course' => esc_html__( 'Course', 'learnpress' ),
179 + 'orders' => esc_html__( 'Orders', 'learnpress' ),
180 + 'aovShort' => esc_html__( 'AOV', 'learnpress' ),
181 + 'status' => esc_html__( 'Status', 'learnpress' ),
182 + 'enrolled' => esc_html__( 'Enrolled', 'learnpress' ),
183 + 'completion' => esc_html__( 'Completion', 'learnpress' ),
184 + 'instructor' => esc_html__( 'Instructor', 'learnpress' ),
185 + 'courses' => esc_html__( 'Courses', 'learnpress' ),
186 + 'topCourses' => esc_html__( 'Top courses', 'learnpress' ),
187 + 'topSoldCourses' => esc_html__( 'Top sold courses', 'learnpress' ),
188 + 'healthy' => esc_html__( 'Healthy', 'learnpress' ),
189 + 'watchCompletion' => esc_html__( 'Watch completion', 'learnpress' ),
190 + 'highFailedQuizzes' => esc_html__( 'High failed quizzes', 'learnpress' ),
191 + 'needsFulfillmentReview' => esc_html__( 'Needs fulfillment review', 'learnpress' ),
192 + 'awaitingPayment' => esc_html__( 'Awaiting payment', 'learnpress' ),
193 + 'exceptionRate' => esc_html__( '%s%% of all orders', 'learnpress' ),
194 + 'orderId' => esc_html__( 'Order ID', 'learnpress' ),
195 + 'student' => esc_html__( 'Student', 'learnpress' ),
196 + 'issue' => esc_html__( 'Issue', 'learnpress' ),
197 + 'date' => esc_html__( 'Date', 'learnpress' ),
198 + 'severity' => esc_html__( 'Severity', 'learnpress' ),
199 + 'high' => esc_html__( 'High', 'learnpress' ),
200 + 'medium' => esc_html__( 'Medium', 'learnpress' ),
201 + 'low' => esc_html__( 'Low', 'learnpress' ),
202 + 'orderExceptions' => esc_html__( 'Recent order exceptions', 'learnpress' ),
203 + 'noOrderExceptions' => esc_html__( 'No failed or cancelled orders in this period.', 'learnpress' ),
204 + 'addedThisPeriod' => esc_html__( '%d added this period', 'learnpress' ),
205 + 'needsInstructorAction' => esc_html__( 'Needs instructor action', 'learnpress' ),
206 + 'scheduledReleases' => esc_html__( 'Scheduled releases', 'learnpress' ),
207 + 'targetPercent' => esc_html__( 'Target: %s%%', 'learnpress' ),
208 + 'publishedCourses' => esc_html__( 'Published courses', 'learnpress' ),
209 + 'noCoursePerformance' => esc_html__( 'No course performance data in this period.', 'learnpress' ),
210 + 'coursePerformance' => esc_html__( 'Course performance', 'learnpress' ),
211 + 'lessons' => esc_html__( 'Lessons', 'learnpress' ),
212 + 'quizzes' => esc_html__( 'Quizzes', 'learnpress' ),
213 + 'assignments' => esc_html__( 'Assignments', 'learnpress' ),
214 + 'published' => esc_html__( 'Published', 'learnpress' ),
215 + 'pending' => esc_html__( 'Pending', 'learnpress' ),
216 + 'future' => esc_html__( 'Future', 'learnpress' ),
217 + 'drafts' => esc_html__( 'Drafts', 'learnpress' ),
218 + 'total' => esc_html__( 'Total', 'learnpress' ),
219 + 'content' => esc_html__( 'Content', 'learnpress' ),
220 + 'newThisPeriod' => esc_html__( '+%d this period', 'learnpress' ),
221 + 'activeInPeriod' => esc_html__( '%d active in this period', 'learnpress' ),
222 + 'activeThisPeriod' => esc_html__( 'active this period', 'learnpress' ),
223 + 'afterEnrollment' => esc_html__( 'After enrollment', 'learnpress' ),
224 + 'currentLearners' => esc_html__( 'Current learners', 'learnpress' ),
225 + 'completionRateSub' => esc_html__( '%s%% completion rate', 'learnpress' ),
226 + 'registeredUsers' => esc_html__( 'Registered users', 'learnpress' ),
227 + 'topStudents' => esc_html__( 'Top students', 'learnpress' ),
228 + 'topCoursesByStudents' => esc_html__( 'Top courses by students', 'learnpress' ),
229 + 'avgScore' => esc_html__( 'Quiz pass rate', 'learnpress' ),
230 + 'lastActive' => esc_html__( 'Last active', 'learnpress' ),
231 + 'startedLabel' => esc_html__( 'Started', 'learnpress' ),
232 + 'completedLabel' => esc_html__( 'Completed', 'learnpress' ),
233 + 'activeLast7dShort' => esc_html__( 'Active 7d', 'learnpress' ),
234 + 'statusActive' => esc_html__( 'Active', 'learnpress' ),
235 + 'statusAtRisk' => esc_html__( 'At risk', 'learnpress' ),
236 + 'statusIdle' => esc_html__( 'Idle', 'learnpress' ),
237 + // Instructors tab.
238 + 'ofNetSales' => esc_html__( '%s%% of net sales', 'learnpress' ),
239 + 'ofTotalInstructors' => esc_html__( '%d total', 'learnpress' ),
240 + 'students' => esc_html__( 'Students', 'learnpress' ),
241 + 'sold' => esc_html__( 'Sold', 'learnpress' ),
242 + 'risk' => esc_html__( 'Risk', 'learnpress' ),
243 + 'actionRequired' => esc_html__( 'Action required', 'learnpress' ),
244 + 'riskHigh' => esc_html__( 'High', 'learnpress' ),
245 + 'riskMedium' => esc_html__( 'Medium', 'learnpress' ),
246 + 'riskHealthy' => esc_html__( 'Healthy', 'learnpress' ),
247 + 'instructorPerformance' => esc_html__( 'Instructor performance', 'learnpress' ),
248 + 'instructorReport' => esc_html__( 'Instructor report', 'learnpress' ),
249 + 'noInstructorData' => esc_html__( 'No instructor data in this period.', 'learnpress' ),
250 + 'instructorReportEmpty' => esc_html__( 'This instructor has no courses yet.', 'learnpress' ),
251 + 'watchlistActions' => array(
252 + 'review_quiz_difficulty' => esc_html__( 'Review quiz difficulty', 'learnpress' ),
253 + 'build_curriculum' => esc_html__( 'Build the curriculum', 'learnpress' ),
254 + 'add_practice_content' => esc_html__( 'Add practice content', 'learnpress' ),
255 + 'monitor' => esc_html__( 'Monitor', 'learnpress' ),
256 + ),
257 + ),
258 + )
259 + ),
128 260 // @deprecated tag 'learn-press-admin-course-editor' 4.4.2 - no any enqueue js for that.
129 - //'learn-press-admin-course-editor' => $this->get_course_data_for_editor_vue(),
261 + // 'learn-press-admin-course-editor' => $this->get_course_data_for_editor_vue(),
130 262 );
131 263 }
132 264
133 265 /**
266 + * Preset entries for the statistics date-range dropdown.
267 + *
268 + * UI presets in display order. Labels are resolved server-side so JS never
269 + * re-implements calendar logic.
270 + *
271 + * @return array[] [ { value, name, rangeLabel } ]
272 + * @since 4.4.2
273 + */
274 + private static function statistics_date_range_presets(): array {
275 + $presets = array();
276 +
277 + foreach ( PeriodResolver::UI_PRESETS as $preset ) {
278 + $presets[] = array(
279 + 'value' => $preset,
280 + 'name' => PeriodResolver::preset_name( $preset ),
281 + 'rangeLabel' => PeriodResolver::range_label_for( PeriodResolver::resolve( $preset ) ),
282 + );
283 + }
284 +
285 + return $presets;
286 + }
287 +
288 + /**
134 289 * Get default scripts in admin.
135 290 *
136 291 * @return mixed
137 292 */
@@ -165,9 +320,9 @@
165 320 '',
166 321 array( 'strategy' => 'async' )
167 322 ),
168 323 // need build if change source vue
169 - 'vue-libs' => new LP_Asset_Key( $this->url( 'js/vendor/vue/vue_libs.js' ) ),
324 + //'vue-libs' => new LP_Asset_Key( $this->url( 'js/vendor/vue/vue_libs.js' ) ),
170 325 //'select2' => new LP_Asset_Key( $this->url( 'src/js/vendor/select2.full.min.js' ) ),
171 326 'jquery-tipsy' => new LP_Asset_Key( $this->url( 'src/js/vendor/jquery/jquery-tipsy.js' ) ),
172 327 'html2pdf' => new LP_Asset_Key( $this->url( 'src/js/vendor/html2pdf.bundle.min.js' ) ),
173 328 'lp-utils' => new LP_Asset_Key(
@@ -175,12 +330,8 @@
175 330 array(),
176 331 array(),
177 332 1
178 333 ),
179 - /*'dropdown-pages' => new LP_Asset_Key(
180 - $this->url( self::$_folder_source . 'js/admin/share/dropdown-pages' . self::$_min_assets . '.js' ),
181 - array( 'lp-utils', 'select2' )
182 - ),*/
183 334 /*
184 335 'jquery-ui-timepicker-addon' => new LP_Asset_Key(
185 336 $this->url( 'src/js/vendor/jquery/jquery-ui-timepicker-addon.js' ),
186 337 array( 'jquery-ui-datepicker' )
@@ -223,9 +374,8 @@
223 374 array(
224 375 'learn-press-global',
225 376 'wp-color-picker',
226 377 'jquery-tipsy',
227 - //'dropdown-pages',
228 378 'wp-api-fetch',
229 379 // 'jquery-ui-timepicker-addon',
230 380 // 'select2'
231 381 ),
@@ -352,16 +502,15 @@
352 502 array( 'learnpress_page_learn-press-tools' ),
353 503 0,
354 504 1
355 505 ),*/
356 - /*
357 - 'lp-setup' => new LP_Asset_Key(
358 - $this->url( 'js/dist/admin/pages/setup' . self::$_min_assets . '.js' ),
359 - array( 'jquery', 'dropdown-pages' ),
506 + 'lp-setup-wizard' => new LP_Asset_Key(
507 + $this->url( 'dist/js/admin/setup-wizard' . self::$_min_assets . '.js' ),
508 + [],
360 509 array( 'lp-page-setup' ),
361 510 0,
362 511 1
363 - ),*/
512 + ),
364 513 /*
365 514 'learn-press-statistic' => new LP_Asset_Key(
366 515 $this->url( 'js/dist/admin/pages/statistic' . self::$_min_assets . '.js' ),
367 516 array( 'jquery', 'jquery-ui-datepicker', 'chart' ),
@@ -389,20 +538,9 @@
389 538 1
390 539 ),*/
391 540 'lp-tools-course-tab' => new LP_Asset_Key(
392 541 $this->url( 'js/dist/admin/pages/tools' . self::$_min_assets . '.js' ),
393 - array(
394 - 'jquery',
395 - 'wp-element',
396 - 'wp-compose',
397 - 'wp-components',
398 - 'wp-data',
399 - 'wp-hooks',
400 - 'wp-api-fetch',
401 - 'lodash',
402 - 'vue-libs',
403 -
404 - ),
542 + [],
405 543 array( 'learnpress_page_learn-press-tools' ),
406 544 0,
407 545 1,
408 546 '',
@@ -421,9 +559,9 @@
421 559 array(
422 560 'wp-url',
423 561 'wp-api-fetch',
424 562 'lodash',
425 - 'select2',
563 + //'select2',
426 564 ),
427 565 array( 'widgets', 'elementor' ),
428 566 0,
429 567 1
@@ -456,19 +594,28 @@
456 594 '',
457 595 array( 'strategy' => 'async' )
458 596 ),
459 597 'lp-admin-tools' => new LP_Asset_Key(
460 - $this->url( 'js/dist/admin/admin-tools' . self::$_min_assets . '.js' ),
598 + $this->url( 'dist/js/admin/admin-tools' . self::$_min_assets . '.js' ),
461 599 array(),
462 600 array( 'learnpress_page_learn-press-tools' ),
463 601 0,
464 - 1,
602 + 0,
465 603 '',
466 604 array( 'strategy' => 'defer' )
467 605 ),
606 + 'lp-themes' => new LP_Asset_Key(
607 + $this->url( 'dist/js/admin/lp-themes' . self::$_min_assets . '.js' ),
608 + array(),
609 + array( 'learnpress_page_learn-press-themes' ),
610 + 0,
611 + 0,
612 + '',
613 + array( 'strategy' => 'async' )
614 + ),
468 615 'lp-admin-statistic' => new LP_Asset_Key(
469 616 $this->url( 'js/dist/admin/admin-statistic' . self::$_min_assets . '.js' ),
470 - array( 'wp-api-fetch' ),
617 + array( 'lp-load-ajax' ),
471 618 array( 'learnpress_page_learn-press-statistics' ),
472 619 0,
473 620 0,
474 621 '',
@@ -539,8 +686,21 @@
539 686 ),
540 687 array(),
541 688 0
542 689 ),
690 + 'lp-help-center' => new LP_Asset_Key(
691 + $this->url( 'css/admin/help-center' . $is_rtl . self::$_min_assets . '.css' ),
692 + array(),
693 + array( 'learnpress_page_learn-press-help-center' ),
694 + 0
695 + ),
696 + 'lp-themes' => new LP_Asset_Key(
697 + $this->url( 'css/admin/themes' . $is_rtl . self::$_min_assets . '.css' ),
698 + array(),
699 + array( 'learnpress_page_learn-press-themes' ),
700 + 0,
701 + 0
702 + ),
543 703 'lp-edit-curriculum' => new LP_Asset_Key(
544 704 $this->url( 'css/edit-curriculum' . $is_rtl . self::$_min_assets . '.css' ),
545 705 array(),
546 706 array(),
@@ -557,14 +717,14 @@
557 717 array(),
558 718 array(),
559 719 1
560 720 ),
561 - 'learn-press-statistic' => new LP_Asset_Key(
721 + /*'learn-press-statistic' => new LP_Asset_Key(
562 722 LP_CSS_URL . 'admin/statistic' . $is_rtl . self::$_min_assets . '.css',
563 723 array(),
564 724 array( 'learners_page_learn-press-statistics' ),
565 725 0
566 - ),
726 + ),*/
567 727 'lp-tom-select' => new LP_Asset_Key(
568 728 $this->url( 'src/css/vendor/tom-select.min.css' ),
569 729 array(),
570 730 array(),
@@ -569,8 +729,14 @@
569 729 array(),
570 730 array(),
571 731 0
572 732 ),
733 + 'lp-setup-wizard' => new LP_Asset_Key(
734 + $this->url( 'css/admin/setup-wizard' . $is_rtl . self::$_min_assets . '.css' ),
735 + array(),
736 + array(),
737 + 1
738 + ),
573 739 )
574 740 );
575 741 }
576 742
@@ -580,9 +746,9 @@
580 746 public function load_scripts() {
581 747 $screen_id = LP_Admin::instance()->get_screen_id();
582 748
583 749 if ( empty( $screen_id ) ) {
584 - return;
750 + $screen_id = '';
585 751 }
586 752
587 753 // wp_enqueue_media(); //Todo: tungnx need check why call for that using.
588 754 $this->handle_js( $screen_id );
@@ -610,9 +776,10 @@
610 776 *
611 777 * @return array|mixed|null
612 778 * @deprecated 4.4.2 - no any enqueue js for that.
613 779 */
614 - /*public function get_course_data_for_editor_vue() {
780 + /*
781 + public function get_course_data_for_editor_vue() {
615 782 global $post, $pagenow;
616 783
617 784 if ( empty( $post ) || ( get_post_type() !== LP_COURSE_CPT ) || ! in_array(
618 785 $pagenow,
@@ -675,8 +842,11 @@
675 842 )
676 843 );
677 844 }*/
678 845
846 + /**
847 + * Instance
848 + */
679 849 public static function instance() {
680 850 if ( ! is_admin() ) {
681 851 return null;
682 852 }