@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * The Template for displaying all course lessons on the course results page. |
5 | 5 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | global $course; |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php if ( is_user_logged_in() ): ?> |
|
17 | +<?php if (is_user_logged_in()): ?> |
|
18 | 18 | |
19 | 19 | <?php |
20 | 20 | /** |
@@ -22,53 +22,53 @@ discard block |
||
22 | 22 | * is uer logged check, just above the lessons header. |
23 | 23 | * @since 1.4.0 |
24 | 24 | */ |
25 | - do_action( 'sensei_course_results_before_lessons', $course->ID ); |
|
25 | + do_action('sensei_course_results_before_lessons', $course->ID); |
|
26 | 26 | ?> |
27 | 27 | |
28 | 28 | <header> |
29 | 29 | |
30 | - <h2> <?php _e( 'Lessons', 'woothemes-sensei' ); ?> </h2> |
|
30 | + <h2> <?php _e('Lessons', 'woothemes-sensei'); ?> </h2> |
|
31 | 31 | |
32 | 32 | </header> |
33 | 33 | |
34 | - <article class="<?php esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ), $course->ID ) ) ); ?> "> |
|
34 | + <article class="<?php esc_attr_e(join(' ', get_post_class(array('course', 'post'), $course->ID))); ?> "> |
|
35 | 35 | |
36 | 36 | <?php |
37 | 37 | |
38 | 38 | $displayed_lessons = array(); |
39 | - $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) ); |
|
39 | + $modules = Sensei()->modules->get_course_modules(intval($course->ID)); |
|
40 | 40 | |
41 | 41 | // List modules with lessons |
42 | - foreach( $modules as $module ) { |
|
42 | + foreach ($modules as $module) { |
|
43 | 43 | |
44 | - $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id ); |
|
44 | + $lessons_query = Sensei()->modules->get_lessons_query($course->ID, $module->term_id); |
|
45 | 45 | $lessons = $lessons_query->get_posts(); |
46 | 46 | |
47 | - if( count( $lessons ) > 0 ) { ?> |
|
47 | + if (count($lessons) > 0) { ?> |
|
48 | 48 | |
49 | 49 | <h3> <?php echo $module->name; ?></h3> |
50 | 50 | |
51 | 51 | <?php |
52 | 52 | $count = 0; |
53 | - foreach( $lessons as $lesson ) { |
|
53 | + foreach ($lessons as $lesson) { |
|
54 | 54 | |
55 | 55 | $lesson_grade = 'n/a'; |
56 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
57 | - if ( $has_questions ) { |
|
58 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() ); |
|
56 | + $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true); |
|
57 | + if ($has_questions) { |
|
58 | + $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id()); |
|
59 | 59 | // Get user quiz grade |
60 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
61 | - if ( $lesson_grade ) { |
|
60 | + $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
61 | + if ($lesson_grade) { |
|
62 | 62 | $lesson_grade .= '%'; |
63 | 63 | } |
64 | 64 | } |
65 | 65 | ?> |
66 | 66 | <h2> |
67 | 67 | |
68 | - <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>" |
|
69 | - title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>"> |
|
68 | + <a href="<?php esc_url_raw(get_permalink($lesson->ID)); ?>" |
|
69 | + title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)); ?>"> |
|
70 | 70 | |
71 | - <?php esc_html_e( $lesson->post_title ); ?> |
|
71 | + <?php esc_html_e($lesson->post_title); ?> |
|
72 | 72 | |
73 | 73 | </a> |
74 | 74 | |
@@ -89,25 +89,25 @@ discard block |
||
89 | 89 | |
90 | 90 | <?php |
91 | 91 | |
92 | - $lessons = Sensei()->modules->get_none_module_lessons( $course->ID ); |
|
93 | - if( 0 < count( $lessons ) ): ?> |
|
92 | + $lessons = Sensei()->modules->get_none_module_lessons($course->ID); |
|
93 | + if (0 < count($lessons)): ?> |
|
94 | 94 | |
95 | 95 | <h3> |
96 | 96 | |
97 | - <?php _e( 'Other Lessons', 'woothemes-sensei' ); ?> |
|
97 | + <?php _e('Other Lessons', 'woothemes-sensei'); ?> |
|
98 | 98 | |
99 | 99 | </h3> |
100 | 100 | |
101 | - <?php foreach ( $lessons as $lesson ): ?> |
|
101 | + <?php foreach ($lessons as $lesson): ?> |
|
102 | 102 | |
103 | 103 | <?php |
104 | 104 | $lesson_grade = 'n/a'; |
105 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
106 | - if ( $has_questions ) { |
|
107 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id()); |
|
105 | + $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true); |
|
106 | + if ($has_questions) { |
|
107 | + $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id()); |
|
108 | 108 | // Get user quiz grade |
109 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
110 | - if ( $lesson_grade ) { |
|
109 | + $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
110 | + if ($lesson_grade) { |
|
111 | 111 | $lesson_grade .= '%'; |
112 | 112 | } |
113 | 113 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | |
116 | 116 | <h2> |
117 | 117 | |
118 | - <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ) ?>" title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ) ?>" > |
|
118 | + <a href="<?php esc_url_raw(get_permalink($lesson->ID)) ?>" title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)) ?>" > |
|
119 | 119 | |
120 | - <?php esc_html_e( sprintf( __( '%s', 'woothemes-sensei' ), $lesson->post_title ) ); ?> |
|
120 | + <?php esc_html_e(sprintf(__('%s', 'woothemes-sensei'), $lesson->post_title)); ?> |
|
121 | 121 | |
122 | 122 | </a> |
123 | 123 | |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | |
133 | 133 | <h2 class="total-grade"> |
134 | 134 | |
135 | - <?php _e( 'Total Grade', 'woothemes-sensei' ); ?> |
|
135 | + <?php _e('Total Grade', 'woothemes-sensei'); ?> |
|
136 | 136 | <span class="lesson-grade"> |
137 | 137 | |
138 | 138 | <?php |
139 | 139 | |
140 | - $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() ); |
|
141 | - echo $course_user_grade . '%'; |
|
140 | + $course_user_grade = Sensei_Utils::sensei_course_user_grade($course->ID, get_current_user_id()); |
|
141 | + echo $course_user_grade.'%'; |
|
142 | 142 | |
143 | 143 | ?> |
144 | 144 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @since 1.4.0 |
157 | 157 | */ |
158 | - do_action( 'sensei_course_results_after_lessons', $course->ID ); |
|
158 | + do_action('sensei_course_results_after_lessons', $course->ID); |
|
159 | 159 | ?> |
160 | 160 | |
161 | 161 | <?php endif; //user logged in ?> |
162 | 162 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * The Template for displaying Multi Line Questions. |
5 | 5 | * |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | * Get the question data with the current quiz id |
19 | 19 | * All data is loaded in this array to keep the template clean. |
20 | 20 | */ |
21 | - $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() ); |
|
21 | + $question_data = WooThemes_Sensei_Question::get_template_data(sensei_get_the_question_id(), get_the_ID()); |
|
22 | 22 | |
23 | 23 | ?> |
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | - Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ] , |
|
28 | - 'textquestion' . $question_data[ 'ID' ] , |
|
29 | - 'sensei_question[' . $question_data[ 'ID' ] . ']' ); |
|
27 | + Sensei_Utils::sensei_text_editor($question_data['user_answer_entry'], |
|
28 | + 'textquestion'.$question_data['ID'], |
|
29 | + 'sensei_question['.$question_data['ID'].']'); |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | ?> |
13 | 13 | |
14 | -<?php get_sensei_header(); ?> |
|
14 | +<?php get_sensei_header(); ?> |
|
15 | 15 | |
16 | 16 | <?php |
17 | 17 | /** |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @hooked Sensei_Course_Results::deprecate_sensei_course_results_content_hook() - 20 |
23 | 23 | */ |
24 | -do_action( 'sensei_course_results_content_before' ); |
|
24 | +do_action('sensei_course_results_content_before'); |
|
25 | 25 | ?> |
26 | 26 | |
27 | 27 | <?php |
28 | 28 | global $course; |
29 | -$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' ); |
|
29 | +$course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course'); |
|
30 | 30 | ?> |
31 | 31 | |
32 | -<article <?php post_class( array( 'course', 'post','course-results' ) ); ?> > |
|
32 | +<article <?php post_class(array('course', 'post', 'course-results')); ?> > |
|
33 | 33 | |
34 | 34 | <section class="entry fix"> |
35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @hooked Sensei_Course_Results::fire_sensei_message_hook() - 20 |
43 | 43 | */ |
44 | - do_action( 'sensei_course_results_content_inside_before' ); |
|
44 | + do_action('sensei_course_results_content_inside_before'); |
|
45 | 45 | ?> |
46 | 46 | |
47 | 47 | <header> |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | |
53 | 53 | </header> |
54 | 54 | |
55 | - <?php if ( is_user_logged_in() ):?> |
|
55 | + <?php if (is_user_logged_in()):?> |
|
56 | 56 | |
57 | 57 | <section class="course-results-lessons"> |
58 | 58 | <?php |
59 | - $started_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
60 | - if( $started_course ) { |
|
59 | + $started_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id()); |
|
60 | + if ($started_course) { |
|
61 | 61 | |
62 | 62 | sensei_the_course_results_lessons(); |
63 | 63 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @hooked Sensei()->course_results->course_info - 20 |
77 | 77 | */ |
78 | - do_action( 'sensei_course_results_content_inside_after' ); |
|
78 | + do_action('sensei_course_results_content_inside_after'); |
|
79 | 79 | ?> |
80 | 80 | |
81 | 81 | </section> |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @since 1.9.0 |
90 | 90 | * |
91 | 91 | */ |
92 | -do_action( 'sensei_course_results_content_after' ); |
|
92 | +do_action('sensei_course_results_content_after'); |
|
93 | 93 | ?> |
94 | 94 | |
95 | 95 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Sensei Analysis Overview List Table Class |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | * @since 1.2.0 |
22 | 22 | * @return void |
23 | 23 | */ |
24 | - public function __construct ( $type = 'users' ) { |
|
25 | - $this->type = in_array( $type, array( 'courses', 'lessons', 'users' ) ) ? $type : 'users'; |
|
24 | + public function __construct($type = 'users') { |
|
25 | + $this->type = in_array($type, array('courses', 'lessons', 'users')) ? $type : 'users'; |
|
26 | 26 | |
27 | 27 | // Load Parent token into constructor |
28 | - parent::__construct( 'analysis_overview' ); |
|
28 | + parent::__construct('analysis_overview'); |
|
29 | 29 | |
30 | 30 | // Actions |
31 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
32 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
31 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
32 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
33 | 33 | |
34 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
34 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
35 | 35 | } // End __construct() |
36 | 36 | |
37 | 37 | /** |
@@ -41,41 +41,41 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function get_columns() { |
43 | 43 | |
44 | - switch( $this->type ) { |
|
44 | + switch ($this->type) { |
|
45 | 45 | case 'courses': |
46 | 46 | $columns = array( |
47 | - 'title' => __( 'Course', 'woothemes-sensei' ), |
|
48 | - 'students' => __( 'Learners', 'woothemes-sensei' ), |
|
49 | - 'lessons' => __( 'Lessons', 'woothemes-sensei' ), |
|
50 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
51 | - 'average_percent' => __( 'Average Percentage', 'woothemes-sensei' ), |
|
47 | + 'title' => __('Course', 'woothemes-sensei'), |
|
48 | + 'students' => __('Learners', 'woothemes-sensei'), |
|
49 | + 'lessons' => __('Lessons', 'woothemes-sensei'), |
|
50 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
51 | + 'average_percent' => __('Average Percentage', 'woothemes-sensei'), |
|
52 | 52 | ); |
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'lessons': |
56 | 56 | $columns = array( |
57 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
58 | - 'course' => __( 'Course', 'woothemes-sensei' ), |
|
59 | - 'students' => __( 'Learners', 'woothemes-sensei' ), |
|
60 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
61 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
57 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
58 | + 'course' => __('Course', 'woothemes-sensei'), |
|
59 | + 'students' => __('Learners', 'woothemes-sensei'), |
|
60 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
61 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
62 | 62 | ); |
63 | 63 | break; |
64 | 64 | |
65 | 65 | case 'users': |
66 | 66 | default: |
67 | 67 | $columns = array( |
68 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
69 | - 'registered' => __( 'Date Registered', 'woothemes-sensei' ), |
|
70 | - 'active_courses' => __( 'Active Courses', 'woothemes-sensei' ), |
|
71 | - 'completed_courses' => __( 'Completed Courses', 'woothemes-sensei' ), |
|
72 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
68 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
69 | + 'registered' => __('Date Registered', 'woothemes-sensei'), |
|
70 | + 'active_courses' => __('Active Courses', 'woothemes-sensei'), |
|
71 | + 'completed_courses' => __('Completed Courses', 'woothemes-sensei'), |
|
72 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
73 | 73 | ); |
74 | 74 | break; |
75 | 75 | } |
76 | 76 | // Backwards compatible filter name, moving forward should have single filter name |
77 | - $columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns', $columns, $this ); |
|
78 | - $columns = apply_filters( 'sensei_analysis_overview_columns', $columns, $this ); |
|
77 | + $columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns', $columns, $this); |
|
78 | + $columns = apply_filters('sensei_analysis_overview_columns', $columns, $this); |
|
79 | 79 | return $columns; |
80 | 80 | } |
81 | 81 | |
@@ -86,41 +86,41 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function get_sortable_columns() { |
88 | 88 | |
89 | - switch( $this->type ) { |
|
89 | + switch ($this->type) { |
|
90 | 90 | case 'courses': |
91 | 91 | $columns = array( |
92 | - 'title' => array( 'title', false ), |
|
93 | - 'students' => array( 'students', false ), |
|
94 | - 'lessons' => array( 'lessons', false ), |
|
95 | - 'completions' => array( 'completions', false ), |
|
96 | - 'average_percent' => array( 'average_percent', false ), |
|
92 | + 'title' => array('title', false), |
|
93 | + 'students' => array('students', false), |
|
94 | + 'lessons' => array('lessons', false), |
|
95 | + 'completions' => array('completions', false), |
|
96 | + 'average_percent' => array('average_percent', false), |
|
97 | 97 | ); |
98 | 98 | break; |
99 | 99 | |
100 | 100 | case 'lessons': |
101 | 101 | $columns = array( |
102 | - 'title' => array( 'title', false ), |
|
103 | - 'course' => array( 'course', false ), |
|
104 | - 'students' => array( 'students', false ), |
|
105 | - 'completions' => array( 'completions', false ), |
|
106 | - 'average_grade' => array( 'average_grade', false ), |
|
102 | + 'title' => array('title', false), |
|
103 | + 'course' => array('course', false), |
|
104 | + 'students' => array('students', false), |
|
105 | + 'completions' => array('completions', false), |
|
106 | + 'average_grade' => array('average_grade', false), |
|
107 | 107 | ); |
108 | 108 | break; |
109 | 109 | |
110 | 110 | case 'users': |
111 | 111 | default: |
112 | 112 | $columns = array( |
113 | - 'title' => array( 'user_login', false ), |
|
114 | - 'registered' => array( 'registered', false ), |
|
115 | - 'active_courses' => array( 'active_courses', false ), |
|
116 | - 'completed_courses' => array( 'completed_courses', false ), |
|
117 | - 'average_grade' => array( 'average_grade', false ) |
|
113 | + 'title' => array('user_login', false), |
|
114 | + 'registered' => array('registered', false), |
|
115 | + 'active_courses' => array('active_courses', false), |
|
116 | + 'completed_courses' => array('completed_courses', false), |
|
117 | + 'average_grade' => array('average_grade', false) |
|
118 | 118 | ); |
119 | 119 | break; |
120 | 120 | } |
121 | 121 | // Backwards compatible filter name, moving forward should have single filter name |
122 | - $columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns_sortable', $columns, $this ); |
|
123 | - $columns = apply_filters( 'sensei_analysis_overview_columns_sortable', $columns, $this ); |
|
122 | + $columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns_sortable', $columns, $this); |
|
123 | + $columns = apply_filters('sensei_analysis_overview_columns_sortable', $columns, $this); |
|
124 | 124 | return $columns; |
125 | 125 | } |
126 | 126 | |
@@ -134,25 +134,25 @@ discard block |
||
134 | 134 | |
135 | 135 | // Handle orderby |
136 | 136 | $orderby = ''; |
137 | - if ( !empty( $_GET['orderby'] ) ) { |
|
138 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
139 | - $orderby = esc_html( $_GET['orderby'] ); |
|
137 | + if ( ! empty($_GET['orderby'])) { |
|
138 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
139 | + $orderby = esc_html($_GET['orderby']); |
|
140 | 140 | } // End If Statement |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Handle order |
144 | 144 | $order = 'ASC'; |
145 | - if ( !empty( $_GET['order'] ) ) { |
|
146 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
145 | + if ( ! empty($_GET['order'])) { |
|
146 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
147 | 147 | } |
148 | 148 | |
149 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
150 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
149 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
150 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
151 | 151 | |
152 | 152 | $paged = $this->get_pagenum(); |
153 | 153 | $offset = 0; |
154 | - if ( !empty($paged) ) { |
|
155 | - $offset = $per_page * ( $paged - 1 ); |
|
154 | + if ( ! empty($paged)) { |
|
155 | + $offset = $per_page * ($paged - 1); |
|
156 | 156 | } // End If Statement |
157 | 157 | |
158 | 158 | $args = array( |
@@ -163,32 +163,32 @@ discard block |
||
163 | 163 | ); |
164 | 164 | |
165 | 165 | // Handle search |
166 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
167 | - $args['search'] = esc_html( $_GET['s'] ); |
|
166 | + if (isset($_GET['s']) && ! empty($_GET['s'])) { |
|
167 | + $args['search'] = esc_html($_GET['s']); |
|
168 | 168 | } |
169 | 169 | |
170 | - switch ( $this->type ) { |
|
170 | + switch ($this->type) { |
|
171 | 171 | case 'courses': |
172 | - $this->items = $this->get_courses( $args ); |
|
172 | + $this->items = $this->get_courses($args); |
|
173 | 173 | break; |
174 | 174 | |
175 | 175 | case 'lessons': |
176 | - $this->items = $this->get_lessons( $args ); |
|
176 | + $this->items = $this->get_lessons($args); |
|
177 | 177 | break; |
178 | 178 | |
179 | 179 | case 'users': |
180 | 180 | default : |
181 | - $this->items = $this->get_learners( $args ); |
|
181 | + $this->items = $this->get_learners($args); |
|
182 | 182 | break; |
183 | 183 | } |
184 | 184 | |
185 | 185 | $total_items = $this->total_items; |
186 | - $total_pages = ceil( $total_items / $per_page ); |
|
187 | - $this->set_pagination_args( array( |
|
186 | + $total_pages = ceil($total_items / $per_page); |
|
187 | + $this->set_pagination_args(array( |
|
188 | 188 | 'total_items' => $total_items, |
189 | 189 | 'total_pages' => $total_pages, |
190 | 190 | 'per_page' => $per_page |
191 | - ) ); |
|
191 | + )); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @since 1.7.0 |
197 | 197 | * @return data |
198 | 198 | */ |
199 | - public function generate_report( $report ) { |
|
199 | + public function generate_report($report) { |
|
200 | 200 | |
201 | 201 | $data = array(); |
202 | 202 | |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | |
205 | 205 | // Handle orderby |
206 | 206 | $orderby = ''; |
207 | - if ( !empty( $_GET['orderby'] ) ) { |
|
208 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
209 | - $orderby = esc_html( $_GET['orderby'] ); |
|
207 | + if ( ! empty($_GET['orderby'])) { |
|
208 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
209 | + $orderby = esc_html($_GET['orderby']); |
|
210 | 210 | } // End If Statement |
211 | 211 | } |
212 | 212 | |
213 | 213 | // Handle order |
214 | 214 | $order = 'ASC'; |
215 | - if ( !empty( $_GET['order'] ) ) { |
|
216 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
215 | + if ( ! empty($_GET['order'])) { |
|
216 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | $args = array( |
@@ -223,37 +223,37 @@ discard block |
||
223 | 223 | |
224 | 224 | |
225 | 225 | // Handle search |
226 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
227 | - $args['search'] = esc_html( $_GET['s'] ); |
|
226 | + if (isset($_GET['s']) && ! empty($_GET['s'])) { |
|
227 | + $args['search'] = esc_html($_GET['s']); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
231 | 231 | // Start the csv with the column headings |
232 | 232 | $column_headers = array(); |
233 | 233 | $columns = $this->get_columns(); |
234 | - foreach( $columns AS $key => $title ) { |
|
234 | + foreach ($columns AS $key => $title) { |
|
235 | 235 | $column_headers[] = $title; |
236 | 236 | } |
237 | 237 | $data[] = $column_headers; |
238 | 238 | |
239 | - switch ( $this->type ) { |
|
239 | + switch ($this->type) { |
|
240 | 240 | case 'courses': |
241 | - $this->items = $this->get_courses( $args ); |
|
241 | + $this->items = $this->get_courses($args); |
|
242 | 242 | break; |
243 | 243 | |
244 | 244 | case 'lessons': |
245 | - $this->items = $this->get_lessons( $args ); |
|
245 | + $this->items = $this->get_lessons($args); |
|
246 | 246 | break; |
247 | 247 | |
248 | 248 | case 'users': |
249 | 249 | default : |
250 | - $this->items = $this->get_learners( $args ); |
|
250 | + $this->items = $this->get_learners($args); |
|
251 | 251 | break; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Process each row |
255 | - foreach( $this->items AS $item) { |
|
256 | - $data[] = $this->get_row_data( $item ); |
|
255 | + foreach ($this->items AS $item) { |
|
256 | + $data[] = $this->get_row_data($item); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | return $data; |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * @param object $item The current item |
266 | 266 | * @return array $column_data; |
267 | 267 | */ |
268 | - protected function get_row_data( $item ) { |
|
268 | + protected function get_row_data($item) { |
|
269 | 269 | |
270 | - switch( $this->type ) { |
|
270 | + switch ($this->type) { |
|
271 | 271 | case 'courses' : |
272 | 272 | // Get Learners (i.e. those who have started) |
273 | 273 | $course_args = array( |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | 'type' => 'sensei_course_status', |
276 | 276 | 'status' => 'any', |
277 | 277 | ); |
278 | - $course_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_learners', $course_args, $item ) ); |
|
278 | + $course_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_learners', $course_args, $item)); |
|
279 | 279 | |
280 | 280 | // Get Course Completions |
281 | 281 | $course_args = array( |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | 'type' => 'sensei_course_status', |
284 | 284 | 'status' => 'complete', |
285 | 285 | ); |
286 | - $course_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_completions', $course_args, $item ) ); |
|
286 | + $course_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_completions', $course_args, $item)); |
|
287 | 287 | |
288 | 288 | // Course Lessons |
289 | - $course_lessons = Sensei()->lesson->lesson_count( array('publish', 'private'), $item->ID ); |
|
289 | + $course_lessons = Sensei()->lesson->lesson_count(array('publish', 'private'), $item->ID); |
|
290 | 290 | |
291 | 291 | // Get Percent Complete |
292 | 292 | $grade_args = array( |
@@ -295,30 +295,30 @@ discard block |
||
295 | 295 | 'status' => 'any', |
296 | 296 | 'meta_key' => 'percent', |
297 | 297 | ); |
298 | - add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
299 | - $course_percentage = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_percentage', $grade_args, $item ), true ); |
|
300 | - remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
298 | + add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
299 | + $course_percentage = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_percentage', $grade_args, $item), true); |
|
300 | + remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
301 | 301 | |
302 | - $percent_count = !empty( $course_percentage->total ) ? $course_percentage->total : 1; |
|
303 | - $percent_total = !empty( $course_percentage->meta_sum ) ? doubleval( $course_percentage->meta_sum ) : 0; |
|
304 | - $course_average_percent = abs( round( doubleval( $percent_total / $percent_count ), 2 ) ); |
|
302 | + $percent_count = ! empty($course_percentage->total) ? $course_percentage->total : 1; |
|
303 | + $percent_total = ! empty($course_percentage->meta_sum) ? doubleval($course_percentage->meta_sum) : 0; |
|
304 | + $course_average_percent = abs(round(doubleval($percent_total / $percent_count), 2)); |
|
305 | 305 | |
306 | 306 | // Output course data |
307 | - if ( $this->csv_output ) { |
|
308 | - $course_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
307 | + if ($this->csv_output) { |
|
308 | + $course_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
309 | 309 | } |
310 | 310 | else { |
311 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
311 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID), admin_url('admin.php')); |
|
312 | 312 | |
313 | - $course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
313 | + $course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
314 | 314 | $course_average_percent .= '%'; |
315 | 315 | } // End If Statement |
316 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $course_title, |
|
316 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $course_title, |
|
317 | 317 | 'students' => $course_students, |
318 | 318 | 'lessons' => $course_lessons, |
319 | 319 | 'completions' => $course_completions, |
320 | 320 | 'average_percent' => $course_average_percent, |
321 | - ), $item, $this ); |
|
321 | + ), $item, $this); |
|
322 | 322 | break; |
323 | 323 | |
324 | 324 | case 'lessons' : |
@@ -328,63 +328,63 @@ discard block |
||
328 | 328 | 'type' => 'sensei_lesson_status', |
329 | 329 | 'status' => 'any', |
330 | 330 | ); |
331 | - $lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) ); |
|
331 | + $lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item)); |
|
332 | 332 | |
333 | 333 | // Get Course Completions |
334 | 334 | $lesson_args = array( |
335 | 335 | 'post_id' => $item->ID, |
336 | 336 | 'type' => 'sensei_lesson_status', |
337 | - 'status' => array( 'complete', 'graded', 'passed', 'failed' ), |
|
337 | + 'status' => array('complete', 'graded', 'passed', 'failed'), |
|
338 | 338 | 'count' => true, |
339 | 339 | ); |
340 | - $lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) ); |
|
340 | + $lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item)); |
|
341 | 341 | |
342 | 342 | // Course |
343 | - $course_id = get_post_meta( $item->ID, '_lesson_course', true ); |
|
344 | - $course_title = $course_id ? get_the_title( $course_id ) : ''; |
|
343 | + $course_id = get_post_meta($item->ID, '_lesson_course', true); |
|
344 | + $course_title = $course_id ? get_the_title($course_id) : ''; |
|
345 | 345 | |
346 | 346 | $lesson_average_grade = __('n/a', 'woothemes-sensei'); |
347 | - if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) { |
|
347 | + if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
348 | 348 | // Get Percent Complete |
349 | 349 | $grade_args = array( |
350 | 350 | 'post_id' => $item->ID, |
351 | 351 | 'type' => 'sensei_lesson_status', |
352 | - 'status' => array( 'graded', 'passed', 'failed' ), |
|
352 | + 'status' => array('graded', 'passed', 'failed'), |
|
353 | 353 | 'meta_key' => 'grade', |
354 | 354 | ); |
355 | - add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
356 | - $lesson_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true ); |
|
357 | - remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
355 | + add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
356 | + $lesson_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true); |
|
357 | + remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
358 | 358 | |
359 | - $grade_count = !empty( $lesson_grades->total ) ? $lesson_grades->total : 1; |
|
360 | - $grade_total = !empty( $lesson_grades->meta_sum ) ? doubleval( $lesson_grades->meta_sum ) : 0; |
|
361 | - $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
359 | + $grade_count = ! empty($lesson_grades->total) ? $lesson_grades->total : 1; |
|
360 | + $grade_total = ! empty($lesson_grades->meta_sum) ? doubleval($lesson_grades->meta_sum) : 0; |
|
361 | + $lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
362 | 362 | } |
363 | 363 | // Output lesson data |
364 | - if ( $this->csv_output ) { |
|
365 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
364 | + if ($this->csv_output) { |
|
365 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
366 | 366 | } |
367 | 367 | else { |
368 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
369 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
368 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
369 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
370 | 370 | |
371 | - if ( $course_id ) { |
|
372 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
373 | - $course_title = '<a href="' . esc_url( $url ) . '">' . $course_title . '</a>'; |
|
371 | + if ($course_id) { |
|
372 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
373 | + $course_title = '<a href="'.esc_url($url).'">'.$course_title.'</a>'; |
|
374 | 374 | } |
375 | 375 | else { |
376 | 376 | $course_title = __('n/a', 'woothemes-sensei'); |
377 | 377 | } |
378 | - if ( is_numeric( $lesson_average_grade ) ) { |
|
378 | + if (is_numeric($lesson_average_grade)) { |
|
379 | 379 | $lesson_average_grade .= '%'; |
380 | 380 | } |
381 | 381 | } // End If Statement |
382 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $lesson_title, |
|
382 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $lesson_title, |
|
383 | 383 | 'course' => $course_title, |
384 | 384 | 'students' => $lesson_students, |
385 | 385 | 'completions' => $lesson_completions, |
386 | 386 | 'average_grade' => $lesson_average_grade, |
387 | - ), $item, $this ); |
|
387 | + ), $item, $this); |
|
388 | 388 | break; |
389 | 389 | |
390 | 390 | case 'users' : |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | 'type' => 'sensei_course_status', |
396 | 396 | 'status' => 'any', |
397 | 397 | ); |
398 | - $user_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_started', $course_args, $item ) ); |
|
398 | + $user_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_started', $course_args, $item)); |
|
399 | 399 | |
400 | 400 | // Get Completed Courses |
401 | 401 | $course_args = array( |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | 'type' => 'sensei_course_status', |
404 | 404 | 'status' => 'complete', |
405 | 405 | ); |
406 | - $user_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_ended', $course_args, $item ) ); |
|
406 | + $user_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_ended', $course_args, $item)); |
|
407 | 407 | |
408 | 408 | // Get Quiz Grades |
409 | 409 | $grade_args = array( |
@@ -412,29 +412,29 @@ discard block |
||
412 | 412 | 'status' => 'any', |
413 | 413 | 'meta_key' => 'grade', |
414 | 414 | ); |
415 | - add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
416 | - $user_quiz_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_lesson_grades', $grade_args, $item ), true ); |
|
417 | - remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
415 | + add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
416 | + $user_quiz_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_lesson_grades', $grade_args, $item), true); |
|
417 | + remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
418 | 418 | |
419 | - $grade_count = !empty( $user_quiz_grades->total ) ? $user_quiz_grades->total : 1; |
|
420 | - $grade_total = !empty( $user_quiz_grades->meta_sum ) ? doubleval( $user_quiz_grades->meta_sum ) : 0; |
|
421 | - $user_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
419 | + $grade_count = ! empty($user_quiz_grades->total) ? $user_quiz_grades->total : 1; |
|
420 | + $grade_total = ! empty($user_quiz_grades->meta_sum) ? doubleval($user_quiz_grades->meta_sum) : 0; |
|
421 | + $user_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
422 | 422 | |
423 | 423 | // Output the users data |
424 | - if ( $this->csv_output ) { |
|
425 | - $user_name = Sensei()->learners->get_learner_full_name( $item->ID ); |
|
424 | + if ($this->csv_output) { |
|
425 | + $user_name = Sensei()->learners->get_learner_full_name($item->ID); |
|
426 | 426 | } |
427 | 427 | else { |
428 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
429 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $item->display_name . '</a></strong>'; |
|
428 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->ID), admin_url('admin.php')); |
|
429 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$item->display_name.'</a></strong>'; |
|
430 | 430 | $user_average_grade .= '%'; |
431 | 431 | } // End If Statement |
432 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $user_name, |
|
432 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $user_name, |
|
433 | 433 | 'registered' => $item->user_registered, |
434 | - 'active_courses' => ( $user_courses_started - $user_courses_ended ), |
|
434 | + 'active_courses' => ($user_courses_started - $user_courses_ended), |
|
435 | 435 | 'completed_courses' => $user_courses_ended, |
436 | 436 | 'average_grade' => $user_average_grade, |
437 | - ), $item, $this ); |
|
437 | + ), $item, $this); |
|
438 | 438 | break; |
439 | 439 | } // end switch |
440 | 440 | return $column_data; |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @since 1.7.0 |
446 | 446 | * @return array courses |
447 | 447 | */ |
448 | - private function get_courses( $args ) { |
|
448 | + private function get_courses($args) { |
|
449 | 449 | $course_args = array( |
450 | 450 | 'post_type' => 'course', |
451 | 451 | 'post_status' => array('publish', 'private'), |
@@ -456,16 +456,16 @@ discard block |
||
456 | 456 | 'suppress_filters' => 0, |
457 | 457 | ); |
458 | 458 | |
459 | - if ( $this->csv_output ) { |
|
459 | + if ($this->csv_output) { |
|
460 | 460 | $course_args['posts_per_page'] = '-1'; |
461 | 461 | } |
462 | 462 | |
463 | - if( isset( $args['search'] ) ) { |
|
463 | + if (isset($args['search'])) { |
|
464 | 464 | $course_args['s'] = $args['search']; |
465 | 465 | } |
466 | 466 | |
467 | 467 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
468 | - $courses_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_courses', $course_args ) ); |
|
468 | + $courses_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_courses', $course_args)); |
|
469 | 469 | $this->total_items = $courses_query->found_posts; |
470 | 470 | return $courses_query->posts; |
471 | 471 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @since 1.7.0 |
477 | 477 | * @return array lessons |
478 | 478 | */ |
479 | - private function get_lessons( $args ) { |
|
479 | + private function get_lessons($args) { |
|
480 | 480 | $lessons_args = array( |
481 | 481 | 'post_type' => 'lesson', |
482 | 482 | 'post_status' => array('publish', 'private'), |
@@ -487,16 +487,16 @@ discard block |
||
487 | 487 | 'suppress_filters' => 0, |
488 | 488 | ); |
489 | 489 | |
490 | - if ( $this->csv_output ) { |
|
490 | + if ($this->csv_output) { |
|
491 | 491 | $lessons_args['posts_per_page'] = '-1'; |
492 | 492 | } |
493 | 493 | |
494 | - if( isset( $args['search'] ) ) { |
|
494 | + if (isset($args['search'])) { |
|
495 | 495 | $lessons_args['s'] = $args['search']; |
496 | 496 | } |
497 | 497 | |
498 | 498 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
499 | - $lessons_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_lessons', $lessons_args ) ); |
|
499 | + $lessons_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_lessons', $lessons_args)); |
|
500 | 500 | $this->total_items = $lessons_query->found_posts; |
501 | 501 | return $lessons_query->posts; |
502 | 502 | } // End get_lessons() |
@@ -506,24 +506,24 @@ discard block |
||
506 | 506 | * @since 1.7.0 |
507 | 507 | * @return array learners |
508 | 508 | */ |
509 | - private function get_learners( $args ) { |
|
509 | + private function get_learners($args) { |
|
510 | 510 | |
511 | - if ( !empty($args['search']) ) { |
|
511 | + if ( ! empty($args['search'])) { |
|
512 | 512 | $args = array( |
513 | - 'search' => '*' . trim( $args['search'], '*' ) . '*', |
|
513 | + 'search' => '*'.trim($args['search'], '*').'*', |
|
514 | 514 | ); |
515 | 515 | } |
516 | 516 | |
517 | 517 | // This stops the full meta data of each user being loaded |
518 | - $args['fields'] = array( 'ID', 'user_login', 'user_email', 'user_registered', 'display_name' ); |
|
518 | + $args['fields'] = array('ID', 'user_login', 'user_email', 'user_registered', 'display_name'); |
|
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Filter the WP_User_Query arguments |
522 | 522 | * @since 1.6.0 |
523 | 523 | * @param $args |
524 | 524 | */ |
525 | - $args = apply_filters( 'sensei_analysis_overview_filter_users', $args ); |
|
526 | - $wp_user_search = new WP_User_Query( $args ); |
|
525 | + $args = apply_filters('sensei_analysis_overview_filter_users', $args); |
|
526 | + $wp_user_search = new WP_User_Query($args); |
|
527 | 527 | $learners = $wp_user_search->get_results(); |
528 | 528 | $this->total_items = $wp_user_search->get_total(); |
529 | 529 | |
@@ -536,13 +536,13 @@ discard block |
||
536 | 536 | * @since 1.2.0 |
537 | 537 | * @return array $stats_to_render of stats boxes and values |
538 | 538 | */ |
539 | - public function stats_boxes () { |
|
539 | + public function stats_boxes() { |
|
540 | 540 | |
541 | 541 | // Get the data required |
542 | 542 | $user_count = count_users(); |
543 | - $user_count = apply_filters( 'sensei_analysis_total_users', $user_count['total_users'], $user_count ); |
|
544 | - $total_courses = Sensei()->course->course_count( array('publish', 'private') ); |
|
545 | - $total_lessons = Sensei()->lesson->lesson_count( array('publish', 'private') ); |
|
543 | + $user_count = apply_filters('sensei_analysis_total_users', $user_count['total_users'], $user_count); |
|
544 | + $total_courses = Sensei()->course->course_count(array('publish', 'private')); |
|
545 | + $total_lessons = Sensei()->lesson->lesson_count(array('publish', 'private')); |
|
546 | 546 | |
547 | 547 | $grade_args = array( |
548 | 548 | 'type' => 'sensei_lesson_status', |
@@ -550,36 +550,36 @@ discard block |
||
550 | 550 | 'meta_key' => 'grade', |
551 | 551 | ); |
552 | 552 | |
553 | - add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
554 | - $total_quiz_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_quiz_grades', $grade_args ), true ); |
|
555 | - remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
553 | + add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
554 | + $total_quiz_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_quiz_grades', $grade_args), true); |
|
555 | + remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
556 | 556 | |
557 | - $total_grade_count = !empty( $total_quiz_grades->total ) ? $total_quiz_grades->total : 1; |
|
558 | - $total_grade_total = !empty( $total_quiz_grades->meta_sum ) ? doubleval( $total_quiz_grades->meta_sum ) : 0; |
|
559 | - $total_average_grade = abs( round( doubleval( $total_grade_total / $total_grade_count ), 2 ) ); |
|
557 | + $total_grade_count = ! empty($total_quiz_grades->total) ? $total_quiz_grades->total : 1; |
|
558 | + $total_grade_total = ! empty($total_quiz_grades->meta_sum) ? doubleval($total_quiz_grades->meta_sum) : 0; |
|
559 | + $total_average_grade = abs(round(doubleval($total_grade_total / $total_grade_count), 2)); |
|
560 | 560 | |
561 | 561 | $course_args = array( |
562 | 562 | 'type' => 'sensei_course_status', |
563 | 563 | 'status' => 'any', |
564 | 564 | ); |
565 | - $total_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_started', $course_args ) ); |
|
565 | + $total_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_started', $course_args)); |
|
566 | 566 | $course_args = array( |
567 | 567 | 'type' => 'sensei_course_status', |
568 | 568 | 'status' => 'complete', |
569 | 569 | ); |
570 | - $total_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_ended', $course_args ) ); |
|
571 | - $average_courses_per_learner = abs( round( doubleval( $total_courses_started / $user_count ), 2 ) ); |
|
570 | + $total_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_ended', $course_args)); |
|
571 | + $average_courses_per_learner = abs(round(doubleval($total_courses_started / $user_count), 2)); |
|
572 | 572 | |
573 | 573 | // Setup the boxes to render |
574 | 574 | $stats_to_render = array( |
575 | - __( 'Total Courses', 'woothemes-sensei' ) => $total_courses, |
|
576 | - __( 'Total Lessons', 'woothemes-sensei' ) => $total_lessons, |
|
577 | - __( 'Total Learners', 'woothemes-sensei' ) => $user_count, |
|
578 | - __( 'Average Courses per Learner', 'woothemes-sensei' ) => $average_courses_per_learner, |
|
579 | - __( 'Average Grade', 'woothemes-sensei' ) => $total_average_grade . '%', |
|
580 | - __( 'Total Completed Courses', 'woothemes-sensei' ) => $total_courses_ended, |
|
575 | + __('Total Courses', 'woothemes-sensei') => $total_courses, |
|
576 | + __('Total Lessons', 'woothemes-sensei') => $total_lessons, |
|
577 | + __('Total Learners', 'woothemes-sensei') => $user_count, |
|
578 | + __('Average Courses per Learner', 'woothemes-sensei') => $average_courses_per_learner, |
|
579 | + __('Average Grade', 'woothemes-sensei') => $total_average_grade.'%', |
|
580 | + __('Total Completed Courses', 'woothemes-sensei') => $total_courses_ended, |
|
581 | 581 | ); |
582 | - return apply_filters( 'sensei_analysis_stats_boxes', $stats_to_render ); |
|
582 | + return apply_filters('sensei_analysis_stats_boxes', $stats_to_render); |
|
583 | 583 | } // End stats_boxes() |
584 | 584 | |
585 | 585 | /** |
@@ -589,12 +589,12 @@ discard block |
||
589 | 589 | * @return void |
590 | 590 | */ |
591 | 591 | public function no_items() { |
592 | - if( ! $this->view || 'users' == $this->view ) { |
|
592 | + if ( ! $this->view || 'users' == $this->view) { |
|
593 | 593 | $type = 'learners'; |
594 | 594 | } else { |
595 | 595 | $type = $this->view; |
596 | 596 | } |
597 | - echo sprintf( __( '%1$sNo %2$s found%3$s', 'woothemes-sensei' ), '<em>', $type, '</em>' ); |
|
597 | + echo sprintf(__('%1$sNo %2$s found%3$s', 'woothemes-sensei'), '<em>', $type, '</em>'); |
|
598 | 598 | } // End no_items() |
599 | 599 | |
600 | 600 | /** |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | 'page' => $this->page_slug, |
610 | 610 | ); |
611 | 611 | $learners_class = $courses_class = $lessons_class = ''; |
612 | - switch( $this->type ) { |
|
612 | + switch ($this->type) { |
|
613 | 613 | case 'courses': |
614 | 614 | $courses_class = 'current'; |
615 | 615 | break; |
@@ -627,18 +627,18 @@ discard block |
||
627 | 627 | $lesson_args['view'] = 'lessons'; |
628 | 628 | $courses_args['view'] = 'courses'; |
629 | 629 | |
630 | - $menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ). '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>'; |
|
631 | - $menu['courses'] = '<a class="' . $courses_class . '" href="' . esc_url ( add_query_arg( $courses_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Courses', 'woothemes-sensei' ) . '</a>'; |
|
632 | - $menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>'; |
|
630 | + $menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>'; |
|
631 | + $menu['courses'] = '<a class="'.$courses_class.'" href="'.esc_url(add_query_arg($courses_args, admin_url('admin.php'))).'">'.__('Courses', 'woothemes-sensei').'</a>'; |
|
632 | + $menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>'; |
|
633 | 633 | |
634 | - $menu = apply_filters( 'sensei_analysis_overview_sub_menu', $menu ); |
|
635 | - if ( !empty($menu) ) { |
|
636 | - echo '<ul class="subsubsub">' . "\n"; |
|
637 | - foreach ( $menu as $class => $item ) { |
|
638 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
634 | + $menu = apply_filters('sensei_analysis_overview_sub_menu', $menu); |
|
635 | + if ( ! empty($menu)) { |
|
636 | + echo '<ul class="subsubsub">'."\n"; |
|
637 | + foreach ($menu as $class => $item) { |
|
638 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
639 | 639 | } |
640 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
641 | - echo '</ul>' . "\n"; |
|
640 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
641 | + echo '</ul>'."\n"; |
|
642 | 642 | } |
643 | 643 | } // End data_table_header() |
644 | 644 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * @return void |
649 | 649 | */ |
650 | 650 | public function data_table_footer() { |
651 | - switch ( $this->type ) { |
|
651 | + switch ($this->type) { |
|
652 | 652 | case 'courses': |
653 | 653 | $report = 'courses-overview'; |
654 | 654 | break; |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | $report = 'user-overview'; |
663 | 663 | break; |
664 | 664 | } // End Switch Statement |
665 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
666 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
665 | + $url = add_query_arg(array('page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
666 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
667 | 667 | } // End data_table_footer() |
668 | 668 | |
669 | 669 | /** |
@@ -671,19 +671,19 @@ discard block |
||
671 | 671 | * @since 1.7.0 |
672 | 672 | * @return void |
673 | 673 | */ |
674 | - public function search_button( $text = '' ) { |
|
675 | - switch( $this->type ) { |
|
674 | + public function search_button($text = '') { |
|
675 | + switch ($this->type) { |
|
676 | 676 | case 'courses': |
677 | - $text = __( 'Search Courses', 'woothemes-sensei' ); |
|
677 | + $text = __('Search Courses', 'woothemes-sensei'); |
|
678 | 678 | break; |
679 | 679 | |
680 | 680 | case 'lessons': |
681 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
681 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
682 | 682 | break; |
683 | 683 | |
684 | 684 | case 'users': |
685 | 685 | default: |
686 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
686 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
687 | 687 | break; |
688 | 688 | } // End Switch Statement |
689 | 689 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Sensei Frontend Class |
@@ -22,78 +22,78 @@ discard block |
||
22 | 22 | * Constructor. |
23 | 23 | * @since 1.0.0 |
24 | 24 | */ |
25 | - public function __construct () { |
|
25 | + public function __construct() { |
|
26 | 26 | |
27 | 27 | // Template output actions |
28 | - add_action( 'sensei_before_main_content', array( $this, 'sensei_output_content_wrapper' ), 10 ); |
|
29 | - add_action( 'sensei_after_main_content', array( $this, 'sensei_output_content_wrapper_end' ), 10 ); |
|
30 | - add_action( 'sensei_lesson_archive_lesson_title', array( $this, 'sensei_lesson_archive_lesson_title' ), 10 ); |
|
28 | + add_action('sensei_before_main_content', array($this, 'sensei_output_content_wrapper'), 10); |
|
29 | + add_action('sensei_after_main_content', array($this, 'sensei_output_content_wrapper_end'), 10); |
|
30 | + add_action('sensei_lesson_archive_lesson_title', array($this, 'sensei_lesson_archive_lesson_title'), 10); |
|
31 | 31 | |
32 | 32 | // 1.2.1 |
33 | - add_action( 'sensei_complete_lesson', array( $this, 'sensei_complete_lesson' ) ); |
|
34 | - add_action( 'init', array( $this, 'sensei_complete_course' ), 5 ); |
|
35 | - add_action( 'sensei_frontend_messages', array( $this, 'sensei_frontend_messages' ) ); |
|
36 | - add_action( 'sensei_lesson_video', array( $this, 'sensei_lesson_video' ), 10, 1 ); |
|
37 | - add_action( 'sensei_complete_lesson_button', array( $this, 'sensei_complete_lesson_button' ) ); |
|
38 | - add_action( 'sensei_reset_lesson_button', array( $this, 'sensei_reset_lesson_button' ) ); |
|
33 | + add_action('sensei_complete_lesson', array($this, 'sensei_complete_lesson')); |
|
34 | + add_action('init', array($this, 'sensei_complete_course'), 5); |
|
35 | + add_action('sensei_frontend_messages', array($this, 'sensei_frontend_messages')); |
|
36 | + add_action('sensei_lesson_video', array($this, 'sensei_lesson_video'), 10, 1); |
|
37 | + add_action('sensei_complete_lesson_button', array($this, 'sensei_complete_lesson_button')); |
|
38 | + add_action('sensei_reset_lesson_button', array($this, 'sensei_reset_lesson_button')); |
|
39 | 39 | |
40 | - add_action( 'sensei_course_archive_meta', array( $this, 'sensei_course_archive_meta' ) ); |
|
40 | + add_action('sensei_course_archive_meta', array($this, 'sensei_course_archive_meta')); |
|
41 | 41 | |
42 | - add_action( 'sensei_lesson_tag_main_content', array( $this, 'sensei_lesson_archive_main_content' ), 10 ); |
|
43 | - add_action( 'sensei_no_permissions_main_content', array( $this, 'sensei_no_permissions_main_content' ), 10 ); |
|
42 | + add_action('sensei_lesson_tag_main_content', array($this, 'sensei_lesson_archive_main_content'), 10); |
|
43 | + add_action('sensei_no_permissions_main_content', array($this, 'sensei_no_permissions_main_content'), 10); |
|
44 | 44 | |
45 | - add_action( 'sensei_lesson_meta', array( $this, 'sensei_lesson_meta' ), 10 ); |
|
46 | - add_action( 'sensei_single_course_content_inside_before', array( $this, 'sensei_course_start' ), 10 ); |
|
45 | + add_action('sensei_lesson_meta', array($this, 'sensei_lesson_meta'), 10); |
|
46 | + add_action('sensei_single_course_content_inside_before', array($this, 'sensei_course_start'), 10); |
|
47 | 47 | |
48 | 48 | // add_filter( 'get_comments_number', array( $this, 'sensei_lesson_comment_count' ), 1 ); |
49 | - add_filter( 'the_title', array( $this, 'sensei_lesson_preview_title' ), 10, 2 ); |
|
49 | + add_filter('the_title', array($this, 'sensei_lesson_preview_title'), 10, 2); |
|
50 | 50 | |
51 | 51 | //1.6.2 |
52 | - add_filter( 'wp_login_failed', array( $this, 'sensei_login_fail_redirect' ), 10 ); |
|
53 | - add_filter( 'init', array( $this, 'sensei_handle_login_request' ), 10 ); |
|
52 | + add_filter('wp_login_failed', array($this, 'sensei_login_fail_redirect'), 10); |
|
53 | + add_filter('init', array($this, 'sensei_handle_login_request'), 10); |
|
54 | 54 | //1.6.3 |
55 | - add_action( 'init', array( $this, 'sensei_process_registration' ), 2 ); |
|
55 | + add_action('init', array($this, 'sensei_process_registration'), 2); |
|
56 | 56 | //1.7.0 |
57 | - add_action( 'sensei_pagination', array( $this, 'sensei_breadcrumb' ), 80, 1 ); |
|
57 | + add_action('sensei_pagination', array($this, 'sensei_breadcrumb'), 80, 1); |
|
58 | 58 | |
59 | 59 | // Fix pagination for course archive pages when filtering by course type |
60 | - add_filter( 'pre_get_posts', array( $this, 'sensei_course_archive_pagination' ) ); |
|
60 | + add_filter('pre_get_posts', array($this, 'sensei_course_archive_pagination')); |
|
61 | 61 | |
62 | 62 | // Scripts and Styles |
63 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
|
64 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
63 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); |
|
64 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
65 | 65 | |
66 | 66 | // Custom Menu Item filters |
67 | - add_filter( 'wp_setup_nav_menu_item', array( $this, 'sensei_setup_nav_menu_item' ) ); |
|
68 | - add_filter( 'wp_nav_menu_objects', array( $this, 'sensei_wp_nav_menu_objects' ) ); |
|
67 | + add_filter('wp_setup_nav_menu_item', array($this, 'sensei_setup_nav_menu_item')); |
|
68 | + add_filter('wp_nav_menu_objects', array($this, 'sensei_wp_nav_menu_objects')); |
|
69 | 69 | // Search Results filters |
70 | - add_filter( 'post_class', array( $this, 'sensei_search_results_classes' ), 10 ); |
|
70 | + add_filter('post_class', array($this, 'sensei_search_results_classes'), 10); |
|
71 | 71 | // Only show course & lesson excerpts in search results |
72 | - add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) ); |
|
72 | + add_filter('the_content', array($this, 'sensei_search_results_excerpt')); |
|
73 | 73 | |
74 | 74 | //Use WooCommerce filter to show admin bar to Teachers. |
75 | - add_action( 'init', array( $this, 'sensei_show_admin_bar') ); |
|
75 | + add_action('init', array($this, 'sensei_show_admin_bar')); |
|
76 | 76 | |
77 | 77 | // Remove course from active courses if an order is cancelled or refunded |
78 | - add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
79 | - add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
80 | - add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
81 | - add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
82 | - add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
83 | - add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
78 | + add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
79 | + add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
80 | + add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
81 | + add_action('woocommerce_order_status_processing_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
82 | + add_action('woocommerce_order_status_completed_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
83 | + add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
84 | 84 | |
85 | 85 | // Make sure correct courses are marked as active for users |
86 | - add_action( 'sensei_before_my_courses', array( $this, 'activate_purchased_courses' ), 10, 1 ); |
|
87 | - add_action( 'sensei_single_course_content_inside_before', array( $this, 'activate_purchased_single_course' ), 10 ); |
|
86 | + add_action('sensei_before_my_courses', array($this, 'activate_purchased_courses'), 10, 1); |
|
87 | + add_action('sensei_single_course_content_inside_before', array($this, 'activate_purchased_single_course'), 10); |
|
88 | 88 | |
89 | 89 | // Lesson tags |
90 | - add_action( 'sensei_lesson_meta_extra', array( $this, 'lesson_tags_display' ), 10, 1 ); |
|
91 | - add_action( 'pre_get_posts', array( $this, 'lesson_tag_archive_filter' ), 10, 1 ); |
|
92 | - add_filter( 'sensei_lessons_archive_text', array( $this, 'lesson_tag_archive_header' ) ); |
|
93 | - add_action( 'sensei_loop_lesson_inside_before', array( $this, 'lesson_tag_archive_description' ), 11 ); |
|
90 | + add_action('sensei_lesson_meta_extra', array($this, 'lesson_tags_display'), 10, 1); |
|
91 | + add_action('pre_get_posts', array($this, 'lesson_tag_archive_filter'), 10, 1); |
|
92 | + add_filter('sensei_lessons_archive_text', array($this, 'lesson_tag_archive_header')); |
|
93 | + add_action('sensei_loop_lesson_inside_before', array($this, 'lesson_tag_archive_description'), 11); |
|
94 | 94 | |
95 | 95 | // Hide Sensei activity comments from lesson and course pages |
96 | - add_filter( 'wp_list_comments_args', array( $this, 'hide_sensei_activity' ) ); |
|
96 | + add_filter('wp_list_comments_args', array($this, 'hide_sensei_activity')); |
|
97 | 97 | } // End __construct() |
98 | 98 | |
99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @since 1.0.0 |
102 | 102 | * @return void |
103 | 103 | */ |
104 | - public function init () { |
|
104 | + public function init() { |
|
105 | 105 | |
106 | 106 | } // End init() |
107 | 107 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * @since 1.7.3 |
113 | 113 | * @return array|mixed |
114 | 114 | */ |
115 | - public function __get( $key ) { |
|
115 | + public function __get($key) { |
|
116 | 116 | |
117 | 117 | |
118 | - if ( 'lesson' == $key || 'course' == $key ) { |
|
119 | - if ( WP_DEBUG ) { |
|
120 | - trigger_error( sprintf( 'Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3' ) ); |
|
118 | + if ('lesson' == $key || 'course' == $key) { |
|
119 | + if (WP_DEBUG) { |
|
120 | + trigger_error(sprintf('Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3')); |
|
121 | 121 | } |
122 | 122 | return Sensei()->$key; |
123 | 123 | } |
@@ -130,32 +130,32 @@ discard block |
||
130 | 130 | * @since 1.0.0 |
131 | 131 | * @return void |
132 | 132 | */ |
133 | - public function enqueue_scripts () { |
|
133 | + public function enqueue_scripts() { |
|
134 | 134 | |
135 | 135 | $disable_js = false; |
136 | - if ( isset( Sensei()->settings->settings[ 'js_disable' ] ) ) { |
|
137 | - $disable_js = Sensei()->settings->settings[ 'js_disable' ]; |
|
136 | + if (isset(Sensei()->settings->settings['js_disable'])) { |
|
137 | + $disable_js = Sensei()->settings->settings['js_disable']; |
|
138 | 138 | } // End If Statement |
139 | - if ( ! $disable_js ) { |
|
139 | + if ( ! $disable_js) { |
|
140 | 140 | |
141 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
141 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
142 | 142 | |
143 | 143 | // My Courses tabs script |
144 | - wp_register_script( $this->token . '-user-dashboard', esc_url( Sensei()->plugin_url . 'assets/js/user-dashboard' . $suffix . '.js' ), array( 'jquery-ui-tabs' ), Sensei()->version, true ); |
|
145 | - wp_enqueue_script( $this->token . '-user-dashboard' ); |
|
144 | + wp_register_script($this->token.'-user-dashboard', esc_url(Sensei()->plugin_url.'assets/js/user-dashboard'.$suffix.'.js'), array('jquery-ui-tabs'), Sensei()->version, true); |
|
145 | + wp_enqueue_script($this->token.'-user-dashboard'); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | // Course Archive javascript |
149 | - if( is_post_type_archive( 'course' ) ){ |
|
149 | + if (is_post_type_archive('course')) { |
|
150 | 150 | |
151 | - wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true ); |
|
152 | - wp_enqueue_script( 'sensei-course-archive-js' ); |
|
151 | + wp_register_script('sensei-course-archive-js', esc_url(Sensei()->plugin_url.'assets/js/frontend/course-archive'.$suffix.'.js'), array('jquery'), '1', true); |
|
152 | + wp_enqueue_script('sensei-course-archive-js'); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | 156 | |
157 | 157 | // Allow additional scripts to be loaded |
158 | - do_action( 'sensei_additional_scripts' ); |
|
158 | + do_action('sensei_additional_scripts'); |
|
159 | 159 | |
160 | 160 | } // End If Statement |
161 | 161 | |
@@ -166,24 +166,24 @@ discard block |
||
166 | 166 | * @since 1.0.0 |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public function enqueue_styles () { |
|
169 | + public function enqueue_styles() { |
|
170 | 170 | |
171 | 171 | |
172 | 172 | $disable_styles = false; |
173 | - if ( isset( Sensei()->settings->settings[ 'styles_disable' ] ) ) { |
|
174 | - $disable_styles = Sensei()->settings->settings[ 'styles_disable' ]; |
|
173 | + if (isset(Sensei()->settings->settings['styles_disable'])) { |
|
174 | + $disable_styles = Sensei()->settings->settings['styles_disable']; |
|
175 | 175 | } // End If Statement |
176 | 176 | |
177 | 177 | // Add filter for theme overrides |
178 | - $disable_styles = apply_filters( 'sensei_disable_styles', $disable_styles ); |
|
178 | + $disable_styles = apply_filters('sensei_disable_styles', $disable_styles); |
|
179 | 179 | |
180 | - if ( ! $disable_styles ) { |
|
180 | + if ( ! $disable_styles) { |
|
181 | 181 | |
182 | - wp_register_style( Sensei()->token . '-frontend', Sensei()->plugin_url . 'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen' ); |
|
183 | - wp_enqueue_style( Sensei()->token . '-frontend' ); |
|
182 | + wp_register_style(Sensei()->token.'-frontend', Sensei()->plugin_url.'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen'); |
|
183 | + wp_enqueue_style(Sensei()->token.'-frontend'); |
|
184 | 184 | |
185 | 185 | // Allow additional stylesheets to be loaded |
186 | - do_action( 'sensei_additional_styles' ); |
|
186 | + do_action('sensei_additional_styles'); |
|
187 | 187 | |
188 | 188 | } // End If Statement |
189 | 189 | |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param string $name (default: '') |
200 | 200 | * @return void |
201 | 201 | */ |
202 | - function sensei_get_template_part( $slug, $name = '' ) { |
|
202 | + function sensei_get_template_part($slug, $name = '') { |
|
203 | 203 | |
204 | - _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' ); |
|
205 | - Sensei_Templates::get_part( $slug, $name ); |
|
204 | + _deprecated_function('class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part'); |
|
205 | + Sensei_Templates::get_part($slug, $name); |
|
206 | 206 | |
207 | 207 | } // End sensei_get_template_part() |
208 | 208 | |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | * @param string $default_path (default: '') |
218 | 218 | * @return void |
219 | 219 | */ |
220 | - function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
220 | + function sensei_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
221 | 221 | |
222 | - _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' ); |
|
223 | - Sensei_Templates::get_template($template_name, $args, $template_path, $default_path ); |
|
222 | + _deprecated_function('sensei_get_template', '1.9.0', 'Sensei_Templates::get_template'); |
|
223 | + Sensei_Templates::get_template($template_name, $args, $template_path, $default_path); |
|
224 | 224 | |
225 | 225 | } // End sensei_get_template() |
226 | 226 | |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | * @param string $default_path (default: '') |
235 | 235 | * @return void |
236 | 236 | */ |
237 | - function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
237 | + function sensei_locate_template($template_name, $template_path = '', $default_path = '') { |
|
238 | 238 | |
239 | - _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' ); |
|
240 | - Sensei_Templates::locate_template( $template_name, $template_path, $default_path ); |
|
239 | + _deprecated_function('sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template'); |
|
240 | + Sensei_Templates::locate_template($template_name, $template_path, $default_path); |
|
241 | 241 | |
242 | 242 | } // End sensei_locate_template() |
243 | 243 | |
@@ -251,20 +251,20 @@ discard block |
||
251 | 251 | function sensei_output_content_wrapper() { |
252 | 252 | |
253 | 253 | // backwards compatibility check for old location under the wrappers directory of the active theme |
254 | - $backwards_compatible_wrapper_location = array( |
|
255 | - Sensei()->template_url . 'wrappers/wrapper-start.php', |
|
254 | + $backwards_compatible_wrapper_location = array( |
|
255 | + Sensei()->template_url.'wrappers/wrapper-start.php', |
|
256 | 256 | 'wrappers/wrapper-start.php' |
257 | 257 | ); |
258 | 258 | |
259 | - $template = locate_template( $backwards_compatible_wrapper_location ); |
|
260 | - if( !empty( $template ) ){ |
|
259 | + $template = locate_template($backwards_compatible_wrapper_location); |
|
260 | + if ( ! empty($template)) { |
|
261 | 261 | |
262 | - Sensei_Templates::get_template( 'wrappers/wrapper-start.php' ); |
|
262 | + Sensei_Templates::get_template('wrappers/wrapper-start.php'); |
|
263 | 263 | return; |
264 | 264 | |
265 | 265 | } |
266 | 266 | |
267 | - Sensei_Templates::get_template( 'globals/wrapper-start.php' ); |
|
267 | + Sensei_Templates::get_template('globals/wrapper-start.php'); |
|
268 | 268 | |
269 | 269 | } // End sensei_output_content_wrapper() |
270 | 270 | |
@@ -278,21 +278,21 @@ discard block |
||
278 | 278 | function sensei_output_content_wrapper_end() { |
279 | 279 | |
280 | 280 | // backwards compatibility check for old location under the wrappers directory of the active theme |
281 | - $backwards_compatible_wrapper_location = array( |
|
282 | - Sensei()->template_url . 'wrappers/wrapper-end.php', |
|
281 | + $backwards_compatible_wrapper_location = array( |
|
282 | + Sensei()->template_url.'wrappers/wrapper-end.php', |
|
283 | 283 | 'wrappers/wrapper-end.php' |
284 | 284 | ); |
285 | 285 | |
286 | - $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location ); |
|
287 | - if( !empty( $backwards_compatible_template ) ){ |
|
286 | + $backwards_compatible_template = locate_template($backwards_compatible_wrapper_location); |
|
287 | + if ( ! empty($backwards_compatible_template)) { |
|
288 | 288 | |
289 | - Sensei_Templates::get_template( 'wrappers/wrapper-end.php' ); |
|
289 | + Sensei_Templates::get_template('wrappers/wrapper-end.php'); |
|
290 | 290 | return; |
291 | 291 | |
292 | 292 | } |
293 | 293 | |
294 | 294 | |
295 | - Sensei_Templates::get_template( 'globals/wrapper-end.php' ); |
|
295 | + Sensei_Templates::get_template('globals/wrapper-end.php'); |
|
296 | 296 | |
297 | 297 | } // End sensei_output_content_wrapper_end() |
298 | 298 | |
@@ -305,57 +305,57 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public static function load_content_pagination() { |
307 | 307 | |
308 | - if( is_singular('course') ) { |
|
308 | + if (is_singular('course')) { |
|
309 | 309 | |
310 | 310 | // backwards compatibility check for old location under the wrappers directory of the active theme |
311 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) ); |
|
312 | - if( !empty( $template ) ){ |
|
311 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-posts.php')); |
|
312 | + if ( ! empty($template)) { |
|
313 | 313 | |
314 | - Sensei_Templates::get_template( 'wrappers/pagination-posts.php' ); |
|
314 | + Sensei_Templates::get_template('wrappers/pagination-posts.php'); |
|
315 | 315 | return; |
316 | 316 | |
317 | 317 | } |
318 | 318 | |
319 | - Sensei_Templates::get_template( 'globals/pagination-posts.php' ); |
|
319 | + Sensei_Templates::get_template('globals/pagination-posts.php'); |
|
320 | 320 | |
321 | - } elseif( is_singular('lesson') ) { |
|
321 | + } elseif (is_singular('lesson')) { |
|
322 | 322 | |
323 | 323 | // backwards compatibility check for old location under the wrappers directory of the active theme |
324 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) ); |
|
325 | - if( !empty( $template ) ){ |
|
324 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-lesson.php')); |
|
325 | + if ( ! empty($template)) { |
|
326 | 326 | |
327 | - Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' ); |
|
327 | + Sensei_Templates::get_template('wrappers/pagination-lesson.php'); |
|
328 | 328 | return; |
329 | 329 | |
330 | 330 | } |
331 | 331 | |
332 | - Sensei_Templates::get_template( 'globals/pagination-lesson.php' ); |
|
332 | + Sensei_Templates::get_template('globals/pagination-lesson.php'); |
|
333 | 333 | |
334 | - } elseif( is_singular('quiz') ) { |
|
334 | + } elseif (is_singular('quiz')) { |
|
335 | 335 | |
336 | 336 | // backwards compatibility check for old location under the wrappers directory of the active theme |
337 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) ); |
|
338 | - if( !empty( $template ) ){ |
|
337 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-quiz.php')); |
|
338 | + if ( ! empty($template)) { |
|
339 | 339 | |
340 | - Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' ); |
|
340 | + Sensei_Templates::get_template('wrappers/pagination-quiz.php'); |
|
341 | 341 | return; |
342 | 342 | |
343 | 343 | } |
344 | 344 | |
345 | - Sensei_Templates::get_template( 'globals/pagination-quiz.php' ); |
|
345 | + Sensei_Templates::get_template('globals/pagination-quiz.php'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
349 | 349 | // backwards compatibility check for old location under the wrappers directory of the active theme |
350 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) ); |
|
351 | - if( !empty( $template ) ){ |
|
350 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination.php')); |
|
351 | + if ( ! empty($template)) { |
|
352 | 352 | |
353 | - Sensei_Templates::get_template( 'wrappers/pagination.php' ); |
|
353 | + Sensei_Templates::get_template('wrappers/pagination.php'); |
|
354 | 354 | return; |
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | - Sensei_Templates::get_template( 'globals/pagination.php' ); |
|
358 | + Sensei_Templates::get_template('globals/pagination.php'); |
|
359 | 359 | |
360 | 360 | } // End If Statement |
361 | 361 | |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | * @param object $item |
382 | 382 | * @return object $item |
383 | 383 | */ |
384 | - public function sensei_setup_nav_menu_item( $item ) { |
|
384 | + public function sensei_setup_nav_menu_item($item) { |
|
385 | 385 | global $pagenow, $wp_rewrite; |
386 | 386 | |
387 | - if( 'nav-menus.php' != $pagenow && !defined('DOING_AJAX') && isset( $item->url ) && 'custom' == $item->type ) { |
|
387 | + if ('nav-menus.php' != $pagenow && ! defined('DOING_AJAX') && isset($item->url) && 'custom' == $item->type) { |
|
388 | 388 | |
389 | 389 | // Set up Sensei menu links |
390 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
391 | - $my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] ); |
|
390 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
391 | + $my_account_page_id = intval(Sensei()->settings->settings['my_course_page']); |
|
392 | 392 | |
393 | 393 | $course_page_url = Sensei_Course::get_courses_page_url(); |
394 | - $lesson_archive_url = get_post_type_archive_link( 'lesson' ); |
|
395 | - $my_courses_url = get_permalink( $my_account_page_id ); |
|
396 | - $my_messages_url = get_post_type_archive_link( 'sensei_message' ); |
|
394 | + $lesson_archive_url = get_post_type_archive_link('lesson'); |
|
395 | + $my_courses_url = get_permalink($my_account_page_id); |
|
396 | + $my_messages_url = get_post_type_archive_link('sensei_message'); |
|
397 | 397 | |
398 | - switch ( $item->url ) { |
|
398 | + switch ($item->url) { |
|
399 | 399 | case '#senseicourses': |
400 | 400 | $item->url = $course_page_url; |
401 | 401 | break; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $item->url = $my_messages_url; |
413 | 413 | // if no archive link exist for sensei_message |
414 | 414 | // set it back to the place holder |
415 | - if( ! $item->url ){ |
|
415 | + if ( ! $item->url) { |
|
416 | 416 | |
417 | 417 | $item->url = '#senseimymessages'; |
418 | 418 | |
@@ -420,21 +420,21 @@ discard block |
||
420 | 420 | break; |
421 | 421 | |
422 | 422 | case '#senseilearnerprofile': |
423 | - $item->url = esc_url( Sensei()->learner_profiles->get_permalink() ); |
|
423 | + $item->url = esc_url(Sensei()->learner_profiles->get_permalink()); |
|
424 | 424 | break; |
425 | 425 | |
426 | 426 | case '#senseiloginlogout': |
427 | - $logout_url = wp_logout_url( home_url() ); |
|
427 | + $logout_url = wp_logout_url(home_url()); |
|
428 | 428 | // Login link links to the My Courses page, to avoid the WP dashboard. |
429 | 429 | $login_url = $my_courses_url; |
430 | 430 | |
431 | - $item->url = ( is_user_logged_in() ? $logout_url : $login_url ); |
|
431 | + $item->url = (is_user_logged_in() ? $logout_url : $login_url); |
|
432 | 432 | |
433 | 433 | // determine the menu title login or logout |
434 | - if ( is_user_logged_in() ) { |
|
435 | - $menu_title = __( 'Logout' ,'woothemes-sensei'); |
|
434 | + if (is_user_logged_in()) { |
|
435 | + $menu_title = __('Logout', 'woothemes-sensei'); |
|
436 | 436 | } else { |
437 | - $menu_title = __( 'Login' ,'woothemes-sensei'); |
|
437 | + $menu_title = __('Login', 'woothemes-sensei'); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @param $menu_title |
446 | 446 | */ |
447 | - $item->title = apply_filters( 'sensei_login_logout_menu_title', $menu_title ); |
|
447 | + $item->title = apply_filters('sensei_login_logout_menu_title', $menu_title); |
|
448 | 448 | |
449 | 449 | break; |
450 | 450 | |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | break; |
453 | 453 | } |
454 | 454 | |
455 | - $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); |
|
456 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); |
|
457 | - $item_url = untrailingslashit( $item->url ); |
|
458 | - $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); |
|
455 | + $_root_relative_current = untrailingslashit($_SERVER['REQUEST_URI']); |
|
456 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_root_relative_current); |
|
457 | + $item_url = untrailingslashit($item->url); |
|
458 | + $_indexless_current = untrailingslashit(preg_replace('/'.preg_quote($wp_rewrite->index, '/').'$/', '', $current_url)); |
|
459 | 459 | // Highlight current menu item |
460 | - if ( $item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) { |
|
460 | + if ($item_url && in_array($item_url, array($current_url, $_indexless_current, $_root_relative_current))) { |
|
461 | 461 | $item->classes[] = 'current-menu-item current_page_item'; |
462 | 462 | } |
463 | 463 | |
@@ -476,26 +476,26 @@ discard block |
||
476 | 476 | * @param object $sorted_menu_items |
477 | 477 | * @return object $sorted_menu_items |
478 | 478 | */ |
479 | - public function sensei_wp_nav_menu_objects( $sorted_menu_items ) { |
|
479 | + public function sensei_wp_nav_menu_objects($sorted_menu_items) { |
|
480 | 480 | |
481 | - foreach( $sorted_menu_items as $k=>$item ) { |
|
481 | + foreach ($sorted_menu_items as $k=>$item) { |
|
482 | 482 | |
483 | 483 | // Remove the My Messages link for logged out users or if Private Messages are disabled |
484 | - if( ! get_post_type_archive_link( 'sensei_message' ) |
|
485 | - && '#senseimymessages' == $item->url ) { |
|
484 | + if ( ! get_post_type_archive_link('sensei_message') |
|
485 | + && '#senseimymessages' == $item->url) { |
|
486 | 486 | |
487 | - if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) { |
|
487 | + if ( ! is_user_logged_in() || (isset(Sensei()->settings->settings['messages_disable']) && Sensei()->settings->settings['messages_disable'])) { |
|
488 | 488 | |
489 | - unset( $sorted_menu_items[$k] ); |
|
489 | + unset($sorted_menu_items[$k]); |
|
490 | 490 | |
491 | 491 | } |
492 | 492 | } |
493 | 493 | // Remove the My Profile link for logged out users. |
494 | - if( Sensei()->learner_profiles->get_permalink() == $item->url ) { |
|
494 | + if (Sensei()->learner_profiles->get_permalink() == $item->url) { |
|
495 | 495 | |
496 | - if ( !is_user_logged_in() || ! ( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) ) { |
|
496 | + if ( ! is_user_logged_in() || ! (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable'])) { |
|
497 | 497 | |
498 | - unset( $sorted_menu_items[$k] ); |
|
498 | + unset($sorted_menu_items[$k]); |
|
499 | 499 | |
500 | 500 | } |
501 | 501 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | function sensei_search_results_classes($classes) { |
508 | 508 | global $post; |
509 | 509 | // Handle Search Classes for Courses, Lessons, and WC Products |
510 | - if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) { |
|
510 | + if (isset($post->post_type) && (('course' == $post->post_type) || ('lesson' == $post->post_type) || ('product' == $post->post_type))) { |
|
511 | 511 | $classes[] = 'post'; |
512 | 512 | } // End If Statement |
513 | 513 | return $classes; |
@@ -535,18 +535,18 @@ discard block |
||
535 | 535 | * @param bool|false $return |
536 | 536 | * @return string|void |
537 | 537 | */ |
538 | - function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) { |
|
538 | + function sensei_course_image($course_id, $width = '100', $height = '100', $return = false) { |
|
539 | 539 | |
540 | - trigger_error( 'Sensei Deprecated function: sensei_course_image since 1.9.0 . Please use Sensei()->course->course_image instead.'); |
|
540 | + trigger_error('Sensei Deprecated function: sensei_course_image since 1.9.0 . Please use Sensei()->course->course_image instead.'); |
|
541 | 541 | |
542 | - if ( ! $return ) { |
|
542 | + if ( ! $return) { |
|
543 | 543 | |
544 | - echo Sensei()->course->course_image( $course_id, $width, $height ); |
|
544 | + echo Sensei()->course->course_image($course_id, $width, $height); |
|
545 | 545 | return ''; |
546 | 546 | |
547 | 547 | } // End If Statement |
548 | 548 | |
549 | - return Sensei()->course->course_image( $course_id, $width, $height ); |
|
549 | + return Sensei()->course->course_image($course_id, $width, $height); |
|
550 | 550 | |
551 | 551 | } // End sensei_course_image() |
552 | 552 | |
@@ -561,15 +561,15 @@ discard block |
||
561 | 561 | * @param bool|false $widget |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) { |
|
564 | + function sensei_lesson_image($lesson_id, $width = '100', $height = '100', $return = false, $widget = false) { |
|
565 | 565 | |
566 | - if( ! $return ){ |
|
566 | + if ( ! $return) { |
|
567 | 567 | |
568 | - echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
568 | + echo Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget); |
|
569 | 569 | return ''; |
570 | 570 | } |
571 | 571 | |
572 | - return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
572 | + return Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget); |
|
573 | 573 | |
574 | 574 | } // End sensei_lesson_image() |
575 | 575 | |
@@ -577,20 +577,20 @@ discard block |
||
577 | 577 | * @since 1.0.0 |
578 | 578 | * @param WP_Query $query |
579 | 579 | */ |
580 | - function sensei_course_archive_pagination( $query ) { |
|
580 | + function sensei_course_archive_pagination($query) { |
|
581 | 581 | |
582 | - if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) { |
|
582 | + if ( ! is_admin() && $query->is_main_query() && isset($_GET['action']) && in_array($_GET['action'], array('newcourses', 'featuredcourses', 'freecourses', 'paidcourses'))) { |
|
583 | 583 | |
584 | 584 | $amount = 0; |
585 | - if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
|
586 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
585 | + if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { |
|
586 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
587 | 587 | } |
588 | 588 | |
589 | - if( $amount ) { |
|
590 | - $query->set( 'posts_per_page', $amount ); |
|
589 | + if ($amount) { |
|
590 | + $query->set('posts_per_page', $amount); |
|
591 | 591 | } |
592 | 592 | |
593 | - $query->set( 'orderby', 'menu_order date' ); |
|
593 | + $query->set('orderby', 'menu_order date'); |
|
594 | 594 | |
595 | 595 | } |
596 | 596 | } |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | function sensei_course_archive_header( ) { |
607 | 607 | |
608 | 608 | trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header '); |
609 | - WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' ); |
|
609 | + WooThemes_Sensei_Course::archive_header('', '<header class="archive-header"><h1>', '</h1></header>'); |
|
610 | 610 | |
611 | 611 | } // sensei_course_archive_header() |
612 | 612 | |
@@ -619,15 +619,15 @@ discard block |
||
619 | 619 | * @return void |
620 | 620 | */ |
621 | 621 | public function sensei_lesson_archive_header( ) { |
622 | - _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' ); |
|
622 | + _deprecated_function('WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header'); |
|
623 | 623 | Sensei()->lesson->the_archive_header(); |
624 | 624 | } // sensei_course_archive_header() |
625 | 625 | |
626 | 626 | /** |
627 | 627 | * @deprecated since 1.9.0 |
628 | 628 | */ |
629 | - public function sensei_message_archive_header( ){ |
|
630 | - _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense'); |
|
629 | + public function sensei_message_archive_header( ) { |
|
630 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_header', 'Please use: Sense'); |
|
631 | 631 | Sensei_Messages::the_archive_header(); |
632 | 632 | } // sensei_message_archive_header() |
633 | 633 | |
@@ -637,15 +637,15 @@ discard block |
||
637 | 637 | * @param WP_Post $post_item |
638 | 638 | * @return void |
639 | 639 | */ |
640 | - function sensei_course_archive_course_title( $post_item ) { |
|
641 | - if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) { |
|
642 | - $post_id = absint( $post_item->ID ); |
|
640 | + function sensei_course_archive_course_title($post_item) { |
|
641 | + if (isset($post_item->ID) && (0 < $post_item->ID)) { |
|
642 | + $post_id = absint($post_item->ID); |
|
643 | 643 | $post_title = $post_item->post_title; |
644 | 644 | } else { |
645 | 645 | $post_id = get_the_ID(); |
646 | 646 | $post_title = get_the_title(); |
647 | 647 | } // End If Statement |
648 | - ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
648 | + ?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
649 | 649 | } // End sensei_course_archive_course_title() |
650 | 650 | |
651 | 651 | /** |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | public function sensei_lesson_archive_lesson_title() { |
657 | 657 | $post_id = get_the_ID(); |
658 | 658 | $post_title = get_the_title(); |
659 | - ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
659 | + ?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
660 | 660 | } // End sensei_lesson_archive_lesson_title() |
661 | 661 | |
662 | 662 | /** |
@@ -665,40 +665,40 @@ discard block |
||
665 | 665 | * @param integer $id course, lesson or quiz id |
666 | 666 | * @return void |
667 | 667 | */ |
668 | - public function sensei_breadcrumb( $id = 0 ) { |
|
668 | + public function sensei_breadcrumb($id = 0) { |
|
669 | 669 | |
670 | 670 | // Only output on lesson, quiz and taxonomy (module) pages |
671 | - if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return; |
|
671 | + if ( ! (is_tax('module') || is_singular('lesson') || is_singular('quiz'))) return; |
|
672 | 672 | |
673 | - if( empty( $id ) ){ |
|
673 | + if (empty($id)) { |
|
674 | 674 | |
675 | 675 | $id = get_the_ID(); |
676 | 676 | |
677 | 677 | } |
678 | 678 | |
679 | - $sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' ); |
|
680 | - $separator = apply_filters( 'sensei_breadcrumb_separator', '>' ); |
|
679 | + $sensei_breadcrumb_prefix = __('Back to: ', 'woothemes-sensei'); |
|
680 | + $separator = apply_filters('sensei_breadcrumb_separator', '>'); |
|
681 | 681 | |
682 | - $html = '<section class="sensei-breadcrumb">' . $sensei_breadcrumb_prefix; |
|
682 | + $html = '<section class="sensei-breadcrumb">'.$sensei_breadcrumb_prefix; |
|
683 | 683 | // Lesson |
684 | - if ( is_singular( 'lesson' ) && 0 < intval( $id ) ) { |
|
685 | - $course_id = intval( get_post_meta( $id, '_lesson_course', true ) ); |
|
686 | - if( ! $course_id ) { |
|
684 | + if (is_singular('lesson') && 0 < intval($id)) { |
|
685 | + $course_id = intval(get_post_meta($id, '_lesson_course', true)); |
|
686 | + if ( ! $course_id) { |
|
687 | 687 | return; |
688 | 688 | } |
689 | - $html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>'; |
|
689 | + $html .= '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Back to the course', 'woothemes-sensei').'">'.get_the_title($course_id).'</a>'; |
|
690 | 690 | } // End If Statement |
691 | 691 | // Quiz |
692 | - if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) { |
|
693 | - $lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) ); |
|
694 | - if( ! $lesson_id ) { |
|
692 | + if (is_singular('quiz') && 0 < intval($id)) { |
|
693 | + $lesson_id = intval(get_post_meta($id, '_quiz_lesson', true)); |
|
694 | + if ( ! $lesson_id) { |
|
695 | 695 | return; |
696 | 696 | } |
697 | - $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' . __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>'; |
|
697 | + $html .= '<a href="'.esc_url(get_permalink($lesson_id)).'" title="'.__('Back to the lesson', 'woothemes-sensei').'">'.get_the_title($lesson_id).'</a>'; |
|
698 | 698 | } // End If Statement |
699 | 699 | |
700 | 700 | // Allow other plugins to filter html |
701 | - $html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator ); |
|
701 | + $html = apply_filters('sensei_breadcrumb_output', $html, $separator); |
|
702 | 702 | $html .= '</section>'; |
703 | 703 | |
704 | 704 | echo $html; |
@@ -710,25 +710,25 @@ discard block |
||
710 | 710 | */ |
711 | 711 | public function sensei_lesson_course_signup_link( ) { |
712 | 712 | |
713 | - _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' ); |
|
713 | + _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link'); |
|
714 | 714 | WooThemes_Sensei_Lesson::course_signup_link(); |
715 | 715 | } |
716 | 716 | |
717 | - public function lesson_tags_display( $lesson_id = 0 ) { |
|
718 | - if( $lesson_id ) { |
|
719 | - $tags = wp_get_post_terms( $lesson_id, 'lesson-tag' ); |
|
720 | - if( $tags && count( $tags ) > 0 ) { |
|
717 | + public function lesson_tags_display($lesson_id = 0) { |
|
718 | + if ($lesson_id) { |
|
719 | + $tags = wp_get_post_terms($lesson_id, 'lesson-tag'); |
|
720 | + if ($tags && count($tags) > 0) { |
|
721 | 721 | $tag_list = ''; |
722 | - foreach( $tags as $tag ) { |
|
723 | - $tag_link = get_term_link( $tag, 'lesson-tag' ); |
|
724 | - if( ! is_wp_error( $tag_link ) ) { |
|
725 | - if( $tag_list ) { $tag_list .= ', '; } |
|
726 | - $tag_list .= '<a href="' . $tag_link . '">' . $tag->name . '</a>'; |
|
722 | + foreach ($tags as $tag) { |
|
723 | + $tag_link = get_term_link($tag, 'lesson-tag'); |
|
724 | + if ( ! is_wp_error($tag_link)) { |
|
725 | + if ($tag_list) { $tag_list .= ', '; } |
|
726 | + $tag_list .= '<a href="'.$tag_link.'">'.$tag->name.'</a>'; |
|
727 | 727 | } |
728 | 728 | } |
729 | - if( $tag_list ) { |
|
729 | + if ($tag_list) { |
|
730 | 730 | ?><section class="lesson-tags"> |
731 | - <?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?> |
|
731 | + <?php printf(__('Lesson tags: %1$s', 'woothemes-sensei'), $tag_list); ?> |
|
732 | 732 | </section><?php |
733 | 733 | } |
734 | 734 | } |
@@ -738,51 +738,51 @@ discard block |
||
738 | 738 | /** |
739 | 739 | * @param WP_Query $query |
740 | 740 | */ |
741 | - public function lesson_tag_archive_filter( $query ) { |
|
742 | - if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) { |
|
741 | + public function lesson_tag_archive_filter($query) { |
|
742 | + if (is_tax('lesson-tag') && $query->is_main_query()) { |
|
743 | 743 | // Limit to lessons only |
744 | - $query->set( 'post_type', 'lesson' ); |
|
744 | + $query->set('post_type', 'lesson'); |
|
745 | 745 | |
746 | 746 | // Set order of lessons |
747 | - $query->set( 'orderby', 'menu_order' ); |
|
748 | - $query->set( 'order', 'ASC' ); |
|
747 | + $query->set('orderby', 'menu_order'); |
|
748 | + $query->set('order', 'ASC'); |
|
749 | 749 | |
750 | 750 | } |
751 | 751 | } |
752 | 752 | |
753 | - public function lesson_tag_archive_header( $title ) { |
|
754 | - if( is_tax( 'lesson-tag' ) ) { |
|
755 | - $title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) ); |
|
753 | + public function lesson_tag_archive_header($title) { |
|
754 | + if (is_tax('lesson-tag')) { |
|
755 | + $title = sprintf(__('Lesson tag: %1$s', 'woothemes-sensei'), apply_filters('sensei_lesson_tag_archive_title', get_queried_object()->name)); |
|
756 | 756 | } |
757 | 757 | return $title; |
758 | 758 | } |
759 | 759 | |
760 | 760 | public function lesson_tag_archive_description() { |
761 | - if( is_tax( 'lesson-tag' ) ) { |
|
761 | + if (is_tax('lesson-tag')) { |
|
762 | 762 | $tag = get_queried_object(); |
763 | - echo '<p class="archive-description lesson-description">' . apply_filters( 'sensei_lesson_tag_archive_description', nl2br( $tag->description ), $tag->term_id ) . '</p>'; |
|
763 | + echo '<p class="archive-description lesson-description">'.apply_filters('sensei_lesson_tag_archive_description', nl2br($tag->description), $tag->term_id).'</p>'; |
|
764 | 764 | } |
765 | 765 | } |
766 | 766 | |
767 | 767 | public function sensei_complete_lesson() { |
768 | - global $post, $current_user; |
|
768 | + global $post, $current_user; |
|
769 | 769 | // Handle Quiz Completion |
770 | - if ( isset( $_POST['quiz_action'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_lesson_noonce' ], 'woothemes_sensei_complete_lesson_noonce' ) ) { |
|
770 | + if (isset($_POST['quiz_action']) && wp_verify_nonce($_POST['woothemes_sensei_complete_lesson_noonce'], 'woothemes_sensei_complete_lesson_noonce')) { |
|
771 | 771 | |
772 | - $sanitized_submit = esc_html( $_POST['quiz_action'] ); |
|
772 | + $sanitized_submit = esc_html($_POST['quiz_action']); |
|
773 | 773 | |
774 | 774 | switch ($sanitized_submit) { |
775 | 775 | case 'lesson-complete': |
776 | 776 | |
777 | - Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true ); |
|
777 | + Sensei_Utils::sensei_start_lesson($post->ID, $current_user->ID, $complete = true); |
|
778 | 778 | |
779 | 779 | break; |
780 | 780 | |
781 | 781 | case 'lesson-reset': |
782 | 782 | |
783 | - Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID ); |
|
783 | + Sensei_Utils::sensei_remove_user_from_lesson($post->ID, $current_user->ID); |
|
784 | 784 | |
785 | - $this->messages = '<div class="sensei-message note">' . __( 'Lesson Reset Successfully.', 'woothemes-sensei' ) . '</div>'; |
|
785 | + $this->messages = '<div class="sensei-message note">'.__('Lesson Reset Successfully.', 'woothemes-sensei').'</div>'; |
|
786 | 786 | break; |
787 | 787 | |
788 | 788 | default: |
@@ -796,14 +796,14 @@ discard block |
||
796 | 796 | } // End sensei_complete_lesson() |
797 | 797 | |
798 | 798 | public function sensei_complete_course() { |
799 | - global $post, $current_user, $wp_query; |
|
800 | - if ( isset( $_POST['course_complete'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_course_noonce' ], 'woothemes_sensei_complete_course_noonce' ) ) { |
|
799 | + global $post, $current_user, $wp_query; |
|
800 | + if (isset($_POST['course_complete']) && wp_verify_nonce($_POST['woothemes_sensei_complete_course_noonce'], 'woothemes_sensei_complete_course_noonce')) { |
|
801 | 801 | |
802 | - $sanitized_submit = esc_html( $_POST['course_complete'] ); |
|
803 | - $sanitized_course_id = absint( esc_html( $_POST['course_complete_id'] ) ); |
|
802 | + $sanitized_submit = esc_html($_POST['course_complete']); |
|
803 | + $sanitized_course_id = absint(esc_html($_POST['course_complete_id'])); |
|
804 | 804 | // Handle submit data |
805 | 805 | switch ($sanitized_submit) { |
806 | - case __( 'Mark as Complete', 'woothemes-sensei' ): |
|
806 | + case __('Mark as Complete', 'woothemes-sensei'): |
|
807 | 807 | |
808 | 808 | // Add user to course |
809 | 809 | $course_metadata = array( |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | 'percent' => 0, // No completed lessons yet |
812 | 812 | 'complete' => 0, |
813 | 813 | ); |
814 | - $activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata ); |
|
814 | + $activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata); |
|
815 | 815 | |
816 | - if ( $activity_logged ) { |
|
816 | + if ($activity_logged) { |
|
817 | 817 | // Get all course lessons |
818 | - $course_lesson_ids = Sensei()->course->course_lessons( $sanitized_course_id, 'any', 'ids' ); |
|
818 | + $course_lesson_ids = Sensei()->course->course_lessons($sanitized_course_id, 'any', 'ids'); |
|
819 | 819 | // Mark all quiz user meta lessons as complete |
820 | - foreach ( $course_lesson_ids as $lesson_item_id ){ |
|
820 | + foreach ($course_lesson_ids as $lesson_item_id) { |
|
821 | 821 | // Mark lesson as complete |
822 | - $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_item_id, $current_user->ID, $complete = true ); |
|
822 | + $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_item_id, $current_user->ID, $complete = true); |
|
823 | 823 | } // End For Loop |
824 | 824 | |
825 | 825 | // Update with final stats |
@@ -827,22 +827,22 @@ discard block |
||
827 | 827 | 'percent' => 100, |
828 | 828 | 'complete' => count($course_lesson_ids), |
829 | 829 | ); |
830 | - $activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'complete', $course_metadata ); |
|
830 | + $activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'complete', $course_metadata); |
|
831 | 831 | |
832 | - do_action( 'sensei_user_course_end', $current_user->ID, $sanitized_course_id ); |
|
832 | + do_action('sensei_user_course_end', $current_user->ID, $sanitized_course_id); |
|
833 | 833 | |
834 | 834 | // Success message |
835 | - $this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s marked as complete.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>'; |
|
835 | + $this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s marked as complete.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>'; |
|
836 | 836 | } // End If Statement |
837 | 837 | |
838 | 838 | break; |
839 | 839 | |
840 | - case __( 'Delete Course', 'woothemes-sensei' ): |
|
840 | + case __('Delete Course', 'woothemes-sensei'): |
|
841 | 841 | |
842 | - Sensei_Utils::sensei_remove_user_from_course( $sanitized_course_id, $current_user->ID ); |
|
842 | + Sensei_Utils::sensei_remove_user_from_course($sanitized_course_id, $current_user->ID); |
|
843 | 843 | |
844 | 844 | // Success message |
845 | - $this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s deleted.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>'; |
|
845 | + $this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s deleted.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>'; |
|
846 | 846 | break; |
847 | 847 | |
848 | 848 | default: |
@@ -858,25 +858,25 @@ discard block |
||
858 | 858 | * @param int $lesson_id |
859 | 859 | * @return array |
860 | 860 | */ |
861 | - public function sensei_get_user_quiz_answers( $lesson_id = 0 ) { |
|
861 | + public function sensei_get_user_quiz_answers($lesson_id = 0) { |
|
862 | 862 | global $current_user; |
863 | 863 | |
864 | 864 | $user_answers = array(); |
865 | 865 | |
866 | - if ( 0 < intval( $lesson_id ) ) { |
|
867 | - $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $lesson_id ); |
|
868 | - foreach( $lesson_quiz_questions as $question ) { |
|
869 | - $answer = maybe_unserialize( base64_decode( Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content' ) ) ) ); |
|
870 | - $user_answers[ $question->ID ] = $answer; |
|
866 | + if (0 < intval($lesson_id)) { |
|
867 | + $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($lesson_id); |
|
868 | + foreach ($lesson_quiz_questions as $question) { |
|
869 | + $answer = maybe_unserialize(base64_decode(Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content')))); |
|
870 | + $user_answers[$question->ID] = $answer; |
|
871 | 871 | } |
872 | 872 | } |
873 | 873 | |
874 | 874 | return $user_answers; |
875 | 875 | } // End sensei_get_user_quiz_answers() |
876 | 876 | |
877 | - public function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { |
|
878 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); |
|
879 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); |
|
877 | + public function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { |
|
878 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); |
|
879 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); |
|
880 | 880 | } // End sensei_has_user_completed_lesson() |
881 | 881 | |
882 | 882 | /** |
@@ -886,14 +886,14 @@ discard block |
||
886 | 886 | Sensei()->notices->print_notices(); |
887 | 887 | } // End sensei_frontend_messages() |
888 | 888 | |
889 | - public function sensei_lesson_video( $post_id = 0 ) { |
|
890 | - if ( 0 < intval( $post_id ) ) { |
|
891 | - $lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true ); |
|
892 | - if ( 'http' == substr( $lesson_video_embed, 0, 4) ) { |
|
889 | + public function sensei_lesson_video($post_id = 0) { |
|
890 | + if (0 < intval($post_id)) { |
|
891 | + $lesson_video_embed = get_post_meta($post_id, '_lesson_video_embed', true); |
|
892 | + if ('http' == substr($lesson_video_embed, 0, 4)) { |
|
893 | 893 | // V2 - make width and height a setting for video embed |
894 | - $lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ ); |
|
894 | + $lesson_video_embed = wp_oembed_get(esc_url($lesson_video_embed)/*, array( 'width' => 100 , 'height' => 100)*/); |
|
895 | 895 | } // End If Statement |
896 | - if ( '' != $lesson_video_embed ) { |
|
896 | + if ('' != $lesson_video_embed) { |
|
897 | 897 | ?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php |
898 | 898 | } // End If Statement |
899 | 899 | } // End If Statement |
@@ -905,19 +905,19 @@ discard block |
||
905 | 905 | $quiz_id = 0; |
906 | 906 | |
907 | 907 | // Lesson quizzes |
908 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID ); |
|
908 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post->ID); |
|
909 | 909 | $pass_required = true; |
910 | - if( $quiz_id ) { |
|
910 | + if ($quiz_id) { |
|
911 | 911 | // Get quiz pass setting |
912 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
912 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
913 | 913 | } |
914 | - if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) { |
|
914 | + if ( ! $quiz_id || ($quiz_id && ! $pass_required)) { |
|
915 | 915 | ?> |
916 | - <form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
916 | + <form class="lesson_button_form" method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
917 | 917 | <input type="hidden" |
918 | 918 | name="woothemes_sensei_complete_lesson_noonce" |
919 | 919 | id="woothemes_sensei_complete_lesson_noonce" |
920 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" |
|
920 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" |
|
921 | 921 | /> |
922 | 922 | |
923 | 923 | <input type="hidden" name="quiz_action" value="lesson-complete" /> |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | <input type="submit" |
926 | 926 | name="quiz_complete" |
927 | 927 | class="quiz-submit complete" |
928 | - value="<?php _e( 'Complete Lesson', 'woothemes-sensei' ); ?>"/> |
|
928 | + value="<?php _e('Complete Lesson', 'woothemes-sensei'); ?>"/> |
|
929 | 929 | |
930 | 930 | </form> |
931 | 931 | <?php |
@@ -938,25 +938,25 @@ discard block |
||
938 | 938 | $quiz_id = 0; |
939 | 939 | |
940 | 940 | // Lesson quizzes |
941 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID ); |
|
941 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post->ID); |
|
942 | 942 | $reset_allowed = true; |
943 | - if( $quiz_id ) { |
|
943 | + if ($quiz_id) { |
|
944 | 944 | // Get quiz pass setting |
945 | - $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
945 | + $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true); |
|
946 | 946 | } |
947 | - if ( ! $quiz_id || !empty($reset_allowed) ) { |
|
947 | + if ( ! $quiz_id || ! empty($reset_allowed)) { |
|
948 | 948 | ?> |
949 | - <form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
949 | + <form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
950 | 950 | |
951 | 951 | <input |
952 | 952 | type="hidden" |
953 | - name="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>" |
|
954 | - id="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>" |
|
955 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" /> |
|
953 | + name="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>" |
|
954 | + id="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>" |
|
955 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" /> |
|
956 | 956 | |
957 | 957 | <input type="hidden" name="quiz_action" value="lesson-reset" /> |
958 | 958 | |
959 | - <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e( 'Reset Lesson', 'woothemes-sensei' ); ?>"/> |
|
959 | + <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e('Reset Lesson', 'woothemes-sensei'); ?>"/> |
|
960 | 960 | |
961 | 961 | </form> |
962 | 962 | <?php |
@@ -979,23 +979,23 @@ discard block |
||
979 | 979 | $post_title = get_the_title(); |
980 | 980 | $author_display_name = get_the_author(); |
981 | 981 | $author_id = get_the_author_meta('ID'); |
982 | - $category_output = get_the_term_list( $post_id, 'course-category', '', ', ', '' ); |
|
983 | - $free_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $post_id ) ); |
|
982 | + $category_output = get_the_term_list($post_id, 'course-category', '', ', ', ''); |
|
983 | + $free_lesson_count = intval(Sensei()->course->course_lesson_preview_count($post_id)); |
|
984 | 984 | ?><section class="entry"> |
985 | 985 | <p class="sensei-course-meta"> |
986 | - <?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?> |
|
987 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span> |
|
986 | + <?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?> |
|
987 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span> |
|
988 | 988 | <?php } // End If Statement ?> |
989 | - <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . ' ' . __( 'Lessons', 'woothemes-sensei' ); ?></span> |
|
990 | - <?php if ( '' != $category_output ) { ?> |
|
991 | - <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span> |
|
989 | + <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).' '.__('Lessons', 'woothemes-sensei'); ?></span> |
|
990 | + <?php if ('' != $category_output) { ?> |
|
991 | + <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span> |
|
992 | 992 | <?php } // End If Statement ?> |
993 | - <?php sensei_simple_course_price( $post_id ); ?> |
|
993 | + <?php sensei_simple_course_price($post_id); ?> |
|
994 | 994 | </p> |
995 | 995 | <p class="course-excerpt"><?php the_excerpt(); ?></p> |
996 | - <?php if ( 0 < $free_lesson_count ) { |
|
997 | - $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?> |
|
998 | - <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p> |
|
996 | + <?php if (0 < $free_lesson_count) { |
|
997 | + $free_lessons = sprintf(__('You can access %d of this course\'s lessons for free', 'woothemes-sensei'), $free_lesson_count); ?> |
|
998 | + <p class="sensei-free-lessons"><a href="<?php echo get_permalink($post_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?></a> - <?php echo $free_lessons; ?></p> |
|
999 | 999 | <?php } ?> |
1000 | 1000 | </section><?php |
1001 | 1001 | } // End sensei_course_archive_meta() |
@@ -1018,33 +1018,33 @@ discard block |
||
1018 | 1018 | * @deprecated since 1.9.0 |
1019 | 1019 | */ |
1020 | 1020 | public function sensei_message_archive_main_content() { |
1021 | - _deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' ); |
|
1021 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed'); |
|
1022 | 1022 | } // End sensei_lesson_archive_main_content() |
1023 | 1023 | |
1024 | 1024 | /** |
1025 | 1025 | * @deprecated since 1.9.0 |
1026 | 1026 | */ |
1027 | 1027 | public function sensei_no_permissions_main_content() { |
1028 | - _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' ); |
|
1028 | + _deprecated_function('Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed'); |
|
1029 | 1029 | } // End sensei_no_permissions_main_content() |
1030 | 1030 | |
1031 | 1031 | public function sensei_course_category_main_content() { |
1032 | 1032 | global $post; |
1033 | - if ( have_posts() ) { ?> |
|
1033 | + if (have_posts()) { ?> |
|
1034 | 1034 | |
1035 | 1035 | <section id="main-course" class="course-container"> |
1036 | 1036 | |
1037 | - <?php do_action( 'sensei_course_archive_header' ); ?> |
|
1037 | + <?php do_action('sensei_course_archive_header'); ?> |
|
1038 | 1038 | |
1039 | - <?php while ( have_posts() ) { the_post(); ?> |
|
1039 | + <?php while (have_posts()) { the_post(); ?> |
|
1040 | 1040 | |
1041 | - <article class="<?php echo join( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ); ?>"> |
|
1041 | + <article class="<?php echo join(' ', get_post_class(array('course', 'post'), get_the_ID())); ?>"> |
|
1042 | 1042 | |
1043 | - <?php do_action( 'sensei_course_image', get_the_ID() ); ?> |
|
1043 | + <?php do_action('sensei_course_image', get_the_ID()); ?> |
|
1044 | 1044 | |
1045 | - <?php do_action( 'sensei_course_archive_course_title', $post ); ?> |
|
1045 | + <?php do_action('sensei_course_archive_course_title', $post); ?> |
|
1046 | 1046 | |
1047 | - <?php do_action( 'sensei_course_archive_meta' ); ?> |
|
1047 | + <?php do_action('sensei_course_archive_meta'); ?> |
|
1048 | 1048 | |
1049 | 1049 | </article> |
1050 | 1050 | |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | |
1057 | 1057 | <p> |
1058 | 1058 | |
1059 | - <?php _e( 'No courses found that match your selection.', 'woothemes-sensei' ); ?> |
|
1059 | + <?php _e('No courses found that match your selection.', 'woothemes-sensei'); ?> |
|
1060 | 1060 | |
1061 | 1061 | </p> |
1062 | 1062 | |
@@ -1073,12 +1073,12 @@ discard block |
||
1073 | 1073 | <div class="col-1"> |
1074 | 1074 | <?php |
1075 | 1075 | // output the actual form markup |
1076 | - Sensei_Templates::get_template( 'user/login-form.php'); |
|
1076 | + Sensei_Templates::get_template('user/login-form.php'); |
|
1077 | 1077 | ?> |
1078 | 1078 | </div> |
1079 | 1079 | |
1080 | 1080 | <?php |
1081 | - if ( get_option('users_can_register') ) { |
|
1081 | + if (get_option('users_can_register')) { |
|
1082 | 1082 | |
1083 | 1083 | // get current url |
1084 | 1084 | $action_url = get_permalink(); |
@@ -1086,38 +1086,38 @@ discard block |
||
1086 | 1086 | ?> |
1087 | 1087 | |
1088 | 1088 | <div class="col-2"> |
1089 | - <h2><?php _e( 'Register', 'woothemes-sensei' ); ?></h2> |
|
1089 | + <h2><?php _e('Register', 'woothemes-sensei'); ?></h2> |
|
1090 | 1090 | |
1091 | - <form method="post" class="register" action="<?php echo esc_url( $action_url ); ?>" > |
|
1091 | + <form method="post" class="register" action="<?php echo esc_url($action_url); ?>" > |
|
1092 | 1092 | |
1093 | - <?php do_action( 'sensei_register_form_start' ); ?> |
|
1093 | + <?php do_action('sensei_register_form_start'); ?> |
|
1094 | 1094 | |
1095 | 1095 | <p class="form-row form-row-wide"> |
1096 | - <label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
1097 | - <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" /> |
|
1096 | + <label for="sensei_reg_username"><?php _e('Username', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
1097 | + <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty($_POST['sensei_reg_username'])) esc_attr_e($_POST['sensei_reg_username']); ?>" /> |
|
1098 | 1098 | </p> |
1099 | 1099 | |
1100 | 1100 | <p class="form-row form-row-wide"> |
1101 | - <label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
1102 | - <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" /> |
|
1101 | + <label for="sensei_reg_email"><?php _e('Email address', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
1102 | + <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty($_POST['sensei_reg_email'])) esc_attr_e($_POST['sensei_reg_email']); ?>" /> |
|
1103 | 1103 | </p> |
1104 | 1104 | |
1105 | 1105 | <p class="form-row form-row-wide"> |
1106 | - <label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
1107 | - <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" /> |
|
1106 | + <label for="sensei_reg_password"><?php _e('Password', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
1107 | + <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty($_POST['sensei_reg_password'])) esc_attr_e($_POST['sensei_reg_password']); ?>" /> |
|
1108 | 1108 | </p> |
1109 | 1109 | |
1110 | 1110 | <!-- Spam Trap --> |
1111 | - <div style="left:-999em; position:absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woothemes-sensei' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> |
|
1111 | + <div style="left:-999em; position:absolute;"><label for="trap"><?php _e('Anti-spam', 'woothemes-sensei'); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> |
|
1112 | 1112 | |
1113 | - <?php do_action( 'sensei_register_form_fields' ); ?> |
|
1114 | - <?php do_action( 'register_form' ); ?> |
|
1113 | + <?php do_action('sensei_register_form_fields'); ?> |
|
1114 | + <?php do_action('register_form'); ?> |
|
1115 | 1115 | |
1116 | 1116 | <p class="form-row"> |
1117 | - <input type="submit" class="button" name="register" value="<?php _e( 'Register', 'woothemes-sensei' ); ?>" /> |
|
1117 | + <input type="submit" class="button" name="register" value="<?php _e('Register', 'woothemes-sensei'); ?>" /> |
|
1118 | 1118 | </p> |
1119 | 1119 | |
1120 | - <?php do_action( 'sensei_register_form_end' ); ?> |
|
1120 | + <?php do_action('sensei_register_form_end'); ?> |
|
1121 | 1121 | |
1122 | 1122 | </form> |
1123 | 1123 | </div> |
@@ -1130,17 +1130,17 @@ discard block |
||
1130 | 1130 | <?php |
1131 | 1131 | } // End sensei_login_form() |
1132 | 1132 | |
1133 | - public function sensei_lesson_meta( $post_id = 0 ) { |
|
1133 | + public function sensei_lesson_meta($post_id = 0) { |
|
1134 | 1134 | global $post; |
1135 | - if ( 0 < intval( $post_id ) ) { |
|
1136 | - $lesson_course_id = absint( get_post_meta( $post_id, '_lesson_course', true ) ); |
|
1135 | + if (0 < intval($post_id)) { |
|
1136 | + $lesson_course_id = absint(get_post_meta($post_id, '_lesson_course', true)); |
|
1137 | 1137 | ?><section class="entry"> |
1138 | 1138 | <p class="sensei-course-meta"> |
1139 | - <?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?> |
|
1140 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span> |
|
1139 | + <?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?> |
|
1140 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span> |
|
1141 | 1141 | <?php } ?> |
1142 | - <?php if ( 0 < intval( $lesson_course_id ) ) { ?> |
|
1143 | - <span class="lesson-course"><?php echo ' ' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . __( 'View course', 'woothemes-sensei' ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span> |
|
1142 | + <?php if (0 < intval($lesson_course_id)) { ?> |
|
1143 | + <span class="lesson-course"><?php echo ' '.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.__('View course', 'woothemes-sensei').'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span> |
|
1144 | 1144 | <?php } ?> |
1145 | 1145 | </p> |
1146 | 1146 | <p class="lesson-excerpt"><?php the_excerpt( ); ?></p> |
@@ -1148,36 +1148,36 @@ discard block |
||
1148 | 1148 | } // End If Statement |
1149 | 1149 | } // sensei_lesson_meta() |
1150 | 1150 | |
1151 | - public function sensei_lesson_preview_title_text( $course_id ) { |
|
1151 | + public function sensei_lesson_preview_title_text($course_id) { |
|
1152 | 1152 | |
1153 | - $preview_text = __( ' (Preview)', 'woothemes-sensei' ); |
|
1153 | + $preview_text = __(' (Preview)', 'woothemes-sensei'); |
|
1154 | 1154 | |
1155 | 1155 | //if this is a paid course |
1156 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
1157 | - $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
1158 | - if ( 0 < $wc_post_id ) { |
|
1159 | - $preview_text = __( ' (Free Preview)', 'woothemes-sensei' ); |
|
1156 | + if (Sensei_WC::is_woocommerce_active()) { |
|
1157 | + $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true); |
|
1158 | + if (0 < $wc_post_id) { |
|
1159 | + $preview_text = __(' (Free Preview)', 'woothemes-sensei'); |
|
1160 | 1160 | } // End If Statement |
1161 | 1161 | } |
1162 | 1162 | return $preview_text; |
1163 | 1163 | } |
1164 | 1164 | |
1165 | - public function sensei_lesson_preview_title( $title = '', $id = 0 ) { |
|
1165 | + public function sensei_lesson_preview_title($title = '', $id = 0) { |
|
1166 | 1166 | global $post, $current_user; |
1167 | 1167 | |
1168 | 1168 | // Limit to lessons and check if lesson ID matches filtered post ID |
1169 | 1169 | // @see https://github.com/woothemes/sensei/issues/574 |
1170 | - if( isset( $post->ID ) && $id == $post->ID && 'lesson' == get_post_type( $post ) ) { |
|
1170 | + if (isset($post->ID) && $id == $post->ID && 'lesson' == get_post_type($post)) { |
|
1171 | 1171 | |
1172 | 1172 | // Limit to main query only |
1173 | - if( is_main_query() ) { |
|
1173 | + if (is_main_query()) { |
|
1174 | 1174 | |
1175 | 1175 | // Get the course ID |
1176 | - $course_id = get_post_meta( $post->ID, '_lesson_course', true ); |
|
1176 | + $course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
1177 | 1177 | |
1178 | 1178 | // Check if the user is taking the course |
1179 | - if( is_singular( 'lesson' ) && Sensei_Utils::is_preview_lesson( $post->ID ) && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID ) && $post->ID == $id ) { |
|
1180 | - $title .= ' ' . $this->sensei_lesson_preview_title_text( $course_id ); |
|
1179 | + if (is_singular('lesson') && Sensei_Utils::is_preview_lesson($post->ID) && ! Sensei_Utils::user_started_course($course_id, $current_user->ID) && $post->ID == $id) { |
|
1180 | + $title .= ' '.$this->sensei_lesson_preview_title_text($course_id); |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | } |
@@ -1188,23 +1188,23 @@ discard block |
||
1188 | 1188 | global $post, $current_user; |
1189 | 1189 | |
1190 | 1190 | // Check if the user is taking the course |
1191 | - $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
1191 | + $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID); |
|
1192 | 1192 | // Handle user starting the course |
1193 | - if ( isset( $_POST['course_start'] ) |
|
1194 | - && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' ) |
|
1195 | - && !$is_user_taking_course ) { |
|
1193 | + if (isset($_POST['course_start']) |
|
1194 | + && wp_verify_nonce($_POST['woothemes_sensei_start_course_noonce'], 'woothemes_sensei_start_course_noonce') |
|
1195 | + && ! $is_user_taking_course) { |
|
1196 | 1196 | |
1197 | 1197 | // Start the course |
1198 | - $activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID ); |
|
1198 | + $activity_logged = Sensei_Utils::user_start_course($current_user->ID, $post->ID); |
|
1199 | 1199 | $this->data = new stdClass(); |
1200 | 1200 | $this->data->is_user_taking_course = false; |
1201 | - if ( $activity_logged ) { |
|
1201 | + if ($activity_logged) { |
|
1202 | 1202 | $this->data->is_user_taking_course = true; |
1203 | 1203 | |
1204 | 1204 | // Refresh page to avoid re-posting |
1205 | 1205 | ?> |
1206 | 1206 | |
1207 | - <script type="text/javascript"> window.location = '<?php echo get_permalink( $post->ID ); ?>'; </script> |
|
1207 | + <script type="text/javascript"> window.location = '<?php echo get_permalink($post->ID); ?>'; </script> |
|
1208 | 1208 | |
1209 | 1209 | <?php |
1210 | 1210 | } // End If Statement |
@@ -1215,15 +1215,15 @@ discard block |
||
1215 | 1215 | * @deprecated since 1.9.0 |
1216 | 1216 | */ |
1217 | 1217 | public function sensei_course_meta() { |
1218 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' ); |
|
1219 | - Sensei()->course->the_course_meta( get_post() ); |
|
1218 | + _deprecated_function('Sensei_Frontend::sensei_course_meta', '1.9.0', 'Sensei_Course::the_course_meta()'); |
|
1219 | + Sensei()->course->the_course_meta(get_post()); |
|
1220 | 1220 | } // End sensei_course_meta() |
1221 | 1221 | |
1222 | 1222 | /** |
1223 | 1223 | * @deprecated since 1.9.0 |
1224 | 1224 | */ |
1225 | 1225 | public function sensei_course_meta_video() { |
1226 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' ); |
|
1226 | + _deprecated_function('Sensei_Frontend::sensei_course_meta_video', '1.9.0', 'Sensei_Course::the_course_video()'); |
|
1227 | 1227 | Sensei_Course::the_course_video(); |
1228 | 1228 | } // End sensei_course_meta_video() |
1229 | 1229 | |
@@ -1238,12 +1238,12 @@ discard block |
||
1238 | 1238 | public function sensei_woocommerce_in_cart_message() { |
1239 | 1239 | global $post, $woocommerce; |
1240 | 1240 | |
1241 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
1242 | - $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() ); |
|
1243 | - if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) { |
|
1241 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
1242 | + $user_course_status_id = Sensei_Utils::user_started_course($post->ID, get_current_user_id()); |
|
1243 | + if (0 < intval($wc_post_id) && ! $user_course_status_id) { |
|
1244 | 1244 | |
1245 | - if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) { |
|
1246 | - echo '<div class="sensei-message info">' . sprintf( __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' ); |
|
1245 | + if (Sensei_WC::is_product_in_cart($wc_post_id)) { |
|
1246 | + echo '<div class="sensei-message info">'.sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei').'</div>', '<a class="cart-complete" href="'.$woocommerce->cart->get_checkout_url().'" title="'.__('complete the purchase', 'woothemes-sensei').'">'.__('complete the purchase', 'woothemes-sensei').'</a>'); |
|
1247 | 1247 | } // End If Statement |
1248 | 1248 | |
1249 | 1249 | } // End If Statement |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | } // End sensei_woocommerce_in_cart_message() |
1252 | 1252 | |
1253 | 1253 | // Deprecated |
1254 | - public function sensei_lesson_comment_count( $count ) { |
|
1254 | + public function sensei_lesson_comment_count($count) { |
|
1255 | 1255 | return $count; |
1256 | 1256 | } // End sensei_lesson_comment_count() |
1257 | 1257 | |
@@ -1260,11 +1260,11 @@ discard block |
||
1260 | 1260 | * @param string $content Original content |
1261 | 1261 | * @return string Modified content |
1262 | 1262 | */ |
1263 | - public function sensei_search_results_excerpt( $content ) { |
|
1263 | + public function sensei_search_results_excerpt($content) { |
|
1264 | 1264 | global $post; |
1265 | 1265 | |
1266 | - if( is_search() && in_array( $post->post_type, array( 'course', 'lesson' ) ) ) { |
|
1267 | - $content = '<p class="course-excerpt">' . the_excerpt( ) . '</p>'; |
|
1266 | + if (is_search() && in_array($post->post_type, array('course', 'lesson'))) { |
|
1267 | + $content = '<p class="course-excerpt">'.the_excerpt( ).'</p>'; |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | return $content; |
@@ -1275,11 +1275,11 @@ discard block |
||
1275 | 1275 | * @param integer $order_id ID of order |
1276 | 1276 | * @return void |
1277 | 1277 | */ |
1278 | - public function remove_active_course( $order_id ) { |
|
1279 | - $order = new WC_Order( $order_id ); |
|
1278 | + public function remove_active_course($order_id) { |
|
1279 | + $order = new WC_Order($order_id); |
|
1280 | 1280 | |
1281 | - foreach ( $order->get_items() as $item ) { |
|
1282 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1281 | + foreach ($order->get_items() as $item) { |
|
1282 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
1283 | 1283 | // If item has variation_id then its a variation of the product |
1284 | 1284 | $item_id = $item['variation_id']; |
1285 | 1285 | } else { |
@@ -1287,11 +1287,11 @@ discard block |
||
1287 | 1287 | $item_id = $item['product_id']; |
1288 | 1288 | } |
1289 | 1289 | |
1290 | - if ( $item_id > 0 ) { |
|
1290 | + if ($item_id > 0) { |
|
1291 | 1291 | |
1292 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1292 | + $user_id = get_post_meta($order_id, '_customer_user', true); |
|
1293 | 1293 | |
1294 | - if( $user_id ) { |
|
1294 | + if ($user_id) { |
|
1295 | 1295 | |
1296 | 1296 | // Get all courses for product |
1297 | 1297 | $args = array( |
@@ -1307,13 +1307,13 @@ discard block |
||
1307 | 1307 | 'order' => 'ASC', |
1308 | 1308 | 'fields' => 'ids', |
1309 | 1309 | ); |
1310 | - $course_ids = get_posts( $args ); |
|
1310 | + $course_ids = get_posts($args); |
|
1311 | 1311 | |
1312 | - if( $course_ids && count( $course_ids ) > 0 ) { |
|
1313 | - foreach( $course_ids as $course_id ) { |
|
1312 | + if ($course_ids && count($course_ids) > 0) { |
|
1313 | + foreach ($course_ids as $course_id) { |
|
1314 | 1314 | |
1315 | 1315 | // Remove all course user meta |
1316 | - Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
1316 | + Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id); |
|
1317 | 1317 | |
1318 | 1318 | } // End For Loop |
1319 | 1319 | } // End If Statement |
@@ -1329,16 +1329,16 @@ discard block |
||
1329 | 1329 | * @param integer $user_id User ID |
1330 | 1330 | * @return void |
1331 | 1331 | */ |
1332 | - public function activate_purchased_courses( $user_id = 0 ) { |
|
1332 | + public function activate_purchased_courses($user_id = 0) { |
|
1333 | 1333 | |
1334 | - if( $user_id ) { |
|
1334 | + if ($user_id) { |
|
1335 | 1335 | |
1336 | - if( Sensei_WC::is_woocommerce_active() ) { |
|
1336 | + if (Sensei_WC::is_woocommerce_active()) { |
|
1337 | 1337 | |
1338 | 1338 | // Get all user's orders |
1339 | 1339 | $order_args = array( |
1340 | 1340 | 'post_type' => 'shop_order', |
1341 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
1341 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
1342 | 1342 | 'posts_per_page' => -1, |
1343 | 1343 | 'meta_query' => array( |
1344 | 1344 | array( |
@@ -1348,25 +1348,25 @@ discard block |
||
1348 | 1348 | ), |
1349 | 1349 | ); |
1350 | 1350 | |
1351 | - $orders = get_posts( $order_args ); |
|
1351 | + $orders = get_posts($order_args); |
|
1352 | 1352 | |
1353 | 1353 | $product_ids = array(); |
1354 | 1354 | $order_ids = array(); |
1355 | 1355 | |
1356 | - foreach( $orders as $post_id ) { |
|
1356 | + foreach ($orders as $post_id) { |
|
1357 | 1357 | |
1358 | 1358 | // Only process each order once |
1359 | - $processed = get_post_meta( $post_id, 'sensei_products_processed', true ); |
|
1359 | + $processed = get_post_meta($post_id, 'sensei_products_processed', true); |
|
1360 | 1360 | |
1361 | - if( $processed && $processed == 'processed' ) { |
|
1361 | + if ($processed && $processed == 'processed') { |
|
1362 | 1362 | continue; |
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | // Get course product IDs from order |
1366 | - $order = new WC_Order( $post_id ); |
|
1366 | + $order = new WC_Order($post_id); |
|
1367 | 1367 | |
1368 | 1368 | $items = $order->get_items(); |
1369 | - foreach( $items as $item ) { |
|
1369 | + foreach ($items as $item) { |
|
1370 | 1370 | if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
1371 | 1371 | $item_id = $item['variation_id']; |
1372 | 1372 | $product_type = 'variation'; |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | $order_ids[] = $post_id; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | - if( count( $product_ids ) > 0 ) { |
|
1383 | + if (count($product_ids) > 0) { |
|
1384 | 1384 | |
1385 | 1385 | // Get all courses from user's orders |
1386 | 1386 | $course_args = array( |
@@ -1397,31 +1397,31 @@ discard block |
||
1397 | 1397 | 'order' => 'ASC', |
1398 | 1398 | 'fields' => 'ids', |
1399 | 1399 | ); |
1400 | - $course_ids = get_posts( $course_args ); |
|
1400 | + $course_ids = get_posts($course_args); |
|
1401 | 1401 | |
1402 | - foreach( $course_ids as $course_id ) { |
|
1402 | + foreach ($course_ids as $course_id) { |
|
1403 | 1403 | |
1404 | - $user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id ); |
|
1404 | + $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id); |
|
1405 | 1405 | |
1406 | 1406 | // Ignore course if already completed |
1407 | - if( Sensei_Utils::user_completed_course( $user_course_status ) ) { |
|
1407 | + if (Sensei_Utils::user_completed_course($user_course_status)) { |
|
1408 | 1408 | continue; |
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | // Ignore course if already started |
1412 | - if( $user_course_status ) { |
|
1412 | + if ($user_course_status) { |
|
1413 | 1413 | continue; |
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | // Mark course as started by user |
1417 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1417 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
1418 | 1418 | } |
1419 | 1419 | } |
1420 | 1420 | |
1421 | - if( count( $order_ids ) > 0 ) { |
|
1422 | - foreach( $order_ids as $order_id ) { |
|
1421 | + if (count($order_ids) > 0) { |
|
1422 | + foreach ($order_ids as $order_id) { |
|
1423 | 1423 | // Mark order as processed |
1424 | - update_post_meta( $order_id, 'sensei_products_processed', 'processed' ); |
|
1424 | + update_post_meta($order_id, 'sensei_products_processed', 'processed'); |
|
1425 | 1425 | } |
1426 | 1426 | } |
1427 | 1427 | } |
@@ -1435,28 +1435,28 @@ discard block |
||
1435 | 1435 | public function activate_purchased_single_course() { |
1436 | 1436 | global $post, $current_user; |
1437 | 1437 | |
1438 | - if( Sensei_WC::is_woocommerce_active() ) { |
|
1438 | + if (Sensei_WC::is_woocommerce_active()) { |
|
1439 | 1439 | |
1440 | - if( ! is_user_logged_in() ) return; |
|
1441 | - if( ! isset( $post->ID ) ) return; |
|
1440 | + if ( ! is_user_logged_in()) return; |
|
1441 | + if ( ! isset($post->ID)) return; |
|
1442 | 1442 | |
1443 | 1443 | $user_id = $current_user->ID; |
1444 | 1444 | $course_id = $post->ID; |
1445 | - $course_product_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
1446 | - if( ! $course_product_id ) { |
|
1445 | + $course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true); |
|
1446 | + if ( ! $course_product_id) { |
|
1447 | 1447 | return; |
1448 | 1448 | } |
1449 | 1449 | |
1450 | - $user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id ); |
|
1450 | + $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id); |
|
1451 | 1451 | |
1452 | 1452 | // Ignore course if already completed |
1453 | - if( Sensei_Utils::user_completed_course( $user_course_status ) ) { |
|
1453 | + if (Sensei_Utils::user_completed_course($user_course_status)) { |
|
1454 | 1454 | |
1455 | 1455 | return; |
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | // Ignore course if already started |
1459 | - if( $user_course_status ) { |
|
1459 | + if ($user_course_status) { |
|
1460 | 1460 | return; |
1461 | 1461 | } |
1462 | 1462 | |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | $order_args = array( |
1465 | 1465 | 'post_type' => 'shop_order', |
1466 | 1466 | 'posts_per_page' => -1, |
1467 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
1467 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
1468 | 1468 | 'meta_query' => array( |
1469 | 1469 | array( |
1470 | 1470 | 'key' => '_customer_user', |
@@ -1473,27 +1473,27 @@ discard block |
||
1473 | 1473 | ), |
1474 | 1474 | 'fields' => 'ids', |
1475 | 1475 | ); |
1476 | - $orders = get_posts( $order_args ); |
|
1476 | + $orders = get_posts($order_args); |
|
1477 | 1477 | |
1478 | - foreach( $orders as $order_post_id ) { |
|
1478 | + foreach ($orders as $order_post_id) { |
|
1479 | 1479 | |
1480 | 1480 | // Get course product IDs from order |
1481 | - $order = new WC_Order( $order_post_id ); |
|
1481 | + $order = new WC_Order($order_post_id); |
|
1482 | 1482 | |
1483 | 1483 | $items = $order->get_items(); |
1484 | - foreach( $items as $item ) { |
|
1485 | - $product = wc_get_product( $item['product_id'] ); |
|
1484 | + foreach ($items as $item) { |
|
1485 | + $product = wc_get_product($item['product_id']); |
|
1486 | 1486 | |
1487 | 1487 | // handle product bundles |
1488 | - if( $product->is_type('bundle') ){ |
|
1488 | + if ($product->is_type('bundle')) { |
|
1489 | 1489 | |
1490 | - $bundled_product = new WC_Product_Bundle( $product->id ); |
|
1490 | + $bundled_product = new WC_Product_Bundle($product->id); |
|
1491 | 1491 | $bundled_items = $bundled_product->get_bundled_items(); |
1492 | 1492 | |
1493 | - foreach( $bundled_items as $bundled_item ){ |
|
1493 | + foreach ($bundled_items as $bundled_item) { |
|
1494 | 1494 | |
1495 | - if( $bundled_item->product_id == $course_product_id ) { |
|
1496 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1495 | + if ($bundled_item->product_id == $course_product_id) { |
|
1496 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
1497 | 1497 | return; |
1498 | 1498 | } |
1499 | 1499 | |
@@ -1502,8 +1502,8 @@ discard block |
||
1502 | 1502 | } else { |
1503 | 1503 | |
1504 | 1504 | // handle regular products |
1505 | - if( $item['product_id'] == $course_product_id ) { |
|
1506 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1505 | + if ($item['product_id'] == $course_product_id) { |
|
1506 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
1507 | 1507 | return; |
1508 | 1508 | } |
1509 | 1509 | |
@@ -1519,9 +1519,9 @@ discard block |
||
1519 | 1519 | * @param array $args Default arguments |
1520 | 1520 | * @return array Modified arguments |
1521 | 1521 | */ |
1522 | - public function hide_sensei_activity( $args = array() ) { |
|
1522 | + public function hide_sensei_activity($args = array()) { |
|
1523 | 1523 | |
1524 | - if( is_singular( 'lesson' ) || is_singular( 'course' ) ) { |
|
1524 | + if (is_singular('lesson') || is_singular('course')) { |
|
1525 | 1525 | $args['type'] = 'comment'; |
1526 | 1526 | } |
1527 | 1527 | |
@@ -1538,9 +1538,9 @@ discard block |
||
1538 | 1538 | |
1539 | 1539 | //if not posted from the sensei login form let |
1540 | 1540 | // WordPress or any other party handle the failed request |
1541 | - if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form'] ){ |
|
1541 | + if ( ! isset($_REQUEST['form']) || 'sensei-login' != $_REQUEST['form']) { |
|
1542 | 1542 | |
1543 | - return ; |
|
1543 | + return; |
|
1544 | 1544 | |
1545 | 1545 | } |
1546 | 1546 | |
@@ -1548,9 +1548,9 @@ discard block |
||
1548 | 1548 | $referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']); |
1549 | 1549 | |
1550 | 1550 | // if there's a valid referrer, and it's not the default log-in screen |
1551 | - if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){ |
|
1551 | + if ( ! empty($referrer) && ! strstr($referrer, 'wp-login') && ! strstr($referrer, 'wp-admin')) { |
|
1552 | 1552 | // let's append some information (login=failed) to the URL for the theme to use |
1553 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1553 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
1554 | 1554 | exit; |
1555 | 1555 | } |
1556 | 1556 | }// End sensei_login_fail_redirect_to_front_end_login |
@@ -1564,10 +1564,10 @@ discard block |
||
1564 | 1564 | |
1565 | 1565 | |
1566 | 1566 | // Check that it is a sensei login request and if it has a valid nonce |
1567 | - if( isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) { |
|
1567 | + if (isset($_REQUEST['form']) && 'sensei-login' == $_REQUEST['form']) { |
|
1568 | 1568 | |
1569 | 1569 | // Validate the login request nonce |
1570 | - if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){ |
|
1570 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'sensei-login')) { |
|
1571 | 1571 | return; |
1572 | 1572 | } |
1573 | 1573 | |
@@ -1576,47 +1576,47 @@ discard block |
||
1576 | 1576 | $referrer = $_REQUEST['_wp_http_referer']; |
1577 | 1577 | //$redirect = $_REQUEST['_sensei_redirect']; |
1578 | 1578 | |
1579 | - if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) ) |
|
1580 | - && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){ |
|
1579 | + if ((isset($_REQUEST['log']) && ! empty($_REQUEST['log'])) |
|
1580 | + && (isset($_REQUEST['pwd']) && ! empty($_REQUEST['pwd']))) { |
|
1581 | 1581 | |
1582 | 1582 | // when the user has entered a password or username do the sensei login |
1583 | 1583 | $creds = array(); |
1584 | 1584 | |
1585 | 1585 | // check if the requests login is an email address |
1586 | - if( is_email( trim( $_REQUEST['log'] ) ) ){ |
|
1586 | + if (is_email(trim($_REQUEST['log']))) { |
|
1587 | 1587 | // query wordpress for the users details |
1588 | - $user = get_user_by( 'email', sanitize_email( $_REQUEST['log'] ) ); |
|
1588 | + $user = get_user_by('email', sanitize_email($_REQUEST['log'])); |
|
1589 | 1589 | |
1590 | 1590 | // validate the user object |
1591 | - if( !$user ){ |
|
1591 | + if ( ! $user) { |
|
1592 | 1592 | |
1593 | 1593 | // the email doesnt exist |
1594 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1594 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
1595 | 1595 | exit; |
1596 | 1596 | |
1597 | 1597 | } |
1598 | 1598 | |
1599 | 1599 | //assigne the username to the creds array for further processing |
1600 | - $creds['user_login'] = $user->user_login ; |
|
1600 | + $creds['user_login'] = $user->user_login; |
|
1601 | 1601 | |
1602 | - }else{ |
|
1602 | + } else { |
|
1603 | 1603 | |
1604 | 1604 | // process this as a default username login |
1605 | - $creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ; |
|
1605 | + $creds['user_login'] = sanitize_text_field($_REQUEST['log']); |
|
1606 | 1606 | |
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | // get setup the rest of the creds array |
1610 | - $creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] ); |
|
1611 | - $creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ; |
|
1610 | + $creds['user_password'] = sanitize_text_field($_REQUEST['pwd']); |
|
1611 | + $creds['remember'] = isset($_REQUEST['rememberme']) ? true : false; |
|
1612 | 1612 | |
1613 | 1613 | //attempt logging in with the given details |
1614 | - $user = wp_signon( $creds, false ); |
|
1614 | + $user = wp_signon($creds, false); |
|
1615 | 1615 | |
1616 | - if ( is_wp_error($user) ){ // on login failure |
|
1617 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1616 | + if (is_wp_error($user)) { // on login failure |
|
1617 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
1618 | 1618 | exit; |
1619 | - }else{ // on login success |
|
1619 | + } else { // on login success |
|
1620 | 1620 | |
1621 | 1621 | /** |
1622 | 1622 | * change the redirect url programatically |
@@ -1626,21 +1626,21 @@ discard block |
||
1626 | 1626 | * @param string $referrer the page where the current url wheresensei login form was posted from |
1627 | 1627 | */ |
1628 | 1628 | |
1629 | - $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) ); |
|
1629 | + $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg('login', $referrer)); |
|
1630 | 1630 | |
1631 | - wp_redirect( esc_url_raw( $success_redirect_url ) ); |
|
1631 | + wp_redirect(esc_url_raw($success_redirect_url)); |
|
1632 | 1632 | exit; |
1633 | 1633 | |
1634 | 1634 | } // end is_wp_error($user) |
1635 | 1635 | |
1636 | - }else{ // if username or password is empty |
|
1636 | + } else { // if username or password is empty |
|
1637 | 1637 | |
1638 | - wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) ); |
|
1638 | + wp_redirect(esc_url_raw(add_query_arg('login', 'emptyfields', $referrer))); |
|
1639 | 1639 | exit; |
1640 | 1640 | |
1641 | 1641 | } // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty |
1642 | 1642 | |
1643 | - }elseif( ( isset( $_GET['login'] ) ) ) { |
|
1643 | + }elseif ((isset($_GET['login']))) { |
|
1644 | 1644 | // else if this request is a redircect from a previously faile login request |
1645 | 1645 | $this->login_message_process(); |
1646 | 1646 | |
@@ -1659,87 +1659,87 @@ discard block |
||
1659 | 1659 | * @return void redirect |
1660 | 1660 | * |
1661 | 1661 | */ |
1662 | - public function sensei_process_registration(){ |
|
1662 | + public function sensei_process_registration() { |
|
1663 | 1663 | global $current_user; |
1664 | 1664 | // check the for the sensei specific registration requests |
1665 | - if( !isset( $_POST['sensei_reg_username'] ) && ! isset( $_POST['sensei_reg_email'] ) && !isset( $_POST['sensei_reg_password'] )){ |
|
1665 | + if ( ! isset($_POST['sensei_reg_username']) && ! isset($_POST['sensei_reg_email']) && ! isset($_POST['sensei_reg_password'])) { |
|
1666 | 1666 | // exit functionas this is not a sensei registration request |
1667 | - return ; |
|
1667 | + return; |
|
1668 | 1668 | } |
1669 | 1669 | // check for spam throw cheating huh |
1670 | - if( isset( $_POST['email_2'] ) && '' !== $_POST['email_2'] ){ |
|
1670 | + if (isset($_POST['email_2']) && '' !== $_POST['email_2']) { |
|
1671 | 1671 | $message = 'Error: The spam field should be empty'; |
1672 | - Sensei()->notices->add_notice( $message, 'alert'); |
|
1672 | + Sensei()->notices->add_notice($message, 'alert'); |
|
1673 | 1673 | return; |
1674 | 1674 | } |
1675 | 1675 | |
1676 | 1676 | // retreive form variables |
1677 | - $new_user_name = sanitize_user( $_POST['sensei_reg_username'] ); |
|
1678 | - $new_user_email = $_POST['sensei_reg_email']; |
|
1679 | - $new_user_password = $_POST['sensei_reg_password']; |
|
1677 | + $new_user_name = sanitize_user($_POST['sensei_reg_username']); |
|
1678 | + $new_user_email = $_POST['sensei_reg_email']; |
|
1679 | + $new_user_password = $_POST['sensei_reg_password']; |
|
1680 | 1680 | |
1681 | 1681 | // Check the username |
1682 | 1682 | $username_error_notice = ''; |
1683 | - if ( $new_user_name == '' ) { |
|
1684 | - $username_error_notice = __( '<strong>ERROR</strong>: Please enter a username.' ); |
|
1685 | - } elseif ( ! validate_username( $new_user_name ) ) { |
|
1686 | - $username_error_notice = __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ); |
|
1687 | - } elseif ( username_exists( $new_user_name ) ) { |
|
1688 | - $username_error_notice = __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ); |
|
1683 | + if ($new_user_name == '') { |
|
1684 | + $username_error_notice = __('<strong>ERROR</strong>: Please enter a username.'); |
|
1685 | + } elseif ( ! validate_username($new_user_name)) { |
|
1686 | + $username_error_notice = __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.'); |
|
1687 | + } elseif (username_exists($new_user_name)) { |
|
1688 | + $username_error_notice = __('<strong>ERROR</strong>: This username is already registered. Please choose another one.'); |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | // exit on username error |
1692 | - if( '' !== $username_error_notice ){ |
|
1693 | - Sensei()->notices->add_notice( $username_error_notice , 'alert'); |
|
1692 | + if ('' !== $username_error_notice) { |
|
1693 | + Sensei()->notices->add_notice($username_error_notice, 'alert'); |
|
1694 | 1694 | return; |
1695 | 1695 | } |
1696 | 1696 | |
1697 | 1697 | // Check the e-mail address |
1698 | 1698 | $email_error_notice = ''; |
1699 | - if ( $new_user_email == '' ) { |
|
1700 | - $email_error_notice = __( '<strong>ERROR</strong>: Please type your e-mail address.' ); |
|
1701 | - } elseif ( ! is_email( $new_user_email ) ) { |
|
1702 | - $email_error_notice = __( '<strong>ERROR</strong>: The email address isn’t correct.' ); |
|
1703 | - } elseif ( email_exists( $new_user_email ) ) { |
|
1704 | - $email_error_notice = __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ); |
|
1699 | + if ($new_user_email == '') { |
|
1700 | + $email_error_notice = __('<strong>ERROR</strong>: Please type your e-mail address.'); |
|
1701 | + } elseif ( ! is_email($new_user_email)) { |
|
1702 | + $email_error_notice = __('<strong>ERROR</strong>: The email address isn’t correct.'); |
|
1703 | + } elseif (email_exists($new_user_email)) { |
|
1704 | + $email_error_notice = __('<strong>ERROR</strong>: This email is already registered, please choose another one.'); |
|
1705 | 1705 | } |
1706 | 1706 | |
1707 | 1707 | // exit on email address error |
1708 | - if( '' !== $email_error_notice ){ |
|
1709 | - Sensei()->notices->add_notice( $email_error_notice , 'alert'); |
|
1708 | + if ('' !== $email_error_notice) { |
|
1709 | + Sensei()->notices->add_notice($email_error_notice, 'alert'); |
|
1710 | 1710 | return; |
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | //check user password |
1714 | 1714 | |
1715 | 1715 | // exit on email address error |
1716 | - if( empty( $new_user_password ) ){ |
|
1717 | - Sensei()->notices->add_notice( __( '<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.' ) , 'alert'); |
|
1716 | + if (empty($new_user_password)) { |
|
1717 | + Sensei()->notices->add_notice(__('<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.'), 'alert'); |
|
1718 | 1718 | return; |
1719 | 1719 | } |
1720 | 1720 | |
1721 | 1721 | // register user |
1722 | - $user_id = wp_create_user( $new_user_name, $new_user_password, $new_user_email ); |
|
1723 | - if ( ! $user_id || is_wp_error( $user_id ) ) { |
|
1724 | - Sensei()->notices->add_notice( sprintf( __( '<strong>ERROR</strong>: Couldn\'t register you… please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ), 'alert'); |
|
1722 | + $user_id = wp_create_user($new_user_name, $new_user_password, $new_user_email); |
|
1723 | + if ( ! $user_id || is_wp_error($user_id)) { |
|
1724 | + Sensei()->notices->add_notice(sprintf(__('<strong>ERROR</strong>: Couldn\'t register you… please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')), 'alert'); |
|
1725 | 1725 | } |
1726 | 1726 | |
1727 | 1727 | // notify the user |
1728 | - wp_new_user_notification( $user_id, $new_user_password ); |
|
1728 | + wp_new_user_notification($user_id, $new_user_password); |
|
1729 | 1729 | |
1730 | 1730 | // set global current user aka log the user in |
1731 | - $current_user = get_user_by( 'id', $user_id ); |
|
1732 | - wp_set_auth_cookie( $user_id, true ); |
|
1731 | + $current_user = get_user_by('id', $user_id); |
|
1732 | + wp_set_auth_cookie($user_id, true); |
|
1733 | 1733 | |
1734 | 1734 | // Redirect |
1735 | 1735 | global $wp; |
1736 | - if ( wp_get_referer() ) { |
|
1737 | - $redirect = esc_url( wp_get_referer() ); |
|
1736 | + if (wp_get_referer()) { |
|
1737 | + $redirect = esc_url(wp_get_referer()); |
|
1738 | 1738 | } else { |
1739 | - $redirect = esc_url( home_url( $wp->request ) ); |
|
1739 | + $redirect = esc_url(home_url($wp->request)); |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | - wp_redirect( apply_filters( 'sensei_registration_redirect', $redirect ) ); |
|
1742 | + wp_redirect(apply_filters('sensei_registration_redirect', $redirect)); |
|
1743 | 1743 | exit; |
1744 | 1744 | |
1745 | 1745 | } // end sensei_process_registration)() |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | * @return void redirect |
1751 | 1751 | * @since 1.7.0 |
1752 | 1752 | */ |
1753 | - public function login_message_process(){ |
|
1753 | + public function login_message_process() { |
|
1754 | 1754 | |
1755 | 1755 | |
1756 | 1756 | // setup the message variables |
@@ -1758,16 +1758,16 @@ discard block |
||
1758 | 1758 | |
1759 | 1759 | //only output message if the url contains login=failed and login=emptyfields |
1760 | 1760 | |
1761 | - if( $_GET['login'] == 'failed' ){ |
|
1761 | + if ($_GET['login'] == 'failed') { |
|
1762 | 1762 | |
1763 | - $message = __('Incorrect login details', 'woothemes-sensei' ); |
|
1763 | + $message = __('Incorrect login details', 'woothemes-sensei'); |
|
1764 | 1764 | |
1765 | - }elseif( $_GET['login'] == 'emptyfields' ){ |
|
1765 | + }elseif ($_GET['login'] == 'emptyfields') { |
|
1766 | 1766 | |
1767 | - $message= __('Please enter your username and password', 'woothemes-sensei' ); |
|
1767 | + $message = __('Please enter your username and password', 'woothemes-sensei'); |
|
1768 | 1768 | } |
1769 | 1769 | |
1770 | - Sensei()->notices->add_notice( $message, 'alert'); |
|
1770 | + Sensei()->notices->add_notice($message, 'alert'); |
|
1771 | 1771 | |
1772 | 1772 | }// end login_message_process |
1773 | 1773 | |
@@ -1779,11 +1779,11 @@ discard block |
||
1779 | 1779 | * @return void redirect |
1780 | 1780 | * |
1781 | 1781 | */ |
1782 | - public function sensei_show_admin_bar () { |
|
1782 | + public function sensei_show_admin_bar() { |
|
1783 | 1783 | |
1784 | 1784 | if (current_user_can('edit_courses')) { |
1785 | 1785 | |
1786 | - add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
1786 | + add_filter('woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
1787 | 1787 | |
1788 | 1788 | } |
1789 | 1789 | |
@@ -1796,4 +1796,4 @@ discard block |
||
1796 | 1796 | * for backward compatibility |
1797 | 1797 | * @since 1.9.0 |
1798 | 1798 | */ |
1799 | -class WooThemes_Sensei_Frontend extends Sensei_Frontend{} |
|
1799 | +class WooThemes_Sensei_Frontend extends Sensei_Frontend {} |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Sensei Analysis User Profile List Table Class |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | * @since 1.2.0 |
22 | 22 | * @return void |
23 | 23 | */ |
24 | - public function __construct ( $user_id = 0 ) { |
|
25 | - $this->user_id = intval( $user_id ); |
|
24 | + public function __construct($user_id = 0) { |
|
25 | + $this->user_id = intval($user_id); |
|
26 | 26 | |
27 | 27 | // Load Parent token into constructor |
28 | - parent::__construct( 'analysis_user_profile' ); |
|
28 | + parent::__construct('analysis_user_profile'); |
|
29 | 29 | |
30 | 30 | // Actions |
31 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
32 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
31 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
32 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
33 | 33 | |
34 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
34 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
35 | 35 | } // End __construct() |
36 | 36 | |
37 | 37 | /** |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function get_columns() { |
43 | 43 | $columns = array( |
44 | - 'title' => __( 'Course', 'woothemes-sensei' ), |
|
45 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
46 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
47 | - 'status' => __( 'Status', 'woothemes-sensei' ), |
|
44 | + 'title' => __('Course', 'woothemes-sensei'), |
|
45 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
46 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
47 | + 'status' => __('Status', 'woothemes-sensei'), |
|
48 | 48 | // 'grade' => __( 'Grade', 'woothemes-sensei' ), |
49 | - 'percent' => __( 'Percent Complete', 'woothemes-sensei' ), |
|
49 | + 'percent' => __('Percent Complete', 'woothemes-sensei'), |
|
50 | 50 | ); |
51 | - $columns = apply_filters( 'sensei_analysis_user_profile_columns', $columns ); |
|
51 | + $columns = apply_filters('sensei_analysis_user_profile_columns', $columns); |
|
52 | 52 | return $columns; |
53 | 53 | } |
54 | 54 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function get_sortable_columns() { |
61 | 61 | $columns = array( |
62 | - 'title' => array( 'title', false ), |
|
63 | - 'started' => array( 'started', false ), |
|
64 | - 'completed' => array( 'completed', false ), |
|
65 | - 'status' => array( 'status', false ), |
|
62 | + 'title' => array('title', false), |
|
63 | + 'started' => array('started', false), |
|
64 | + 'completed' => array('completed', false), |
|
65 | + 'status' => array('status', false), |
|
66 | 66 | // 'grade' => array( 'grade', false ), |
67 | - 'percent' => array( 'percent', false ) |
|
67 | + 'percent' => array('percent', false) |
|
68 | 68 | ); |
69 | - $columns = apply_filters( 'sensei_analysis_user_profile_columns_sortable', $columns ); |
|
69 | + $columns = apply_filters('sensei_analysis_user_profile_columns_sortable', $columns); |
|
70 | 70 | return $columns; |
71 | 71 | } |
72 | 72 | |
@@ -80,32 +80,32 @@ discard block |
||
80 | 80 | |
81 | 81 | // Handle orderby (needs work) |
82 | 82 | $orderby = ''; |
83 | - if ( !empty( $_GET['orderby'] ) ) { |
|
84 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
85 | - $orderby = esc_html( $_GET['orderby'] ); |
|
83 | + if ( ! empty($_GET['orderby'])) { |
|
84 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
85 | + $orderby = esc_html($_GET['orderby']); |
|
86 | 86 | } // End If Statement |
87 | 87 | } |
88 | 88 | |
89 | 89 | // Handle order |
90 | 90 | $order = 'ASC'; |
91 | - if ( !empty( $_GET['order'] ) ) { |
|
92 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
91 | + if ( ! empty($_GET['order'])) { |
|
92 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
96 | 96 | $search = false; |
97 | - if ( !empty( $_GET['s'] ) ) { |
|
98 | - $search = esc_html( $_GET['s'] ); |
|
97 | + if ( ! empty($_GET['s'])) { |
|
98 | + $search = esc_html($_GET['s']); |
|
99 | 99 | } // End If Statement |
100 | 100 | $this->search = $search; |
101 | 101 | |
102 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
103 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
102 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
103 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
104 | 104 | |
105 | 105 | $paged = $this->get_pagenum(); |
106 | 106 | $offset = 0; |
107 | - if ( !empty($paged) ) { |
|
108 | - $offset = $per_page * ( $paged - 1 ); |
|
107 | + if ( ! empty($paged)) { |
|
108 | + $offset = $per_page * ($paged - 1); |
|
109 | 109 | } // End If Statement |
110 | 110 | |
111 | 111 | $args = array( |
@@ -114,19 +114,19 @@ discard block |
||
114 | 114 | 'orderby' => $orderby, |
115 | 115 | 'order' => $order, |
116 | 116 | ); |
117 | - if ( $this->search ) { |
|
117 | + if ($this->search) { |
|
118 | 118 | $args['search'] = $this->search; |
119 | 119 | } // End If Statement |
120 | 120 | |
121 | - $this->items = $this->get_course_statuses( $args ); |
|
121 | + $this->items = $this->get_course_statuses($args); |
|
122 | 122 | |
123 | 123 | $total_items = $this->total_items; |
124 | - $total_pages = ceil( $total_items / $per_page ); |
|
125 | - $this->set_pagination_args( array( |
|
124 | + $total_pages = ceil($total_items / $per_page); |
|
125 | + $this->set_pagination_args(array( |
|
126 | 126 | 'total_items' => $total_items, |
127 | 127 | 'total_pages' => $total_pages, |
128 | 128 | 'per_page' => $per_page |
129 | - ) ); |
|
129 | + )); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @since 1.7.0 |
135 | 135 | * @return data |
136 | 136 | */ |
137 | - public function generate_report( $report ) { |
|
137 | + public function generate_report($report) { |
|
138 | 138 | |
139 | 139 | $data = array(); |
140 | 140 | |
@@ -142,22 +142,22 @@ discard block |
||
142 | 142 | |
143 | 143 | // Handle orderby |
144 | 144 | $orderby = ''; |
145 | - if ( !empty( $_GET['orderby'] ) ) { |
|
146 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
147 | - $orderby = esc_html( $_GET['orderby'] ); |
|
145 | + if ( ! empty($_GET['orderby'])) { |
|
146 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
147 | + $orderby = esc_html($_GET['orderby']); |
|
148 | 148 | } // End If Statement |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Handle order |
152 | 152 | $order = 'ASC'; |
153 | - if ( !empty( $_GET['order'] ) ) { |
|
154 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
153 | + if ( ! empty($_GET['order'])) { |
|
154 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Handle search |
158 | 158 | $search = false; |
159 | - if ( !empty( $_GET['s'] ) ) { |
|
160 | - $search = esc_html( $_GET['s'] ); |
|
159 | + if ( ! empty($_GET['s'])) { |
|
160 | + $search = esc_html($_GET['s']); |
|
161 | 161 | } // End If Statement |
162 | 162 | $this->search = $search; |
163 | 163 | |
@@ -165,23 +165,23 @@ discard block |
||
165 | 165 | 'orderby' => $orderby, |
166 | 166 | 'order' => $order, |
167 | 167 | ); |
168 | - if ( $this->search ) { |
|
168 | + if ($this->search) { |
|
169 | 169 | $args['search'] = $this->search; |
170 | 170 | } // End If Statement |
171 | 171 | |
172 | 172 | // Start the csv with the column headings |
173 | 173 | $column_headers = array(); |
174 | 174 | $columns = $this->get_columns(); |
175 | - foreach( $columns AS $key => $title ) { |
|
175 | + foreach ($columns AS $key => $title) { |
|
176 | 176 | $column_headers[] = $title; |
177 | 177 | } |
178 | 178 | $data[] = $column_headers; |
179 | 179 | |
180 | - $this->items = $this->get_course_statuses( $args ); |
|
180 | + $this->items = $this->get_course_statuses($args); |
|
181 | 181 | |
182 | 182 | // Process each row |
183 | - foreach( $this->items AS $item) { |
|
184 | - $data[] = $this->get_row_data( $item ); |
|
183 | + foreach ($this->items AS $item) { |
|
184 | + $data[] = $this->get_row_data($item); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | return $data; |
@@ -192,43 +192,43 @@ discard block |
||
192 | 192 | * @since 1.7.0 |
193 | 193 | * @param object $item The current item |
194 | 194 | */ |
195 | - protected function get_row_data( $item ) { |
|
195 | + protected function get_row_data($item) { |
|
196 | 196 | |
197 | - $course_title = get_the_title( $item->comment_post_ID ); |
|
198 | - $course_percent = get_comment_meta( $item->comment_ID, 'percent', true ); |
|
199 | - $course_start_date = get_comment_meta( $item->comment_ID, 'start', true ); |
|
197 | + $course_title = get_the_title($item->comment_post_ID); |
|
198 | + $course_percent = get_comment_meta($item->comment_ID, 'percent', true); |
|
199 | + $course_start_date = get_comment_meta($item->comment_ID, 'start', true); |
|
200 | 200 | $course_end_date = ''; |
201 | 201 | |
202 | - if( 'complete' == $item->comment_approved ) { |
|
202 | + if ('complete' == $item->comment_approved) { |
|
203 | 203 | |
204 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
204 | + $status = __('Completed', 'woothemes-sensei'); |
|
205 | 205 | $status_class = 'graded'; |
206 | 206 | |
207 | 207 | $course_end_date = $item->comment_date; |
208 | 208 | |
209 | 209 | } else { |
210 | 210 | |
211 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
211 | + $status = __('In Progress', 'woothemes-sensei'); |
|
212 | 212 | $status_class = 'in-progress'; |
213 | 213 | |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Output users data |
217 | - if ( !$this->csv_output ) { |
|
218 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) ); |
|
217 | + if ( ! $this->csv_output) { |
|
218 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID), admin_url('admin.php')); |
|
219 | 219 | |
220 | - $course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $course_title . '</a></strong>'; |
|
221 | - $status = sprintf( '<span class="%s">%s</span>', $status_class, $status ); |
|
222 | - if ( is_numeric($course_percent) ) { |
|
220 | + $course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.$course_title.'</a></strong>'; |
|
221 | + $status = sprintf('<span class="%s">%s</span>', $status_class, $status); |
|
222 | + if (is_numeric($course_percent)) { |
|
223 | 223 | $course_percent .= '%'; |
224 | 224 | } |
225 | 225 | } // End If Statement |
226 | - $column_data = apply_filters( 'sensei_analysis_user_profile_column_data', array( 'title' => $course_title, |
|
226 | + $column_data = apply_filters('sensei_analysis_user_profile_column_data', array('title' => $course_title, |
|
227 | 227 | 'started' => $course_start_date, |
228 | 228 | 'completed' => $course_end_date, |
229 | 229 | 'status' => $status, |
230 | 230 | 'percent' => $course_percent, |
231 | - ), $item ); |
|
231 | + ), $item); |
|
232 | 232 | |
233 | 233 | return $column_data; |
234 | 234 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @since 1.7.0 |
239 | 239 | * @return array statuses |
240 | 240 | */ |
241 | - private function get_course_statuses( $args ) { |
|
241 | + private function get_course_statuses($args) { |
|
242 | 242 | |
243 | 243 | $activity_args = array( |
244 | 244 | 'user_id' => $this->user_id, |
@@ -250,23 +250,23 @@ discard block |
||
250 | 250 | 'status' => 'any', |
251 | 251 | ); |
252 | 252 | |
253 | - $activity_args = apply_filters( 'sensei_analysis_user_profile_filter_statuses', $activity_args ); |
|
253 | + $activity_args = apply_filters('sensei_analysis_user_profile_filter_statuses', $activity_args); |
|
254 | 254 | |
255 | 255 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
256 | - $this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
256 | + $this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
257 | 257 | |
258 | 258 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
259 | - if ( $this->total_items < $activity_args['offset'] ) { |
|
259 | + if ($this->total_items < $activity_args['offset']) { |
|
260 | 260 | |
261 | - $new_paged = floor( $this->total_items / $activity_args['number'] ); |
|
261 | + $new_paged = floor($this->total_items / $activity_args['number']); |
|
262 | 262 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
263 | 263 | |
264 | 264 | } |
265 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
265 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
266 | 266 | |
267 | 267 | // Need to always return an array, even with only 1 item |
268 | - if ( !is_array($statuses) ) { |
|
269 | - $statuses = array( $statuses ); |
|
268 | + if ( ! is_array($statuses)) { |
|
269 | + $statuses = array($statuses); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | return $statuses; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @return void |
280 | 280 | */ |
281 | 281 | public function no_items() { |
282 | - echo __( 'No courses found.', 'woothemes-sensei' ); |
|
282 | + echo __('No courses found.', 'woothemes-sensei'); |
|
283 | 283 | } // End no_items() |
284 | 284 | |
285 | 285 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @return void |
289 | 289 | */ |
290 | 290 | public function data_table_header() { |
291 | - echo '<strong>' . __( 'Courses', 'woothemes-sensei' ) . '</strong>'; |
|
291 | + echo '<strong>'.__('Courses', 'woothemes-sensei').'</strong>'; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | * @return void |
298 | 298 | */ |
299 | 299 | public function data_table_footer() { |
300 | - $user = get_user_by( 'id', $this->user_id ); |
|
301 | - $report = sanitize_title( $user->display_name ) . '-course-overview'; |
|
302 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
303 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
300 | + $user = get_user_by('id', $this->user_id); |
|
301 | + $report = sanitize_title($user->display_name).'-course-overview'; |
|
302 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
303 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | * @since 1.7.0 |
309 | 309 | * @return void |
310 | 310 | */ |
311 | - public function search_button( $text = '' ) { |
|
312 | - return __( 'Search Courses', 'woothemes-sensei' );; |
|
311 | + public function search_button($text = '') { |
|
312 | + return __('Search Courses', 'woothemes-sensei'); ; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } // End Class |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Sensei_Main |
@@ -142,41 +142,41 @@ discard block |
||
142 | 142 | * @param string $file The base file of the plugin. |
143 | 143 | * @since 1.0.0 |
144 | 144 | */ |
145 | - public function __construct ( $file ) { |
|
145 | + public function __construct($file) { |
|
146 | 146 | |
147 | 147 | // Setup object data |
148 | 148 | $this->file = $file; |
149 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
150 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
151 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
152 | - $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); |
|
149 | + $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file)); |
|
150 | + $this->plugin_path = trailingslashit(dirname($file)); |
|
151 | + $this->template_url = apply_filters('sensei_template_url', 'sensei/'); |
|
152 | + $this->permissions_message = array('title' => __('Permission Denied', 'woothemes-sensei'), 'message' => __('Unfortunately you do not have permissions to access this page.', 'woothemes-sensei')); |
|
153 | 153 | |
154 | 154 | // Initialize the core Sensei functionality |
155 | 155 | $this->init(); |
156 | 156 | |
157 | 157 | // Installation |
158 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
158 | + if (is_admin() && ! defined('DOING_AJAX')) $this->install(); |
|
159 | 159 | |
160 | 160 | // Run this on activation. |
161 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
161 | + register_activation_hook($this->file, array($this, 'activation')); |
|
162 | 162 | |
163 | 163 | // Setup post types. |
164 | 164 | $this->post_types = new Sensei_PostTypes(); |
165 | 165 | $this->post_types->token = 'woothemes-sensei-posttypes'; |
166 | 166 | |
167 | 167 | // Lad the updates class |
168 | - $this->updates = new WooThemes_Sensei_Updates( $this ); |
|
168 | + $this->updates = new WooThemes_Sensei_Updates($this); |
|
169 | 169 | |
170 | 170 | // Setup settings screen. |
171 | 171 | $this->settings = new Sensei_Settings(); |
172 | 172 | $this->settings->token = 'woothemes-sensei-settings'; |
173 | 173 | |
174 | 174 | // Setup Admin Settings data |
175 | - if ( is_admin() ) { |
|
175 | + if (is_admin()) { |
|
176 | 176 | |
177 | 177 | $this->settings->has_tabs = true; |
178 | - $this->settings->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
|
179 | - $this->settings->menu_label = __( 'Settings', 'woothemes-sensei' ); |
|
178 | + $this->settings->name = __('Sensei Settings', 'woothemes-sensei'); |
|
179 | + $this->settings->menu_label = __('Settings', 'woothemes-sensei'); |
|
180 | 180 | $this->settings->page_slug = 'woothemes-sensei-settings'; |
181 | 181 | |
182 | 182 | } // End If Statement |
@@ -204,24 +204,24 @@ discard block |
||
204 | 204 | $this->quiz = $this->post_types->quiz; |
205 | 205 | |
206 | 206 | // load the modules class |
207 | - add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); |
|
207 | + add_action('plugins_loaded', array($this, 'load_modules_class')); |
|
208 | 208 | |
209 | 209 | // Load Learner Management Functionality |
210 | - $this->learners = new Sensei_Learners( $file ); |
|
210 | + $this->learners = new Sensei_Learners($file); |
|
211 | 211 | $this->learners->token = $this->token; |
212 | 212 | |
213 | 213 | // Differentiate between administration and frontend logic. |
214 | - if ( is_admin() ) { |
|
214 | + if (is_admin()) { |
|
215 | 215 | |
216 | 216 | // Load Admin Welcome class |
217 | 217 | new Sensei_Welcome(); |
218 | 218 | |
219 | 219 | // Load Admin Class |
220 | - $this->admin = new Sensei_Admin( $file ); |
|
220 | + $this->admin = new Sensei_Admin($file); |
|
221 | 221 | $this->admin->token = $this->token; |
222 | 222 | |
223 | 223 | // Load Analysis Reports |
224 | - $this->analysis = new Sensei_Analysis( $file ); |
|
224 | + $this->analysis = new Sensei_Analysis($file); |
|
225 | 225 | $this->analysis->token = $this->token; |
226 | 226 | |
227 | 227 | |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | // Load Grading Functionality |
241 | - $this->grading = new Sensei_Grading( $file ); |
|
241 | + $this->grading = new Sensei_Grading($file); |
|
242 | 242 | $this->grading->token = $this->token; |
243 | 243 | |
244 | 244 | // Load Email Class |
245 | - $this->emails = new Sensei_Emails( $file ); |
|
245 | + $this->emails = new Sensei_Emails($file); |
|
246 | 246 | $this->emails->token = $this->token; |
247 | 247 | |
248 | 248 | // Load Learner Profiles Class |
@@ -254,38 +254,38 @@ discard block |
||
254 | 254 | |
255 | 255 | // Force WooCommerce Required Settings |
256 | 256 | $this->set_woocommerce_functionality(); |
257 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
258 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
257 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
258 | + add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support')); |
|
259 | 259 | |
260 | 260 | // WooCommerce Payment Actions |
261 | - add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
262 | - add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
263 | - add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
264 | - add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
265 | - add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
266 | - add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
267 | - add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); |
|
261 | + add_action('woocommerce_payment_complete', array($this, 'sensei_woocommerce_complete_order')); |
|
262 | + add_action('woocommerce_thankyou', array($this, 'sensei_woocommerce_complete_order')); |
|
263 | + add_action('woocommerce_order_status_completed', array($this, 'sensei_woocommerce_complete_order')); |
|
264 | + add_action('woocommerce_order_status_processing', array($this, 'sensei_woocommerce_complete_order')); |
|
265 | + add_action('woocommerce_order_status_cancelled', array($this, 'sensei_woocommerce_cancel_order')); |
|
266 | + add_action('woocommerce_order_status_refunded', array($this, 'sensei_woocommerce_cancel_order')); |
|
267 | + add_action('subscriptions_activated_for_order', array($this, 'sensei_activate_subscription')); |
|
268 | 268 | |
269 | 269 | // WooCommerce Subscriptions Actions |
270 | - add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); |
|
271 | - add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
272 | - add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
273 | - add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
274 | - add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
270 | + add_action('reactivated_subscription', array($this, 'sensei_woocommerce_reactivate_subscription'), 10, 2); |
|
271 | + add_action('subscription_expired', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
272 | + add_action('subscription_end_of_prepaid_term', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
273 | + add_action('cancelled_subscription', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
274 | + add_action('subscription_put_on-hold', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
275 | 275 | |
276 | 276 | // Add Email link to course orders |
277 | - add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); |
|
277 | + add_action('woocommerce_email_after_order_table', array($this, 'sensei_woocommerce_email_course_details'), 10, 1); |
|
278 | 278 | |
279 | 279 | // Filter comment counts |
280 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
280 | + add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2); |
|
281 | 281 | |
282 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
282 | + add_action('body_class', array($this, 'body_class')); |
|
283 | 283 | |
284 | 284 | // Check for and activate JetPack LaTeX support |
285 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
285 | + add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules |
|
286 | 286 | |
287 | 287 | // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
288 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
288 | + add_action('init', array($this, 'flush_rewrite_rules'), 101); |
|
289 | 289 | |
290 | 290 | } // End __construct() |
291 | 291 | |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * Load the foundations of Sensei. |
294 | 294 | * @since 1.9.0 |
295 | 295 | */ |
296 | - protected function init(){ |
|
296 | + protected function init() { |
|
297 | 297 | |
298 | 298 | // Localisation |
299 | 299 | $this->load_plugin_textdomain(); |
300 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
300 | + add_action('init', array($this, 'load_localisation'), 0); |
|
301 | 301 | |
302 | 302 | // load the shortcode loader into memory, so as to listen to all for |
303 | 303 | // all shortcodes on the front end |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param $plugin |
315 | 315 | */ |
316 | - public static function activation_flush_rules( $plugin ){ |
|
316 | + public static function activation_flush_rules($plugin) { |
|
317 | 317 | |
318 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
318 | + if (strpos($plugin, '/woothemes-sensei.php') > 0) { |
|
319 | 319 | |
320 | 320 | flush_rewrite_rules(true); |
321 | 321 | |
@@ -335,12 +335,12 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public static function instance() { |
337 | 337 | |
338 | - if ( is_null( self::$_instance ) ) { |
|
338 | + if (is_null(self::$_instance)) { |
|
339 | 339 | |
340 | 340 | //Sensei requires a reference to the main Sensei plugin file |
341 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
341 | + $sensei_main_plugin_file = dirname(dirname(__FILE__)).'/woothemes-sensei.php'; |
|
342 | 342 | |
343 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
343 | + self::$_instance = new self($sensei_main_plugin_file); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @since 1.8.0 |
354 | 354 | */ |
355 | 355 | public function __clone() { |
356 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '2.1' ); |
|
356 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '2.1'); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @since 1.8.0 |
362 | 362 | */ |
363 | 363 | public function __wakeup() { |
364 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '2.1' ); |
|
364 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '2.1'); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function run_updates() { |
374 | 374 | // Run updates if administrator |
375 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
375 | + if (current_user_can('manage_options') || current_user_can('manage_sensei')) { |
|
376 | 376 | |
377 | 377 | $this->updates->update(); |
378 | 378 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function set_woocommerce_functionality() { |
389 | 389 | // Disable guest checkout if a course is in the cart as we need a valid user to store data for |
390 | - add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); |
|
390 | + add_filter('pre_option_woocommerce_enable_guest_checkout', array($this, 'disable_guest_checkout')); |
|
391 | 391 | |
392 | 392 | // Mark orders with virtual products as complete rather then stay processing |
393 | - add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); |
|
393 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'virtual_order_payment_complete'), 10, 2); |
|
394 | 394 | |
395 | 395 | } // End set_woocommerce_functionality() |
396 | 396 | |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | * @param boolean $guest_checkout Current guest checkout setting |
400 | 400 | * @return boolean Modified guest checkout setting |
401 | 401 | */ |
402 | - public function disable_guest_checkout( $guest_checkout ) { |
|
402 | + public function disable_guest_checkout($guest_checkout) { |
|
403 | 403 | global $woocommerce; |
404 | 404 | |
405 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
405 | + if ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
406 | 406 | |
407 | - if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { |
|
408 | - foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { |
|
409 | - if( isset( $product['product_id'] ) ) { |
|
407 | + if (isset($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents) > 0) { |
|
408 | + foreach ($woocommerce->cart->cart_contents as $cart_key => $product) { |
|
409 | + if (isset($product['product_id'])) { |
|
410 | 410 | $args = array( |
411 | 411 | 'posts_per_page' => -1, |
412 | 412 | 'post_type' => 'course', |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | ) |
418 | 418 | ) |
419 | 419 | ); |
420 | - $posts = get_posts( $args ); |
|
421 | - if( $posts && count( $posts ) > 0 ) { |
|
422 | - foreach( $posts as $course ) { |
|
420 | + $posts = get_posts($args); |
|
421 | + if ($posts && count($posts) > 0) { |
|
422 | + foreach ($posts as $course) { |
|
423 | 423 | $guest_checkout = ''; |
424 | 424 | break; |
425 | 425 | } |
@@ -439,17 +439,17 @@ discard block |
||
439 | 439 | * @param int $order_id |
440 | 440 | * @return string |
441 | 441 | **/ |
442 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
443 | - $order = new WC_Order( $order_id ); |
|
444 | - if ( ! isset ( $order ) ) return; |
|
445 | - if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { |
|
442 | + public function virtual_order_payment_complete($order_status, $order_id) { |
|
443 | + $order = new WC_Order($order_id); |
|
444 | + if ( ! isset ($order)) return; |
|
445 | + if ($order_status == 'wc-processing' && ($order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed')) { |
|
446 | 446 | $virtual_order = true; |
447 | 447 | |
448 | - if ( count( $order->get_items() ) > 0 ) { |
|
449 | - foreach( $order->get_items() as $item ) { |
|
450 | - if ( $item['product_id'] > 0 ) { |
|
451 | - $_product = $order->get_product_from_item( $item ); |
|
452 | - if ( ! $_product->is_virtual() ) { |
|
448 | + if (count($order->get_items()) > 0) { |
|
449 | + foreach ($order->get_items() as $item) { |
|
450 | + if ($item['product_id'] > 0) { |
|
451 | + $_product = $order->get_product_from_item($item); |
|
452 | + if ( ! $_product->is_virtual()) { |
|
453 | 453 | $virtual_order = false; |
454 | 454 | break; |
455 | 455 | } // End If Statement |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } // End If Statement |
459 | 459 | |
460 | 460 | // virtual order, mark as completed |
461 | - if ( $virtual_order ) { |
|
461 | + if ($virtual_order) { |
|
462 | 462 | return 'completed'; |
463 | 463 | } // End If Statement |
464 | 464 | } // End If Statement |
@@ -471,21 +471,21 @@ discard block |
||
471 | 471 | * @since 1.0.0 |
472 | 472 | * @return void |
473 | 473 | */ |
474 | - public function register_widgets () { |
|
474 | + public function register_widgets() { |
|
475 | 475 | // Widget List (key => value is filename => widget class). |
476 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
476 | + $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' => 'Course_Component', |
|
477 | 477 | 'lesson-component' => 'Lesson_Component', |
478 | 478 | 'course-categories' => 'Course_Categories', |
479 | - 'category-courses' => 'Category_Courses' ) |
|
479 | + 'category-courses' => 'Category_Courses') |
|
480 | 480 | ); |
481 | - foreach ( $widget_list as $key => $value ) { |
|
482 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . esc_attr( $key ) . '.php' ) ) { |
|
483 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . esc_attr( $key ) . '.php' ); |
|
484 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
481 | + foreach ($widget_list as $key => $value) { |
|
482 | + if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.esc_attr($key).'.php')) { |
|
483 | + require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.esc_attr($key).'.php'); |
|
484 | + register_widget('WooThemes_Sensei_'.$value.'_Widget'); |
|
485 | 485 | } |
486 | 486 | } // End For Loop |
487 | 487 | |
488 | - do_action( 'sensei_register_widgets' ); |
|
488 | + do_action('sensei_register_widgets'); |
|
489 | 489 | } // End register_widgets() |
490 | 490 | |
491 | 491 | /** |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @since 1.0.0 |
495 | 495 | * @return void |
496 | 496 | */ |
497 | - public function load_localisation () { |
|
498 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
497 | + public function load_localisation() { |
|
498 | + load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/'); |
|
499 | 499 | } // End load_localisation() |
500 | 500 | |
501 | 501 | /** |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | * @since 1.0.0 |
505 | 505 | * @return void |
506 | 506 | */ |
507 | - public function load_plugin_textdomain () { |
|
507 | + public function load_plugin_textdomain() { |
|
508 | 508 | $domain = 'woothemes-sensei'; |
509 | 509 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
510 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
511 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
512 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
510 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
511 | + load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'); |
|
512 | + load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/'); |
|
513 | 513 | } // End load_plugin_textdomain() |
514 | 514 | |
515 | 515 | /** |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @since 1.0.0 |
519 | 519 | * @return void |
520 | 520 | */ |
521 | - public function activation () { |
|
521 | + public function activation() { |
|
522 | 522 | $this->register_plugin_version(); |
523 | 523 | } // End activation() |
524 | 524 | |
@@ -529,9 +529,9 @@ discard block |
||
529 | 529 | * @since 1.0.0 |
530 | 530 | * @return void |
531 | 531 | */ |
532 | - public function install () { |
|
533 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
534 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
532 | + public function install() { |
|
533 | + register_activation_hook($this->file, array($this, 'activate_sensei')); |
|
534 | + register_activation_hook($this->file, 'flush_rewrite_rules'); |
|
535 | 535 | } // End install() |
536 | 536 | |
537 | 537 | |
@@ -541,9 +541,9 @@ discard block |
||
541 | 541 | * @since 1.0.0 |
542 | 542 | * @return void |
543 | 543 | */ |
544 | - public function activate_sensei () { |
|
545 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
546 | - update_option( 'sensei_installed', 1 ); |
|
544 | + public function activate_sensei() { |
|
545 | + update_option('skip_install_sensei_pages', 0); |
|
546 | + update_option('sensei_installed', 1); |
|
547 | 547 | } // End activate_sensei() |
548 | 548 | |
549 | 549 | /** |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | * @since 1.0.0 |
553 | 553 | * @return void |
554 | 554 | */ |
555 | - private function register_plugin_version () { |
|
556 | - if ( $this->version != '' ) { |
|
555 | + private function register_plugin_version() { |
|
556 | + if ($this->version != '') { |
|
557 | 557 | |
558 | 558 | // Check previous version to see if forced updates must run |
559 | 559 | // $old_version = get_option( 'woothemes-sensei-version', false ); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | // delete_option( 'woothemes-sensei-force-updates' ); |
564 | 564 | // } |
565 | 565 | |
566 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
566 | + update_option('woothemes-sensei-version', $this->version); |
|
567 | 567 | } |
568 | 568 | } // End register_plugin_version() |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @since 1.0.1 |
574 | 574 | * @return void |
575 | 575 | */ |
576 | - public function ensure_post_thumbnails_support () { |
|
577 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
576 | + public function ensure_post_thumbnails_support() { |
|
577 | + if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); } |
|
578 | 578 | } // End ensure_post_thumbnails_support() |
579 | 579 | |
580 | 580 | |
@@ -586,10 +586,10 @@ discard block |
||
586 | 586 | * @return void |
587 | 587 | * @deprecated |
588 | 588 | */ |
589 | - public function template_loader ( $template = '' ) { |
|
589 | + public function template_loader($template = '') { |
|
590 | 590 | |
591 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
592 | - return Sensei_Templates::template_loader( $template ); |
|
591 | + _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead'); |
|
592 | + return Sensei_Templates::template_loader($template); |
|
593 | 593 | |
594 | 594 | } // End template_loader() |
595 | 595 | |
@@ -599,15 +599,15 @@ discard block |
||
599 | 599 | * @since 1.0.0 |
600 | 600 | * @return string $sensei_plugin_path |
601 | 601 | */ |
602 | - public function plugin_path () { |
|
602 | + public function plugin_path() { |
|
603 | 603 | |
604 | - if ( $this->plugin_path ) { |
|
604 | + if ($this->plugin_path) { |
|
605 | 605 | |
606 | - $sensei_plugin_path = $this->plugin_path; |
|
606 | + $sensei_plugin_path = $this->plugin_path; |
|
607 | 607 | |
608 | - }else{ |
|
608 | + } else { |
|
609 | 609 | |
610 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
610 | + $sensei_plugin_path = plugin_dir_path(__FILE__); |
|
611 | 611 | |
612 | 612 | } |
613 | 613 | |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @param string $page |
624 | 624 | * @return int |
625 | 625 | */ |
626 | - public function get_page_id ( $page ) { |
|
627 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
628 | - return ( $page ) ? $page : -1; |
|
626 | + public function get_page_id($page) { |
|
627 | + $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id')); |
|
628 | + return ($page) ? $page : -1; |
|
629 | 629 | } // End get_page_id() |
630 | 630 | |
631 | 631 | |
@@ -637,18 +637,18 @@ discard block |
||
637 | 637 | * @param array/Object $order_user (default: array()) Specific user's data. |
638 | 638 | * @return void |
639 | 639 | */ |
640 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
640 | + public function woocommerce_course_update($course_id = 0, $order_user = array()) { |
|
641 | 641 | global $current_user; |
642 | 642 | |
643 | - if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return; |
|
643 | + if ( ! isset($current_user) || ! $current_user->ID > 0) return; |
|
644 | 644 | |
645 | 645 | $data_update = false; |
646 | 646 | |
647 | 647 | // Get the product ID |
648 | - $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); |
|
648 | + $wc_post_id = get_post_meta(intval($course_id), '_course_woocommerce_product', true); |
|
649 | 649 | |
650 | 650 | // Check if in the admin |
651 | - if ( is_admin() ) { |
|
651 | + if (is_admin()) { |
|
652 | 652 | $user_login = $order_user['user_login']; |
653 | 653 | $user_email = $order_user['user_email']; |
654 | 654 | $user_url = $order_user['user_url']; |
@@ -661,25 +661,25 @@ discard block |
||
661 | 661 | } // End If Statement |
662 | 662 | |
663 | 663 | // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? |
664 | - $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); |
|
665 | - if( 0 < absint( $course_prerequisite_id ) ) { |
|
666 | - $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); |
|
667 | - if ( ! $prereq_course_complete ) { |
|
664 | + $course_prerequisite_id = (int) get_post_meta($course_id, '_course_prerequisite', true); |
|
665 | + if (0 < absint($course_prerequisite_id)) { |
|
666 | + $prereq_course_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, intval($user_id)); |
|
667 | + if ( ! $prereq_course_complete) { |
|
668 | 668 | // Remove all course user meta |
669 | - return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
669 | + return Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
673 | - $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); |
|
673 | + $is_user_taking_course = Sensei_Utils::user_started_course(intval($course_id), intval($user_id)); |
|
674 | 674 | |
675 | - if( ! $is_user_taking_course ) { |
|
675 | + if ( ! $is_user_taking_course) { |
|
676 | 676 | |
677 | - if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { |
|
677 | + if (Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product($user_email, $user_id, $wc_post_id) && (0 < $wc_post_id)) { |
|
678 | 678 | |
679 | - $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); |
|
679 | + $activity_logged = Sensei_Utils::user_start_course(intval($user_id), intval($course_id)); |
|
680 | 680 | |
681 | 681 | $is_user_taking_course = false; |
682 | - if ( true == $activity_logged ) { |
|
682 | + if (true == $activity_logged) { |
|
683 | 683 | $is_user_taking_course = true; |
684 | 684 | } // End If Statement |
685 | 685 | } // End If Statement |
@@ -697,14 +697,14 @@ discard block |
||
697 | 697 | * @param array $data (default: array()) |
698 | 698 | * @return bool |
699 | 699 | */ |
700 | - public function check_user_permissions ( $page = '', $data = array() ) { |
|
700 | + public function check_user_permissions($page = '', $data = array()) { |
|
701 | 701 | // REFACTOR |
702 | 702 | global $current_user, $post; |
703 | 703 | |
704 | 704 | // if use is not logged in |
705 | - if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') ){ |
|
706 | - $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); |
|
707 | - $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); |
|
705 | + if (empty($current_user->caps) && Sensei()->settings->get('access_permission')) { |
|
706 | + $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei'); |
|
707 | + $this->permissions_message['message'] = sprintf(__('You must be logged in to view this %s'), get_post_type()); |
|
708 | 708 | return; |
709 | 709 | } |
710 | 710 | |
@@ -714,104 +714,104 @@ discard block |
||
714 | 714 | |
715 | 715 | $user_allowed = false; |
716 | 716 | |
717 | - switch ( $page ) { |
|
717 | + switch ($page) { |
|
718 | 718 | case 'course-single': |
719 | 719 | // check for prerequisite course or lesson, |
720 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); |
|
721 | - $update_course = $this->woocommerce_course_update( $post->ID ); |
|
720 | + $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true); |
|
721 | + $update_course = $this->woocommerce_course_update($post->ID); |
|
722 | 722 | // Count completed lessons |
723 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
723 | + if (0 < absint($course_prerequisite_id)) { |
|
724 | 724 | |
725 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
725 | + $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID); |
|
726 | 726 | |
727 | 727 | } |
728 | 728 | else { |
729 | 729 | $prerequisite_complete = true; |
730 | 730 | } // End If Statement |
731 | 731 | // Handles restrictions |
732 | - if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { |
|
733 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
734 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
735 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); |
|
732 | + if ( ! $prerequisite_complete && 0 < absint($course_prerequisite_id)) { |
|
733 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
734 | + $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
735 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link); |
|
736 | 736 | } else { |
737 | 737 | $user_allowed = true; |
738 | 738 | } // End If Statement |
739 | 739 | break; |
740 | 740 | case 'lesson-single': |
741 | 741 | // Check for WC purchase |
742 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
742 | + $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
743 | 743 | |
744 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
745 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
746 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
744 | + $update_course = $this->woocommerce_course_update($lesson_course_id); |
|
745 | + $is_preview = Sensei_Utils::is_preview_lesson($post->ID); |
|
746 | + if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
747 | 747 | $user_allowed = true; |
748 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
748 | + } elseif ($this->access_settings() && false == $is_preview) { |
|
749 | 749 | |
750 | 750 | $user_allowed = true; |
751 | 751 | } else { |
752 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
753 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
754 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
755 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
756 | - if ( $is_preview ) { |
|
757 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
752 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
753 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
754 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
755 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
756 | + if ($is_preview) { |
|
757 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
758 | 758 | } else { |
759 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
759 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link); |
|
760 | 760 | } |
761 | 761 | } else { |
762 | - if ( $is_preview ) { |
|
763 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
762 | + if ($is_preview) { |
|
763 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
764 | 764 | } else { |
765 | 765 | /** This filter is documented in class-woothemes-sensei-frontend.php */ |
766 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
766 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
767 | 767 | } |
768 | 768 | } // End If Statement |
769 | 769 | } // End If Statement |
770 | 770 | break; |
771 | 771 | case 'quiz-single': |
772 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
773 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
772 | + $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true); |
|
773 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
774 | 774 | |
775 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
776 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
775 | + $update_course = $this->woocommerce_course_update($lesson_course_id); |
|
776 | + if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) { |
|
777 | 777 | |
778 | 778 | // Check for prerequisite lesson for this quiz |
779 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
780 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
779 | + $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
780 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID); |
|
781 | 781 | |
782 | 782 | // Handle restrictions |
783 | - if( sensei_all_access() ) { |
|
783 | + if (sensei_all_access()) { |
|
784 | 784 | $user_allowed = true; |
785 | 785 | } else { |
786 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
787 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
788 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
789 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
786 | + if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) { |
|
787 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
788 | + $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>'; |
|
789 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link); |
|
790 | 790 | } else { |
791 | 791 | $user_allowed = true; |
792 | 792 | } // End If Statement |
793 | 793 | } // End If Statement |
794 | - } elseif( $this->access_settings() ) { |
|
794 | + } elseif ($this->access_settings()) { |
|
795 | 795 | // Check if the user has started the course |
796 | 796 | |
797 | - if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
797 | + if (is_user_logged_in() && ! Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) && (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission']))) { |
|
798 | 798 | |
799 | 799 | $user_allowed = false; |
800 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
801 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
802 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
803 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
804 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
800 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
801 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
802 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
803 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
804 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
805 | 805 | } else { |
806 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
806 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
807 | 807 | } // End If Statement |
808 | 808 | } else { |
809 | 809 | $user_allowed = true; |
810 | 810 | } // End If Statement |
811 | 811 | } else { |
812 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
813 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
814 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
812 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
813 | + $course_link = '<a href="'.esc_url(get_permalink(get_post_meta(get_post_meta($post->ID, '_quiz_lesson', true), '_lesson_course', true))).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
814 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link); |
|
815 | 815 | } // End If Statement |
816 | 816 | break; |
817 | 817 | default: |
@@ -833,14 +833,14 @@ discard block |
||
833 | 833 | * } |
834 | 834 | * @param string $post_id |
835 | 835 | */ |
836 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
836 | + $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID); |
|
837 | 837 | |
838 | 838 | |
839 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
839 | + if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) { |
|
840 | 840 | $user_allowed = true; |
841 | 841 | } |
842 | 842 | |
843 | - return apply_filters( 'sensei_access_permissions', $user_allowed ); |
|
843 | + return apply_filters('sensei_access_permissions', $user_allowed); |
|
844 | 844 | } // End get_placeholder_image() |
845 | 845 | |
846 | 846 | |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | * @access public |
851 | 851 | * @return void |
852 | 852 | */ |
853 | - public function access_settings () { |
|
853 | + public function access_settings() { |
|
854 | 854 | |
855 | - if( sensei_all_access() ) return true; |
|
855 | + if (sensei_all_access()) return true; |
|
856 | 856 | |
857 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
858 | - if ( is_user_logged_in() ) { |
|
857 | + if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) { |
|
858 | + if (is_user_logged_in()) { |
|
859 | 859 | return true; |
860 | 860 | } else { |
861 | 861 | return false; |
@@ -872,38 +872,38 @@ discard block |
||
872 | 872 | * @param int $order_id WC order ID |
873 | 873 | * @return void |
874 | 874 | */ |
875 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
875 | + public function sensei_woocommerce_complete_order($order_id = 0) { |
|
876 | 876 | $order_user = array(); |
877 | 877 | // Check for WooCommerce |
878 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { |
|
878 | + if (Sensei_WC::is_woocommerce_active() && (0 < $order_id)) { |
|
879 | 879 | // Get order object |
880 | - $order = new WC_Order( $order_id ); |
|
881 | - $user = get_user_by( 'id', $order->user_id ); |
|
880 | + $order = new WC_Order($order_id); |
|
881 | + $user = get_user_by('id', $order->user_id); |
|
882 | 882 | $order_user['ID'] = $user->ID; |
883 | 883 | $order_user['user_login'] = $user->user_login; |
884 | 884 | $order_user['user_email'] = $user->user_email; |
885 | 885 | $order_user['user_url'] = $user->user_url; |
886 | 886 | // Run through each product ordered |
887 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
888 | - foreach( $order->get_items() as $item ) { |
|
887 | + if (0 < sizeof($order->get_items())) { |
|
888 | + foreach ($order->get_items() as $item) { |
|
889 | 889 | $product_type = ''; |
890 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
890 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
891 | 891 | $item_id = $item['variation_id']; |
892 | 892 | $product_type = 'variation'; |
893 | 893 | } else { |
894 | 894 | $item_id = $item['product_id']; |
895 | 895 | } // End If Statement |
896 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
896 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
897 | 897 | // Get courses that use the WC product |
898 | - $courses = $this->post_types->course->get_product_courses( $_product->id ); |
|
898 | + $courses = $this->post_types->course->get_product_courses($_product->id); |
|
899 | 899 | // Loop and update those courses |
900 | - foreach ( $courses as $course_item ) { |
|
901 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
900 | + foreach ($courses as $course_item) { |
|
901 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
902 | 902 | } // End For Loop |
903 | 903 | } // End For Loop |
904 | 904 | } // End If Statement |
905 | 905 | // Add meta to indicate that payment has been completed successfully |
906 | - update_post_meta( $order_id, 'sensei_payment_complete', '1' ); |
|
906 | + update_post_meta($order_id, 'sensei_payment_complete', '1'); |
|
907 | 907 | } // End If Statement |
908 | 908 | } // End sensei_woocommerce_complete_order() |
909 | 909 | |
@@ -914,36 +914,36 @@ discard block |
||
914 | 914 | * @param integer $order_id order ID |
915 | 915 | * @return void |
916 | 916 | */ |
917 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
917 | + public function sensei_woocommerce_cancel_order($order_id) { |
|
918 | 918 | |
919 | 919 | // Get order object |
920 | - $order = new WC_Order( $order_id ); |
|
920 | + $order = new WC_Order($order_id); |
|
921 | 921 | |
922 | 922 | // Run through each product ordered |
923 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
923 | + if (0 < sizeof($order->get_items())) { |
|
924 | 924 | |
925 | 925 | // Get order user |
926 | - $user_id = $order->__get( 'user_id' ); |
|
926 | + $user_id = $order->__get('user_id'); |
|
927 | 927 | |
928 | - foreach( $order->get_items() as $item ) { |
|
928 | + foreach ($order->get_items() as $item) { |
|
929 | 929 | |
930 | 930 | $product_type = ''; |
931 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
931 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
932 | 932 | $item_id = $item['variation_id']; |
933 | 933 | $product_type = 'variation'; |
934 | 934 | } else { |
935 | 935 | $item_id = $item['product_id']; |
936 | 936 | } // End If Statement |
937 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
937 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
938 | 938 | |
939 | 939 | // Get courses that use the WC product |
940 | 940 | $courses = array(); |
941 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
941 | + $courses = $this->post_types->course->get_product_courses($item_id); |
|
942 | 942 | |
943 | 943 | // Loop and update those courses |
944 | - foreach ($courses as $course_item){ |
|
944 | + foreach ($courses as $course_item) { |
|
945 | 945 | // Check and Remove course from courses user meta |
946 | - $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); |
|
946 | + $dataset_changes = Sensei_Utils::sensei_remove_user_from_course($course_item->ID, $user_id); |
|
947 | 947 | } // End For Loop |
948 | 948 | } // End For Loop |
949 | 949 | } // End If Statement |
@@ -957,9 +957,9 @@ discard block |
||
957 | 957 | * @param integer $subscription_key Subscription Unique Key |
958 | 958 | * @return void |
959 | 959 | */ |
960 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { |
|
961 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
962 | - self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); |
|
960 | + public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) { |
|
961 | + $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key); |
|
962 | + self::sensei_woocommerce_cancel_order($subscription['order_id']); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | /** |
@@ -970,18 +970,18 @@ discard block |
||
970 | 970 | * @param integer $subscription_key Subscription Unique Key |
971 | 971 | * @return void |
972 | 972 | */ |
973 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { |
|
974 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
975 | - $order = new WC_Order( $subscription['order_id'] ); |
|
976 | - $user = get_user_by( 'id', $order->user_id ); |
|
973 | + public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) { |
|
974 | + $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key); |
|
975 | + $order = new WC_Order($subscription['order_id']); |
|
976 | + $user = get_user_by('id', $order->user_id); |
|
977 | 977 | $order_user = array(); |
978 | 978 | $order_user['ID'] = $user->ID; |
979 | 979 | $order_user['user_login'] = $user->user_login; |
980 | 980 | $order_user['user_email'] = $user->user_email; |
981 | 981 | $order_user['user_url'] = $user->user_url; |
982 | - $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); |
|
983 | - foreach ( $courses as $course_item ){ |
|
984 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
982 | + $courses = $this->post_types->course->get_product_courses($subscription['product_id']); |
|
983 | + foreach ($courses as $course_item) { |
|
984 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
985 | 985 | } // End For Loop |
986 | 986 | } // End sensei_woocommerce_reactivate_subscription |
987 | 987 | |
@@ -996,30 +996,30 @@ discard block |
||
996 | 996 | * @param string $product_type '' or 'variation' |
997 | 997 | * @return WC_Product $wc_product_object |
998 | 998 | */ |
999 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
999 | + public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') { |
|
1000 | 1000 | |
1001 | 1001 | $wc_product_object = false; |
1002 | - if ( 0 < intval( $wc_product_id ) ) { |
|
1002 | + if (0 < intval($wc_product_id)) { |
|
1003 | 1003 | |
1004 | 1004 | // Get the product |
1005 | - if ( function_exists( 'wc_get_product' ) ) { |
|
1005 | + if (function_exists('wc_get_product')) { |
|
1006 | 1006 | |
1007 | - $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 |
|
1007 | + $wc_product_object = wc_get_product($wc_product_id); // Post WC 2.3 |
|
1008 | 1008 | |
1009 | - } elseif ( function_exists( 'get_product' ) ) { |
|
1009 | + } elseif (function_exists('get_product')) { |
|
1010 | 1010 | |
1011 | - $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 |
|
1011 | + $wc_product_object = get_product($wc_product_id); // Post WC 2.0 |
|
1012 | 1012 | |
1013 | 1013 | } else { |
1014 | 1014 | |
1015 | 1015 | // Pre WC 2.0 |
1016 | - if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { |
|
1016 | + if ('variation' == $product_type || 'subscription_variation' == $product_type) { |
|
1017 | 1017 | |
1018 | - $wc_product_object = new WC_Product_Variation( $wc_product_id ); |
|
1018 | + $wc_product_object = new WC_Product_Variation($wc_product_id); |
|
1019 | 1019 | |
1020 | 1020 | } else { |
1021 | 1021 | |
1022 | - $wc_product_object = new WC_Product( $wc_product_id ); |
|
1022 | + $wc_product_object = new WC_Product($wc_product_id); |
|
1023 | 1023 | |
1024 | 1024 | } // End If Statement |
1025 | 1025 | |
@@ -1037,9 +1037,9 @@ discard block |
||
1037 | 1037 | * @access public |
1038 | 1038 | * @return void |
1039 | 1039 | */ |
1040 | - public function load_class ( $class_name = '' ) { |
|
1041 | - if ( '' != $class_name && '' != $this->token ) { |
|
1042 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
1040 | + public function load_class($class_name = '') { |
|
1041 | + if ('' != $class_name && '' != $this->token) { |
|
1042 | + require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php'); |
|
1043 | 1043 | } // End If Statement |
1044 | 1044 | } // End load_class() |
1045 | 1045 | |
@@ -1050,17 +1050,17 @@ discard block |
||
1050 | 1050 | * @param integer $order_id order ID |
1051 | 1051 | * @return void |
1052 | 1052 | */ |
1053 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
1054 | - if ( 0 < intval( $order_id ) ) { |
|
1055 | - $order = new WC_Order( $order_id ); |
|
1053 | + public function sensei_activate_subscription($order_id = 0) { |
|
1054 | + if (0 < intval($order_id)) { |
|
1055 | + $order = new WC_Order($order_id); |
|
1056 | 1056 | $user = get_user_by('id', $order->user_id); |
1057 | 1057 | $order_user['ID'] = $user->ID; |
1058 | 1058 | $order_user['user_login'] = $user->user_login; |
1059 | 1059 | $order_user['user_email'] = $user->user_email; |
1060 | 1060 | $order_user['user_url'] = $user->user_url; |
1061 | 1061 | // Run through each product ordered |
1062 | - if (sizeof($order->get_items())>0) { |
|
1063 | - foreach($order->get_items() as $item) { |
|
1062 | + if (sizeof($order->get_items()) > 0) { |
|
1063 | + foreach ($order->get_items() as $item) { |
|
1064 | 1064 | $product_type = ''; |
1065 | 1065 | if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
1066 | 1066 | $item_id = $item['variation_id']; |
@@ -1068,15 +1068,15 @@ discard block |
||
1068 | 1068 | } else { |
1069 | 1069 | $item_id = $item['product_id']; |
1070 | 1070 | } // End If Statement |
1071 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
1071 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
1072 | 1072 | // Get courses that use the WC product |
1073 | 1073 | $courses = array(); |
1074 | - if ( $product_type == 'subscription_variation' ) { |
|
1075 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
1074 | + if ($product_type == 'subscription_variation') { |
|
1075 | + $courses = $this->post_types->course->get_product_courses($item_id); |
|
1076 | 1076 | } // End If Statement |
1077 | 1077 | // Loop and update those courses |
1078 | - foreach ($courses as $course_item){ |
|
1079 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1078 | + foreach ($courses as $course_item) { |
|
1079 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
1080 | 1080 | } // End For Loop |
1081 | 1081 | } // End For Loop |
1082 | 1082 | } // End If Statement |
@@ -1090,12 +1090,12 @@ discard block |
||
1090 | 1090 | * @param WC_Order $order |
1091 | 1091 | * @return void |
1092 | 1092 | */ |
1093 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
1093 | + public function sensei_woocommerce_email_course_details($order) { |
|
1094 | 1094 | global $woocommerce; |
1095 | 1095 | |
1096 | 1096 | // exit early if not wc-completed or wc-processing |
1097 | - if( 'wc-completed' != $order->post_status |
|
1098 | - && 'wc-processing' != $order->post_status ) { |
|
1097 | + if ('wc-completed' != $order->post_status |
|
1098 | + && 'wc-processing' != $order->post_status) { |
|
1099 | 1099 | return; |
1100 | 1100 | } |
1101 | 1101 | |
@@ -1103,14 +1103,14 @@ discard block |
||
1103 | 1103 | $order_id = $order->id; |
1104 | 1104 | |
1105 | 1105 | //If object have items go through them all to find course |
1106 | - if ( 0 < sizeof( $order_items ) ) { |
|
1106 | + if (0 < sizeof($order_items)) { |
|
1107 | 1107 | |
1108 | - echo '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; |
|
1108 | + echo '<h2>'.__('Course details', 'woothemes-sensei').'</h2>'; |
|
1109 | 1109 | |
1110 | - foreach ( $order_items as $item ) { |
|
1110 | + foreach ($order_items as $item) { |
|
1111 | 1111 | |
1112 | 1112 | $product_type = ''; |
1113 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1113 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
1114 | 1114 | // If item has variation_id then its from variation |
1115 | 1115 | $item_id = $item['variation_id']; |
1116 | 1116 | $product_type = 'variation'; |
@@ -1119,9 +1119,9 @@ discard block |
||
1119 | 1119 | $item_id = $item['product_id']; |
1120 | 1120 | } // End If Statement |
1121 | 1121 | |
1122 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1122 | + $user_id = get_post_meta($order_id, '_customer_user', true); |
|
1123 | 1123 | |
1124 | - if( $user_id ) { |
|
1124 | + if ($user_id) { |
|
1125 | 1125 | |
1126 | 1126 | // Get all courses for product |
1127 | 1127 | $args = array( |
@@ -1136,16 +1136,16 @@ discard block |
||
1136 | 1136 | 'orderby' => 'menu_order date', |
1137 | 1137 | 'order' => 'ASC', |
1138 | 1138 | ); |
1139 | - $courses = get_posts( $args ); |
|
1139 | + $courses = get_posts($args); |
|
1140 | 1140 | |
1141 | - if( $courses && count( $courses ) > 0 ) { |
|
1141 | + if ($courses && count($courses) > 0) { |
|
1142 | 1142 | |
1143 | - foreach( $courses as $course ) { |
|
1143 | + foreach ($courses as $course) { |
|
1144 | 1144 | |
1145 | 1145 | $title = $course->post_title; |
1146 | - $permalink = get_permalink( $course->ID ); |
|
1146 | + $permalink = get_permalink($course->ID); |
|
1147 | 1147 | |
1148 | - echo '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; |
|
1148 | + echo '<p><strong>'.sprintf(__('View course: %1$s', 'woothemes-sensei'), '</strong><a href="'.esc_url($permalink).'">'.$title.'</a>').'</p>'; |
|
1149 | 1149 | } |
1150 | 1150 | } |
1151 | 1151 | } |
@@ -1161,44 +1161,44 @@ discard block |
||
1161 | 1161 | * @param integer $post_id |
1162 | 1162 | * @return array |
1163 | 1163 | */ |
1164 | - public function sensei_count_comments( $comments, $post_id ) { |
|
1164 | + public function sensei_count_comments($comments, $post_id) { |
|
1165 | 1165 | global $wpdb; |
1166 | 1166 | |
1167 | 1167 | $post_id = (int) $post_id; |
1168 | 1168 | |
1169 | 1169 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
1170 | 1170 | |
1171 | - if ( false !== $count ) { |
|
1171 | + if (false !== $count) { |
|
1172 | 1172 | return $count; |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - $statuses = array( '' ); // Default to the WP normal comments |
|
1176 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
1177 | - foreach ( (array) $stati AS $status ) { |
|
1178 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
1175 | + $statuses = array(''); // Default to the WP normal comments |
|
1176 | + $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A); |
|
1177 | + foreach ((array) $stati AS $status) { |
|
1178 | + if ('sensei_' != substr($status['comment_type'], 0, 7)) { |
|
1179 | 1179 | $statuses[] = $status['comment_type']; |
1180 | 1180 | } |
1181 | 1181 | } |
1182 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
1182 | + $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')"; |
|
1183 | 1183 | |
1184 | - if ( $post_id > 0 ) |
|
1185 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1184 | + if ($post_id > 0) |
|
1185 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
1186 | 1186 | |
1187 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1187 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1188 | 1188 | |
1189 | 1189 | $total = 0; |
1190 | 1190 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
1191 | - foreach ( (array) $count as $row ) { |
|
1191 | + foreach ((array) $count as $row) { |
|
1192 | 1192 | // Don't count post-trashed toward totals |
1193 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
1193 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
1194 | 1194 | $total += $row['num_comments']; |
1195 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
1195 | + if (isset($approved[$row['comment_approved']])) |
|
1196 | 1196 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | $stats['total_comments'] = $total; |
1200 | - foreach ( $approved as $key ) { |
|
1201 | - if ( empty($stats[$key]) ) |
|
1200 | + foreach ($approved as $key) { |
|
1201 | + if (empty($stats[$key])) |
|
1202 | 1202 | $stats[$key] = 0; |
1203 | 1203 | } |
1204 | 1204 | |
@@ -1216,15 +1216,15 @@ discard block |
||
1216 | 1216 | * @return void |
1217 | 1217 | */ |
1218 | 1218 | public function init_image_sizes() { |
1219 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
1220 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
1221 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
1222 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
1223 | - |
|
1224 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
1225 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
1226 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
1227 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
1219 | + $course_archive_thumbnail = $this->get_image_size('course_archive_image'); |
|
1220 | + $course_single_thumbnail = $this->get_image_size('course_single_image'); |
|
1221 | + $lesson_archive_thumbnail = $this->get_image_size('lesson_archive_image'); |
|
1222 | + $lesson_single_thumbnail = $this->get_image_size('lesson_single_image'); |
|
1223 | + |
|
1224 | + add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']); |
|
1225 | + add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']); |
|
1226 | + add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']); |
|
1227 | + add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | /** |
@@ -1237,37 +1237,37 @@ discard block |
||
1237 | 1237 | * @param mixed $image_size |
1238 | 1238 | * @return string |
1239 | 1239 | */ |
1240 | - public function get_image_size( $image_size ) { |
|
1240 | + public function get_image_size($image_size) { |
|
1241 | 1241 | |
1242 | 1242 | // Only return sizes we define in settings |
1243 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
1244 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1243 | + if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image'))) |
|
1244 | + return apply_filters('sensei_get_image_size_'.$image_size, ''); |
|
1245 | 1245 | |
1246 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
1247 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
1246 | + if ( ! isset($this->settings->settings[$image_size.'_width'])) { |
|
1247 | + $this->settings->settings[$image_size.'_width'] = false; |
|
1248 | 1248 | } |
1249 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
1250 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
1249 | + if ( ! isset($this->settings->settings[$image_size.'_height'])) { |
|
1250 | + $this->settings->settings[$image_size.'_height'] = false; |
|
1251 | 1251 | } |
1252 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
1253 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
1252 | + if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) { |
|
1253 | + $this->settings->settings[$image_size.'_hard_crop'] = false; |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | - $size = array_filter( array( |
|
1257 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
1258 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
1259 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
1260 | - ) ); |
|
1256 | + $size = array_filter(array( |
|
1257 | + 'width' => $this->settings->settings[$image_size.'_width'], |
|
1258 | + 'height' => $this->settings->settings[$image_size.'_height'], |
|
1259 | + 'crop' => $this->settings->settings[$image_size.'_hard_crop'] |
|
1260 | + )); |
|
1261 | 1261 | |
1262 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
1263 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
1264 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
1262 | + $size['width'] = isset($size['width']) ? $size['width'] : '100'; |
|
1263 | + $size['height'] = isset($size['height']) ? $size['height'] : '100'; |
|
1264 | + $size['crop'] = isset($size['crop']) ? $size['crop'] : 0; |
|
1265 | 1265 | |
1266 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
1266 | + return apply_filters('sensei_get_image_size_'.$image_size, $size); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | - public function body_class( $classes ) { |
|
1270 | - if( is_sensei() ) { |
|
1269 | + public function body_class($classes) { |
|
1270 | + if (is_sensei()) { |
|
1271 | 1271 | $classes[] = 'sensei'; |
1272 | 1272 | } |
1273 | 1273 | return $classes; |
@@ -1280,9 +1280,9 @@ discard block |
||
1280 | 1280 | * @since 1.7.0 |
1281 | 1281 | */ |
1282 | 1282 | public function jetpack_latex_support() { |
1283 | - if ( function_exists( 'latex_markup') ) { |
|
1284 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
1285 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
1283 | + if (function_exists('latex_markup')) { |
|
1284 | + add_filter('sensei_question_title', 'latex_markup'); |
|
1285 | + add_filter('sensei_answer_text', 'latex_markup'); |
|
1286 | 1286 | } |
1287 | 1287 | } |
1288 | 1288 | |
@@ -1294,21 +1294,21 @@ discard block |
||
1294 | 1294 | * |
1295 | 1295 | * @since 1.8.0 |
1296 | 1296 | */ |
1297 | - public function load_modules_class(){ |
|
1297 | + public function load_modules_class() { |
|
1298 | 1298 | global $sensei_modules; |
1299 | 1299 | |
1300 | - if( !class_exists( 'Sensei_Modules' ) |
|
1301 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
1300 | + if ( ! class_exists('Sensei_Modules') |
|
1301 | + && 'Sensei_Modules' != get_class($sensei_modules)) { |
|
1302 | 1302 | |
1303 | 1303 | //Load the modules class |
1304 | - require_once( 'class-sensei-modules.php'); |
|
1305 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
1304 | + require_once('class-sensei-modules.php'); |
|
1305 | + Sensei()->modules = new Sensei_Core_Modules($this->file); |
|
1306 | 1306 | |
1307 | - }else{ |
|
1307 | + } else { |
|
1308 | 1308 | // fallback for people still using the modules extension. |
1309 | 1309 | global $sensei_modules; |
1310 | 1310 | Sensei()->modules = $sensei_modules; |
1311 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
1311 | + add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30); |
|
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | |
@@ -1317,12 +1317,12 @@ discard block |
||
1317 | 1317 | * |
1318 | 1318 | * @since 1.8.0 |
1319 | 1319 | */ |
1320 | - public function disable_sensei_modules_extension(){ ?> |
|
1320 | + public function disable_sensei_modules_extension() { ?> |
|
1321 | 1321 | <div class="notice updated fade"> |
1322 | 1322 | <p> |
1323 | 1323 | <?php |
1324 | 1324 | $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
1325 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
1325 | + $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> '; |
|
1326 | 1326 | ?> |
1327 | 1327 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
1328 | 1328 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
@@ -1340,18 +1340,18 @@ discard block |
||
1340 | 1340 | * |
1341 | 1341 | * @since 1.9.0 |
1342 | 1342 | */ |
1343 | - public function flush_rewrite_rules(){ |
|
1343 | + public function flush_rewrite_rules() { |
|
1344 | 1344 | |
1345 | 1345 | // ensures that the rewrite rules are flushed on the second |
1346 | 1346 | // attempt. This ensure that the settings for any other process |
1347 | 1347 | // have been completed and saved to the database before we refresh the |
1348 | 1348 | // rewrite rules. |
1349 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
1350 | - if( '1' == $option ) { |
|
1349 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
1350 | + if ('1' == $option) { |
|
1351 | 1351 | |
1352 | 1352 | update_option('sensei_flush_rewrite_rules', '2'); |
1353 | 1353 | |
1354 | - }elseif( '2' == $option ) { |
|
1354 | + }elseif ('2' == $option) { |
|
1355 | 1355 | |
1356 | 1356 | flush_rewrite_rules(); |
1357 | 1357 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | * |
1367 | 1367 | * @since 1.9.0 |
1368 | 1368 | */ |
1369 | - public function initiate_rewrite_rules_flush(){ |
|
1369 | + public function initiate_rewrite_rules_flush() { |
|
1370 | 1370 | |
1371 | 1371 | update_option('sensei_flush_rewrite_rules', '1'); |
1372 | 1372 | |
@@ -1379,4 +1379,4 @@ discard block |
||
1379 | 1379 | * for backward compatibility |
1380 | 1380 | * @since 1.9.0 |
1381 | 1381 | */ |
1382 | -class Woothemes_Sensei extends Sensei_Main{ } |
|
1382 | +class Woothemes_Sensei extends Sensei_Main { } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
3 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
4 | 4 | |
5 | -if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Completed_Course' ) ) : |
|
5 | +if ( ! class_exists('WooThemes_Sensei_Email_Teacher_Completed_Course')) : |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * Teacher Completed Course |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function __construct() { |
33 | 33 | $this->template = 'teacher-completed-course'; |
34 | - $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has completed a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
|
35 | - $this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has completed a course', 'woothemes-sensei' ), $this->template ); |
|
34 | + $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your student has completed a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template); |
|
35 | + $this->heading = apply_filters('sensei_email_heading', __('Your student has completed a course', 'woothemes-sensei'), $this->template); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | * @access public |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - function trigger( $learner_id = 0, $course_id = 0 ) { |
|
44 | + function trigger($learner_id = 0, $course_id = 0) { |
|
45 | 45 | global $sensei_email_data; |
46 | 46 | |
47 | 47 | // Get learner user object |
48 | - $this->learner = new WP_User( $learner_id ); |
|
48 | + $this->learner = new WP_User($learner_id); |
|
49 | 49 | |
50 | 50 | // Get teacher ID and user object |
51 | - $teacher_id = get_post_field( 'post_author', $course_id, 'raw' ); |
|
52 | - $this->teacher = new WP_User( $teacher_id ); |
|
51 | + $teacher_id = get_post_field('post_author', $course_id, 'raw'); |
|
52 | + $this->teacher = new WP_User($teacher_id); |
|
53 | 53 | |
54 | 54 | // Get passed status |
55 | - $passed = __( 'passed', 'woothemes-sensei' ); |
|
56 | - if( ! Sensei_Utils::sensei_user_passed_course( $course_id, $learner_id ) ) { |
|
57 | - $passed = __( 'failed', 'woothemes-sensei' ); |
|
55 | + $passed = __('passed', 'woothemes-sensei'); |
|
56 | + if ( ! Sensei_Utils::sensei_user_passed_course($course_id, $learner_id)) { |
|
57 | + $passed = __('failed', 'woothemes-sensei'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Construct data array |
61 | - $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
61 | + $sensei_email_data = apply_filters('sensei_email_data', array( |
|
62 | 62 | 'template' => $this->template, |
63 | 63 | 'heading' => $this->heading, |
64 | 64 | 'teacher_id' => $teacher_id, |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | 'learner_name' => $this->learner->display_name, |
67 | 67 | 'course_id' => $course_id, |
68 | 68 | 'passed' => $passed, |
69 | - ), $this->template ); |
|
69 | + ), $this->template); |
|
70 | 70 | |
71 | 71 | // Set recipient (learner) |
72 | - $this->recipient = stripslashes( $this->teacher->user_email ); |
|
72 | + $this->recipient = stripslashes($this->teacher->user_email); |
|
73 | 73 | |
74 | 74 | // Send mail |
75 | - Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
75 | + Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template)); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
3 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
4 | 4 | |
5 | -if ( ! class_exists( 'WooThemes_Sensei_Email_Learner_Completed_Course' ) ) : |
|
5 | +if ( ! class_exists('WooThemes_Sensei_Email_Learner_Completed_Course')) : |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * Learner Completed Course |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function __construct() { |
32 | 32 | $this->template = 'learner-completed-course'; |
33 | - $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have completed a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
|
34 | - $this->heading = apply_filters( 'sensei_email_heading', __( 'You have completed a course', 'woothemes-sensei' ), $this->template ); |
|
33 | + $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have completed a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template); |
|
34 | + $this->heading = apply_filters('sensei_email_heading', __('You have completed a course', 'woothemes-sensei'), $this->template); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,32 +40,32 @@ discard block |
||
40 | 40 | * @access public |
41 | 41 | * @return void |
42 | 42 | */ |
43 | - function trigger( $user_id = 0, $course_id = 0 ) { |
|
43 | + function trigger($user_id = 0, $course_id = 0) { |
|
44 | 44 | global $sensei_email_data; |
45 | 45 | |
46 | 46 | // Get learner user object |
47 | - $this->user = new WP_User( $user_id ); |
|
47 | + $this->user = new WP_User($user_id); |
|
48 | 48 | |
49 | 49 | // Get passed status |
50 | - $passed = __( 'passed', 'woothemes-sensei' ); |
|
51 | - if( ! Sensei_Utils::sensei_user_passed_course( $course_id, $user_id ) ) { |
|
52 | - $passed = __( 'failed', 'woothemes-sensei' ); |
|
50 | + $passed = __('passed', 'woothemes-sensei'); |
|
51 | + if ( ! Sensei_Utils::sensei_user_passed_course($course_id, $user_id)) { |
|
52 | + $passed = __('failed', 'woothemes-sensei'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Construct data array |
56 | - $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
56 | + $sensei_email_data = apply_filters('sensei_email_data', array( |
|
57 | 57 | 'template' => $this->template, |
58 | 58 | 'heading' => $this->heading, |
59 | 59 | 'user_id' => $user_id, |
60 | 60 | 'course_id' => $course_id, |
61 | 61 | 'passed' => $passed, |
62 | - ), $this->template ); |
|
62 | + ), $this->template); |
|
63 | 63 | |
64 | 64 | // Set recipient (learner) |
65 | - $this->recipient = stripslashes( $this->user->user_email ); |
|
65 | + $this->recipient = stripslashes($this->user->user_email); |
|
66 | 66 | |
67 | 67 | // Send mail |
68 | - Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
68 | + Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template)); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 |