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/lp-admin-functions.php +77 -386 4.1.7.3.24.4.8 View file →
@@ -11,8 +11,25 @@
11 11 * Prevent loading this file directly
12 12 */
13 13 defined( 'ABSPATH' ) || exit();
14 14
15 +/**
16 + * Check whether MCP capabilities are available in current WordPress runtime.
17 + *
18 + * @return bool
19 + */
20 +function learn_press_is_mcp_available(): bool {
21 + $wp_version = (string) get_bloginfo( 'version' );
22 +
23 + if ( version_compare( $wp_version, '6.9', '<' ) ) {
24 + return false;
25 + }
26 +
27 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
28 +
29 + return is_plugin_active( 'mcp-adapter/mcp-adapter.php' );
30 +}
31 +
15 32 if ( ! function_exists( 'learn_press_add_row_action_link' ) ) {
16 33 /**
17 34 * Setup action links to the admin course, lesson, quiz, question. e.g: Add Duplicate link, hide View link for lesson, quiz so on.
18 35 *
@@ -47,9 +64,9 @@
47 64 $link['class'],
48 65 $link['data'],
49 66 $link['title']
50 67 ) . '</li>';
51 - };
68 + }
52 69
53 70 $drop_down[] = '</ul>';
54 71 $link = sprintf(
55 72 '<div class="lpr-row-actions"><a href="%s">%s</a>%s</div>',
@@ -105,9 +122,9 @@
105 122 add_filter( 'post_row_actions', 'learn_press_add_row_action_link' );
106 123 add_filter( 'page_row_actions', 'learn_press_add_row_action_link' );
107 124 }
108 125
109 -function learn_press_is_hidden_post_box( $id, $user_id = 0 ) {
126 +/*function learn_press_is_hidden_post_box( $id, $user_id = 0 ) {
110 127 if ( ! $user_id ) {
111 128 $user_id = get_current_user_id();
112 129 }
113 130
@@ -116,9 +133,9 @@
116 133 $data = array();
117 134 }
118 135
119 136 return false !== array_search( $id, $data );
120 -}
137 +}*/
121 138
122 139 /**
123 140 * List all pages as a dropdown with "Add New Page" option
124 141 *
@@ -131,11 +148,9 @@
131 148 function learn_press_pages_dropdown( $name, $selected = false, $args = array() ) {
132 149 $id = null;
133 150 $class = null;
134 151 $css = null;
135 - $before = array(
136 - 'add_new_page' => __( '[ Add a new page ]', 'learnpress' ),
137 - );
152 + $before = [];
138 153 $after = null;
139 154 $echo = true;
140 155 $allow_create = true;
141 156
@@ -148,9 +163,9 @@
148 163 if ( empty( $id ) ) {
149 164 $id = $name;
150 165 }
151 166
152 - $class .= 'list-pages lp-list-pages learn-press-select2';
167 + $class .= 'list-pages lp-list-pages lp-tom-select';
153 168
154 169 $args = array(
155 170 'name' => $name,
156 171 'id' => $id,
@@ -223,8 +238,10 @@
223 238 &#124;
224 239 <a class="view-page" href="<?php echo get_permalink( $selected ); ?>"
225 240 target="_blank"><?php esc_html_e( 'View page', 'learnpress' ); ?></a>
226 241 </p>
242 + <!-- Not use input on here, will be not save value -->
243 + <div class="field_name" name="<?php echo esc_attr( $id ); ?>"></div>
227 244
228 245 <?php
229 246 $output .= ob_get_clean();
230 247 } else {
@@ -235,9 +252,10 @@
235 252
236 253 if ( $echo ) {
237 254 $allowed_html = wp_kses_allowed_html( 'post' );
238 255 $allowed_html['select'] = [
239 - 'name' => [],
256 + 'name' => [],
257 + 'class' => [],
240 258 ];
241 259 $allowed_html['option'] = [
242 260 'value' => [],
243 261 'selected' => [],
@@ -245,9 +263,15 @@
245 263 ];
246 264 $allowed_html['input'] = [
247 265 'type' => [],
248 266 'placeholder' => [],
267 + 'name' => [],
268 + 'class' => [],
249 269 ];
270 + $allowed_html['div'] = [
271 + 'name' => [],
272 + 'class' => [],
273 + ];
250 274
251 275 echo wp_kses( $output, $allowed_html );
252 276 }
253 277
@@ -364,10 +388,11 @@
364 388 *
365 389 * @param array $args
366 390 *
367 391 * @return string
392 + * @deprecated 4.2.6.9.3
368 393 */
369 -function learn_press_email_formats_dropdown( $args = array() ) {
394 +/*function learn_press_email_formats_dropdown( $args = array() ) {
370 395 $args = wp_parse_args(
371 396 $args,
372 397 array(
373 398 'name' => 'learn-press-dropdown-email-formats',
@@ -416,9 +441,9 @@
416 441 echo wp_kses_post( $output );
417 442 }
418 443
419 444 return $output;
420 -}
445 +}*/
421 446
422 447 /**
423 448 * Return array of email formats.
424 449 *
@@ -451,195 +476,8 @@
451 476 return $content;
452 477 }
453 478
454 479 /**
455 - * Get list of themes that support LearnPress.
456 - *
457 - * @return mixed
458 - */
459 -function learn_press_get_education_themes() {
460 -
461 - // New theme can be added here
462 - return apply_filters(
463 - 'learn-press/education-themes',
464 - array(
465 - '23451388' => 'kindergarten',
466 - '22773871' => 'ivy-school',
467 - '20370918' => 'wordpress-lms',
468 - '14058034' => 'eduma',
469 - '17097658' => 'coach',
470 - '11797847' => 'lms',
471 - )
472 - );
473 -}
474 -
475 -if ( ! function_exists( 'learn_press_get_item_referral' ) ) {
476 - /**
477 - * Set item link referral.
478 - *
479 - * @param int|string $item_id
480 - *
481 - * @return string
482 - */
483 - function learn_press_get_item_referral( $item_id ) {
484 - $affiliate_links = array(
485 - 14058034 => 'https://1.envato.market/G5Ook', // Eduma
486 - 22773871 => 'https://1.envato.market/akrzZ', // Ivy-school
487 - 20370918 => 'https://1.envato.market/13Zkd', // Course Builder LMS
488 - 17097658 => 'https://1.envato.market/Xq2Ra', // Coach
489 - 23451388 => 'https://1.envato.market/oWov9', // StarKid
490 - 11797847 => 'https://1.envato.market/zknvM', // Epsilon
491 - 13321455 => 'https://1.envato.market/G5Rkk', // Sailing
492 - 19029758 => 'https://1.envato.market/mAYdZ', // Travel Tour Booking
493 - 12124219 => 'https://1.envato.market/qJYdO', // Resca
494 - 18828322 => 'https://1.envato.market/VW2K3', // LuxStay
495 - 8254575 => 'https://1.envato.market/xWYdO', // Squareroot
496 - 13782850 => 'https://1.envato.market/Qo71z',
497 - 14025178 => 'https://1.envato.market/9R0oQ',
498 - 17739078 => 'https://1.envato.market/jkYda',
499 - 16210005 => 'https://1.envato.market/56oJD',
500 - 11733602 => 'https://1.envato.market/keYdv',
501 - 13513609 => 'https://1.envato.market/aq7dQ',
502 - 19693761 => 'https://1.envato.market/A976D',
503 - 12532973 => 'https://1.envato.market/Ge79B',
504 - 19305239 => 'https://1.envato.market/10JAB',
505 - 23716060 => 'https://1.envato.market/ZO7WW',
506 - 20466233 => 'https://1.envato.market/gjYd0',
507 - 21070438 => 'https://1.envato.market/xPz65',
508 - 20794183 => 'https://1.envato.market/o1YdY',
509 - 20979215 => 'https://1.envato.market/03R5V',
510 - 11151269 => 'https://1.envato.market/Br7L4',
511 - 8905392 => 'https://1.envato.market/zEYd7',
512 - 23168294 => 'https://1.envato.market/Wn7on',
513 - 17719422 => 'https://1.envato.market/0WVaL',
514 - 21680592 => 'https://1.envato.market/qqO6y',
515 - );
516 -
517 - return isset( $affiliate_links[ $item_id ] ) ? $affiliate_links[ $item_id ] : 'https://themeforest.net/user/thimpress/portfolio/';
518 - }
519 -}
520 -
521 -/**
522 - * Display advertisement about related themes at the bottom of admin pages.
523 - *
524 - * @updated 12 Nov 2018 - Enable/Disable shuffle the list of themes
525 - *
526 - * @return bool|void
527 - */
528 -function learn_press_footer_advertisement() {
529 - $admin_post_type = array(
530 - 'lp_course',
531 - 'lp_lesson',
532 - 'lp_quiz',
533 - 'lp_question',
534 - 'lp_order',
535 - );
536 -
537 - // And our admin pages
538 - $pages = array(
539 - 'learnpress_page_learn-press-statistics',
540 - 'learnpress_page_learn-press-settings',
541 - 'learnpress_page_learn-press-tools',
542 -
543 - );
544 -
545 - $screen = get_current_screen();
546 -
547 - if ( ! $screen ) {
548 - return;
549 - }
550 -
551 - if ( ! ( ( in_array(
552 - $screen->post_type,
553 - $admin_post_type
554 - ) && $screen->base === 'edit' ) || ( in_array( $screen->id, $pages ) ) ) ) {
555 - return;
556 - }
557 -
558 - $theme_ids = learn_press_get_education_themes();
559 - $current_theme = wp_get_theme();
560 -
561 - $include = array_keys( $theme_ids );
562 -
563 - $key = array_search( $current_theme->name, $theme_ids, true );
564 -
565 - if ( false !== $key ) {
566 - unset( $theme_ids[ $key ] );
567 - }
568 -
569 - $list_themes = (array) LP_Plugins_Helper::get_related_themes(
570 - 'education',
571 - array(
572 - 'include' => $include,
573 - )
574 - );
575 -
576 - if ( empty( $list_themes ) ) {
577 - return;
578 - }
579 -
580 - // Disable shuffle themes for 3 days
581 - $shuffle = LP_Settings::instance()->get( 'ad_shuffle_themes' );
582 -
583 - if ( ! $shuffle ) {
584 - if ( wp_next_scheduled( 'learn-press/schedule-enable-shuffle-themes' ) === false ) {
585 - wp_schedule_single_event( time() + 3 * DAY_IN_SECONDS, 'learn-press/schedule-enable-shuffle-themes' );
586 - }
587 -
588 - // Keep the first theme always in #1 and shuffle other themes
589 - $first_theme = array_shift( $list_themes );
590 - shuffle( $list_themes );
591 - array_unshift( $list_themes, $first_theme );
592 - } else {
593 - shuffle( $list_themes );
594 - }
595 - ?>
596 -
597 - <div id="learn-press-advertisement" class="learn-press-advertisement-slider">
598 - <?php
599 - foreach ( $list_themes as $theme ) {
600 - if ( empty( $theme['url'] ) ) {
601 - continue;
602 - }
603 -
604 - $url = learn_press_get_item_referral( $theme['id'] );
605 - $full_description = learn_press_trim_content( $theme['description'] );
606 - $short_description = learn_press_trim_content( $theme['description'], 75 );
607 - $url_demo = $theme['attributes'][4]['value'];
608 - ?>
609 -
610 - <div id="thimpress-<?php echo esc_attr( $theme['id'] ); ?>" class="slide-item">
611 - <div class="slide-thumbnail">
612 - <a href="<?php echo esc_url_raw( $url ); ?>">
613 - <img src="<?php echo esc_url_raw( $theme['previews']['landscape_preview']['landscape_url'] ); ?>"/>
614 - </a>
615 - </div>
616 -
617 - <div class="slide-detail">
618 - <h2><a href="<?php echo esc_url_raw( $url ); ?>"><?php echo esc_html( $theme['name'] ); ?></a></h2>
619 - <p class="slide-description description-full">
620 - <?php echo wp_kses_post( $full_description ); ?>
621 - </p>
622 -
623 - <p class="slide-description description-short">
624 - <?php echo wp_kses_post( $short_description ); ?>
625 - </p>
626 -
627 - <p class="slide-controls">
628 - <a href="<?php echo esc_url_raw( $url ); ?>" class="button button-primary"
629 - target="_blank"><?php esc_html_e( 'Get it now', 'learnpress' ); ?></a>
630 - <a href="<?php echo esc_url_raw( $url_demo ); ?>" class="button"
631 - target="_blank"><?php esc_html_e( 'View Demo', 'learnpress' ); ?></a>
632 - </p>
633 - </div>
634 - </div>
635 -
636 - <?php } ?>
637 - </div>
638 - <?php
639 -}
640 -
641 -/**
642 480 * Count number of orders between to dates
643 481 *
644 482 * @param string
645 483 * @param int
@@ -739,10 +577,11 @@
739 577 *
740 578 * @param string
741 579 *
742 580 * @return int
581 + * @deprecated 4.2.6.9.3
743 582 */
744 -function learn_press_get_courses_by_price( $fee ) {
583 +/*function learn_press_get_courses_by_price( $fee ) {
745 584 global $wpdb;
746 585
747 586 $user_id = get_current_user_id();
748 587
@@ -765,9 +604,9 @@
765 604 )
766 605 );
767 606
768 607 return $courses;
769 -}
608 +}*/
770 609
771 610 /**
772 611 * Get data about students to render in chart
773 612 *
@@ -775,10 +614,11 @@
775 614 * @param null $by
776 615 * @param float $time_ago
777 616 *
778 617 * @return array
618 + * @deprecated 4.2.6.9.3
779 619 */
780 -function learn_press_get_chart_students( $from = null, $by = null, $time_ago = 0 ) {
620 +/*function learn_press_get_chart_students( $from = null, $by = null, $time_ago = 0 ) {
781 621 $labels = array();
782 622 $datasets = array();
783 623
784 624 if ( is_null( $from ) ) {
@@ -817,9 +657,9 @@
817 657 return array(
818 658 'labels' => $labels,
819 659 'datasets' => $datasets,
820 660 );
821 -}
661 +}*/
822 662
823 663 /**
824 664 * Get data about students to render in chart
825 665 *
@@ -827,10 +667,11 @@
827 667 * @param null $by
828 668 * @param float $time_ago
829 669 *
830 670 * @return array
671 + * @deprecated 4.2.6.9.3
831 672 */
832 -function learn_press_get_chart_users( $from = null, $by = null, $time_ago = 0 ) {
673 +/*function learn_press_get_chart_users( $from = null, $by = null, $time_ago = 0 ) {
833 674 global $wpdb;
834 675
835 676 $labels = array();
836 677 $datasets = array();
@@ -968,9 +809,9 @@
968 809 'labels' => $labels,
969 810 'datasets' => $datasets,
970 811 'sql' => $query,
971 812 );
972 -}
813 +}*/
973 814
974 815
975 816 /**
976 817 * Get data about students to render in chart
@@ -979,10 +820,11 @@
979 820 * @param null $by
980 821 * @param float $time_ago
981 822 *
982 823 * @return array
824 + * @deprecated 4.2.6.9.3
983 825 */
984 -function learn_press_get_chart_courses( $from = null, $by = null, $time_ago = 0 ) {
826 +/*function learn_press_get_chart_courses( $from = null, $by = null, $time_ago = 0 ) {
985 827 global $wpdb;
986 828
987 829 $labels = array();
988 830 $datasets = array();
@@ -1172,9 +1014,9 @@
1172 1014 'labels' => $labels,
1173 1015 'datasets' => $datasets,
1174 1016 'sql' => $query,
1175 1017 );
1176 -}
1018 +}*/
1177 1019
1178 1020
1179 1021 /**
1180 1022 * Get data about students to render in chart
@@ -1183,13 +1025,14 @@
1183 1025 * @param null $by
1184 1026 * @param float $time_ago
1185 1027 *
1186 1028 * @return array
1029 + * @deprecated 4.2.6.9.3
1187 1030 */
1188 -function learn_press_get_chart_orders( $from = null, $by = null, $time_ago = 0 ) {
1031 +/*function learn_press_get_chart_orders( $from = null, $by = null, $time_ago = 0 ) {
1189 1032 global $wpdb;
1190 - // var_dump( current_user_can(LP_TEACHER_ROLE) );
1191 - // exit();
1033 + $sql_join = '';
1034 +
1192 1035 $report_sales_by = learn_press_get_request( 'report_sales_by' );
1193 1036 $course_id = learn_press_get_request( 'course_id' );
1194 1037 $cat_id = learn_press_get_request( 'cat_id' );
1195 1038
@@ -1242,13 +1085,13 @@
1242 1085 $query_where = '';
1243 1086 $sql_join = '';
1244 1087 if ( 'course' === $report_sales_by ) {
1245 1088 $sql_join .= " INNER JOIN `{$wpdb->prefix}learnpress_order_items` `lpoi` "
1246 - . ' ON o.ID=lpoi.order_id '
1247 - . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
1248 - . ' ON lpoi.order_item_id=loim.learnpress_order_item_id '
1249 - . " AND loim.meta_key='_course_id' "
1250 - . ' AND CAST(loim.meta_value AS SIGNED)=%d ';
1089 + . ' ON o.ID=lpoi.order_id '
1090 + . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
1091 + . ' ON lpoi.order_item_id=loim.learnpress_order_item_id '
1092 + . " AND loim.meta_key='_course_id' "
1093 + . ' AND CAST(loim.meta_value AS SIGNED)=%d ';
1251 1094 if ( current_user_can( LP_TEACHER_ROLE ) ) {
1252 1095 $user_id = learn_press_get_current_user_id();
1253 1096 $sql_join .= $wpdb->prepare(
1254 1097 ' AND CAST(loim.meta_value AS SIGNED) IN '
@@ -1260,18 +1103,18 @@
1260 1103 $query_join .= $wpdb->prepare( $sql_join, $course_id );
1261 1104
1262 1105 } elseif ( 'category' === $report_sales_by ) {
1263 1106 $sql_join .= " INNER JOIN `{$wpdb->prefix}learnpress_order_items` `lpoi` "
1264 - . ' ON o.ID=lpoi.order_id '
1265 - . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
1266 - . ' ON lpoi.order_item_id=loim.learnpress_order_item_id '
1267 - . " AND loim.meta_key='_course_id' "
1268 - . ' AND CAST(loim.meta_value AS SIGNED) IN('
1269 - // sub query
1270 - . ' SELECT tr.object_id '
1271 - . " FROM {$wpdb->prefix}term_taxonomy tt INNER JOIN {$wpdb->prefix}term_relationships tr "
1272 - . " ON tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.taxonomy='course_category' "
1273 - . ' WHERE tt.term_id=%d)';
1107 + . ' ON o.ID=lpoi.order_id '
1108 + . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
1109 + . ' ON lpoi.order_item_id=loim.learnpress_order_item_id '
1110 + . " AND loim.meta_key='_course_id' "
1111 + . ' AND CAST(loim.meta_value AS SIGNED) IN('
1112 + // sub query
1113 + . ' SELECT tr.object_id '
1114 + . " FROM {$wpdb->prefix}term_taxonomy tt INNER JOIN {$wpdb->prefix}term_relationships tr "
1115 + . " ON tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.taxonomy='course_category' "
1116 + . ' WHERE tt.term_id=%d)';
1274 1117 $query_join .= $wpdb->prepare( $sql_join, $cat_id );
1275 1118 }
1276 1119 if ( current_user_can( LP_TEACHER_ROLE ) ) {
1277 1120 $user_id = learn_press_get_current_user_id();
@@ -1379,16 +1222,17 @@
1379 1222 'labels' => $labels,
1380 1223 'datasets' => $datasets,
1381 1224 'sql' => $query,
1382 1225 );
1383 -}
1226 +}*/
1384 1227
1385 1228 /**
1386 1229 * Get data about courses to render in the chart
1387 1230 *
1388 1231 * @return array
1232 + * @deprecated 4.2.6.9.3
1389 1233 */
1390 -function learn_press_get_chart_courses2() {
1234 +/*function learn_press_get_chart_courses2() {
1391 1235 $labels = array(
1392 1236 __( 'Pending Courses/Publish Courses', 'learnpress' ),
1393 1237 __( 'Free Courses/Paid Courses', 'learnpress' ),
1394 1238 );
@@ -1413,9 +1257,9 @@
1413 1257 return array(
1414 1258 'labels' => $labels,
1415 1259 'datasets' => $datasets,
1416 1260 );
1417 -}
1261 +}*/
1418 1262
1419 1263 /**
1420 1264 * Get colors setting up by admin user
1421 1265 *
@@ -1559,31 +1403,8 @@
1559 1403
1560 1404 return $slug;
1561 1405 }
1562 1406
1563 -function learn_press_request_query( $vars = array() ) {
1564 - global $typenow, $wp_query, $wp_post_statuses;
1565 -
1566 - if ( LP_ORDER_CPT === $typenow ) {
1567 - if ( ! isset( $vars['post_status'] ) ) {
1568 - $post_statuses = learn_press_get_order_statuses();
1569 -
1570 - foreach ( $post_statuses as $status => $value ) {
1571 - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
1572 - unset( $post_statuses[ $status ] );
1573 - }
1574 - }
1575 -
1576 - $vars['post_status'] = array_keys( $post_statuses );
1577 -
1578 - }
1579 - }
1580 -
1581 - return $vars;
1582 -}
1583 -
1584 -add_filter( 'request', 'learn_press_request_query', 0 );
1585 -
1586 1407 function _learn_press_reset_course_data() {
1587 1408 if ( empty( $_REQUEST['reset-course-data'] ) ) {
1588 1409 return false;
1589 1410 }
@@ -1769,9 +1590,13 @@
1769 1590 'post_excerpt' => $post->post_excerpt,
1770 1591 'post_parent' => $post->post_parent,
1771 1592 'post_password' => $post->post_password,
1772 1593 'post_status' => 'draft',
1773 - 'post_title' => $post->post_title . __( 'Copy', 'learnpress' ),
1594 + 'post_title' => sprintf(
1595 + '%1$s (%2$s)',
1596 + $post->post_title,
1597 + _x( 'Copy', 'Duplicate item title suffix', 'learnpress' )
1598 + ),
1774 1599 'post_type' => $post->post_type,
1775 1600 'to_ping' => $post->to_ping,
1776 1601 'menu_order' => $post->menu_order,
1777 1602 'exclude_meta' => array(),
@@ -1855,9 +1680,9 @@
1855 1680 }
1856 1681
1857 1682 for ( $j = $i + 1; $j < count( $ktypes ); $j ++ ) {
1858 1683 if ( isset( $question_types[ $ktypes[ $j ] ], $question_types[ $ktypes[ $max ] ] )
1859 - && $question_types[ $ktypes[ $j ] ] > $question_types[ $ktypes[ $max ] ]
1684 + && $question_types[ $ktypes[ $j ] ] > $question_types[ $ktypes[ $max ] ]
1860 1685 ) {
1861 1686 $max = $j;
1862 1687 }
1863 1688 }
@@ -2333,53 +2158,8 @@
2333 2158 }
2334 2159 }
2335 2160
2336 2161 /**
2337 - * Filter to modal search items to void filter the posts by author.
2338 - *
2339 - * @param int|string $context_id
2340 - * @param string $context
2341 - *
2342 - * @return bool|int|string
2343 - * @since 3.0.4
2344 - */
2345 -function learn_press_modal_search_items_context( $context_id, $context ) {
2346 - if ( 'order-items' === $context ) {
2347 - $context_id = false;
2348 - }
2349 -
2350 - return $context_id;
2351 -}
2352 -
2353 -add_filter( 'learn-press/modal-search-items/context-id', 'learn_press_modal_search_items_context', 10, 2 );
2354 -
2355 -/**
2356 - * Sync post meta when saving post type.
2357 - *
2358 - * @param int $post_id
2359 - *
2360 - * @since 3.2.0
2361 - * @editor tungnx
2362 - * @modify 1.4.1 - comment - not use
2363 - */
2364 -/*function learn_press_maybe_sync_data( $post_id ) {
2365 - $post_type = get_post_type( $post_id );
2366 -
2367 - switch ( $post_type ) {
2368 - case LP_COURSE_CPT:
2369 - LP_Repair_Database::instance()->sync_user_courses();
2370 - break;
2371 - case LP_LESSON_CPT:
2372 - break;
2373 - case LP_QUIZ_CPT:
2374 - break;
2375 - default:
2376 - }
2377 -}*/
2378 -
2379 -//add_action( 'save_post', 'learn_press_maybe_sync_data' );
2380 -
2381 -/**
2382 2162 * Return id of current screen.
2383 2163 *
2384 2164 * @return bool|string
2385 2165 * @since 3.2.6
@@ -2384,101 +2164,12 @@
2384 2164 * @return bool|string
2385 2165 * @since 3.2.6
2386 2166 */
2387 2167 function learn_press_get_screen_id() {
2168 + _deprecated_function( __METHOD__, '4.2.3.6' );
2388 2169 $screen = get_current_screen();
2389 2170 $screen_id = $screen ? $screen->id : false;
2390 2171
2391 2172 return $screen_id;
2392 -}
2393 -
2394 -/**
2395 - * Check if current screen is a page of LP or
2396 - * editing post type of LP such as course, lesson, etc...
2397 - *
2398 - * @return bool
2399 - * @since 3.2.6
2400 - */
2401 -/*
2402 -function learn_press_is_admin_page() {
2403 - $screen_id = learn_press_get_screen_id();
2404 - $is_learnpress = false;
2405 -
2406 - $post_types = apply_filters(
2407 - 'learn-press/admin-post-type-pages',
2408 - array( LP_COURSE_CPT, LP_QUIZ_CPT, LP_LESSON_CPT, LP_QUESTION_CPT, LP_ORDER_CPT, 'lp_cert', 'lp_assignment' )
2409 - );
2410 - foreach ( $post_types as $post_type ) {
2411 - if ( in_array( $screen_id, array( "edit-{$post_type}", $post_type ) ) ) {
2412 - $is_learnpress = true;
2413 - break;
2414 - }
2415 - }
2416 -
2417 - if ( strpos( $screen_id, 'learnpress_page_' ) === 0 ) {
2418 - $is_learnpress = true;
2419 - }
2420 -
2421 - return apply_filters( 'learn-press/is-admin-page', $is_learnpress, $screen_id );
2422 -}*/
2423 -
2424 -function learn_press_get_orders_status_chart_data() {
2425 - $data = array(
2426 - 'type' => 'pie',
2427 - 'data' => array(
2428 - 'labels' => array(),
2429 - 'datasets' => array(
2430 - array(
2431 - 'label' => '# of Votes',
2432 - 'data' => array(),
2433 - 'backgroundColor' => array(
2434 - 'rgba(54, 162, 235, 0.2)',
2435 - 'rgba(255, 206, 86, 0.2)',
2436 - 'rgba(75, 192, 192, 0.2)',
2437 - 'rgba(153, 102, 255, 0.2)',
2438 - 'rgba(255, 159, 64, 0.2)',
2439 - ),
2440 - 'borderColor' => array(
2441 - 'rgba(54, 162, 235, 1)',
2442 - 'rgba(255, 206, 86, 1)',
2443 - 'rgba(75, 192, 192, 1)',
2444 - 'rgba(153, 102, 255, 1)',
2445 - 'rgba(255, 159, 64, 1)',
2446 - ),
2447 - 'borderWidth' => 1,
2448 - ),
2449 - ),
2450 - ),
2451 - 'options' => array(
2452 - 'scales' => array(
2453 - 'yAxes' => array(
2454 - array(
2455 - 'ticks' => array(
2456 - 'beginAtZero' => true,
2457 - ),
2458 - ),
2459 - ),
2460 - ),
2461 - ),
2462 - );
2463 -
2464 - $order_statuses = learn_press_get_order_statuses( true, true );
2465 - $specific_statuses = array( 'lp-completed', 'lp-failed' );
2466 -
2467 - foreach ( $order_statuses as $status ) {
2468 - if ( ! in_array( $status, $specific_statuses ) ) {
2469 - $specific_statuses[] = $status;
2470 - }
2471 - }
2472 -
2473 - $labels = learn_press_get_order_statuses();
2474 - $counts = learn_press_count_orders( array( 'status' => $specific_statuses ) );
2475 -
2476 - foreach ( $counts as $k => $v ) {
2477 - $data['data']['labels'][] = isset( $labels[ $k ] ) ? $labels[ $k ] : 'Untitled';
2478 - $data['data']['datasets'][0]['data'][] = $v;
2479 - }
2480 -
2481 - return $data;
2482 2173 }
2483 2174
2484 2175 require_once 'class-lp-post-type-actions.php';