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