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 +331 -136 4.3.7 → 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 *
@@ -29,10 +30,10 @@
29 30 * @version 1.0.0
30 31 * @since 4.2.5.6
31 32 */
32 33 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' ] );
34 + LP_Helper::print_inline_script_tag( 'lpDataAdmin', $this->localize_data_global(), array( 'id' => 'lpDataAdmin' ) );
35 + LP_Helper::print_inline_script_tag( 'lpData', $this->localize_data_global(), array( 'id' => 'lpData' ) );
35 36 }
36 37
37 38 /**
38 39 * Localize data for all page backend.
@@ -49,9 +50,9 @@
49 50 $html_search_author_field = ob_get_clean();
50 51
51 52 return apply_filters(
52 53 'learn-press/admin/localize-data-global',
53 - [
54 + array(
54 55 'site_url' => site_url(),
55 56 'user_id' => get_current_user_id(),
56 57 'is_admin' => current_user_can( ADMIN_ROLE ),
57 58 'theme' => get_stylesheet(),
@@ -61,18 +62,19 @@
61 62 'lpAjaxUrl' => LP_Settings::url_handle_lp_ajax(),
62 63 'nonce' => wp_create_nonce( 'wp_rest' ),
63 64 'courses_url' => learn_press_get_page_link( 'courses' ),
64 65 'urlParams' => lp_archive_skeleton_get_args(),
65 - 'i18n' => [
66 + 'i18n' => array(
66 67 'select_page' => esc_html__( 'Select page', 'learnpress' ),
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' ),
71 - ],
72 + 'select_user' => esc_html__( 'Select users', 'learnpress' ),
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 - 'toast' => [
76 + 'toast' => array(
75 77 'gravity' => 'bottom',
76 78 'position' => 'center',
77 79 'duration' => 3000,
78 80 'close' => 1,
@@ -77,17 +79,17 @@
77 79 'duration' => 3000,
78 80 'close' => 1,
79 81 'stopOnFocus' => 1,
80 82 'classPrefix' => 'lp-toast',
81 - ],
83 + ),
82 84 'single_instructor_id' => learn_press_get_page_id( 'single_instructor' ),
83 - 'lpAi' => [
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' ),
86 - ],
87 + 'modelImage' => LP_Settings::get_option( 'open_ai_image_model_type', 'gpt-image-1' ),
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 + )
90 92 );
91 93 }
92 94
93 95 /**
@@ -98,9 +100,10 @@
98 100 protected function _get_script_data(): array {
99 101 $current_screen = get_current_screen();
100 102
101 103 return array(
102 - 'learn-press-global' => learn_press_global_script_params(),
104 + 'learn-press-global' => learn_press_global_script_params(),
105 + /*
103 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' ),
@@ -105,10 +108,11 @@
105 108 array(
106 109 'i18n_error' => esc_html__( 'Oops! Error.', 'learnpress' ),
107 110 'i18n_guest' => esc_html__( 'Guest', 'learnpress' ),
108 111 )
109 - ),
110 - 'learn-press-update' => apply_filters(
112 + ),*/
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?',
@@ -114,10 +118,10 @@
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?',
115 119 'learnpress'
116 120 ),
117 121 )
118 - ),
119 - 'lp-admin' => apply_filters(
122 + ),*/
123 + 'lp-admin' => apply_filters(
120 124 'learn-press/admin/script-data',
121 125 array(
122 126 'ajax' => admin_url( 'admin-ajax.php' ),
123 127 'questionTypes' => learn_press_question_types(),
@@ -124,13 +128,165 @@
124 128 'supportAnswerOptions' => learn_press_get_question_support_answer_options(),
125 129 'screen' => $current_screen,
126 130 )
127 131 ),
128 - 'learn-press-admin-course-editor' => $this->get_course_data_for_editor_vue(),
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 + ),
260 + // @deprecated tag 'learn-press-admin-course-editor' 4.4.2 - no any enqueue js for that.
261 + // 'learn-press-admin-course-editor' => $this->get_course_data_for_editor_vue(),
129 262 );
130 263 }
131 264
132 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 + /**
133 289 * Get default scripts in admin.
134 290 *
135 291 * @return mixed
136 292 */
@@ -136,76 +292,82 @@
136 292 */
137 293 protected function _get_scripts(): array {
138 294 $lp_admin_js = new LP_Asset_Key(
139 295 $this->url( 'js/dist/admin/admin' . self::$_min_assets . '.js' ),
140 - [ 'wp-i18n', 'lp-utils', 'select2' ],
141 - [],
296 + array( 'wp-i18n', 'lp-utils' ),
297 + array(),
142 298 0,
143 299 0,
144 300 '',
145 - [ 'strategy' => 'async' ]
301 + array( 'strategy' => 'async' )
146 302 );
147 303 $lp_admin_js->exclude_screen(
148 - [
304 + array(
149 305 'plugin-install',
150 306 'learnpress_page_learn-press-statistics',
151 307 'learnpress_page_learn-press-addons',
152 - ]
308 + )
153 309 );
154 310
155 311 $scripts = apply_filters(
156 312 'learn-press/admin-default-scripts',
157 313 array(
158 - 'lp-load-ajax' => new LP_Asset_Key(
314 + 'lp-load-ajax' => new LP_Asset_Key(
159 315 self::url( 'js/dist/loadAJAX' . self::$_min_assets . '.js' ),
160 - [],
161 - [],
316 + array(),
317 + array(),
162 318 0,
163 319 0,
164 320 '',
165 - [ 'strategy' => 'async' ]
321 + array( 'strategy' => 'async' )
166 322 ),
167 323 // 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(
324 + //'vue-libs' => new LP_Asset_Key( $this->url( 'js/vendor/vue/vue_libs.js' ) ),
325 + //'select2' => new LP_Asset_Key( $this->url( 'src/js/vendor/select2.full.min.js' ) ),
326 + 'jquery-tipsy' => new LP_Asset_Key( $this->url( 'src/js/vendor/jquery/jquery-tipsy.js' ) ),
327 + 'html2pdf' => new LP_Asset_Key( $this->url( 'src/js/vendor/html2pdf.bundle.min.js' ) ),
328 + 'lp-utils' => new LP_Asset_Key(
173 329 $this->url( 'js/dist/utils' . self::$_min_assets . '.js' ),
174 330 array(),
175 331 array(),
176 332 1
177 333 ),
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(
334 + /*
335 + 'jquery-ui-timepicker-addon' => new LP_Asset_Key(
183 336 $this->url( 'src/js/vendor/jquery/jquery-ui-timepicker-addon.js' ),
184 337 array( 'jquery-ui-datepicker' )
185 338 ),*/
186 - 'lp-addons' => new LP_Asset_Key(
339 + 'lp-addons' => new LP_Asset_Key(
187 340 $this->url( 'js/dist/admin/addons' . self::$_min_assets . '.js' ),
188 - [],
189 - [ 'learnpress_page_learn-press-addons' ],
341 + array(),
342 + array( 'learnpress_page_learn-press-addons' ),
190 343 0,
191 344 0,
192 345 '',
193 - [ 'strategy' => 'async' ]
346 + array( 'strategy' => 'async' )
194 347 ),
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(
348 + // 'advanced-list' => new LP_Asset_Key( $this->url( self::$_folder_source . 'js/admin/share/advanced-list' . self::$_min_assets . '.js' ) ),
349 + 'learn-press-global' => new LP_Asset_Key(
197 350 $this->url( self::$_folder_source . 'js/global' . self::$_min_assets . '.js' ),
198 351 array( 'jquery', 'underscore', 'utils', 'jquery-ui-sortable' )
199 352 ),
200 353 'lp-admin' => $lp_admin_js,
201 354 'lp-admin-mcp-api-keys' => new LP_Asset_Key(
202 - $this->url( 'src/js/admin/mcp-api-keys.js' ),
355 + $this->url( 'js/dist/admin/mcp-api-keys.js' ),
203 356 [ 'lp-load-ajax' ],
204 357 [ 'learnpress_page_learn-press-settings' ],
205 358 0,
206 359 1,
207 360 '',
361 + array( 'strategy' => 'defer' )
362 + ),
363 + 'lp-admin-webhooks' => new LP_Asset_Key(
364 + $this->url( 'js/dist/admin/webhooks.js' ),
365 + [ 'lp-load-ajax', 'lp-admin' ],
366 + [ 'learnpress_page_learn-press-settings' ],
367 + 0,
368 + 1,
369 + '',
208 370 [ 'strategy' => 'defer' ]
209 371 ),
210 372 'lp-admin-learnpress' => new LP_Asset_Key(
211 373 $this->url( 'js/dist/admin/learnpress' . self::$_min_assets . '.js' ),
@@ -212,26 +374,25 @@
212 374 array(
213 375 'learn-press-global',
214 376 'wp-color-picker',
215 377 'jquery-tipsy',
216 - 'dropdown-pages',
217 378 'wp-api-fetch',
218 - //'jquery-ui-timepicker-addon',
219 - //'select2'
379 + // 'jquery-ui-timepicker-addon',
380 + // 'select2'
220 381 ),
221 382 array(
222 383 LP_LESSON_CPT,
223 384 LP_QUIZ_CPT,
224 385 LP_COURSE_CPT,
225 - //LP_ORDER_CPT,
386 + // LP_ORDER_CPT,
226 387 'learnpress_page_learn-press-settings',
227 388 ),
228 389 0,
229 390 1,
230 391 '',
231 - [ 'strategy' => 'defer' ]
392 + array( 'strategy' => 'defer' )
232 393 ),
233 - 'lp-duplicate-post' => new LP_Asset_Key(
394 + 'lp-duplicate-post' => new LP_Asset_Key(
234 395 $this->url( self::$_folder_source . 'js/admin/lp-duplicate-post' . self::$_min_assets . '.js' ),
235 396 array( 'jquery' ),
236 397 array(
237 398 'edit-' . LP_COURSE_CPT,
@@ -241,9 +402,10 @@
241 402 ),
242 403 0,
243 404 1
244 405 ),
245 - /*'learn-press-admin-course-editor' => new LP_Asset_Key(
406 + /*
407 + 'learn-press-admin-course-editor' => new LP_Asset_Key(
246 408 $this->url( 'js/dist/admin/editor/course' . self::$_min_assets . '.js' ),
247 409 array( 'vue-libs', 'lp-utils' ),
248 410 array( LP_COURSE_CPT ),
249 411 0,
@@ -248,45 +410,46 @@
248 410 array( LP_COURSE_CPT ),
249 411 0,
250 412 0
251 413 ),*/
252 - 'lp-admin-courses' => new LP_Asset_Key(
414 + 'lp-admin-courses' => new LP_Asset_Key(
253 415 $this->url( 'dist/js/admin/admin-courses' . self::$_min_assets . '.js' ),
254 - [ 'lp-load-ajax', 'wp-i18n' ],
255 - [ 'edit-' . LP_COURSE_CPT ],
416 + array( 'lp-load-ajax', 'wp-i18n' ),
417 + array( 'edit-' . LP_COURSE_CPT ),
256 418 0,
257 419 0,
258 420 '',
259 - [ 'strategy' => 'async' ]
421 + array( 'strategy' => 'async' )
260 422 ),
261 - 'lp-edit-course' => new LP_Asset_Key(
423 + 'lp-edit-course' => new LP_Asset_Key(
262 424 $this->url( 'dist/js/admin/edit-course' . self::$_min_assets . '.js' ),
263 - [ 'lp-load-ajax' ],
264 - [],
425 + array( 'lp-load-ajax' ),
426 + array(),
265 427 1,
266 428 0,
267 429 '',
268 - [ 'strategy' => 'async' ]
430 + array( 'strategy' => 'async' )
269 431 ),
270 - 'lp-edit-quiz' => new LP_Asset_Key(
432 + 'lp-edit-quiz' => new LP_Asset_Key(
271 433 $this->url( 'dist/js/admin/edit-quiz' . self::$_min_assets . '.js' ),
272 - [ 'lp-load-ajax' ],
273 - [],
434 + array( 'lp-load-ajax' ),
435 + array(),
274 436 1,
275 437 0,
276 438 '',
277 - [ 'strategy' => 'async' ]
439 + array( 'strategy' => 'async' )
278 440 ),
279 - 'lp-edit-question' => new LP_Asset_Key(
441 + 'lp-edit-question' => new LP_Asset_Key(
280 442 $this->url( 'dist/js/admin/edit-question' . self::$_min_assets . '.js' ),
281 - [ 'lp-load-ajax' ],
282 - [],
443 + array( 'lp-load-ajax' ),
444 + array(),
283 445 1,
284 446 0,
285 447 '',
286 - [ 'strategy' => 'async' ]
448 + array( 'strategy' => 'async' )
287 449 ),
288 - /*'learn-press-admin-quiz-editor' => new LP_Asset_Key(
450 + /*
451 + 'learn-press-admin-quiz-editor' => new LP_Asset_Key(
289 452 $this->url( 'js/dist/admin/editor/quiz' . self::$_min_assets . '.js' ),
290 453 array( 'vue-libs', 'lp-utils' ),
291 454 array( LP_QUIZ_CPT ),
292 455 0,
@@ -291,9 +454,10 @@
291 454 array( LP_QUIZ_CPT ),
292 455 0,
293 456 0
294 457 ),*/
295 - /*'learn-press-admin-question-editor' => new LP_Asset_Key(
458 + /*
459 + 'learn-press-admin-question-editor' => new LP_Asset_Key(
296 460 $this->url( 'js/dist/admin/editor/question' . self::$_min_assets . '.js' ),
297 461 array( 'vue-libs', 'lodash', 'lp-utils' ),
298 462 array( LP_QUESTION_CPT ),
299 463 0,
@@ -298,9 +462,10 @@
298 462 array( LP_QUESTION_CPT ),
299 463 0,
300 464 0
301 465 ),*/
302 - /*'learn-press-meta-box-order' => new LP_Asset_Key(
466 + /*
467 + 'learn-press-meta-box-order' => new LP_Asset_Key(
303 468 $this->url( self::$_folder_source . 'js/admin/partial/meta-box-order' . self::$_min_assets . '.js' ),
304 469 array(
305 470 'vue-libs',
306 471 'advanced-list',
@@ -310,18 +475,18 @@
310 475 array( LP_ORDER_CPT ),
311 476 0,
312 477 1
313 478 ),*/
314 - 'lp-admin-order' => new LP_Asset_Key(
479 + 'lp-admin-order' => new LP_Asset_Key(
315 480 $this->url( 'js/dist/admin/admin-order' . self::$_min_assets . '.js' ),
316 - array( 'html2pdf' ),
481 + array( 'html2pdf', 'lp-load-ajax' ),
317 482 array( LP_ORDER_CPT ),
318 483 0,
319 484 0,
320 485 '',
321 - [ 'strategy' => 'defer' ]
486 + array( 'strategy' => 'defer' )
322 487 ),
323 - 'lp-admin-orders' => new LP_Asset_Key(
488 + 'lp-admin-orders' => new LP_Asset_Key(
324 489 $this->url( 'js/dist/admin/admin-orders' . self::$_min_assets . '.js' ),
325 490 array(),
326 491 array( 'edit-' . LP_ORDER_CPT ),
327 492 0,
@@ -326,12 +491,13 @@
326 491 array( 'edit-' . LP_ORDER_CPT ),
327 492 0,
328 493 0,
329 494 '',
330 - [ 'strategy' => 'async' ]
495 + array( 'strategy' => 'async' )
331 496 ),
332 497
333 - /*'learn-press-sync-data' => new LP_Asset_Key(
498 + /*
499 + 'learn-press-sync-data' => new LP_Asset_Key(
334 500 $this->url( 'js/dist/admin/pages/sync-data' . self::$_min_assets . '.js' ),
335 501 array(),
336 502 array( 'learnpress_page_learn-press-tools' ),
337 503 0,
@@ -336,16 +502,17 @@
336 502 array( 'learnpress_page_learn-press-tools' ),
337 503 0,
338 504 1
339 505 ),*/
340 - /*'lp-setup' => new LP_Asset_Key(
341 - $this->url( 'js/dist/admin/pages/setup' . self::$_min_assets . '.js' ),
342 - 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 + [],
343 509 array( 'lp-page-setup' ),
344 510 0,
345 511 1
346 - ),*/
347 - /*'learn-press-statistic' => new LP_Asset_Key(
512 + ),
513 + /*
514 + 'learn-press-statistic' => new LP_Asset_Key(
348 515 $this->url( 'js/dist/admin/pages/statistic' . self::$_min_assets . '.js' ),
349 516 array( 'jquery', 'jquery-ui-datepicker', 'chart' ),
350 517 array( 'learnpress_page_learn-press-statistics' ),
351 518 0,
@@ -350,9 +517,10 @@
350 517 array( 'learnpress_page_learn-press-statistics' ),
351 518 0,
352 519 1
353 520 ),*/
354 - /*'lp-modal-search-courses' => new LP_Asset_Key(
521 + /*
522 + 'lp-modal-search-courses' => new LP_Asset_Key(
355 523 $this->url( self::$_folder_source . 'js/admin/share/modal-search-courses' . self::$_min_assets . '.js' ),
356 524 array(
357 525 'vue-libs',
358 526 'jquery',
@@ -360,9 +528,10 @@
360 528 array( LP_ORDER_CPT ),
361 529 1,
362 530 1
363 531 ),*/
364 - /*'lp-modal-search-users' => new LP_Asset_Key(
532 + /*
533 + 'lp-modal-search-users' => new LP_Asset_Key(
365 534 $this->url( self::$_folder_source . 'js/admin/share/modal-search-users' . self::$_min_assets . '.js' ),
366 535 array( 'jquery' ),
367 536 array( LP_ORDER_CPT ),
368 537 1,
@@ -367,29 +536,19 @@
367 536 array( LP_ORDER_CPT ),
368 537 1,
369 538 1
370 539 ),*/
371 - 'lp-tools-course-tab' => new LP_Asset_Key(
540 + 'lp-tools-course-tab' => new LP_Asset_Key(
372 541 $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 - ),
542 + [],
385 543 array( 'learnpress_page_learn-press-tools' ),
386 544 0,
387 545 1,
388 546 '',
389 - [ 'strategy' => 'defer' ]
547 + array( 'strategy' => 'defer' )
390 548 ),
391 - /*'lp-dashboard' => new LP_Asset_Key(
549 + /*
550 + 'lp-dashboard' => new LP_Asset_Key(
392 551 self::url( 'js/dist/admin/pages/dashboard' . self::$_min_assets . '.js' ),
393 552 [],
394 553 array( 'dashboard' ),
395 554 0,
@@ -394,30 +553,30 @@
394 553 array( 'dashboard' ),
395 554 0,
396 555 1
397 556 ),*/
398 - 'lp-widgets-admin' => new LP_Asset_Key(
557 + 'lp-widgets-admin' => new LP_Asset_Key(
399 558 self::url( 'js/dist/admin/pages/widgets' . self::$_min_assets . '.js' ),
400 559 array(
401 560 'wp-url',
402 561 'wp-api-fetch',
403 562 'lodash',
404 - 'select2',
563 + //'select2',
405 564 ),
406 565 array( 'widgets', 'elementor' ),
407 566 0,
408 567 1
409 568 ),
410 - 'lp-admin-notices' => new LP_Asset_Key(
569 + 'lp-admin-notices' => new LP_Asset_Key(
411 570 self::url( 'js/dist/admin/admin-notices' . self::$_min_assets . '.js' ),
412 - [],
413 - [],
571 + array(),
572 + array(),
414 573 1,
415 574 0,
416 575 '',
417 - [ 'strategy' => 'async' ]
576 + array( 'strategy' => 'async' )
418 577 ),
419 - 'lp-material' => new LP_Asset_Key(
578 + 'lp-material' => new LP_Asset_Key(
420 579 $this->url( 'js/dist/admin/course-material' . self::$_min_assets . '.js' ),
421 580 array(),
422 581 array(
423 582 LP_COURSE_CPT,
@@ -432,32 +591,42 @@
432 591 array( 'learnpress_page_learn-press-students-enrolled' ),
433 592 0,
434 593 0,
435 594 '',
436 - [ 'strategy' => 'async' ]
595 + array( 'strategy' => 'async' )
437 596 ),
438 - 'lp-admin-tools' => new LP_Asset_Key(
439 - $this->url( 'js/dist/admin/admin-tools' . self::$_min_assets . '.js' ),
440 - [],
597 + 'lp-admin-tools' => new LP_Asset_Key(
598 + $this->url( 'dist/js/admin/admin-tools' . self::$_min_assets . '.js' ),
599 + array(),
441 600 array( 'learnpress_page_learn-press-tools' ),
442 601 0,
443 - 1,
602 + 0,
444 603 '',
445 - [ 'strategy' => 'defer' ]
604 + array( 'strategy' => 'defer' )
446 605 ),
447 - 'lp-admin-statistic' => new LP_Asset_Key(
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 + ),
615 + 'lp-admin-statistic' => new LP_Asset_Key(
448 616 $this->url( 'js/dist/admin/admin-statistic' . self::$_min_assets . '.js' ),
449 - array( 'wp-api-fetch' ),
617 + array( 'lp-load-ajax' ),
450 618 array( 'learnpress_page_learn-press-statistics' ),
451 619 0,
452 620 0,
453 621 '',
454 - [ 'strategy' => 'defer' ]
622 + array( 'strategy' => 'defer' )
455 623 ),
456 624 )
457 625 );
458 626
459 - /*$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
627 + /*
628 + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
460 629 if ( $screen && $screen->id === 'site-editor' ) {
461 630 $scripts['editor-check'] = new LP_Asset_Key(
462 631 self::url( 'js/dist/gutenberg/editor-check' . self::$_min_assets . '.js' ),
463 632 array(
@@ -486,15 +655,17 @@
486 655
487 656 return apply_filters(
488 657 'learn-press/admin-default-styles',
489 658 array(
490 - 'select2' => new LP_Asset_Key(
659 + /*'select2' => new LP_Asset_Key(
491 660 $this->url( 'src/css/vendor/select2.min.css' )
492 - ),
493 - /*'font-awesome' => new LP_Asset_Key(
661 + ),*/
662 + /*
663 + 'font-awesome' => new LP_Asset_Key(
494 664 $this->url( 'src/css/vendor/font-awesome-5.min.css' )
495 665 ),*/
496 - /*'jquery-ui' => new LP_Asset_Key(
666 + /*
667 + 'jquery-ui' => new LP_Asset_Key(
497 668 $this->url( 'src/css/vendor/jquery-ui/jquery-ui.min.css' )
498 669 ),
499 670 'jquery-ui-timepicker' => new LP_Asset_Key(
500 671 $this->url( 'src/css/vendor/jquery-ui-timepicker-addon.css' )
@@ -506,47 +677,66 @@
506 677 $this->url( 'css/admin/admin' . $is_rtl . self::$_min_assets . '.css' ),
507 678 array(
508 679 'wp-color-picker',
509 680 'wp-components',
510 - //'select2',
511 - //'jquery-ui',
512 - //'jquery-ui-timepicker',
513 - //'font-awesome',
681 + // 'select2',
682 + // 'jquery-ui',
683 + // 'jquery-ui-timepicker',
684 + // 'font-awesome',
514 685 'jquery-tipsy',
515 686 ),
516 687 array(),
517 688 0
518 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 + ),
519 703 'lp-edit-curriculum' => new LP_Asset_Key(
520 704 $this->url( 'css/edit-curriculum' . $is_rtl . self::$_min_assets . '.css' ),
521 - [],
522 - [],
705 + array(),
706 + array(),
523 707 1
524 708 ),
525 709 'lp-edit-quiz' => new LP_Asset_Key(
526 710 $this->url( 'css/edit-quiz' . $is_rtl . self::$_min_assets . '.css' ),
527 - [],
528 - [],
711 + array(),
712 + array(),
529 713 1
530 714 ),
531 715 'lp-edit-question' => new LP_Asset_Key(
532 716 $this->url( 'css/edit-question' . $is_rtl . self::$_min_assets . '.css' ),
533 - [],
534 - [],
717 + array(),
718 + array(),
535 719 1
536 720 ),
537 - 'learn-press-statistic' => new LP_Asset_Key(
721 + /*'learn-press-statistic' => new LP_Asset_Key(
538 722 LP_CSS_URL . 'admin/statistic' . $is_rtl . self::$_min_assets . '.css',
539 723 array(),
540 724 array( 'learners_page_learn-press-statistics' ),
541 725 0
542 - ),
726 + ),*/
543 727 'lp-tom-select' => new LP_Asset_Key(
544 728 $this->url( 'src/css/vendor/tom-select.min.css' ),
545 - [],
546 - [],
729 + array(),
730 + array(),
547 731 0
548 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 + ),
549 739 )
550 740 );
551 741 }
552 742
@@ -556,12 +746,12 @@
556 746 public function load_scripts() {
557 747 $screen_id = LP_Admin::instance()->get_screen_id();
558 748
559 749 if ( empty( $screen_id ) ) {
560 - return;
750 + $screen_id = '';
561 751 }
562 752
563 - //wp_enqueue_media(); //Todo: tungnx need check why call for that using.
753 + // wp_enqueue_media(); //Todo: tungnx need check why call for that using.
564 754 $this->handle_js( $screen_id );
565 755 $this->handle_style( $screen_id );
566 756
567 757 do_action( 'learn-press/admin/after-enqueue-scripts' );
@@ -584,9 +774,11 @@
584 774 /**
585 775 * Get course data for Vue Editor Course use.
586 776 *
587 777 * @return array|mixed|null
778 + * @deprecated 4.4.2 - no any enqueue js for that.
588 779 */
780 + /*
589 781 public function get_course_data_for_editor_vue() {
590 782 global $post, $pagenow;
591 783
592 784 if ( empty( $post ) || ( get_post_type() !== LP_COURSE_CPT ) || ! in_array(
@@ -595,9 +787,9 @@
595 787 'post.php',
596 788 'post-new.php',
597 789 )
598 790 ) ) {
599 - return [];
791 + return array();
600 792 }
601 793
602 794 $course = CourseModel::find( $post->ID, true );
603 795 if ( $course ) {
@@ -648,10 +840,13 @@
648 840 'urlEdit' => admin_url( 'post.php?action=edit&post=' ),
649 841 ),
650 842 )
651 843 );
652 - }
844 + }*/
653 845
846 + /**
847 + * Instance
848 + */
654 849 public static function instance() {
655 850 if ( ! is_admin() ) {
656 851 return null;
657 852 }