PluginProbe
Tutor LMS – eLearning and online course solution / 1.9.4
Tutor LMS – eLearning and online course solution v1.9.4
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/Utils.php +70 -23 1.9.31.9.4 View file →
@@ -122,15 +122,22 @@
122 122 *
123 123 * @since v.1.0.0
124 124 */
125 125 public function get_pages() {
126 +
127 + do_action( 'tutor_utils/get_pages/before' );
128 +
126 129 $pages = array();
127 130 $wp_pages = get_pages();
128 - if ( is_array( $wp_pages ) && count( $wp_pages ) ) {
129 - foreach ( $wp_pages as $page ) {
131 +
132 + if (is_array($wp_pages) && count($wp_pages)) {
133 + foreach ($wp_pages as $page) {
130 134 $pages[$page->ID] = $page->post_title;
131 135 }
132 136 }
137 +
138 + do_action( 'tutor_utils/get_pages/after' );
139 +
133 140 return $pages;
134 141 }
135 142
136 143 /**
@@ -239,13 +246,14 @@
239 246 * Determine if PMPro is activated
240 247 *
241 248 * @since v.1.3.6
242 249 */
243 - public function has_pmpro() {
250 + public function has_pmpro($check_monetization=false) {
244 251 $activated_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
245 252 $depends = array( 'paid-memberships-pro/paid-memberships-pro.php' );
246 253 $has_pmpro = count( array_intersect( $depends, $activated_plugins ) ) == count( $depends );
247 - return $has_pmpro;
254 +
255 + return $has_pmpro && (!$check_monetization || get_tutor_option('monetize_by') == 'pmpro' );
248 256 }
249 257
250 258 public function has_wcs(){
251 259 $activated_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
@@ -486,25 +494,17 @@
486 494
487 495 $instructor_id = $this->get_user_id( $instructor_id );
488 496 $course_post_type = tutor()->course_post_type;
489 497
490 - $query = $wpdb->get_results( $wpdb->prepare(
491 - "SELECT ID,
492 - post_author,
493 - post_title,
494 - post_name,
495 - post_status,
496 - menu_order
497 - FROM {$wpdb->posts}
498 - WHERE post_author = %d
499 - AND post_status IN ('publish', 'pending')
500 - AND post_type = %s;
501 - ",
502 - $instructor_id,
503 - $course_post_type
504 - ) );
505 -
506 - return $query;
498 + global $current_user;
499 + $courses = get_posts(array(
500 + 'post_type' => $course_post_type,
501 + 'author' => $instructor_id,
502 + 'post_status' => array('publish', 'pending'),
503 + 'posts_per_page' => -1
504 + ));
505 +
506 + return $courses;
507 507 }
508 508
509 509 /**
510 510 * @param $instructor_id
@@ -5734,8 +5734,34 @@
5734 5734 return $children;
5735 5735 }
5736 5736
5737 5737 /**
5738 + * @param int $parent
5739 + *
5740 + * @return array
5741 + *
5742 + * Get course tags in array with child
5743 + *
5744 + * @since v.1.9.3
5745 + */
5746 + public function get_course_tags( ) {
5747 + $args = apply_filters( 'tutor_get_course_tags_args', array(
5748 + 'taxonomy' => 'course-tag',
5749 + 'hide_empty' => false
5750 + ));
5751 +
5752 + $terms = get_terms( $args );
5753 +
5754 + $children = array();
5755 + foreach ( $terms as $term ) {
5756 + $term->children = array();
5757 + $children[ $term->term_id ] = $term;
5758 + }
5759 +
5760 + return $children;
5761 + }
5762 +
5763 + /**
5738 5764 * @param int $parent_id
5739 5765 *
5740 5766 * @return array|int|\WP_Error
5741 5767 *
@@ -7015,15 +7041,36 @@
7015 7041 * @since v1.9.2
7016 7042 *
7017 7043 * Check if current screen is under tutor dashboard
7018 7044 */
7019 - public function is_tutor_dashboard() {
7045 + public function is_tutor_dashboard($subpage = null) {
7020 7046
7021 - if(is_admin()) {
7047 + // To Do: Add subpage check later
7048 +
7049 + if(function_exists('is_admin') && is_admin()) {
7022 7050 $screen = get_current_screen();
7023 7051 return is_object( $screen ) && $screen->parent_base == 'tutor';
7024 7052 }
7025 7053
7054 + return false;
7055 + }
7056 +
7057 + /**
7058 + * @return boolean
7059 + *
7060 + * @since v1.9.4
7061 + *
7062 + * Check if current screen tutor frontend dashboard
7063 + */
7064 + public function is_tutor_frontend_dashboard($subpage = null) {
7065 +
7066 + global $wp_query;
7067 + if ($wp_query->is_page) {
7068 + $dashboard_page = tutor_utils()->array_get('tutor_dashboard_page', $wp_query->query_vars);
7069 +
7070 + return $subpage ? $dashboard_page == $subpage : $dashboard_page;
7071 + }
7072 +
7026 7073 return false;
7027 7074 }
7028 7075
7029 7076 public function get_unique_slug($slug, $post_type=null, $num_assigned=false) {