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