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