Completed
Push — master ( 78b9e3...efb4fd )
by Dwain
04:49
created
templates/single-course/lessons.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying all single course meta information.
5 5
  *
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
          * @hooked WooThemes_Sensei_Course::load_single_course_lessons_query
23 23
          * @since 1.9.0
24 24
          */
25
-        do_action( 'sensei_single_course_lessons_before' );
25
+        do_action('sensei_single_course_lessons_before');
26 26
 
27 27
     ?>
28 28
 
29 29
     <?php
30 30
 
31 31
     //lessons loaded into loop in the sensei_single_course_lessons_before hook
32
-    if( have_posts() ):
32
+    if (have_posts()):
33 33
 
34 34
         // start course lessons loop
35
-        while ( have_posts() ): the_post();  ?>
35
+        while (have_posts()): the_post(); ?>
36 36
 
37 37
             <article <?php post_class(); ?> >
38 38
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                      * @hooked WooThemes_Sensei_Lesson::the_lesson_thumbnail - 8
51 51
                      *
52 52
                      */
53
-                    do_action( 'sensei_single_course_inside_before_lesson', get_the_ID() );
53
+                    do_action('sensei_single_course_inside_before_lesson', get_the_ID());
54 54
 
55 55
                 ?>
56 56
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                      *
76 76
                      * @since 1.9.0
77 77
                      */
78
-                    do_action( 'sensei_single_course_inside_after_lesson', get_the_ID() );
78
+                    do_action('sensei_single_course_inside_after_lesson', get_the_ID());
79 79
 
80 80
                 ?>
81 81
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
          *
95 95
          * @since 1.9.0
96 96
          */
97
-        do_action( 'sensei_single_course_lessons_after' );
97
+        do_action('sensei_single_course_lessons_after');
98 98
 
99 99
     ?>
100 100
 
Please login to merge, or discard this patch.
templates/course-results.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
          * @param integer $course_id
43 43
          *
44 44
          */
45
-        do_action( 'sensei_course_results_content_inside_before', $course->ID );
45
+        do_action('sensei_course_results_content_inside_before', $course->ID);
46 46
         ?>
47 47
 
48 48
         <header>
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
         </header>
55 55
 
56
-        <?php if ( is_user_logged_in() ):?>
56
+        <?php if (is_user_logged_in()):?>
57 57
 
58 58
             <?php
59 59
             /**
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
              *
66 66
              * @hooked Sensei_Course_Results::course_info() - 20
67 67
              */
68
-            do_action( 'sensei_course_results_content_inside_before_lessons', $course->ID );
68
+            do_action('sensei_course_results_content_inside_before_lessons', $course->ID);
69 69
             ?>
70 70
 
71 71
 
72 72
             <section class="course-results-lessons">
73 73
                 <?php
74
-                $started_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
75
-                if( $started_course ) {
74
+                $started_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id());
75
+                if ($started_course) {
76 76
 
77 77
                     sensei_the_course_results_lessons();
78 78
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
          *
93 93
          * @hooked Sensei()->course_results->course_info - 20
94 94
          */
95
-        do_action( 'sensei_course_results_content_inside_after', $course->ID );
95
+        do_action('sensei_course_results_content_inside_after', $course->ID);
96 96
         ?>
97 97
 
98 98
     </section>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  * @since 1.9.0
107 107
  *
108 108
  */
109
-do_action( 'sensei_course_results_content_after' );
109
+do_action('sensei_course_results_content_after');
110 110
 ?>
111 111
 
112 112
 
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-shortcode-user-courses.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * This class is loaded int WP by the shortcode loader class.
5 5
  *
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
      * @param string $content
62 62
      * @param string $shortcode the shortcode that was called for this instance
63 63
      */
64
-    public function __construct( $attributes, $content, $shortcode ){
64
+    public function __construct($attributes, $content, $shortcode) {
65 65
 
66
-        if(!  is_user_logged_in() ) {
66
+        if ( ! is_user_logged_in()) {
67 67
             // show the login form
68 68
             Sensei_Templates::get_template('user/login-form.php');
69 69
             return;
70 70
         }
71 71
 
72 72
         // set up all argument need for constructing the course query
73
-        $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10';
74
-        $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title';
75
-        $this->status = isset( $attributes['status'] ) ? $attributes['status'] : 'all';
73
+        $this->number = isset($attributes['number']) ? $attributes['number'] : '10';
74
+        $this->orderby = isset($attributes['orderby']) ? $attributes['orderby'] : 'title';
75
+        $this->status = isset($attributes['status']) ? $attributes['status'] : 'all';
76 76
 
77 77
         // set the default for menu_order to be ASC
78
-        if( 'menu_order' == $this->orderby && !isset( $attributes['order']  ) ){
78
+        if ('menu_order' == $this->orderby && ! isset($attributes['order'])) {
79 79
 
80
-            $this->order =  'ASC';
80
+            $this->order = 'ASC';
81 81
 
82
-        }else{
82
+        } else {
83 83
 
84 84
             // for everything else use the value passed or the default DESC
85
-            $this->order = isset( $attributes['order']  ) ? $attributes['order'] : 'ASC';
85
+            $this->order = isset($attributes['order']) ? $attributes['order'] : 'ASC';
86 86
 
87 87
         }
88 88
 
@@ -96,20 +96,20 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @since 1.9.0
98 98
      */
99
-    protected function setup_course_query(){
99
+    protected function setup_course_query() {
100 100
 
101
-        $status_query = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status' );
102
-        $user_courses_logs = Sensei_Utils::sensei_check_for_activity( $status_query , true );
103
-        if ( !is_array($user_courses_logs) ) {
101
+        $status_query = array('user_id' => get_current_user_id(), 'type' => 'sensei_course_status');
102
+        $user_courses_logs = Sensei_Utils::sensei_check_for_activity($status_query, true);
103
+        if ( ! is_array($user_courses_logs)) {
104 104
 
105
-            $user_courses_logs = array( $user_courses_logs );
105
+            $user_courses_logs = array($user_courses_logs);
106 106
 
107 107
         }
108 108
 
109 109
         $completed_ids = $active_ids = array();
110
-        foreach( $user_courses_logs as $course_status ) {
110
+        foreach ($user_courses_logs as $course_status) {
111 111
 
112
-            if ( Sensei_Utils::user_completed_course( $course_status, get_current_user_id() ) ) {
112
+            if (Sensei_Utils::user_completed_course($course_status, get_current_user_id())) {
113 113
 
114 114
                 $completed_ids[] = $course_status->comment_post_ID;
115 115
 
@@ -120,34 +120,34 @@  discard block
 block discarded – undo
120 120
             }
121 121
         }
122 122
 
123
-        if( 'completed' == $this->status ){
123
+        if ('completed' == $this->status) {
124 124
 
125
-            $included_courses =  $completed_ids;
125
+            $included_courses = $completed_ids;
126 126
 
127 127
 
128
-        }elseif( 'active'==$this->status ){
128
+        }elseif ('active' == $this->status) {
129 129
 
130
-            $included_courses =  $active_ids;
130
+            $included_courses = $active_ids;
131 131
 
132
-        }else{ // all courses
132
+        } else { // all courses
133 133
 
134
-            if( empty( $completed_ids ) ){
134
+            if (empty($completed_ids)) {
135 135
 
136
-                add_action( 'sensei_loop_course_inside_before', array( $this, 'completed_no_course_message_output' ) );
136
+                add_action('sensei_loop_course_inside_before', array($this, 'completed_no_course_message_output'));
137 137
             }
138 138
 
139
-            if( empty( $active_ids ) ){
139
+            if (empty($active_ids)) {
140 140
 
141
-                add_action( 'sensei_loop_course_inside_before', array( $this, 'active_no_course_message_output' ) );
141
+                add_action('sensei_loop_course_inside_before', array($this, 'active_no_course_message_output'));
142 142
 
143 143
             }
144 144
 
145
-            if( empty( $completed_ids ) &&  empty( $active_ids )  ){
145
+            if (empty($completed_ids) && empty($active_ids)) {
146 146
 
147 147
                 $included_courses = array('-1000'); // don't show any courses
148 148
 
149
-            }else{
150
-                $included_courses = Sensei_Utils::array_zip_merge( (array)$active_ids, (array)$completed_ids );
149
+            } else {
150
+                $included_courses = Sensei_Utils::array_zip_merge((array) $active_ids, (array) $completed_ids);
151 151
             }
152 152
 
153 153
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // if the shortcode is not active or in active and the active and completed
159 159
         // tabs show up.
160 160
         $number_of_posts = $this->number;
161
-        if( 'active' != $this->status && 'complete' != $this->status  ){
161
+        if ('active' != $this->status && 'complete' != $this->status) {
162 162
             $number_of_posts = 1000;
163 163
         }
164 164
 
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
             'post_status'      => 'publish',
170 170
             'orderby'          => $this->orderby,
171 171
             'order'            => $this->order,
172
-            'paged' => empty( $query_var_paged )? 1 : $query_var_paged,
172
+            'paged' => empty($query_var_paged) ? 1 : $query_var_paged,
173 173
             'posts_per_page'   => $number_of_posts,
174 174
             'post__in'         => $included_courses,
175 175
         );
176 176
 
177
-        $this->query = new WP_Query( $query_args );
177
+        $this->query = new WP_Query($query_args);
178 178
 
179 179
     }// end setup _course_query
180 180
 
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @since 1.9.0
186 186
      */
187
-    public function completed_no_course_message_output(){
187
+    public function completed_no_course_message_output() {
188 188
         ?>
189 189
         <li class="user-completed">
190 190
             <div class="sensei-message info">
191 191
 
192
-                <?php _e( 'You have not completed any courses yet.', 'woothemes-sensei' ); ?>
192
+                <?php _e('You have not completed any courses yet.', 'woothemes-sensei'); ?>
193 193
 
194 194
             </div>
195 195
         </li>
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
      *
203 203
      * @since 1.9.0
204 204
      */
205
-    public function active_no_course_message_output(){
205
+    public function active_no_course_message_output() {
206 206
         ?>
207 207
 
208 208
         <li class="user-active">
209 209
             <div class="sensei-message info">
210 210
 
211
-                <?php _e( 'You have no active courses.', 'woothemes-sensei' ); ?>
211
+                <?php _e('You have no active courses.', 'woothemes-sensei'); ?>
212 212
 
213
-                <a href="<?php esc_attr_e( Sensei_Course::get_courses_page_url() ); ?>">
213
+                <a href="<?php esc_attr_e(Sensei_Course::get_courses_page_url()); ?>">
214 214
 
215
-                    <?php  _e( 'Start a Course!', 'woothemes-sensei' ); ?>
215
+                    <?php  _e('Start a Course!', 'woothemes-sensei'); ?>
216 216
 
217 217
                 </a>
218 218
 
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return string $content
228 228
      */
229
-    public function render(){
229
+    public function render() {
230 230
 
231 231
         global $wp_query;
232 232
 
233
-        if(!  is_user_logged_in() ) {
233
+        if ( ! is_user_logged_in()) {
234 234
             return '';
235 235
         }
236 236
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         Sensei_Templates::get_template('globals/pagination.php');
250 250
         echo '</section>';
251 251
 
252
-        $shortcode_output =  ob_get_clean();
252
+        $shortcode_output = ob_get_clean();
253 253
 
254 254
         $this->detach_shortcode_hooks();
255 255
 
@@ -265,23 +265,23 @@  discard block
 block discarded – undo
265 265
      *
266 266
      * @since 1.9.0
267 267
      */
268
-    public function attach_shortcode_hooks(){
268
+    public function attach_shortcode_hooks() {
269 269
 
270 270
         // attach the toggle functionality
271 271
         // don't show the toggle action if the user specified complete or active for this shortcode
272
-        if( ! in_array( $this->status, array( 'active', 'complete' ) ) ){
272
+        if ( ! in_array($this->status, array('active', 'complete'))) {
273 273
 
274
-            add_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) );
275
-            add_action( 'wp_footer', array( $this, 'print_course_toggle_actions_inline_script' ), 90 );
274
+            add_action('sensei_loop_course_before', array($this, 'course_toggle_actions'));
275
+            add_action('wp_footer', array($this, 'print_course_toggle_actions_inline_script'), 90);
276 276
 
277 277
         }
278 278
 
279 279
         // add extra classes to distinguish the course based on user completed or active
280
-        add_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 );
280
+        add_filter('sensei_course_loop_content_class', array($this, 'course_status_class_tagging'), 20, 2);
281 281
 
282 282
         // attach progress meter below course
283
-        add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) );
284
-        add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) );
283
+        add_action('sensei_course_content_inside_after', array($this, 'attach_course_progress'));
284
+        add_action('sensei_course_content_inside_after', array($this, 'attach_course_buttons'));
285 285
 
286 286
     }
287 287
 
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
      *
291 291
      * @since 1.9.0
292 292
      */
293
-    public function detach_shortcode_hooks(){
293
+    public function detach_shortcode_hooks() {
294 294
 
295 295
         //remove all hooks after the output is generated
296
-        remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) );
297
-        remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) );
298
-        remove_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 );
299
-        remove_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) );
296
+        remove_action('sensei_course_content_inside_after', array($this, 'attach_course_progress'));
297
+        remove_action('sensei_course_content_inside_after', array($this, 'attach_course_buttons'));
298
+        remove_filter('sensei_course_loop_content_class', array($this, 'course_status_class_tagging'), 20, 2);
299
+        remove_action('sensei_loop_course_before', array($this, 'course_toggle_actions'));
300 300
     }
301 301
 
302 302
     /**
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
      *
305 305
      * @param $course
306 306
      */
307
-    public function attach_course_progress( $course_id ){
307
+    public function attach_course_progress($course_id) {
308 308
 
309
-        $percentage = Sensei()->course->get_completion_percentage( $course_id, get_current_user_id() );
310
-        echo Sensei()->course->get_progress_meter( $percentage );
309
+        $percentage = Sensei()->course->get_completion_percentage($course_id, get_current_user_id());
310
+        echo Sensei()->course->get_progress_meter($percentage);
311 311
 
312 312
     }// attach_course_progress
313 313
 
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
      *
320 320
      * @param integer $course_id
321 321
      */
322
-    public function attach_course_buttons( $course_id ){
322
+    public function attach_course_buttons($course_id) {
323 323
 
324
-        Sensei()->course->the_course_action_buttons( get_post( $course_id ) );
324
+        Sensei()->course->the_course_action_buttons(get_post($course_id));
325 325
 
326 326
     }// attach_course_buttons
327 327
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      * @param WP_Post $course
335 335
      * @return array $classes
336 336
      */
337
-    public function course_status_class_tagging($classes, $course){
337
+    public function course_status_class_tagging($classes, $course) {
338 338
 
339
-        if ( Sensei_Utils::user_completed_course( $course, get_current_user_id() ) ) {
339
+        if (Sensei_Utils::user_completed_course($course, get_current_user_id())) {
340 340
 
341 341
             $classes[] = 'user-completed';
342 342
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     /**
354 354
      * Output the course toggle functionality
355 355
      */
356
-    public function course_toggle_actions(){ ?>
356
+    public function course_toggle_actions() { ?>
357 357
 
358 358
         <section id="user-course-status-toggle">
359 359
             <a id="sensei-user-courses-active-action" href=""><?php _e('Active Courses'); ?></a>
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-legacy-shortcodes.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @since 1.9.0
24 24
      */
25
-    public static function init(){
25
+    public static function init() {
26 26
 
27
-        add_shortcode( 'allcourses',      array( __CLASS__, 'all_courses' ) );
28
-        add_shortcode( 'newcourses',      array( __CLASS__,'new_courses' ) );
29
-        add_shortcode( 'featuredcourses', array( __CLASS__,'featured_courses') );
30
-        add_shortcode( 'freecourses',     array( __CLASS__,'free_courses') );
31
-        add_shortcode( 'paidcourses',     array( __CLASS__,'paid_courses') );
32
-        add_shortcode( 'usercourses',     array( __CLASS__,'user_courses' ) );
27
+        add_shortcode('allcourses', array(__CLASS__, 'all_courses'));
28
+        add_shortcode('newcourses', array(__CLASS__, 'new_courses'));
29
+        add_shortcode('featuredcourses', array(__CLASS__, 'featured_courses'));
30
+        add_shortcode('freecourses', array(__CLASS__, 'free_courses'));
31
+        add_shortcode('paidcourses', array(__CLASS__, 'paid_courses'));
32
+        add_shortcode('usercourses', array(__CLASS__, 'user_courses'));
33 33
 
34 34
     }
35 35
     /**
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
      * @param mixed $content (default: null)
43 43
      * @return string
44 44
      */
45
-    public static function all_courses( $atts, $content = null ) {
45
+    public static function all_courses($atts, $content = null) {
46 46
 
47
-        return self::generate_shortcode_courses( '', 'allcourses' ); // all courses but no title
47
+        return self::generate_shortcode_courses('', 'allcourses'); // all courses but no title
48 48
 
49 49
     } // all_courses()
50 50
 
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      * @param mixed $content (default: null)
57 57
      * @return string
58 58
      */
59
-    public static function paid_courses( $atts, $content = null ) {
59
+    public static function paid_courses($atts, $content = null) {
60 60
 
61
-        return self::generate_shortcode_courses( 'Paid Courses', 'paidcourses' );
61
+        return self::generate_shortcode_courses('Paid Courses', 'paidcourses');
62 62
 
63 63
     } // End paid_courses()
64 64
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      * @param mixed $content (default: null)
72 72
      * @return string
73 73
      */
74
-    public static function featured_courses( $atts, $content = null ) {
74
+    public static function featured_courses($atts, $content = null) {
75 75
 
76
-        return self::generate_shortcode_courses( 'Featured Courses', 'featuredcourses' );
76
+        return self::generate_shortcode_courses('Featured Courses', 'featuredcourses');
77 77
 
78 78
     } // End featured_courses()
79 79
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @param mixed $content (default: null)
86 86
      * @return string
87 87
      */
88
-    public static function free_courses( $atts, $content = null ) {
88
+    public static function free_courses($atts, $content = null) {
89 89
 
90
-        return self::generate_shortcode_courses( 'Free Courses', 'freecourses' );
90
+        return self::generate_shortcode_courses('Free Courses', 'freecourses');
91 91
 
92 92
     } // End free_courses()
93 93
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
      * @param mixed $content (default: null)
100 100
      * @return string
101 101
      */
102
-    public static function new_courses( $atts, $content = null ) {
102
+    public static function new_courses($atts, $content = null) {
103 103
 
104
-        return self::generate_shortcode_courses( 'New Courses', 'newcourses' );
104
+        return self::generate_shortcode_courses('New Courses', 'newcourses');
105 105
 
106 106
     } // End new_courses()
107 107
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @param $shortcode_specific_override
115 115
      * @return string
116 116
      */
117
-    public static function generate_shortcode_courses( $title , $shortcode_specific_override  ){
117
+    public static function generate_shortcode_courses($title, $shortcode_specific_override) {
118 118
 
119 119
         global  $shortcode_override, $posts_array;
120 120
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
         // do not show this short code if there is a shortcode int he url and
124 124
         // this specific shortcode is not the one requested in the ur.
125
-        $specific_shortcode_requested = isset( $_GET['action'] ) ?  sanitize_text_field(  $_GET['action']  ) : '';
126
-        if( ! empty( $specific_shortcode_requested) &&
127
-            $specific_shortcode_requested != $shortcode_override ){
125
+        $specific_shortcode_requested = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
126
+        if ( ! empty($specific_shortcode_requested) &&
127
+            $specific_shortcode_requested != $shortcode_override) {
128 128
 
129 129
             return '';
130 130
 
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
         $courses = ob_get_clean();
137 137
 
138 138
         $content = '';
139
-        if( count( $posts_array ) > 0 ){
139
+        if (count($posts_array) > 0) {
140 140
 
141
-            $before = empty($title)? '' : '<header class="archive-header"><h2>'. $title .'</h2></header>';
141
+            $before = empty($title) ? '' : '<header class="archive-header"><h2>'.$title.'</h2></header>';
142 142
             $before .= '<section id="main-course" class="course-container">';
143 143
 
144 144
             $after = '</section>';
145 145
 
146 146
             //assemble
147
-            $content = $before . $courses . $after;
147
+            $content = $before.$courses.$after;
148 148
 
149 149
         }
150 150
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
      * @param mixed $content (default: null)
162 162
      * @return string
163 163
      */
164
-    public static function user_courses( $atts, $content = null ) {
164
+    public static function user_courses($atts, $content = null) {
165 165
         global $shortcode_override;
166
-        extract( shortcode_atts( array(	'amount' => 0 ), $atts ) );
166
+        extract(shortcode_atts(array('amount' => 0), $atts));
167 167
 
168 168
         $shortcode_override = 'usercourses';
169 169
 
170 170
         ob_start();
171 171
 
172
-        if( is_user_logged_in() ){
172
+        if (is_user_logged_in()) {
173 173
 
174
-            Sensei_Templates::get_template( 'user/my-courses.php' );
174
+            Sensei_Templates::get_template('user/my-courses.php');
175 175
 
176
-        }else{
176
+        } else {
177 177
 
178 178
             Sensei()->frontend->sensei_login_form();
179 179
 
@@ -189,54 +189,54 @@  discard block
 block discarded – undo
189 189
      * loop-course.php for the old shortcodes.
190 190
      * @since 1.9.0
191 191
      */
192
-    public static function initialise_legacy_course_loop(){
192
+    public static function initialise_legacy_course_loop() {
193 193
 
194 194
         global  $post, $wp_query, $shortcode_override, $course_excludes;
195 195
 
196 196
         // Handle Query Type
197 197
         $query_type = '';
198 198
 
199
-        if ( isset( $_GET[ 'action' ] ) && ( '' != esc_html( $_GET[ 'action' ] ) ) ) {
200
-            $query_type = esc_html( $_GET[ 'action' ] );
199
+        if (isset($_GET['action']) && ('' != esc_html($_GET['action']))) {
200
+            $query_type = esc_html($_GET['action']);
201 201
         } // End If Statement
202 202
 
203
-        if ( '' != $shortcode_override ) {
203
+        if ('' != $shortcode_override) {
204 204
             $query_type = $shortcode_override;
205 205
         } // End If Statement
206 206
 
207
-        if ( !is_array( $course_excludes ) ) { $course_excludes = array(); }
207
+        if ( ! is_array($course_excludes)) { $course_excludes = array(); }
208 208
 
209 209
         // Check that query returns results
210 210
         // Handle Pagination
211
-        $paged = $wp_query->get( 'paged' );
212
-        $paged = empty( $paged ) ? 1 : $paged;
211
+        $paged = $wp_query->get('paged');
212
+        $paged = empty($paged) ? 1 : $paged;
213 213
 
214 214
 
215 215
         // Check for pagination settings
216
-        if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
216
+        if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
217 217
 
218
-            $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
218
+            $amount = absint(Sensei()->settings->settings['course_archive_amount']);
219 219
 
220 220
         } else {
221 221
 
222
-            $amount = $wp_query->get( 'posts_per_page' );
222
+            $amount = $wp_query->get('posts_per_page');
223 223
 
224 224
         } // End If Statement
225 225
 
226 226
         // This is not a paginated page (or it's simply the first page of a paginated page/post)
227 227
 
228 228
         global $posts_array;
229
-        $course_includes   = array();
229
+        $course_includes = array();
230 230
 
231
-        $query_args = Sensei()->course->get_archive_query_args( $shortcode_override, $amount, $course_includes, $course_excludes );
232
-        $course_query = new WP_Query( $query_args );
231
+        $query_args = Sensei()->course->get_archive_query_args($shortcode_override, $amount, $course_includes, $course_excludes);
232
+        $course_query = new WP_Query($query_args);
233 233
         $posts_array = $course_query->get_posts();
234 234
 
235 235
         // output the courses
236
-        if( ! empty( $posts_array ) ) {
236
+        if ( ! empty($posts_array)) {
237 237
 
238 238
             //output all courses for current query
239
-            self::loop_courses( $course_query, $amount );
239
+            self::loop_courses($course_query, $amount);
240 240
 
241 241
         }
242 242
 
@@ -249,31 +249,31 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param WP_Query $course_query
251 251
      */
252
-    public static function loop_courses( $course_query, $amount ){
252
+    public static function loop_courses($course_query, $amount) {
253 253
 
254 254
         global $shortcode_override, $posts_array, $post, $wp_query, $shortcode_override, $course_excludes, $course_includes;
255 255
 
256
-        if ( count( $course_query->get_posts() ) > 0 ) {
256
+        if (count($course_query->get_posts()) > 0) {
257 257
 
258
-            do_action( 'sensei_course_archive_header', $shortcode_override );
258
+            do_action('sensei_course_archive_header', $shortcode_override);
259 259
 
260
-            foreach ( $course_query->get_posts() as $course){
260
+            foreach ($course_query->get_posts() as $course) {
261 261
 
262 262
                 // Make sure the other loops dont include the same post twice!
263
-                array_push( $course_excludes, $course->ID );
263
+                array_push($course_excludes, $course->ID);
264 264
 
265 265
                 // output the course markup
266
-                self::the_course( $course->ID );
266
+                self::the_course($course->ID);
267 267
 
268 268
             } // End For Loop
269 269
 
270 270
             // More and Prev links
271
-            $posts_array_query = new WP_Query(Sensei()->course->course_query( $shortcode_override, $amount, $course_includes, $course_excludes ) );
271
+            $posts_array_query = new WP_Query(Sensei()->course->course_query($shortcode_override, $amount, $course_includes, $course_excludes));
272 272
             $posts_array       = $posts_array_query->get_posts();
273 273
             $max_pages = $course_query->found_posts / $amount;
274
-            if ( '' != $shortcode_override && ( $max_pages > $course_query->get( 'paged' ) ) ) {
274
+            if ('' != $shortcode_override && ($max_pages > $course_query->get('paged'))) {
275 275
 
276
-                switch( $shortcode_override ){
276
+                switch ($shortcode_override) {
277 277
                     case 'paidcourses':
278 278
                         $filter = 'paid';
279 279
                         break;
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
                 }
290 290
 
291 291
                 $quer_args = array();
292
-                $quer_args[ 'paged' ] = '2';
293
-                if( !empty( $filter ) ){
294
-                    $quer_args[ 'course_filter' ] = $filter;
292
+                $quer_args['paged'] = '2';
293
+                if ( ! empty($filter)) {
294
+                    $quer_args['course_filter'] = $filter;
295 295
                 }
296 296
 
297
-                $course_pagination_link = get_post_type_archive_link( 'course' );
298
-                $more_link_text = esc_html( Sensei()->settings->settings[ 'course_archive_more_link_text' ] );
299
-                $more_link_url =  esc_url( add_query_arg( $quer_args, $course_pagination_link ) );
297
+                $course_pagination_link = get_post_type_archive_link('course');
298
+                $more_link_text = esc_html(Sensei()->settings->settings['course_archive_more_link_text']);
299
+                $more_link_url = esc_url(add_query_arg($quer_args, $course_pagination_link));
300 300
 
301 301
                 // next/more
302 302
                 $html  = '<div class="navigation"><div class="nav-next">';
303
-                $html .= '<a href="' . $more_link_url . '">';
303
+                $html .= '<a href="'.$more_link_url.'">';
304 304
                 $html .= $more_link_text;
305 305
                 $html .= '<span class="meta-nav"></span></a></div>';
306 306
 
307
-                echo apply_filters( 'course_archive_next_link', $html );
307
+                echo apply_filters('course_archive_next_link', $html);
308 308
 
309 309
             } // End If Statement
310 310
 
@@ -316,23 +316,23 @@  discard block
 block discarded – undo
316 316
      *
317 317
      * @param $course_id
318 318
      */
319
-    public static function the_course( $course_id ){
319
+    public static function the_course($course_id) {
320 320
 
321 321
         // Get meta data
322
-        $course =  get_post( $course_id );
323
-        $user_info = get_userdata( absint( $course->post_author ) );
324
-        $author_link = get_author_posts_url( absint( $course->post_author ) );
322
+        $course = get_post($course_id);
323
+        $user_info = get_userdata(absint($course->post_author));
324
+        $author_link = get_author_posts_url(absint($course->post_author));
325 325
         $author_display_name = $user_info->display_name;
326 326
         $author_id = $course->post_author;
327
-        $category_output = get_the_term_list( $course_id, 'course-category', '', ', ', '' );
328
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course_id ) );
329
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
327
+        $category_output = get_the_term_list($course_id, 'course-category', '', ', ', '');
328
+        $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course_id));
329
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
330 330
         ?>
331 331
 
332
-        <article class="<?php echo esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_id ) ) ); ?>">
332
+        <article class="<?php echo esc_attr(join(' ', get_post_class(array('course', 'post'), $course_id))); ?>">
333 333
             <?php
334 334
             // so that legacy shortcodes work with the party plugins that wants to hook in
335
-            do_action('sensei_course_content_before',$course->ID );
335
+            do_action('sensei_course_content_before', $course->ID);
336 336
             ?>
337 337
             <div class="course-content">
338 338
 
@@ -348,19 +348,19 @@  discard block
 block discarded – undo
348 348
 
349 349
                     <p class="sensei-course-meta">
350 350
 
351
-                        <?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
352
-                            <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo $author_link; ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name   ); ?></a></span>
351
+                        <?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
352
+                            <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo $author_link; ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
353 353
                         <?php } // End If Statement ?>
354 354
 
355 355
                         <span class="course-lesson-count">
356
-                                    <?php echo Sensei()->course->course_lesson_count( $course_id ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?>
356
+                                    <?php echo Sensei()->course->course_lesson_count($course_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?>
357 357
                                 </span>
358 358
 
359
-                        <?php if ( '' != $category_output ) { ?>
360
-                            <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
359
+                        <?php if ('' != $category_output) { ?>
360
+                            <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
361 361
                         <?php } // End If Statement ?>
362 362
 
363
-                        <?php sensei_simple_course_price( $course_id ); ?>
363
+                        <?php sensei_simple_course_price($course_id); ?>
364 364
 
365 365
                     </p>
366 366
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 
369 369
                     </p>
370 370
 
371
-                    <?php if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
372
-                        $preview_lessons = sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ); ?>
371
+                    <?php if (0 < $preview_lesson_count && ! $is_user_taking_course) {
372
+                        $preview_lessons = sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?>
373 373
                         <p class="sensei-free-lessons">
374
-                            <a href="<?php echo get_permalink( $course_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
374
+                            <a href="<?php echo get_permalink($course_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?>
375 375
                             </a> - <?php echo $preview_lessons; ?>
376 376
                         </p>
377 377
                     <?php } ?>
Please login to merge, or discard this patch.
includes/class-sensei-quiz.php 1 patch
Spacing   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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 Quiz Class
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param $file
24 24
 	 */
25
-	public function __construct ( $file = __FILE__ ) {
25
+	public function __construct($file = __FILE__) {
26 26
 		$this->file = $file;
27 27
         $this->token = 'quiz';
28
-		$this->meta_fields = array( 'quiz_passmark', 'quiz_lesson', 'quiz_type', 'quiz_grade_type', 'pass_required','enable_quiz_reset' );
29
-		add_action( 'save_post', array( $this, 'update_author' ));
28
+		$this->meta_fields = array('quiz_passmark', 'quiz_lesson', 'quiz_type', 'quiz_grade_type', 'pass_required', 'enable_quiz_reset');
29
+		add_action('save_post', array($this, 'update_author'));
30 30
 
31 31
 		// listen to the reset button click
32
-		add_action( 'template_redirect', array( $this, 'reset_button_click_listener'  ) );
32
+		add_action('template_redirect', array($this, 'reset_button_click_listener'));
33 33
 
34 34
         // fire the complete quiz button submit for grading action
35
-        add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_quiz_submit_listener' ) );
35
+        add_action('sensei_single_quiz_content_inside_before', array($this, 'user_quiz_submit_listener'));
36 36
 
37 37
 		// fire the save user answers quiz button click responder
38
-		add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_save_quiz_answers_listener' ) );
38
+		add_action('sensei_single_quiz_content_inside_before', array($this, 'user_save_quiz_answers_listener'));
39 39
 
40 40
         // fire the load global data function
41
-        add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'load_global_quiz_data' ), 80 );
41
+        add_action('sensei_single_quiz_content_inside_before', array($this, 'load_global_quiz_data'), 80);
42 42
 
43
-        add_action( 'template_redirect', array ( $this, 'quiz_has_no_questions') );
43
+        add_action('template_redirect', array($this, 'quiz_has_no_questions'));
44 44
 
45 45
 
46 46
     } // End __construct()
@@ -51,25 +51,25 @@  discard block
 block discarded – undo
51 51
 	* @param int $post_id
52 52
 	* @return void
53 53
 	*/
54
-	public function update_author( $post_id ){
54
+	public function update_author($post_id) {
55 55
 
56 56
 		// If this isn't a 'lesson' post, don't update it.
57 57
         // if this is a revision don't save it
58
-	    if ( isset( $_POST['post_type'] ) && 'lesson' != $_POST['post_type']
59
-            || wp_is_post_revision( $post_id ) ) {
58
+	    if (isset($_POST['post_type']) && 'lesson' != $_POST['post_type']
59
+            || wp_is_post_revision($post_id)) {
60 60
 
61 61
                 return;
62 62
 
63 63
         }
64 64
 	    // get the lesson author id to be use late
65
-	    $saved_post = get_post( $post_id );
66
-	    $new_lesson_author_id =  $saved_post->post_author;
65
+	    $saved_post = get_post($post_id);
66
+	    $new_lesson_author_id = $saved_post->post_author;
67 67
 
68 68
 	    //get the lessons quiz
69
-		$lesson_quizzes = Sensei()->lesson->lesson_quizzes( $post_id );
70
-	    foreach ( (array) $lesson_quizzes as $quiz_item ) {
69
+		$lesson_quizzes = Sensei()->lesson->lesson_quizzes($post_id);
70
+	    foreach ((array) $lesson_quizzes as $quiz_item) {
71 71
 
72
-	    	if( ! $quiz_item ) {
72
+	    	if ( ! $quiz_item) {
73 73
 	    		continue;
74 74
 	    	}
75 75
 
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			);
81 81
 
82 82
             // remove the action so that it doesn't fire again
83
-            remove_action( 'save_post', array( $this, 'update_author' ));
83
+            remove_action('save_post', array($this, 'update_author'));
84 84
 
85 85
 			// Update the post into the database
86
-		  	wp_update_post( $my_post );
86
+		  	wp_update_post($my_post);
87 87
 	    }
88 88
 
89 89
 	    return;
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
 	 * @param int $quiz_id
98 98
 	 * @return int @lesson_id
99 99
 	 */
100
-	public function get_lesson_id( $quiz_id ){
100
+	public function get_lesson_id($quiz_id) {
101 101
 
102
-		if( empty( $quiz_id ) || ! intval( $quiz_id ) > 0 ){
102
+		if (empty($quiz_id) || ! intval($quiz_id) > 0) {
103 103
 			global $post;
104
-			if( 'quiz' == get_post_type( $post ) ){
104
+			if ('quiz' == get_post_type($post)) {
105 105
 				$quiz_id = $post->ID;
106
-			}else{
106
+			} else {
107 107
 				return false;
108 108
 			}
109 109
 
110 110
 		}
111 111
 
112
-		$quiz = get_post( $quiz_id );
112
+		$quiz = get_post($quiz_id);
113 113
 		$lesson_id = $quiz->post_parent;
114 114
 
115 115
 		return $lesson_id;
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
      * @since 1.7.3
125 125
      * @return bool $saved;
126 126
      */
127
-    public function user_save_quiz_answers_listener(){
127
+    public function user_save_quiz_answers_listener() {
128 128
 
129
-        if( ! isset( $_POST[ 'quiz_save' ])
130
-            || !isset( $_POST[ 'sensei_question' ] )
131
-            || empty( $_POST[ 'sensei_question' ] )
132
-            ||  ! wp_verify_nonce( $_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce'  ) > 1 ) {
129
+        if ( ! isset($_POST['quiz_save'])
130
+            || ! isset($_POST['sensei_question'])
131
+            || empty($_POST['sensei_question'])
132
+            ||  ! wp_verify_nonce($_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce') > 1) {
133 133
             return;
134 134
         }
135 135
 
136 136
         global $post;
137
-        $lesson_id = $this->get_lesson_id( $post->ID );
138
-        $quiz_answers = $_POST[ 'sensei_question' ];
137
+        $lesson_id = $this->get_lesson_id($post->ID);
138
+        $quiz_answers = $_POST['sensei_question'];
139 139
         // call the save function
140
-        self::save_user_answers( $quiz_answers, $_FILES , $lesson_id  , get_current_user_id() );
140
+        self::save_user_answers($quiz_answers, $_FILES, $lesson_id, get_current_user_id());
141 141
 
142 142
         // remove the hook as it should only fire once per click
143
-        remove_action( 'sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener' );
143
+        remove_action('sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener');
144 144
 
145 145
     } // end user_save_quiz_answers_listener
146 146
 
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return false or int $answers_saved
161 161
 	 */
162
-	public static function save_user_answers( $quiz_answers, $files = array(), $lesson_id , $user_id = 0 ){
162
+	public static function save_user_answers($quiz_answers, $files = array(), $lesson_id, $user_id = 0) {
163 163
 
164
-        if( ! ( $user_id > 0 ) ){
164
+        if ( ! ($user_id > 0)) {
165 165
             $user_id = get_current_user_id();
166 166
         }
167 167
 
168 168
         // make sure the parameters are valid before continuing
169
-		if( empty( $lesson_id ) || empty( $user_id )
170
-			|| 'lesson' != get_post_type( $lesson_id )
171
-			||!get_userdata( $user_id )
172
-			|| !is_array( $quiz_answers ) ){
169
+		if (empty($lesson_id) || empty($user_id)
170
+			|| 'lesson' != get_post_type($lesson_id)
171
+			||! get_userdata($user_id)
172
+			|| ! is_array($quiz_answers)) {
173 173
 
174 174
 			return false;
175 175
 
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
         // start the lesson before saving the data in case the user has not started the lesson
180
-        $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
180
+        $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
181 181
 
182 182
 		//prepare the answers
183
-		$prepared_answers = self::prepare_form_submitted_answers( $quiz_answers , $files );
183
+		$prepared_answers = self::prepare_form_submitted_answers($quiz_answers, $files);
184 184
 
185 185
 		// save the user data
186
-        $answers_saved = Sensei_Utils::add_user_data( 'quiz_answers', $lesson_id, $prepared_answers, $user_id ) ;
186
+        $answers_saved = Sensei_Utils::add_user_data('quiz_answers', $lesson_id, $prepared_answers, $user_id);
187 187
 
188 188
 		// were the answers saved correctly?
189
-		if( intval( $answers_saved ) > 0){
189
+		if (intval($answers_saved) > 0) {
190 190
 
191 191
             // save transient to make retrieval faster
192 192
             $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
193
-            set_transient( $transient_key, $prepared_answers, 10 * DAY_IN_SECONDS );
193
+            set_transient($transient_key, $prepared_answers, 10 * DAY_IN_SECONDS);
194 194
 
195 195
             // update the message showed to user
196
-            Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Saved Successfully.', 'woothemes-sensei' )  . '</div>';
196
+            Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Saved Successfully.', 'woothemes-sensei').'</div>';
197 197
         }
198 198
 
199 199
 		return $answers_saved;
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array $answers or false
217 217
 	 */
218
-	public function get_user_answers( $lesson_id, $user_id ){
218
+	public function get_user_answers($lesson_id, $user_id) {
219 219
 
220 220
 		$answers = false;
221 221
 
222
-		if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
223
-		|| ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
222
+		if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
223
+		|| ! intval($user_id) > 0 || ! get_userdata($user_id)) {
224 224
 			return false;
225 225
 		}
226 226
 
227 227
         // save some time and get the transient cached data
228 228
         $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
229
-        $transient_cached_answers = get_transient( $transient_key );
229
+        $transient_cached_answers = get_transient($transient_key);
230 230
 
231 231
         // return the transient or get the values get the values from the comment meta
232
-        if( !empty( $transient_cached_answers  ) && false != $transient_cached_answers ){
232
+        if ( ! empty($transient_cached_answers) && false != $transient_cached_answers) {
233 233
 
234 234
             $encoded_user_answers = $transient_cached_answers;
235 235
 
236
-        }else{
236
+        } else {
237 237
 
238
-            $encoded_user_answers = Sensei_Utils::get_user_data( 'quiz_answers', $lesson_id  , $user_id );
238
+            $encoded_user_answers = Sensei_Utils::get_user_data('quiz_answers', $lesson_id, $user_id);
239 239
 
240 240
         } // end if transient check
241 241
 
242
-		if( ! is_array( $encoded_user_answers ) ){
242
+		if ( ! is_array($encoded_user_answers)) {
243 243
 			return false;
244 244
 		}
245 245
 
246 246
         //set the transient with the new valid data for faster retrieval in future
247
-        set_transient( $transient_key,  $encoded_user_answers, 10 * DAY_IN_SECONDS);
247
+        set_transient($transient_key, $encoded_user_answers, 10 * DAY_IN_SECONDS);
248 248
 
249 249
 		// decode an unserialize all answers
250
-		foreach( $encoded_user_answers as $question_id => $encoded_answer ) {
251
-			$decoded_answer = base64_decode( $encoded_answer );
252
-			$answers[$question_id] = maybe_unserialize( $decoded_answer );
250
+		foreach ($encoded_user_answers as $question_id => $encoded_answer) {
251
+			$decoded_answer = base64_decode($encoded_answer);
252
+			$answers[$question_id] = maybe_unserialize($decoded_answer);
253 253
 		}
254 254
 
255 255
 		return $answers;
@@ -266,23 +266,23 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return void;
268 268
 	 */
269
-	public function reset_button_click_listener( ){
269
+	public function reset_button_click_listener( ) {
270 270
 
271
-		if( ! isset( $_POST[ 'quiz_reset' ])
272
-			||  ! wp_verify_nonce( $_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce'  ) > 1 ) {
271
+		if ( ! isset($_POST['quiz_reset'])
272
+			||  ! wp_verify_nonce($_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce') > 1) {
273 273
 
274 274
 			return; // exit
275 275
 		}
276 276
 
277 277
 		global $post;
278 278
 		$current_quiz_id = $post->ID;
279
-		$lesson_id = $this->get_lesson_id( $current_quiz_id );
279
+		$lesson_id = $this->get_lesson_id($current_quiz_id);
280 280
 
281 281
         // reset all user data
282
-        $this->reset_user_lesson_data( $lesson_id, get_current_user_id() );
282
+        $this->reset_user_lesson_data($lesson_id, get_current_user_id());
283 283
 
284 284
 		//this function should only run once
285
-		remove_action( 'template_redirect', array( $this, 'reset_button_click_listener'  ) );
285
+		remove_action('template_redirect', array($this, 'reset_button_click_listener'));
286 286
 
287 287
 	} // end reset_button_click_listener
288 288
 
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 	public function user_quiz_submit_listener() {
302 302
 
303 303
         // only respond to valid quiz completion submissions
304
-        if( ! isset( $_POST[ 'quiz_complete' ])
305
-            || !isset( $_POST[ 'sensei_question' ] )
306
-            || empty( $_POST[ 'sensei_question' ] )
307
-            ||  ! wp_verify_nonce( $_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce'  ) > 1 ) {
304
+        if ( ! isset($_POST['quiz_complete'])
305
+            || ! isset($_POST['sensei_question'])
306
+            || empty($_POST['sensei_question'])
307
+            ||  ! wp_verify_nonce($_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce') > 1) {
308 308
             return;
309 309
         }
310 310
 
311 311
         global $post, $current_user;
312
-        $lesson_id = $this->get_lesson_id( $post->ID );
313
-        $quiz_answers = $_POST[ 'sensei_question' ];
312
+        $lesson_id = $this->get_lesson_id($post->ID);
313
+        $quiz_answers = $_POST['sensei_question'];
314 314
 
315
-        self::submit_answers_for_grading( $quiz_answers, $_FILES ,  $lesson_id  , $current_user->ID );
315
+        self::submit_answers_for_grading($quiz_answers, $_FILES, $lesson_id, $current_user->ID);
316 316
 
317 317
 	} // End sensei_complete_quiz()
318 318
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      * @access public
327 327
      *
328 328
      */
329
-    public function load_global_quiz_data(){
329
+    public function load_global_quiz_data() {
330 330
 
331 331
         global  $post, $current_user;
332 332
         $this->data = new stdClass();
@@ -335,46 +335,46 @@  discard block
 block discarded – undo
335 335
         $grade = 0;
336 336
 
337 337
         // Get Quiz Questions
338
-        $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $post->ID );
338
+        $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($post->ID);
339 339
 
340
-        $quiz_lesson_id = absint( get_post_meta( $post->ID, '_quiz_lesson', true ) );
340
+        $quiz_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true));
341 341
 
342 342
         // Get quiz grade type
343
-        $quiz_grade_type = get_post_meta( $post->ID, '_quiz_grade_type', true );
343
+        $quiz_grade_type = get_post_meta($post->ID, '_quiz_grade_type', true);
344 344
 
345 345
         // Get quiz pass setting
346
-        $pass_required = get_post_meta( $post->ID, '_pass_required', true );
346
+        $pass_required = get_post_meta($post->ID, '_pass_required', true);
347 347
 
348 348
         // Get quiz pass mark
349
-        $quiz_passmark = abs( round( doubleval( get_post_meta( $post->ID, '_quiz_passmark', true ) ), 2 ) );
349
+        $quiz_passmark = abs(round(doubleval(get_post_meta($post->ID, '_quiz_passmark', true)), 2));
350 350
 
351 351
         // Get latest quiz answers and grades
352
-        $lesson_id = Sensei()->quiz->get_lesson_id( $post->ID );
353
-        $user_quizzes = Sensei()->quiz->get_user_answers( $lesson_id, get_current_user_id() );
354
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $current_user->ID );
352
+        $lesson_id = Sensei()->quiz->get_lesson_id($post->ID);
353
+        $user_quizzes = Sensei()->quiz->get_user_answers($lesson_id, get_current_user_id());
354
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $current_user->ID);
355 355
         $user_quiz_grade = 0;
356
-        if( isset( $user_lesson_status->comment_ID ) ) {
357
-            $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
356
+        if (isset($user_lesson_status->comment_ID)) {
357
+            $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
358 358
         }
359 359
 
360
-        if ( ! is_array($user_quizzes) ) { $user_quizzes = array(); }
360
+        if ( ! is_array($user_quizzes)) { $user_quizzes = array(); }
361 361
 
362 362
         // Check again that the lesson is complete
363
-        $user_lesson_end = Sensei_Utils::user_completed_lesson( $user_lesson_status );
363
+        $user_lesson_end = Sensei_Utils::user_completed_lesson($user_lesson_status);
364 364
         $user_lesson_complete = false;
365
-        if ( $user_lesson_end ) {
365
+        if ($user_lesson_end) {
366 366
             $user_lesson_complete = true;
367 367
         } // End If Statement
368 368
 
369
-        $reset_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true );
369
+        $reset_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true);
370 370
         //backwards compatibility
371
-        if( 'on' == $reset_allowed ) {
371
+        if ('on' == $reset_allowed) {
372 372
             $reset_allowed = 1;
373 373
         }
374 374
 
375 375
         // Build frontend data object for backwards compatibility
376 376
         // using this is no longer recommended
377
-        $this->data->user_quiz_grade = $user_quiz_grade;// Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
377
+        $this->data->user_quiz_grade = $user_quiz_grade; // Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
378 378
         $this->data->quiz_passmark = $quiz_passmark;
379 379
         $this->data->quiz_lesson = $quiz_lesson_id;
380 380
         $this->data->quiz_grade_type = $quiz_grade_type; // get_post_meta( $quiz_id, '_quiz_grade_type', true );
@@ -399,41 +399,41 @@  discard block
 block discarded – undo
399 399
 	 * @param $files
400 400
 	 * @return array
401 401
 	 */
402
-	public static function prepare_form_submitted_answers( $unprepared_answers,  $files ){
402
+	public static function prepare_form_submitted_answers($unprepared_answers, $files) {
403 403
 
404 404
 
405 405
 		$prepared_answers = array();
406 406
 
407 407
 		// validate incoming answers
408
-		if( empty( $unprepared_answers  ) || ! is_array( $unprepared_answers ) ){
408
+		if (empty($unprepared_answers) || ! is_array($unprepared_answers)) {
409 409
 			return false;
410 410
 		}
411 411
 
412 412
 		// Loop through submitted quiz answers and save them appropriately
413
-		foreach( $unprepared_answers as $question_id => $answer ) {
413
+		foreach ($unprepared_answers as $question_id => $answer) {
414 414
 
415 415
 			//get the current questions question type
416
-            $question_type = Sensei()->question->get_question_type( $question_id );
416
+            $question_type = Sensei()->question->get_question_type($question_id);
417 417
 
418 418
 			// Sanitise answer
419
-			if( 0 == get_magic_quotes_gpc() ) {
420
-				$answer = wp_unslash( $answer );
419
+			if (0 == get_magic_quotes_gpc()) {
420
+				$answer = wp_unslash($answer);
421 421
 			}
422 422
 
423 423
             // compress the answer for saving
424
-			if( 'multi-line' == $question_type ) {
425
-                $answer = esc_html( $answer );
426
-            }elseif( 'file-upload' == $question_type  ){
427
-                $file_key = 'file_upload_' . $question_id;
428
-                if( isset( $files[ $file_key ] ) ) {
429
-                        $attachment_id = Sensei_Utils::upload_file(  $files[ $file_key ] );
430
-                        if( $attachment_id ) {
424
+			if ('multi-line' == $question_type) {
425
+                $answer = esc_html($answer);
426
+            }elseif ('file-upload' == $question_type) {
427
+                $file_key = 'file_upload_'.$question_id;
428
+                if (isset($files[$file_key])) {
429
+                        $attachment_id = Sensei_Utils::upload_file($files[$file_key]);
430
+                        if ($attachment_id) {
431 431
                             $answer = $attachment_id;
432 432
                         }
433 433
                     }
434 434
             } // end if
435 435
 
436
-			$prepared_answers[ $question_id ] =  base64_encode( maybe_serialize( $answer ) );
436
+			$prepared_answers[$question_id] = base64_encode(maybe_serialize($answer));
437 437
 
438 438
 		}// end for each $quiz_answers
439 439
 
@@ -453,54 +453,54 @@  discard block
 block discarded – undo
453 453
      * @param int $user_id
454 454
      * @param int $lesson_id
455 455
      */
456
-    public function reset_user_lesson_data( $lesson_id , $user_id = 0 ){
456
+    public function reset_user_lesson_data($lesson_id, $user_id = 0) {
457 457
 
458 458
         //make sure the parameters are valid
459
-        if( empty( $lesson_id ) || empty( $user_id )
460
-            || 'lesson' != get_post_type( $lesson_id )
461
-            || ! get_userdata( $user_id ) ){
459
+        if (empty($lesson_id) || empty($user_id)
460
+            || 'lesson' != get_post_type($lesson_id)
461
+            || ! get_userdata($user_id)) {
462 462
             return false;
463 463
         }
464 464
 
465 465
 
466 466
 
467 467
         //get the users lesson status to make
468
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
469
-        if( ! isset( $user_lesson_status->comment_ID ) ) {
468
+        $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
469
+        if ( ! isset($user_lesson_status->comment_ID)) {
470 470
             // this user is not taking this lesson so this process is not needed
471 471
             return false;
472 472
         }
473 473
 
474 474
         //get the lesson quiz and course
475
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
476
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
475
+        $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
476
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
477 477
 
478 478
         // reset the transients
479 479
         $answers_transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
480 480
         $grades_transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
481 481
         $answers_feedback_transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
482
-        delete_transient( $answers_transient_key );
483
-        delete_transient( $grades_transient_key );
484
-        delete_transient( $answers_feedback_transient_key );
482
+        delete_transient($answers_transient_key);
483
+        delete_transient($grades_transient_key);
484
+        delete_transient($answers_feedback_transient_key);
485 485
 
486 486
         // reset the quiz answers and feedback notes
487
-        $deleted_answers = Sensei_Utils::delete_user_data( 'quiz_answers', $lesson_id, $user_id );
488
-        $deleted_grades = Sensei_Utils::delete_user_data( 'quiz_grades', $lesson_id, $user_id );
489
-        $deleted_user_feedback = Sensei_Utils::delete_user_data( 'quiz_answers_feedback', $lesson_id, $user_id );
487
+        $deleted_answers = Sensei_Utils::delete_user_data('quiz_answers', $lesson_id, $user_id);
488
+        $deleted_grades = Sensei_Utils::delete_user_data('quiz_grades', $lesson_id, $user_id);
489
+        $deleted_user_feedback = Sensei_Utils::delete_user_data('quiz_answers_feedback', $lesson_id, $user_id);
490 490
 
491 491
         // Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade
492
-        Sensei_Utils::sensei_delete_quiz_answers( $quiz_id, $user_id );
492
+        Sensei_Utils::sensei_delete_quiz_answers($quiz_id, $user_id);
493 493
 
494
-        Sensei_Utils::update_lesson_status( $user_id , $lesson_id, 'in-progress', array( 'questions_asked' => '', 'grade' => '' ) );
494
+        Sensei_Utils::update_lesson_status($user_id, $lesson_id, 'in-progress', array('questions_asked' => '', 'grade' => ''));
495 495
 
496 496
         // Update course completion
497
-        Sensei_Utils::update_course_status( $user_id, $course_id );
497
+        Sensei_Utils::update_course_status($user_id, $course_id);
498 498
 
499 499
         // Run any action on quiz/lesson reset (previously this didn't occur on resetting a quiz, see resetting a lesson in sensei_complete_lesson()
500
-        do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id );
501
-        Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Reset Successfully.', 'woothemes-sensei' ) . '</div>';
500
+        do_action('sensei_user_lesson_reset', $user_id, $lesson_id);
501
+        Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Reset Successfully.', 'woothemes-sensei').'</div>';
502 502
 
503
-        return ( $deleted_answers && $deleted_grades ) ;
503
+        return ($deleted_answers && $deleted_grades);
504 504
 
505 505
     } // end reset_user_lesson_data
506 506
 
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
       *
521 521
       * @return bool $answers_submitted
522 522
       */
523
-     public static function submit_answers_for_grading( $quiz_answers , $files = array() , $lesson_id , $user_id = 0 ){
523
+     public static function submit_answers_for_grading($quiz_answers, $files = array(), $lesson_id, $user_id = 0) {
524 524
 
525 525
          $answers_submitted = false;
526 526
 
527 527
          // get the user_id if none was passed in use the current logged in user
528
-         if( ! intval( $user_id ) > 0 ) {
528
+         if ( ! intval($user_id) > 0) {
529 529
              $user_id = get_current_user_id();
530 530
          }
531 531
 
532 532
          // make sure the parameters are valid before continuing
533
-         if( empty( $lesson_id ) || empty( $user_id )
534
-             || 'lesson' != get_post_type( $lesson_id )
535
-             ||!get_userdata( $user_id )
536
-             || !is_array( $quiz_answers ) ){
533
+         if (empty($lesson_id) || empty($user_id)
534
+             || 'lesson' != get_post_type($lesson_id)
535
+             ||! get_userdata($user_id)
536
+             || ! is_array($quiz_answers)) {
537 537
 
538 538
              return false;
539 539
 
@@ -543,38 +543,38 @@  discard block
 block discarded – undo
543 543
          $grade = 0;
544 544
 
545 545
          // Get Quiz ID
546
-         $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
546
+         $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
547 547
 
548 548
          // Get quiz grade type
549
-         $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true );
549
+         $quiz_grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true);
550 550
 
551 551
          // Get quiz pass setting
552
-         $pass_required = get_post_meta( $quiz_id, '_pass_required', true );
552
+         $pass_required = get_post_meta($quiz_id, '_pass_required', true);
553 553
 
554 554
          // Get the minimum percentage need to pass this quiz
555
-         $quiz_pass_percentage = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
555
+         $quiz_pass_percentage = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2));
556 556
 
557 557
          // Handle Quiz Questions asked
558 558
          // This is to ensure we save the questions that we've asked this user and that this can't be change unless
559 559
          // the quiz is reset by admin or user( user: only if the setting is enabled ).
560 560
          // get the questions asked when when the quiz questions were generated for the user : Sensei_Lesson::lesson_quiz_questions
561
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
562
-         $questions_asked = get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true );
563
-         if( empty( $questions_asked ) ){
561
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
562
+         $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
563
+         if (empty($questions_asked)) {
564 564
 
565
-             $questions_asked = array_keys( $quiz_answers );
566
-             $questions_asked_string = implode( ',', $questions_asked );
565
+             $questions_asked = array_keys($quiz_answers);
566
+             $questions_asked_string = implode(',', $questions_asked);
567 567
 
568 568
              // Save questions that were asked in this quiz
569
-             update_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string );
569
+             update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string);
570 570
 
571 571
          }
572 572
 
573 573
          // Save Quiz Answers for grading, the save function also calls the sensei_start_lesson
574
-         self::save_user_answers( $quiz_answers , $files , $lesson_id , $user_id );
574
+         self::save_user_answers($quiz_answers, $files, $lesson_id, $user_id);
575 575
 
576 576
          // Grade quiz
577
-         $grade = Sensei_Grading::grade_quiz_auto( $quiz_id, $quiz_answers, 0 , $quiz_grade_type );
577
+         $grade = Sensei_Grading::grade_quiz_auto($quiz_id, $quiz_answers, 0, $quiz_grade_type);
578 578
 
579 579
          // Get Lesson Grading Setting
580 580
          $lesson_metadata = array();
@@ -584,13 +584,13 @@  discard block
 block discarded – undo
584 584
          $answers_submitted = true;
585 585
 
586 586
          // if this condition is false the quiz should manually be graded by admin
587
-         if ('auto' == $quiz_grade_type && ! is_wp_error( $grade )  ) {
587
+         if ('auto' == $quiz_grade_type && ! is_wp_error($grade)) {
588 588
 
589 589
              // Quiz has been automatically Graded
590
-             if ( 'on' == $pass_required ) {
590
+             if ('on' == $pass_required) {
591 591
 
592 592
                  // Student has reached the pass mark and lesson is complete
593
-                 if ( $quiz_pass_percentage <= $grade ) {
593
+                 if ($quiz_pass_percentage <= $grade) {
594 594
 
595 595
                      $lesson_status = 'passed';
596 596
 
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
 
612 612
          } // end if ! is_wp_error( $grade ...
613 613
 
614
-         Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $lesson_status, $lesson_metadata );
614
+         Sensei_Utils::update_lesson_status($user_id, $lesson_id, $lesson_status, $lesson_metadata);
615 615
 
616
-         if( 'passed' == $lesson_status || 'graded' == $lesson_status ){
616
+         if ('passed' == $lesson_status || 'graded' == $lesson_status) {
617 617
 
618 618
              /**
619 619
               * Lesson end action hook
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
               * @param int $user_id
624 624
               * @param int $lesson_id
625 625
               */
626
-             do_action( 'sensei_user_lesson_end', $user_id, $lesson_id );
626
+             do_action('sensei_user_lesson_end', $user_id, $lesson_id);
627 627
 
628 628
          }
629 629
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
           * @param string $quiz_pass_percentage
640 640
           * @param string $quiz_grade_type
641 641
           */
642
-         do_action( 'sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type );
642
+         do_action('sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type);
643 643
 
644 644
          return $answers_submitted;
645 645
 
@@ -659,38 +659,38 @@  discard block
 block discarded – undo
659 659
       *
660 660
       * @return bool $answers_submitted
661 661
       */
662
-     public function get_user_question_answer( $lesson_id, $question_id, $user_id = 0 ){
662
+     public function get_user_question_answer($lesson_id, $question_id, $user_id = 0) {
663 663
 
664 664
          // parameter validation
665
-         if( empty( $lesson_id ) || empty( $question_id )
666
-             || ! ( intval( $lesson_id  ) > 0 )
667
-             || ! ( intval( $question_id  ) > 0 )
668
-             || 'lesson' != get_post_type( $lesson_id )
669
-             || 'question' != get_post_type( $question_id )) {
665
+         if (empty($lesson_id) || empty($question_id)
666
+             || ! (intval($lesson_id) > 0)
667
+             || ! (intval($question_id) > 0)
668
+             || 'lesson' != get_post_type($lesson_id)
669
+             || 'question' != get_post_type($question_id)) {
670 670
 
671 671
              return false;
672 672
          }
673 673
 
674
-         if( ! ( intval( $user_id ) > 0 )   ){
674
+         if ( ! (intval($user_id) > 0)) {
675 675
              $user_id = get_current_user_id();
676 676
          }
677 677
 
678
-         $users_answers = $this->get_user_answers( $lesson_id, $user_id );
678
+         $users_answers = $this->get_user_answers($lesson_id, $user_id);
679 679
 
680
-         if( !$users_answers || empty( $users_answers )
681
-         ||  ! is_array( $users_answers ) || ! isset( $users_answers[ $question_id ] ) ){
680
+         if ( ! $users_answers || empty($users_answers)
681
+         ||  ! is_array($users_answers) || ! isset($users_answers[$question_id])) {
682 682
 
683 683
              //Fallback for pre 1.7.4 data
684
-             $comment =  Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ), true );
684
+             $comment = Sensei_Utils::sensei_check_for_activity(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer'), true);
685 685
 
686
-             if( ! isset( $comment->comment_content ) ){
686
+             if ( ! isset($comment->comment_content)) {
687 687
                  return false;
688 688
              }
689 689
 
690
-             return maybe_unserialize( base64_decode( $comment->comment_content ) );
690
+             return maybe_unserialize(base64_decode($comment->comment_content));
691 691
          }
692 692
 
693
-         return $users_answers[ $question_id ];
693
+         return $users_answers[$question_id];
694 694
 
695 695
      }// end get_user_question_answer
696 696
 
@@ -711,18 +711,18 @@  discard block
 block discarded – undo
711 711
       *
712 712
       * @return bool
713 713
       */
714
-     public function set_user_grades( $quiz_grades, $lesson_id, $user_id = 0 ){
714
+     public function set_user_grades($quiz_grades, $lesson_id, $user_id = 0) {
715 715
 
716 716
          // get the user_id if none was passed in use the current logged in user
717
-         if( ! intval( $user_id ) > 0 ) {
717
+         if ( ! intval($user_id) > 0) {
718 718
              $user_id = get_current_user_id();
719 719
          }
720 720
 
721 721
          // make sure the parameters are valid before continuing
722
-         if( empty( $lesson_id ) || empty( $user_id )
723
-             || 'lesson' != get_post_type( $lesson_id )
724
-             ||!get_userdata( $user_id )
725
-             || !is_array( $quiz_grades ) ){
722
+         if (empty($lesson_id) || empty($user_id)
723
+             || 'lesson' != get_post_type($lesson_id)
724
+             ||! get_userdata($user_id)
725
+             || ! is_array($quiz_grades)) {
726 726
 
727 727
              return false;
728 728
 
@@ -731,15 +731,15 @@  discard block
 block discarded – undo
731 731
          $success = false;
732 732
 
733 733
          // save that data for the user on the lesson comment meta
734
-         $comment_meta_id = Sensei_Utils::add_user_data( 'quiz_grades', $lesson_id, $quiz_grades, $user_id   );
734
+         $comment_meta_id = Sensei_Utils::add_user_data('quiz_grades', $lesson_id, $quiz_grades, $user_id);
735 735
 
736 736
          // were the grades save successfully ?
737
-         if( intval( $comment_meta_id ) > 0 ) {
737
+         if (intval($comment_meta_id) > 0) {
738 738
 
739 739
              $success = true;
740 740
              // save transient
741
-             $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id;
742
-             set_transient( $transient_key, $quiz_grades, 10 * DAY_IN_SECONDS );
741
+             $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
742
+             set_transient($transient_key, $quiz_grades, 10 * DAY_IN_SECONDS);
743 743
          }
744 744
 
745 745
          return $success;
@@ -758,36 +758,36 @@  discard block
 block discarded – undo
758 758
       *
759 759
       * @return array $user_quiz_grades or false if none exists for this users
760 760
       */
761
-     public function get_user_grades( $lesson_id, $user_id = 0 ){
761
+     public function get_user_grades($lesson_id, $user_id = 0) {
762 762
 
763 763
          $user_grades = array();
764 764
 
765 765
          // get the user_id if none was passed in use the current logged in user
766
-         if( ! intval( $user_id ) > 0 ) {
766
+         if ( ! intval($user_id) > 0) {
767 767
              $user_id = get_current_user_id();
768 768
          }
769 769
 
770
-         if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
771
-             || ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
770
+         if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
771
+             || ! intval($user_id) > 0 || ! get_userdata($user_id)) {
772 772
              return false;
773 773
          }
774 774
 
775 775
          // save some time and get the transient cached data
776
-         $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id;
777
-         $user_grades = get_transient( $transient_key );
776
+         $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
777
+         $user_grades = get_transient($transient_key);
778 778
 
779 779
          // get the data if nothing was stored in the transient
780
-         if( empty( $user_grades  ) || false != $user_grades ){
780
+         if (empty($user_grades) || false != $user_grades) {
781 781
 
782
-             $user_grades = Sensei_Utils::get_user_data( 'quiz_grades', $lesson_id, $user_id );
782
+             $user_grades = Sensei_Utils::get_user_data('quiz_grades', $lesson_id, $user_id);
783 783
 
784 784
              //set the transient with the new valid data for faster retrieval in future
785
-             set_transient( $transient_key,  $user_grades, 10 * DAY_IN_SECONDS );
785
+             set_transient($transient_key, $user_grades, 10 * DAY_IN_SECONDS);
786 786
 
787 787
          } // end if transient check
788 788
 
789 789
          // if there is no data for this user
790
-         if( ! is_array( $user_grades ) ){
790
+         if ( ! is_array($user_grades)) {
791 791
              return false;
792 792
          }
793 793
 
@@ -810,21 +810,21 @@  discard block
 block discarded – undo
810 810
       *
811 811
       * @return bool $question_grade
812 812
       */
813
-     public function get_user_question_grade( $lesson_id, $question_id, $user_id = 0 ){
813
+     public function get_user_question_grade($lesson_id, $question_id, $user_id = 0) {
814 814
 
815 815
          // parameter validation
816
-         if( empty( $lesson_id ) || empty( $question_id )
817
-             || ! ( intval( $lesson_id  ) > 0 )
818
-             || ! ( intval( $question_id  ) > 0 )
819
-             || 'lesson' != get_post_type( $lesson_id )
820
-             || 'question' != get_post_type( $question_id )) {
816
+         if (empty($lesson_id) || empty($question_id)
817
+             || ! (intval($lesson_id) > 0)
818
+             || ! (intval($question_id) > 0)
819
+             || 'lesson' != get_post_type($lesson_id)
820
+             || 'question' != get_post_type($question_id)) {
821 821
 
822 822
              return false;
823 823
          }
824 824
 
825
-         $all_user_grades = self::get_user_grades( $lesson_id,$user_id );
825
+         $all_user_grades = self::get_user_grades($lesson_id, $user_id);
826 826
 
827
-         if( ! $all_user_grades || ! isset(  $all_user_grades[ $question_id ] ) ){
827
+         if ( ! $all_user_grades || ! isset($all_user_grades[$question_id])) {
828 828
 
829 829
              //fallback to data pre 1.7.4
830 830
              $args = array(
@@ -833,17 +833,17 @@  discard block
 block discarded – undo
833 833
                  'type'    => 'sensei_user_answer'
834 834
              );
835 835
 
836
-             $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true );
836
+             $question_activity = Sensei_Utils::sensei_check_for_activity($args, true);
837 837
              $fall_back_grade = false;
838
-             if( isset( $question_activity->comment_ID ) ){
839
-                 $fall_back_grade = get_comment_meta(  $question_activity->comment_ID , 'user_grade', true );
838
+             if (isset($question_activity->comment_ID)) {
839
+                 $fall_back_grade = get_comment_meta($question_activity->comment_ID, 'user_grade', true);
840 840
              }
841 841
 
842 842
              return $fall_back_grade;
843 843
 
844 844
          } // end if $all_user_grades...
845 845
 
846
-         return $all_user_grades[ $question_id ];
846
+         return $all_user_grades[$question_id];
847 847
 
848 848
      }// end get_user_question_grade
849 849
 
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
       *
866 866
       * @return false or int $feedback_saved
867 867
       */
868
-    public function save_user_answers_feedback( $answers_feedback, $lesson_id , $user_id = 0 ){
868
+    public function save_user_answers_feedback($answers_feedback, $lesson_id, $user_id = 0) {
869 869
 
870 870
         // make sure the parameters are valid before continuing
871
-        if( empty( $lesson_id ) || empty( $user_id )
872
-            || 'lesson' != get_post_type( $lesson_id )
873
-            ||!get_userdata( $user_id )
874
-            || !is_array( $answers_feedback ) ){
871
+        if (empty($lesson_id) || empty($user_id)
872
+            || 'lesson' != get_post_type($lesson_id)
873
+            ||! get_userdata($user_id)
874
+            || ! is_array($answers_feedback)) {
875 875
 
876 876
             return false;
877 877
 
@@ -879,25 +879,25 @@  discard block
 block discarded – undo
879 879
 
880 880
 
881 881
         // check if the lesson is started before saving, if not start the lesson for the user
882
-        if ( !( 0 < intval( Sensei_Utils::user_started_lesson( $lesson_id, $user_id) ) ) ) {
883
-            Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
882
+        if ( ! (0 < intval(Sensei_Utils::user_started_lesson($lesson_id, $user_id)))) {
883
+            Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
884 884
         }
885 885
 
886 886
         // encode the feedback
887
-        $encoded_answers_feedback =  array();
888
-        foreach( $answers_feedback as $question_id => $feedback ){
889
-            $encoded_answers_feedback[ $question_id ] = base64_encode( $feedback );
887
+        $encoded_answers_feedback = array();
888
+        foreach ($answers_feedback as $question_id => $feedback) {
889
+            $encoded_answers_feedback[$question_id] = base64_encode($feedback);
890 890
         }
891 891
 
892 892
         // save the user data
893
-        $feedback_saved = Sensei_Utils::add_user_data( 'quiz_answers_feedback', $lesson_id , $encoded_answers_feedback, $user_id ) ;
893
+        $feedback_saved = Sensei_Utils::add_user_data('quiz_answers_feedback', $lesson_id, $encoded_answers_feedback, $user_id);
894 894
 
895 895
         //Were the the question feedback save correctly?
896
-        if( intval( $feedback_saved ) > 0){
896
+        if (intval($feedback_saved) > 0) {
897 897
 
898 898
             // save transient to make retrieval faster in future
899 899
              $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
900
-             set_transient( $transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS );
900
+             set_transient($transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS);
901 901
 
902 902
         }
903 903
 
@@ -922,42 +922,42 @@  discard block
 block discarded – undo
922 922
       *  $type string $question_feedback
923 923
       * }
924 924
       */
925
-     public function get_user_answers_feedback( $lesson_id , $user_id = 0 ){
925
+     public function get_user_answers_feedback($lesson_id, $user_id = 0) {
926 926
 
927 927
          $answers_feedback = array();
928 928
 
929 929
          // get the user_id if none was passed in use the current logged in user
930
-         if( ! intval( $user_id ) > 0 ) {
930
+         if ( ! intval($user_id) > 0) {
931 931
              $user_id = get_current_user_id();
932 932
          }
933 933
 
934
-         if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
935
-             || ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
934
+         if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
935
+             || ! intval($user_id) > 0 || ! get_userdata($user_id)) {
936 936
              return false;
937 937
          }
938 938
 
939 939
          // first check the transient to save a few split seconds
940 940
          $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
941
-         $encoded_feedback = get_transient( $transient_key );
941
+         $encoded_feedback = get_transient($transient_key);
942 942
 
943 943
          // get the data if nothing was stored in the transient
944
-         if( empty( $encoded_feedback  ) || !$encoded_feedback ){
944
+         if (empty($encoded_feedback) || ! $encoded_feedback) {
945 945
 
946
-             $encoded_feedback = Sensei_Utils::get_user_data( 'quiz_answers_feedback', $lesson_id, $user_id );
946
+             $encoded_feedback = Sensei_Utils::get_user_data('quiz_answers_feedback', $lesson_id, $user_id);
947 947
 
948 948
              //set the transient with the new valid data for faster retrieval in future
949
-             set_transient( $transient_key,  $encoded_feedback, 10 * DAY_IN_SECONDS);
949
+             set_transient($transient_key, $encoded_feedback, 10 * DAY_IN_SECONDS);
950 950
 
951 951
          } // end if transient check
952 952
 
953 953
          // if there is no data for this user
954
-         if( ! is_array( $encoded_feedback ) ){
954
+         if ( ! is_array($encoded_feedback)) {
955 955
              return false;
956 956
          }
957 957
 
958
-         foreach( $encoded_feedback as $question_id => $feedback ){
958
+         foreach ($encoded_feedback as $question_id => $feedback) {
959 959
 
960
-             $answers_feedback[ $question_id ] = base64_decode( $feedback );
960
+             $answers_feedback[$question_id] = base64_decode($feedback);
961 961
 
962 962
          }
963 963
 
@@ -980,25 +980,25 @@  discard block
 block discarded – undo
980 980
       *
981 981
       * @return string $feedback or bool if false
982 982
       */
983
-     public function get_user_question_feedback( $lesson_id, $question_id, $user_id = 0 ){
983
+     public function get_user_question_feedback($lesson_id, $question_id, $user_id = 0) {
984 984
 
985 985
          $feedback = false;
986 986
 
987 987
          // parameter validation
988
-         if( empty( $lesson_id ) || empty( $question_id )
989
-             || ! ( intval( $lesson_id  ) > 0 )
990
-             || ! ( intval( $question_id  ) > 0 )
991
-             || 'lesson' != get_post_type( $lesson_id )
992
-             || 'question' != get_post_type( $question_id )) {
988
+         if (empty($lesson_id) || empty($question_id)
989
+             || ! (intval($lesson_id) > 0)
990
+             || ! (intval($question_id) > 0)
991
+             || 'lesson' != get_post_type($lesson_id)
992
+             || 'question' != get_post_type($question_id)) {
993 993
 
994 994
              return false;
995 995
          }
996 996
 
997 997
          // get all the feedback for the user on the given lesson
998
-         $all_feedback = $this->get_user_answers_feedback( $lesson_id, $user_id );
998
+         $all_feedback = $this->get_user_answers_feedback($lesson_id, $user_id);
999 999
 
1000
-         if( !$all_feedback || empty( $all_feedback )
1001
-             || ! is_array( $all_feedback ) || ! isset( $all_feedback[ $question_id ] ) ){
1000
+         if ( ! $all_feedback || empty($all_feedback)
1001
+             || ! is_array($all_feedback) || ! isset($all_feedback[$question_id])) {
1002 1002
 
1003 1003
              //fallback to data pre 1.7.4
1004 1004
 
@@ -1008,23 +1008,23 @@  discard block
 block discarded – undo
1008 1008
                  'user_id' => $user_id,
1009 1009
                  'type'    => 'sensei_user_answer'
1010 1010
              );
1011
-             $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true );
1011
+             $question_activity = Sensei_Utils::sensei_check_for_activity($args, true);
1012 1012
 
1013 1013
              // set the default to false and return that if no old data is available.
1014
-             if( isset( $question_activity->comment_ID ) ){
1015
-                 $feedback = base64_decode( get_comment_meta(  $question_activity->comment_ID , 'answer_note', true ) );
1014
+             if (isset($question_activity->comment_ID)) {
1015
+                 $feedback = base64_decode(get_comment_meta($question_activity->comment_ID, 'answer_note', true));
1016 1016
              }
1017 1017
 
1018 1018
              // finally use the default question feedback
1019
-             if( empty( $feedback ) ){
1020
-                 $feedback = get_post_meta( $question_id, '_answer_feedback', true );
1019
+             if (empty($feedback)) {
1020
+                 $feedback = get_post_meta($question_id, '_answer_feedback', true);
1021 1021
              }
1022 1022
 
1023 1023
              return $feedback;
1024 1024
 
1025 1025
          }
1026 1026
 
1027
-         return $all_feedback[ $question_id ];
1027
+         return $all_feedback[$question_id];
1028 1028
 
1029 1029
      } // end get_user_question_feedback
1030 1030
 
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 
1043 1043
      public function quiz_has_no_questions() {
1044 1044
 
1045
-         if( ! is_singular( 'quiz' ) )  {
1045
+         if ( ! is_singular('quiz')) {
1046 1046
              return;
1047 1047
          }
1048 1048
 
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
          $lesson_id = $this->get_lesson_id($post->ID);
1052 1052
 
1053
-         $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
1053
+         $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
1054 1054
 
1055 1055
          $lesson = get_post($lesson_id);
1056 1056
 
1057
-         if ( is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name" ) {
1057
+         if (is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name") {
1058 1058
 
1059 1059
              wp_redirect(get_permalink($lesson->ID), 301);
1060 1060
              exit;
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
   *
1069 1069
   * @deprecated since 1.9.0
1070 1070
   */
1071
- public static function deprecate_quiz_sensei_single_main_content_hook(){
1071
+ public static function deprecate_quiz_sensei_single_main_content_hook() {
1072 1072
 
1073 1073
      sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_quiz_content_inside_before or sensei_single_quiz_content_inside_after');
1074 1074
 
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
      *
1079 1079
      * @deprecated since 1.9.0
1080 1080
      */
1081
-     public static function deprecate_quiz_sensei_quiz_single_title_hook(){
1081
+     public static function deprecate_quiz_sensei_quiz_single_title_hook() {
1082 1082
 
1083 1083
          sensei_do_deprecated_action('sensei_quiz_single_title', '1.9.0', 'sensei_single_quiz_content_inside_before ');
1084 1084
 
@@ -1091,29 +1091,29 @@  discard block
 block discarded – undo
1091 1091
       * @param int $id title post id
1092 1092
       * @return string $quiz_title
1093 1093
       */
1094
-     public static function single_quiz_title( $title, $post_id ){
1094
+     public static function single_quiz_title($title, $post_id) {
1095 1095
 
1096
-         if( 'quiz' == get_post_type( $post_id ) ){
1096
+         if ('quiz' == get_post_type($post_id)) {
1097 1097
 
1098 1098
              $title_with_no_quizzes = $title;
1099 1099
 
1100 1100
              // if the title has quiz, remove it: legacy titles have the word quiz stored.
1101
-             if( 1 < substr_count( strtoupper( $title_with_no_quizzes ), 'QUIZ' ) ){
1101
+             if (1 < substr_count(strtoupper($title_with_no_quizzes), 'QUIZ')) {
1102 1102
 
1103 1103
                  // remove all possible appearances of quiz
1104
-                 $title_with_no_quizzes = str_replace( 'quiz', '', $title  );
1105
-                 $title_with_no_quizzes = str_replace( 'Quiz', '', $title_with_no_quizzes  );
1106
-                 $title_with_no_quizzes = str_replace( 'QUIZ', '', $title_with_no_quizzes  );
1104
+                 $title_with_no_quizzes = str_replace('quiz', '', $title);
1105
+                 $title_with_no_quizzes = str_replace('Quiz', '', $title_with_no_quizzes);
1106
+                 $title_with_no_quizzes = str_replace('QUIZ', '', $title_with_no_quizzes);
1107 1107
 
1108 1108
              }
1109 1109
 
1110
-             $title = $title_with_no_quizzes .  ' ' . __( 'Quiz', 'woothemes-sensei' );
1110
+             $title = $title_with_no_quizzes.' '.__('Quiz', 'woothemes-sensei');
1111 1111
          }
1112 1112
 
1113 1113
          /**
1114 1114
           * hook document in class-woothemes-sensei-message.php
1115 1115
           */
1116
-         return apply_filters( 'sensei_single_title', $title, get_post_type( ) );
1116
+         return apply_filters('sensei_single_title', $title, get_post_type( ));
1117 1117
 
1118 1118
      }
1119 1119
 
@@ -1125,21 +1125,21 @@  discard block
 block discarded – undo
1125 1125
       * @since 1.9.0
1126 1126
       *
1127 1127
       */
1128
-     public static function start_quiz_questions_loop(){
1128
+     public static function start_quiz_questions_loop() {
1129 1129
 
1130 1130
          global $sensei_question_loop;
1131 1131
 
1132 1132
          //intialize the questions loop object
1133 1133
          $sensei_question_loop['current'] = -1;
1134
-         $sensei_question_loop['total']   =  0;
1134
+         $sensei_question_loop['total']   = 0;
1135 1135
          $sensei_question_loop['questions'] = array();
1136 1136
 
1137 1137
 
1138
-         $questions = Sensei()->lesson->lesson_quiz_questions( get_the_ID() );
1138
+         $questions = Sensei()->lesson->lesson_quiz_questions(get_the_ID());
1139 1139
 
1140
-         if( count( $questions  ) > 0  ){
1140
+         if (count($questions) > 0) {
1141 1141
 
1142
-             $sensei_question_loop['total']   =  count( $questions );
1142
+             $sensei_question_loop['total']   = count($questions);
1143 1143
              $sensei_question_loop['questions'] = $questions;
1144 1144
              $sensei_question_loop['quiz_id'] = get_the_ID();
1145 1145
 
@@ -1155,9 +1155,9 @@  discard block
 block discarded – undo
1155 1155
       * @since 1.9.0
1156 1156
       *
1157 1157
       */
1158
-     public static function stop_quiz_questions_loop(){
1158
+     public static function stop_quiz_questions_loop() {
1159 1159
 
1160
-         $sensei_question_loop['total']   =  0;
1160
+         $sensei_question_loop['total']   = 0;
1161 1161
          $sensei_question_loop['questions'] = array();
1162 1162
          $sensei_question_loop['quiz_id'] = '';
1163 1163
 
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
       *
1169 1169
       * @since 1.9.0
1170 1170
       */
1171
-     public static function the_title(){
1171
+     public static function the_title() {
1172 1172
          ?>
1173 1173
          <header>
1174 1174
 
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
                  /**
1179 1179
                   * Filter documented in class-sensei-messages.php the_title
1180 1180
                   */
1181
-                 echo apply_filters( 'sensei_single_title', get_the_title( get_post() ), get_post_type( get_the_ID() ) );
1181
+                 echo apply_filters('sensei_single_title', get_the_title(get_post()), get_post_type(get_the_ID()));
1182 1182
                  ?>
1183 1183
 
1184 1184
              </h1>
@@ -1193,11 +1193,11 @@  discard block
 block discarded – undo
1193 1193
       *
1194 1194
       * @param $quiz_id
1195 1195
       */
1196
-    public static function  the_user_status_message( $quiz_id ){
1196
+    public static function  the_user_status_message($quiz_id) {
1197 1197
 
1198
-        $lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
1199
-        $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id , get_current_user_id() );
1200
-        echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
1198
+        $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
1199
+        $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, get_current_user_id());
1200
+        echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
1201 1201
 
1202 1202
     }
1203 1203
 
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
       * @since 1.9.0
1209 1209
       * @deprecated
1210 1210
       */
1211
-     public static function deprecate_sensei_quiz_action_buttons_hook(){
1211
+     public static function deprecate_sensei_quiz_action_buttons_hook() {
1212 1212
 
1213
-         sensei_do_deprecated_action( 'sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after');
1213
+         sensei_do_deprecated_action('sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after');
1214 1214
 
1215 1215
      }
1216 1216
 
@@ -1224,50 +1224,50 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
          global $post, $current_user;
1226 1226
 
1227
-         $lesson_id = (int) get_post_meta( $post->ID, '_quiz_lesson', true );
1228
-         $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true );
1229
-         $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
1227
+         $lesson_id = (int) get_post_meta($post->ID, '_quiz_lesson', true);
1228
+         $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true);
1229
+         $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
1230 1230
          $show_actions = true;
1231
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $current_user->ID );
1231
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $current_user->ID);
1232 1232
 
1233 1233
          //setup quiz grade
1234 1234
          $user_quiz_grade = '';
1235
-         if( ! empty( $user_lesson_status  ) ){
1236
-             $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1235
+         if ( ! empty($user_lesson_status)) {
1236
+             $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1237 1237
          }
1238 1238
 
1239 1239
 
1240
-         if( intval( $lesson_prerequisite ) > 0 ) {
1240
+         if (intval($lesson_prerequisite) > 0) {
1241 1241
 
1242 1242
              // If the user hasn't completed the prereq then hide the current actions
1243
-             $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $current_user->ID );
1243
+             $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
1244 1244
 
1245 1245
          }
1246
-         if ( $show_actions && is_user_logged_in() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
1246
+         if ($show_actions && is_user_logged_in() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
1247 1247
 
1248 1248
              // Get Reset Settings
1249
-             $reset_quiz_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true ); ?>
1249
+             $reset_quiz_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true); ?>
1250 1250
 
1251 1251
              <!-- Action Nonce's -->
1252 1252
              <input type="hidden" name="woothemes_sensei_complete_quiz_nonce" id="woothemes_sensei_complete_quiz_nonce"
1253
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_complete_quiz_nonce' ) ); ?>" />
1253
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_quiz_nonce')); ?>" />
1254 1254
              <input type="hidden" name="woothemes_sensei_reset_quiz_nonce" id="woothemes_sensei_reset_quiz_nonce"
1255
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_reset_quiz_nonce' ) ); ?>" />
1255
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_reset_quiz_nonce')); ?>" />
1256 1256
              <input type="hidden" name="woothemes_sensei_save_quiz_nonce" id="woothemes_sensei_save_quiz_nonce"
1257
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_save_quiz_nonce' ) ); ?>" />
1257
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_save_quiz_nonce')); ?>" />
1258 1258
              <!--#end Action Nonce's -->
1259 1259
 
1260
-             <?php if ( '' == $user_quiz_grade) { ?>
1260
+             <?php if ('' == $user_quiz_grade) { ?>
1261 1261
 
1262
-                 <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php  _e( 'Complete Quiz', 'woothemes-sensei' ); ?>"/></span>
1262
+                 <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php  _e('Complete Quiz', 'woothemes-sensei'); ?>"/></span>
1263 1263
 
1264
-                 <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e( 'Save Quiz', 'woothemes-sensei' ); ?>"/></span>
1264
+                 <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e('Save Quiz', 'woothemes-sensei'); ?>"/></span>
1265 1265
 
1266 1266
              <?php } // End If Statement ?>
1267 1267
 
1268
-             <?php if ( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) { ?>
1268
+             <?php if (isset($reset_quiz_allowed) && $reset_quiz_allowed) { ?>
1269 1269
 
1270
-                 <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e( 'Reset Quiz', 'woothemes-sensei' ); ?>"/></span>
1270
+                 <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e('Reset Quiz', 'woothemes-sensei'); ?>"/></span>
1271 1271
 
1272 1272
              <?php } ?>
1273 1273
 
@@ -1285,13 +1285,13 @@  discard block
 block discarded – undo
1285 1285
       *
1286 1286
       * @return double $user_quiz_grade
1287 1287
       */
1288
-     public static function get_user_quiz_grade( $lesson_id, $user_id ){
1288
+     public static function get_user_quiz_grade($lesson_id, $user_id) {
1289 1289
 
1290 1290
          // get the quiz grade
1291
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1291
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1292 1292
          $user_quiz_grade = 0;
1293
-         if( isset( $user_lesson_status->comment_ID ) ) {
1294
-             $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1293
+         if (isset($user_lesson_status->comment_ID)) {
1294
+             $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1295 1295
          }
1296 1296
 
1297 1297
          return (double) $user_quiz_grade;
@@ -1309,13 +1309,13 @@  discard block
 block discarded – undo
1309 1309
       * @param int $lesson_id
1310 1310
       * @return bool
1311 1311
       */
1312
-     public static function is_reset_allowed( $lesson_id ){
1312
+     public static function is_reset_allowed($lesson_id) {
1313 1313
 
1314
-         $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1314
+         $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1315 1315
 
1316
-         $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
1316
+         $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true);
1317 1317
          //backwards compatibility
1318
-         if( 'on' == $reset_allowed ) {
1318
+         if ('on' == $reset_allowed) {
1319 1319
              $reset_allowed = 1;
1320 1320
          }
1321 1321
 
@@ -1332,4 +1332,4 @@  discard block
 block discarded – undo
1332 1332
  * @ignore only for backward compatibility
1333 1333
  * @since 1.9.0
1334 1334
  */
1335
-class WooThemes_Sensei_Quiz extends Sensei_Quiz{}
1335
+class WooThemes_Sensei_Quiz extends Sensei_Quiz {}
Please login to merge, or discard this patch.
includes/class-sensei-settings.php 1 patch
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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 Settings Class
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 	 * @access public
19 19
 	 * @since 1.0.0
20 20
 	 */
21
-	public function __construct () {
21
+	public function __construct() {
22 22
 	    parent::__construct(); // Required in extended classes.
23 23
 
24 24
         $this->token = 'woothemes-sensei-settings';
25
-        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
25
+        add_action('init', array(__CLASS__, 'flush_rewrite_rules'));
26 26
 
27 27
         // Setup Admin Settings data
28
-        if ( is_admin() ) {
28
+        if (is_admin()) {
29 29
 
30 30
             $this->has_tabs 	= true;
31
-            $this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
32
-            $this->menu_label	= __( 'Settings', 'woothemes-sensei' );
31
+            $this->name = __('Sensei Settings', 'woothemes-sensei');
32
+            $this->menu_label = __('Settings', 'woothemes-sensei');
33 33
             $this->page_slug	= 'woothemes-sensei-settings';
34 34
 
35 35
         } // End If Statement
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
      * @param string $setting_name
47 47
      * @return mixed
48 48
      */
49
-    public function get( $setting_name ){
49
+    public function get($setting_name) {
50 50
 
51
-        if( isset( $this->settings[ $setting_name ] ) ){
51
+        if (isset($this->settings[$setting_name])) {
52 52
 
53
-            return $this->settings[ $setting_name ];
53
+            return $this->settings[$setting_name];
54 54
 
55 55
         }
56 56
 
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
      * @param $setting
64 64
      * @param $new_value
65 65
      */
66
-    public function set( $setting, $new_value ){
66
+    public function set($setting, $new_value) {
67 67
 
68
-        $settings = get_option( $this->token, array() );
68
+        $settings = get_option($this->token, array());
69 69
 
70
-        if( isset(  $settings[ $setting ] ) ){
70
+        if (isset($settings[$setting])) {
71 71
 
72
-            $settings[ $setting ] = $new_value;
73
-            return update_option( $this->token,$settings );
72
+            $settings[$setting] = $new_value;
73
+            return update_option($this->token, $settings);
74 74
 
75 75
         }
76 76
         return false;
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 	 * @since  1.0.0
84 84
 	 * @return void
85 85
 	 */
86
-	public function register_settings_screen () {
86
+	public function register_settings_screen() {
87 87
 
88 88
 		$this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen.
89
-		$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) );
89
+		$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen'));
90 90
 		$this->hook = $hook;
91 91
 
92
-		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
93
-			add_action( 'admin_notices', array( $this, 'settings_errors' ) );
94
-			add_action( 'admin_notices', array( $this, 'language_pack_notices' ) );
95
-			add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
96
-			add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
92
+		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
93
+			add_action('admin_notices', array($this, 'settings_errors'));
94
+			add_action('admin_notices', array($this, 'language_pack_notices'));
95
+			add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
96
+			add_action('admin_print_styles', array($this, 'enqueue_styles'));
97 97
 		}
98 98
 	} // End register_settings_screen()
99 99
 
@@ -103,49 +103,49 @@  discard block
 block discarded – undo
103 103
 	 * @since  1.0.0
104 104
 	 * @return void
105 105
 	 */
106
-	public function init_sections () {
106
+	public function init_sections() {
107 107
 		$sections = array();
108 108
 
109 109
 		$sections['default-settings'] = array(
110
-			'name' 			=> __( 'General', 'woothemes-sensei' ),
111
-			'description'	=> __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' )
110
+			'name' 			=> __('General', 'woothemes-sensei'),
111
+			'description'	=> __('Settings that apply to the entire plugin.', 'woothemes-sensei')
112 112
 		);
113 113
 
114 114
 		$sections['course-settings'] = array(
115
-			'name' 			=> __( 'Courses', 'woothemes-sensei' ),
116
-			'description'	=> __( 'Settings that apply to all Courses.', 'woothemes-sensei' )
115
+			'name' 			=> __('Courses', 'woothemes-sensei'),
116
+			'description'	=> __('Settings that apply to all Courses.', 'woothemes-sensei')
117 117
 		);
118 118
 
119 119
 		$sections['lesson-settings'] = array(
120
-			'name' 			=> __( 'Lessons', 'woothemes-sensei' ),
121
-			'description'	=> __( 'Settings that apply to all Lessons.', 'woothemes-sensei' )
120
+			'name' 			=> __('Lessons', 'woothemes-sensei'),
121
+			'description'	=> __('Settings that apply to all Lessons.', 'woothemes-sensei')
122 122
 		);
123 123
 
124 124
 		$sections['email-notification-settings'] = array(
125
-			'name' 			=> __( 'Email Notifications', 'woothemes-sensei' ),
126
-			'description'	=> __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' )
125
+			'name' 			=> __('Email Notifications', 'woothemes-sensei'),
126
+			'description'	=> __('Settings for email notifications sent from your site.', 'woothemes-sensei')
127 127
 		);
128 128
 
129 129
 		$sections['learner-profile-settings'] = array(
130
-			'name' 			=> __( 'Learner Profiles', 'woothemes-sensei' ),
131
-			'description'	=> __( 'Settings for public Learner Profiles.', 'woothemes-sensei' )
130
+			'name' 			=> __('Learner Profiles', 'woothemes-sensei'),
131
+			'description'	=> __('Settings for public Learner Profiles.', 'woothemes-sensei')
132 132
 		);
133 133
 
134
-		if ( Sensei_WC::is_woocommerce_present() ) {
134
+		if (Sensei_WC::is_woocommerce_present()) {
135 135
 			$sections['woocommerce-settings'] = array(
136
-				'name' 			=> __( 'WooCommerce', 'woothemes-sensei' ),
137
-				'description'	=> __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' )
136
+				'name' 			=> __('WooCommerce', 'woothemes-sensei'),
137
+				'description'	=> __('Optional settings for WooCommerce functions.', 'woothemes-sensei')
138 138
 			);
139 139
 		} // End If Statement
140 140
 
141
-		if ( 'en_US' !== get_locale() ) {
141
+		if ('en_US' !== get_locale()) {
142 142
 			$sections['language-settings'] = array(
143
-				'name' 			=> __( 'Language', 'woothemes-sensei' ),
144
-				'description'	=> __( 'Language options.', 'woothemes-sensei' )
143
+				'name' 			=> __('Language', 'woothemes-sensei'),
144
+				'description'	=> __('Language options.', 'woothemes-sensei')
145 145
 			);
146 146
 		}
147 147
 
148
-		$this->sections = apply_filters( 'sensei_settings_tabs', $sections );
148
+		$this->sections = apply_filters('sensei_settings_tabs', $sections);
149 149
 	} // End init_sections()
150 150
 
151 151
 	/**
@@ -155,71 +155,71 @@  discard block
 block discarded – undo
155 155
 	 * @uses   Sensei_Utils::get_slider_types()
156 156
 	 * @return void
157 157
 	 */
158
-	public function init_fields () {
158
+	public function init_fields() {
159 159
 		global $pagenow;
160 160
 
161 161
 		$pages_array = $this->pages_array();
162
-		$posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' );
163
-		$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) );
164
-		$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );
162
+		$posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20');
163
+		$complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei'));
164
+		$course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei'));
165 165
 
166 166
 	    $fields = array();
167 167
 
168 168
 		$fields['access_permission'] = array(
169
-								'name' => __( 'Access Permissions', 'woothemes-sensei' ),
170
-								'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ),
169
+								'name' => __('Access Permissions', 'woothemes-sensei'),
170
+								'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'),
171 171
 								'type' => 'checkbox',
172 172
 								'default' => true,
173 173
 								'section' => 'default-settings'
174 174
 								);
175 175
 
176 176
 		$fields['messages_disable'] = array(
177
-								'name' => __( 'Disable Private Messages', 'woothemes-sensei' ),
178
-								'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ),
177
+								'name' => __('Disable Private Messages', 'woothemes-sensei'),
178
+								'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'),
179 179
 								'type' => 'checkbox',
180 180
 								'default' => false,
181 181
 								'section' => 'default-settings'
182 182
 								);
183 183
 
184 184
 		$fields['course_page'] = array(
185
-								'name' => __( 'Course Archive Page', 'woothemes-sensei' ),
186
-								'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ),
185
+								'name' => __('Course Archive Page', 'woothemes-sensei'),
186
+								'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'),
187 187
 								'type' => 'select',
188
-								'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ),
188
+								'default' => get_option('woothemes-sensei_courses_page_id', 0),
189 189
 								'section' => 'default-settings',
190 190
 								'required' => 0,
191 191
 								'options' => $pages_array
192 192
 								);
193 193
 
194 194
 		$fields['my_course_page'] = array(
195
-								'name' => __( 'My Courses Page', 'woothemes-sensei' ),
196
-								'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ),
195
+								'name' => __('My Courses Page', 'woothemes-sensei'),
196
+								'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'),
197 197
 								'type' => 'select',
198
-								'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ),
198
+								'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0),
199 199
 								'section' => 'default-settings',
200 200
 								'required' => 0,
201 201
 								'options' => $pages_array
202 202
 								);
203 203
 
204 204
 		$fields['placeholder_images_enable'] = array(
205
-								'name' => __( 'Use placeholder images', 'woothemes-sensei' ),
206
-								'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ),
205
+								'name' => __('Use placeholder images', 'woothemes-sensei'),
206
+								'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'),
207 207
 								'type' => 'checkbox',
208 208
 								'default' => false,
209 209
 								'section' => 'default-settings'
210 210
 								);
211 211
 
212 212
 		$fields['styles_disable'] = array(
213
-								'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ),
214
-								'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ),
213
+								'name' => __('Disable Sensei Styles', 'woothemes-sensei'),
214
+								'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'),
215 215
 								'type' => 'checkbox',
216 216
 								'default' => false,
217 217
 								'section' => 'default-settings'
218 218
 								);
219 219
 
220 220
 		$fields['js_disable'] = array(
221
-								'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ),
222
-								'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ),
221
+								'name' => __('Disable Sensei Javascript', 'woothemes-sensei'),
222
+								'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'),
223 223
 								'type' => 'checkbox',
224 224
 								'default' => false,
225 225
 								'section' => 'default-settings'
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
     	// Course Settings
229 229
 
230 230
     	$fields['course_completion'] = array(
231
-								'name' => __( 'Courses are complete:', 'woothemes-sensei' ),
232
-								'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ),
231
+								'name' => __('Courses are complete:', 'woothemes-sensei'),
232
+								'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'),
233 233
 								'type' => 'select',
234 234
 								'default' => 'passed',
235 235
 								'section' => 'course-settings',
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 								);
239 239
 
240 240
     	$fields['course_author'] = array(
241
-								'name' => __( 'Display Course Author', 'woothemes-sensei' ),
242
-								'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ),
241
+								'name' => __('Display Course Author', 'woothemes-sensei'),
242
+								'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'),
243 243
 								'type' => 'checkbox',
244 244
 								'default' => true,
245 245
 								'section' => 'course-settings'
246 246
 								);
247 247
 
248 248
 		$fields['my_course_amount'] = array(
249
-								'name' => __( 'My Courses Pagination', 'woothemes-sensei' ),
250
-								'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ),
249
+								'name' => __('My Courses Pagination', 'woothemes-sensei'),
250
+								'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'),
251 251
 								'type' => 'range',
252 252
 								'default' => '0',
253 253
 								'section' => 'course-settings',
@@ -256,16 +256,16 @@  discard block
 block discarded – undo
256 256
 								);
257 257
 
258 258
 		$fields['course_archive_image_enable'] = array(
259
-								'name' => __( 'Course Archive Image', 'woothemes-sensei' ),
260
-								'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ),
259
+								'name' => __('Course Archive Image', 'woothemes-sensei'),
260
+								'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'),
261 261
 								'type' => 'checkbox',
262 262
 								'default' => true,
263 263
 								'section' => 'course-settings'
264 264
 								);
265 265
 
266 266
 		$fields['course_archive_image_width'] = array(
267
-								'name' => __( 'Image Width - Archive', 'woothemes-sensei' ),
268
-								'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
267
+								'name' => __('Image Width - Archive', 'woothemes-sensei'),
268
+								'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
269 269
 								'type' => 'text',
270 270
 								'default' => '100',
271 271
 								'section' => 'course-settings',
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 								);
274 274
 
275 275
 		$fields['course_archive_image_height'] = array(
276
-								'name' => __( 'Image Height - Archive', 'woothemes-sensei' ),
277
-								'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
276
+								'name' => __('Image Height - Archive', 'woothemes-sensei'),
277
+								'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
278 278
 								'type' => 'text',
279 279
 								'default' => '100',
280 280
 								'section' => 'course-settings',
@@ -282,24 +282,24 @@  discard block
 block discarded – undo
282 282
 								);
283 283
 
284 284
 		$fields['course_archive_image_hard_crop'] = array(
285
-								'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ),
286
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
285
+								'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'),
286
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
287 287
 								'type' => 'checkbox',
288 288
 								'default' => false,
289 289
 								'section' => 'course-settings'
290 290
 								);
291 291
 
292 292
 		$fields['course_single_image_enable'] = array(
293
-								'name' => __( 'Single Course Image', 'woothemes-sensei' ),
294
-								'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ),
293
+								'name' => __('Single Course Image', 'woothemes-sensei'),
294
+								'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'),
295 295
 								'type' => 'checkbox',
296 296
 								'default' => false,
297 297
 								'section' => 'course-settings'
298 298
 								);
299 299
 
300 300
 		$fields['course_single_image_width'] = array(
301
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
302
-								'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
301
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
302
+								'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
303 303
 								'type' => 'text',
304 304
 								'default' => '100',
305 305
 								'section' => 'course-settings',
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 								);
308 308
 
309 309
 		$fields['course_single_image_height'] = array(
310
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
311
-								'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
310
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
311
+								'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
312 312
 								'type' => 'text',
313 313
 								'default' => '100',
314 314
 								'section' => 'course-settings',
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 								);
317 317
 
318 318
 		$fields['course_single_image_hard_crop'] = array(
319
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
320
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
319
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
320
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
321 321
 								'type' => 'checkbox',
322 322
 								'default' => false,
323 323
 								'section' => 'course-settings'
324 324
 								);
325 325
 
326 326
 		$fields['course_single_content_display'] = array(
327
-								'name' => __( 'Single Course page displays:', 'woothemes-sensei' ),
328
-								'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ),
327
+								'name' => __('Single Course page displays:', 'woothemes-sensei'),
328
+								'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'),
329 329
 								'type' => 'select',
330 330
 								'default' => 'excerpt',
331 331
 								'section' => 'course-settings',
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
 								);
335 335
 
336 336
 		$fields['course_archive_featured_enable'] = array(
337
-								'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ),
338
-								'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
337
+								'name' => __('Featured Courses Panel', 'woothemes-sensei'),
338
+								'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
339 339
 								'type' => 'checkbox',
340 340
 								'default' => true,
341 341
 								'section' => 'course-settings'
342 342
 								);
343 343
 
344 344
 		$fields['course_archive_more_link_text'] = array(
345
-								'name' => __( 'More link text', 'woothemes-sensei' ),
346
-								'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ),
345
+								'name' => __('More link text', 'woothemes-sensei'),
346
+								'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'),
347 347
 								'type' => 'text',
348
-								'default' => __ ( 'More', 'woothemes-sensei' ),
348
+								'default' => __('More', 'woothemes-sensei'),
349 349
 								'section' => 'course-settings',
350 350
 								'required' => 0
351 351
 								);
@@ -353,32 +353,32 @@  discard block
 block discarded – undo
353 353
 		// Lesson Settings
354 354
 
355 355
 		$fields['lesson_comments'] = array(
356
-								'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ),
357
-								'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ),
356
+								'name' => __('Allow Comments for Lessons', 'woothemes-sensei'),
357
+								'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'),
358 358
 								'type' => 'checkbox',
359 359
 								'default' => true,
360 360
 								'section' => 'lesson-settings'
361 361
 								);
362 362
 
363 363
 		$fields['lesson_author'] = array(
364
-								'name' => __( 'Display Lesson Author', 'woothemes-sensei' ),
365
-								'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ),
364
+								'name' => __('Display Lesson Author', 'woothemes-sensei'),
365
+								'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'),
366 366
 								'type' => 'checkbox',
367 367
 								'default' => true,
368 368
 								'section' => 'lesson-settings'
369 369
 								);
370 370
 
371 371
 		$fields['course_lesson_image_enable'] = array(
372
-								'name' => __( 'Course Lesson Images', 'woothemes-sensei' ),
373
-								'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ),
372
+								'name' => __('Course Lesson Images', 'woothemes-sensei'),
373
+								'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'),
374 374
 								'type' => 'checkbox',
375 375
 								'default' => false,
376 376
 								'section' => 'lesson-settings'
377 377
 								);
378 378
 
379 379
 		$fields['lesson_archive_image_width'] = array(
380
-								'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ),
381
-								'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
380
+								'name' => __('Image Width - Course Lessons', 'woothemes-sensei'),
381
+								'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
382 382
 								'type' => 'text',
383 383
 								'default' => '100',
384 384
 								'section' => 'lesson-settings',
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 								);
387 387
 
388 388
 		$fields['lesson_archive_image_height'] = array(
389
-								'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ),
390
-								'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
389
+								'name' => __('Image Height - Course Lessons', 'woothemes-sensei'),
390
+								'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
391 391
 								'type' => 'text',
392 392
 								'default' => '100',
393 393
 								'section' => 'lesson-settings',
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
 								);
396 396
 
397 397
 		$fields['lesson_archive_image_hard_crop'] = array(
398
-								'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ),
399
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
398
+								'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'),
399
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
400 400
 								'type' => 'checkbox',
401 401
 								'default' => false,
402 402
 								'section' => 'lesson-settings'
403 403
 								);
404 404
 
405 405
 		$fields['lesson_single_image_enable'] = array(
406
-								'name' => __( 'Single Lesson Images', 'woothemes-sensei' ),
407
-								'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ),
406
+								'name' => __('Single Lesson Images', 'woothemes-sensei'),
407
+								'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'),
408 408
 								'type' => 'checkbox',
409 409
 								'default' => false,
410 410
 								'section' => 'lesson-settings'
411 411
 								);
412 412
 
413 413
 		$fields['lesson_single_image_width'] = array(
414
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
415
-								'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
414
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
415
+								'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
416 416
 								'type' => 'text',
417 417
 								'default' => '100',
418 418
 								'section' => 'lesson-settings',
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 								);
421 421
 
422 422
 		$fields['lesson_single_image_height'] = array(
423
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
424
-								'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
423
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
424
+								'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
425 425
 								'type' => 'text',
426 426
 								'default' => '100',
427 427
 								'section' => 'lesson-settings',
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 								);
430 430
 
431 431
 		$fields['lesson_single_image_hard_crop'] = array(
432
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
433
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
432
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
433
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
434 434
 								'type' => 'checkbox',
435 435
 								'default' => false,
436 436
 								'section' => 'lesson-settings'
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 
439 439
 		// Learner Profile settings
440 440
 
441
-		$profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') );
442
-		$profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%';
441
+		$profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei'));
442
+		$profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%';
443 443
 
444 444
 		$fields['learner_profile_enable'] = array(
445
-							'name' => __( 'Public learner profiles', 'woothemes-sensei' ),
446
-							'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ),
445
+							'name' => __('Public learner profiles', 'woothemes-sensei'),
446
+							'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example),
447 447
 							'type' => 'checkbox',
448 448
 							'default' => true,
449 449
 							'section' => 'learner-profile-settings'
450 450
 							);
451 451
 
452 452
 		$fields['learner_profile_show_courses'] = array(
453
-							'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ),
454
-							'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ),
453
+							'name' => __('Show learner\'s courses', 'woothemes-sensei'),
454
+							'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'),
455 455
 							'type' => 'checkbox',
456 456
 							'default' => true,
457 457
 							'section' => 'learner-profile-settings'
@@ -460,70 +460,70 @@  discard block
 block discarded – undo
460 460
 		// Email notifications
461 461
 
462 462
 		$learner_email_options = array(
463
-			'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ),
464
-			'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ),
463
+			'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'),
464
+			'learner-completed-course' => __('They complete a course', 'woothemes-sensei'),
465 465
 		);
466 466
 
467 467
 		$teacher_email_options = array(
468
-            'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
469
-            'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
470
-            'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
471
-            'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
472
-			'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ),
468
+            'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'),
469
+            'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'),
470
+            'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'),
471
+            'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'),
472
+			'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'),
473 473
 		);
474 474
 
475 475
 		$global_email_options = array(
476
-			'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ),
476
+			'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'),
477 477
 		);
478 478
 
479 479
 		$fields['email_learners'] = array(
480
-								'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ),
481
-								'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ),
480
+								'name' => __('Emails Sent to Learners', 'woothemes-sensei'),
481
+								'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'),
482 482
 								'type' => 'multicheck',
483 483
 								'options' => $learner_email_options,
484
-								'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ),
484
+								'defaults' => array('learner-graded-quiz', 'learner-completed-course'),
485 485
 								'section' => 'email-notification-settings'
486 486
 								);
487 487
 
488 488
 		$fields['email_teachers'] = array(
489
-								'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ),
490
-								'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ),
489
+								'name' => __('Emails Sent to Teachers', 'woothemes-sensei'),
490
+								'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'),
491 491
 								'type' => 'multicheck',
492 492
 								'options' => $teacher_email_options,
493
-								'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ),
493
+								'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'),
494 494
 								'section' => 'email-notification-settings'
495 495
 								);
496 496
 
497 497
 		$fields['email_global'] = array(
498
-								'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ),
499
-								'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ),
498
+								'name' => __('Emails Sent to All Users', 'woothemes-sensei'),
499
+								'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'),
500 500
 								'type' => 'multicheck',
501 501
 								'options' => $global_email_options,
502
-								'defaults' => array( 'new-message-reply' ),
502
+								'defaults' => array('new-message-reply'),
503 503
 								'section' => 'email-notification-settings'
504 504
 								);
505 505
 
506 506
 		$fields['email_from_name'] = array(
507
-								'name' => __( '"From" Name', 'woothemes-sensei' ),
508
-								'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ),
507
+								'name' => __('"From" Name', 'woothemes-sensei'),
508
+								'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'),
509 509
 								'type' => 'text',
510
-								'default' => get_bloginfo( 'name' ),
510
+								'default' => get_bloginfo('name'),
511 511
 								'section' => 'email-notification-settings',
512 512
 								'required' => 1
513 513
 								);
514 514
 
515 515
 		$fields['email_from_address'] = array(
516
-								'name' => __( '"From" Address', 'woothemes-sensei' ),
517
-								'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ),
516
+								'name' => __('"From" Address', 'woothemes-sensei'),
517
+								'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'),
518 518
 								'type' => 'text',
519
-								'default' => get_bloginfo( 'admin_email' ),
519
+								'default' => get_bloginfo('admin_email'),
520 520
 								'section' => 'email-notification-settings',
521 521
 								'required' => 1
522 522
 								);
523 523
 
524 524
 		$fields['email_header_image'] = array(
525
-								'name' => __( 'Header Image', 'woothemes-sensei' ),
526
-								'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ),
525
+								'name' => __('Header Image', 'woothemes-sensei'),
526
+								'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'),
527 527
 								'type' => 'text',
528 528
 								'default' => '',
529 529
 								'section' => 'email-notification-settings',
@@ -531,17 +531,17 @@  discard block
 block discarded – undo
531 531
 								);
532 532
 
533 533
 		$fields['email_footer_text'] = array(
534
-								'name' => __( 'Email Footer Text', 'woothemes-sensei' ),
535
-								'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ),
534
+								'name' => __('Email Footer Text', 'woothemes-sensei'),
535
+								'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'),
536 536
 								'type' => 'textarea',
537
-								'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ),
537
+								'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')),
538 538
 								'section' => 'email-notification-settings',
539 539
 								'required' => 0
540 540
 								);
541 541
 
542 542
 		$fields['email_base_color'] = array(
543
-								'name' => __( 'Base Colour', 'woothemes-sensei' ),
544
-								'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
543
+								'name' => __('Base Colour', 'woothemes-sensei'),
544
+								'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
545 545
 								'type' => 'color',
546 546
 								'default' => '#557da1',
547 547
 								'section' => 'email-notification-settings',
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 								);
550 550
 
551 551
 		$fields['email_background_color'] = array(
552
-								'name' => __( 'Background Colour', 'woothemes-sensei' ),
553
-								'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
552
+								'name' => __('Background Colour', 'woothemes-sensei'),
553
+								'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
554 554
 								'type' => 'color',
555 555
 								'default' => '#f5f5f5',
556 556
 								'section' => 'email-notification-settings',
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 								);
559 559
 
560 560
 		$fields['email_body_background_color'] = array(
561
-								'name' => __( 'Body Background Colour', 'woothemes-sensei' ),
562
-								'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
561
+								'name' => __('Body Background Colour', 'woothemes-sensei'),
562
+								'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
563 563
 								'type' => 'color',
564 564
 								'default' => '#fdfdfd',
565 565
 								'section' => 'email-notification-settings',
@@ -567,35 +567,35 @@  discard block
 block discarded – undo
567 567
 								);
568 568
 
569 569
 		$fields['email_text_color'] = array(
570
-								'name' => __( 'Body Text Colour', 'woothemes-sensei' ),
571
-								'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
570
+								'name' => __('Body Text Colour', 'woothemes-sensei'),
571
+								'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
572 572
 								'type' => 'color',
573 573
 								'default' => '#505050',
574 574
 								'section' => 'email-notification-settings',
575 575
 								'required' => 1
576 576
 								);
577 577
 
578
-		if ( Sensei_WC::is_woocommerce_present() ) {
578
+		if (Sensei_WC::is_woocommerce_present()) {
579 579
 			// WooCommerce Settings
580 580
     		$fields['woocommerce_enabled'] = array(
581
-									'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ),
582
-									'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ),
581
+									'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'),
582
+									'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'),
583 583
 									'type' => 'checkbox',
584 584
 									'default' => true,
585 585
 									'section' => 'woocommerce-settings'
586 586
 									);
587 587
 
588 588
 			$fields['course_archive_free_enable'] = array(
589
-									'name' => __( 'Free Courses Panel', 'woothemes-sensei' ),
590
-									'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
589
+									'name' => __('Free Courses Panel', 'woothemes-sensei'),
590
+									'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
591 591
 									'type' => 'checkbox',
592 592
 									'default' => true,
593 593
 									'section' => 'woocommerce-settings'
594 594
 									);
595 595
 
596 596
 			$fields['course_archive_paid_enable'] = array(
597
-									'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ),
598
-									'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
597
+									'name' => __('Paid Courses Panel', 'woothemes-sensei'),
598
+									'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
599 599
 									'type' => 'checkbox',
600 600
 									'default' => true,
601 601
 									'section' => 'woocommerce-settings'
@@ -603,18 +603,18 @@  discard block
 block discarded – undo
603 603
 
604 604
 		} // End If Statement
605 605
 
606
-		if ( 'en_US' !== get_locale() ) {
606
+		if ('en_US' !== get_locale()) {
607 607
 			$fields['install_language_pack'] = array(
608
-				'name'        => __( 'Install Language Pack', 'woothemes-sensei' ),
609
-				'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ),
608
+				'name'        => __('Install Language Pack', 'woothemes-sensei'),
609
+				'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'),
610 610
 				'type'        => 'button',
611 611
 				'section'     => 'language-settings',
612 612
 				'target'      => Sensei_Language_Pack_Manager::get_install_uri(),
613
-				'label'       => __( 'Install', 'woothemes-sensei' )
613
+				'label'       => __('Install', 'woothemes-sensei')
614 614
 			);
615 615
 		}
616 616
 
617
-		$this->fields = apply_filters( 'sensei_settings_fields', $fields );
617
+		$this->fields = apply_filters('sensei_settings_fields', $fields);
618 618
 
619 619
 	} // End init_fields()
620 620
 
@@ -624,20 +624,20 @@  discard block
 block discarded – undo
624 624
 	 * @param  $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1.
625 625
 	 * @return array Options between 0.1 and 10 seconds.
626 626
 	 */
627
-	private function get_duration_options ( $include_milliseconds = true ) {
628
-		$numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' );
627
+	private function get_duration_options($include_milliseconds = true) {
628
+		$numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0');
629 629
 		$options = array();
630 630
 
631
-		if ( true == (bool)$include_milliseconds ) {
632
-			$milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' );
633
-			foreach ( $milliseconds as $k => $v ) {
631
+		if (true == (bool) $include_milliseconds) {
632
+			$milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9');
633
+			foreach ($milliseconds as $k => $v) {
634 634
 				$options[$v] = $v;
635 635
 			}
636 636
 		} else {
637 637
 			$options['0.5'] = '0.5';
638 638
 		}
639 639
 
640
-		foreach ( $numbers as $k => $v ) {
640
+		foreach ($numbers as $k => $v) {
641 641
 			$options[$v] = $v;
642 642
 		}
643 643
 
@@ -653,25 +653,25 @@  discard block
 block discarded – undo
653 653
 	private function pages_array() {
654 654
 		// REFACTOR - Transform this into a field type instead.
655 655
 		// Setup an array of portfolio gallery terms for a dropdown.
656
-		$args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' );
657
-		$pages_dropdown = wp_dropdown_pages( $args );
656
+		$args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC');
657
+		$pages_dropdown = wp_dropdown_pages($args);
658 658
 		$page_items = array();
659 659
 
660 660
 		// Quick string hack to make sure we get the pages with the indents.
661
-		$pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown );
662
-		$pages_dropdown = str_replace( '</select>', '', $pages_dropdown );
663
-		$pages_split = explode( '</option>', $pages_dropdown );
661
+		$pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown);
662
+		$pages_dropdown = str_replace('</select>', '', $pages_dropdown);
663
+		$pages_split = explode('</option>', $pages_dropdown);
664 664
 
665
-		$page_items[] = __( 'Select a Page:', 'woothemes-sensei' );
665
+		$page_items[] = __('Select a Page:', 'woothemes-sensei');
666 666
 
667
-		foreach ( $pages_split as $k => $v ) {
667
+		foreach ($pages_split as $k => $v) {
668 668
 		    $id = '';
669 669
 		    // Get the ID value.
670
-		    preg_match( '/value="(.*?)"/i', $v, $matches );
670
+		    preg_match('/value="(.*?)"/i', $v, $matches);
671 671
 
672
-		    if ( isset( $matches[1] ) ) {
672
+		    if (isset($matches[1])) {
673 673
 		        $id = $matches[1];
674
-		        $page_items[$id] = trim( strip_tags( $v ) );
674
+		        $page_items[$id] = trim(strip_tags($v));
675 675
 		    } // End If Statement
676 676
 		} // End For Loop
677 677
 
@@ -695,10 +695,10 @@  discard block
 block discarded – undo
695 695
      *
696 696
      * @since 1.9.0
697 697
      */
698
-    public static function flush_rewrite_rules(){
698
+    public static function flush_rewrite_rules() {
699 699
 
700
-        if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
701
-            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
700
+        if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page']
701
+            && isset($_POST['action']) && 'update' == $_POST['action']) {
702 702
 
703 703
             Sensei()->initiate_rewrite_rules_flush();
704 704
 
@@ -712,4 +712,4 @@  discard block
 block discarded – undo
712 712
  * @ignore only for backward compatibility
713 713
  * @since 1.9.0
714 714
  */
715
-class WooThemes_Sensei_Settings extends Sensei_Settings{}
715
+class WooThemes_Sensei_Settings extends Sensei_Settings {}
Please login to merge, or discard this patch.
includes/class-sensei-admin.php 1 patch
Spacing   +416 added lines, -416 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * Handles all admin views, assets and navigation.
@@ -14,51 +14,51 @@  discard block
 block discarded – undo
14 14
 	 * Constructor.
15 15
 	 * @since  1.0.0
16 16
 	 */
17
-	public function __construct () {
17
+	public function __construct() {
18 18
 
19 19
         //register admin styles
20
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) );
20
+		add_action('admin_enqueue_scripts', array($this, 'admin_styles_global'));
21 21
 
22 22
         //register admin scripts
23
-        add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
23
+        add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
24 24
 
25
-		add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) );
26
-		add_action( 'settings_before_form', array( $this, 'install_pages_output' ) );
27
-		add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
28
-		add_action( 'menu_order', array( $this, 'admin_menu_order' ) );
29
-		add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) );
30
-		add_action( 'admin_init', array( $this, 'page_redirect' ) );
31
-		add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) );
32
-        add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
25
+		add_action('admin_print_styles', array($this, 'admin_notices_styles'));
26
+		add_action('settings_before_form', array($this, 'install_pages_output'));
27
+		add_action('admin_menu', array($this, 'admin_menu'), 10);
28
+		add_action('menu_order', array($this, 'admin_menu_order'));
29
+		add_action('admin_head', array($this, 'admin_menu_highlight'));
30
+		add_action('admin_init', array($this, 'page_redirect'));
31
+		add_action('admin_init', array($this, 'sensei_add_custom_menu_items'));
32
+        add_action('admin_init', array(__CLASS__, 'install_pages'));
33 33
 
34 34
 		// Duplicate lesson & courses
35
-		add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 );
36
-		add_action( 'admin_action_duplicate_lesson', array( $this, 'duplicate_lesson_action' ) );
37
-		add_action( 'admin_action_duplicate_course', array( $this, 'duplicate_course_action' ) );
38
-		add_action( 'admin_action_duplicate_course_with_lessons', array( $this, 'duplicate_course_with_lessons_action' ) );
35
+		add_filter('post_row_actions', array($this, 'duplicate_action_link'), 10, 2);
36
+		add_action('admin_action_duplicate_lesson', array($this, 'duplicate_lesson_action'));
37
+		add_action('admin_action_duplicate_course', array($this, 'duplicate_course_action'));
38
+		add_action('admin_action_duplicate_course_with_lessons', array($this, 'duplicate_course_with_lessons_action'));
39 39
 
40 40
 		// Handle lessons list table filtering
41
-		add_action( 'restrict_manage_posts', array( $this, 'lesson_filter_options' ) );
42
-		add_filter( 'request', array( $this, 'lesson_filter_actions' ) );
41
+		add_action('restrict_manage_posts', array($this, 'lesson_filter_options'));
42
+		add_filter('request', array($this, 'lesson_filter_actions'));
43 43
 
44 44
 		// Add Sensei items to 'at a glance' widget
45
-		add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
45
+		add_filter('dashboard_glance_items', array($this, 'glance_items'), 10, 1);
46 46
 
47 47
 		// Handle course and lesson deletions
48
-		add_action( 'trash_course', array( $this, 'delete_content' ), 10, 2 );
49
-		add_action( 'trash_lesson', array( $this, 'delete_content' ), 10, 2 );
48
+		add_action('trash_course', array($this, 'delete_content'), 10, 2);
49
+		add_action('trash_lesson', array($this, 'delete_content'), 10, 2);
50 50
 
51 51
 		// Delete user activity when user is deleted
52
-		add_action( 'deleted_user', array( $this, 'delete_user_activity' ), 10, 1 );
52
+		add_action('deleted_user', array($this, 'delete_user_activity'), 10, 1);
53 53
 
54 54
 		// Add notices to WP dashboard
55
-		add_action( 'admin_notices', array( $this, 'theme_compatibility_notices' ) );
55
+		add_action('admin_notices', array($this, 'theme_compatibility_notices'));
56 56
 
57 57
 		// Reset theme notices when switching themes
58
-		add_action( 'switch_theme', array( $this, 'reset_theme_check_notices' ) );
58
+		add_action('switch_theme', array($this, 'reset_theme_check_notices'));
59 59
 
60 60
 		// Allow Teacher access the admin area
61
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'admin_access' ) );
61
+		add_filter('woocommerce_prevent_admin_access', array($this, 'admin_access'));
62 62
 
63 63
 	} // End __construct()
64 64
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 	public function admin_menu() {
71 71
 		global $menu;
72 72
 		$menu_cap = '';
73
-		if( current_user_can( 'manage_sensei' ) ) {
73
+		if (current_user_can('manage_sensei')) {
74 74
 			$menu_cap = 'manage_sensei';
75 75
 		} else {
76
-			if( current_user_can( 'manage_sensei_grades' ) ) {
76
+			if (current_user_can('manage_sensei_grades')) {
77 77
 				$menu_cap = 'manage_sensei_grades';
78 78
 			}
79 79
 		}
80 80
 
81
-		if( $menu_cap ) {
82
-			$menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' );
83
-            add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
81
+		if ($menu_cap) {
82
+			$menu[] = array('', 'read', 'separator-sensei', '', 'wp-menu-separator sensei');
83
+            add_menu_page('Sensei', 'Sensei', $menu_cap, 'sensei', array(Sensei()->analysis, 'analysis_page'), '', '50');
84 84
 		}
85 85
 
86
-		add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) );
87
-		add_submenu_page( 'edit.php?post_type=lesson', __( 'Order Lessons', 'woothemes-sensei' ), __( 'Order Lessons', 'woothemes-sensei' ), 'edit_lessons', 'lesson-order', array( $this, 'lesson_order_screen' ) );
86
+		add_submenu_page('edit.php?post_type=course', __('Order Courses', 'woothemes-sensei'), __('Order Courses', 'woothemes-sensei'), 'manage_sensei', 'course-order', array($this, 'course_order_screen'));
87
+		add_submenu_page('edit.php?post_type=lesson', __('Order Lessons', 'woothemes-sensei'), __('Order Lessons', 'woothemes-sensei'), 'edit_lessons', 'lesson-order', array($this, 'lesson_order_screen'));
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
 	 * @param  array $menu_order Existing menu order
94 94
 	 * @return array 			 Modified menu order for Sensei
95 95
 	 */
96
-	public function admin_menu_order( $menu_order ) {
96
+	public function admin_menu_order($menu_order) {
97 97
 
98 98
 		// Initialize our custom order array
99 99
 		$sensei_menu_order = array();
100 100
 
101 101
 		// Get the index of our custom separator
102
-		$sensei_separator = array_search( 'separator-sensei', $menu_order );
102
+		$sensei_separator = array_search('separator-sensei', $menu_order);
103 103
 
104 104
 		// Loop through menu order and do some rearranging
105
-		foreach ( $menu_order as $index => $item ) :
105
+		foreach ($menu_order as $index => $item) :
106 106
 
107
-			if ( ( ( 'sensei' ) == $item ) ) :
107
+			if ((('sensei') == $item)) :
108 108
 				$sensei_menu_order[] = 'separator-sensei';
109 109
 				$sensei_menu_order[] = $item;
110
-				unset( $menu_order[$sensei_separator] );
111
-			elseif ( !in_array( $item, array( 'separator-sensei' ) ) ) :
110
+				unset($menu_order[$sensei_separator]);
111
+			elseif ( ! in_array($item, array('separator-sensei'))) :
112 112
 				$sensei_menu_order[] = $item;
113 113
 			endif;
114 114
 
@@ -128,28 +128,28 @@  discard block
 block discarded – undo
128 128
 
129 129
 		$screen = get_current_screen();
130 130
 
131
-        if( empty( $screen ) ){
131
+        if (empty($screen)) {
132 132
             return;
133 133
         }
134 134
 
135
-		if ( $screen->base == 'post' && $post_type == 'course' ) {
135
+		if ($screen->base == 'post' && $post_type == 'course') {
136 136
 
137
-			$parent_file  = 'edit.php?post_type=course';
137
+			$parent_file = 'edit.php?post_type=course';
138 138
 
139
-		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) {
139
+		} elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') {
140 140
 
141 141
 			$submenu_file = 'edit-tags.php?taxonomy=course-category&amp;post_type=course';
142 142
 			$parent_file  = 'edit.php?post_type=course';
143 143
 
144
-        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
144
+        } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') {
145 145
 
146 146
             $submenu_file = 'edit-tags.php?taxonomy=module';
147 147
             $parent_file  = 'edit.php?post_type=course';
148 148
 
149
-		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) {
149
+		} elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) {
150 150
 
151 151
             $submenu_file = 'edit.php?post_type=sensei_message';
152
-			$parent_file  = 'sensei';
152
+			$parent_file = 'sensei';
153 153
 
154 154
 		}
155 155
 	}
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * @return void
161 161
 	 */
162 162
 	public function page_redirect() {
163
-		if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) {
164
-			wp_safe_redirect( 'admin.php?page=sensei_analysis' );
163
+		if (isset($_GET['page']) && $_GET['page'] == 'sensei') {
164
+			wp_safe_redirect('admin.php?page=sensei_analysis');
165 165
 			exit;
166 166
 		}
167 167
 	}
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	function install_pages_output() {
178 178
 
179
-        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
179
+        if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
180 180
 
181 181
             ?>
182 182
             <div id="message" class="updated sensei-message sensei-connect">
183
-                <p><?php _e( '<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p>
183
+                <p><?php _e('<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei'); ?></p>
184 184
                 <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a>
185 185
                 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p>
186 186
             </div>
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 	 * @param int $post_parent (default: 0)
203 203
 	 * @return integer $page_id
204 204
 	 */
205
-	function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) {
205
+	function create_page($slug, $page_title = '', $page_content = '', $post_parent = 0) {
206 206
 		global $wpdb;
207 207
 
208
-        $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) );
209
-		if ( $page_id ) :
208
+        $page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug));
209
+		if ($page_id) :
210 210
 			return $page_id;
211 211
 		endif;
212 212
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	        'comment_status' 	=> 'closed'
222 222
 	    );
223 223
 
224
-	    $page_id = wp_insert_post( $page_data );
224
+	    $page_id = wp_insert_post($page_data);
225 225
 
226 226
 	    return $page_id;
227 227
 
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	function create_pages() {
238 238
 
239 239
 		// Courses page
240
-	    $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ),  __('Courses', 'woothemes-sensei'), '' );
241
-        Sensei()->settings->set( 'course_page', $new_course_page_id );
240
+	    $new_course_page_id = $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), __('Courses', 'woothemes-sensei'), '');
241
+        Sensei()->settings->set('course_page', $new_course_page_id);
242 242
 
243 243
         // User Dashboard page
244
-	    $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' );
245
-        Sensei()->settings->set( 'my_course_page',$new_my_course_page_id  );
244
+	    $new_my_course_page_id = $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]');
245
+        Sensei()->settings->set('my_course_page', $new_my_course_page_id);
246 246
 
247 247
 	} // End create_pages()
248 248
 
@@ -252,25 +252,25 @@  discard block
 block discarded – undo
252 252
 	 * @since 1.0.0
253 253
 	 * @return void
254 254
 	 */
255
-	public function admin_styles_global ( $hook ) {
255
+	public function admin_styles_global($hook) {
256 256
 		global $post_type;
257 257
 
258
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
259
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
260
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) );
258
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
259
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
260
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order'));
261 261
 
262 262
 		// Global Styles for icons and menu items
263
-		wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' );
264
-		wp_enqueue_style( 'woothemes-sensei-global' );
263
+		wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen');
264
+		wp_enqueue_style('woothemes-sensei-global');
265 265
 
266 266
         // Select 2 styles
267
-        wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
267
+        wp_enqueue_style('sensei-core-select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen');
268 268
 
269 269
 		// Test for Write Panel Pages
270
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
270
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
271 271
 
272
-			wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' );
273
-			wp_enqueue_style( 'woothemes-sensei-admin-custom' );
272
+			wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen');
273
+			wp_enqueue_style('woothemes-sensei-admin-custom');
274 274
 
275 275
 		}
276 276
 
@@ -285,20 +285,20 @@  discard block
 block discarded – undo
285 285
      * @since 1.8.2
286 286
      * @access public
287 287
      */
288
-    public function register_scripts( $hook ){
288
+    public function register_scripts($hook) {
289 289
 
290 290
         $screen = get_current_screen();
291 291
 
292 292
         // Allow developers to load non-minified versions of scripts
293
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
293
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
294 294
 
295 295
         // Select2 script used to enhance all select boxes
296
-        wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
296
+        wp_register_script('sensei-core-select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version);
297 297
 
298 298
         // load edit module scripts
299
-        if( 'edit-module' ==  $screen->id ){
299
+        if ('edit-module' == $screen->id) {
300 300
 
301
-            wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
301
+            wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true);
302 302
 
303 303
         }
304 304
 
@@ -316,19 +316,19 @@  discard block
 block discarded – undo
316 316
 	    <div id="message" class="updated sensei-message sensei-connect">
317 317
 
318 318
             <p>
319
-                <?php _e( '<strong>Welcome to Sensei</strong> &#8211; You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?>
319
+                <?php _e('<strong>Welcome to Sensei</strong> &#8211; You\'re almost ready to create some courses!', 'woothemes-sensei'); ?>
320 320
             </p>
321 321
 
322 322
             <p class="submit">
323 323
 
324
-                <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>"
324
+                <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>"
325 325
                    class="button-primary">
326 326
 
327
-                    <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?>
327
+                    <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?>
328 328
 
329 329
                 </a>
330 330
 
331
-                <a class="skip button" href="<?php echo esc_url( add_query_arg( 'skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings' ) ) ); ?>">
331
+                <a class="skip button" href="<?php echo esc_url(add_query_arg('skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>">
332 332
 
333 333
                     <?php _e('Skip setup', 'woothemes-sensei'); ?>
334 334
 
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 	    <div id="message" class="updated sensei-message sensei-connect">
352 352
 
353 353
 	    	<p>
354
-                <?php _e( '<strong>Sensei has been installed</strong> &#8211; You\'re ready to start creating courses!', 'woothemes-sensei' ); ?>
354
+                <?php _e('<strong>Sensei has been installed</strong> &#8211; You\'re ready to start creating courses!', 'woothemes-sensei'); ?>
355 355
             </p>
356 356
 
357 357
 			<p class="submit">
358
-                <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/">
358
+                <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e('Settings', 'woothemes-sensei'); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/">
359 359
                     <?php _e('Documentation', 'woothemes-sensei'); ?>
360 360
                 </a>
361 361
             </p>
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 	public function language_pack_install_notice() {
389 389
 		?>
390 390
 		<div id="message" class="updated sensei-message sensei-connect">
391
-				<p><?php _e( '<strong>Sensei in your language</strong> &#8211; There is a translation available for your language.', 'woothemes-sensei' ); ?><p>
391
+				<p><?php _e('<strong>Sensei in your language</strong> &#8211; There is a translation available for your language.', 'woothemes-sensei'); ?><p>
392 392
 
393 393
 				<p class="submit">
394
-					<a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a>
395
-					<a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a>
394
+					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a>
395
+					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a>
396 396
 				</p>
397 397
 		</div>
398 398
 		<?php
@@ -408,20 +408,20 @@  discard block
 block discarded – undo
408 408
 	function admin_notices_styles() {
409 409
 
410 410
 		// Installed notices
411
-	    if ( 1 == get_option( 'sensei_installed' ) ) {
411
+	    if (1 == get_option('sensei_installed')) {
412 412
 
413
-	    	wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
413
+	    	wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version);
414 414
 
415
-	    	if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
416
-	    		add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
417
-	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
418
-	    		add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
415
+	    	if (get_option('skip_install_sensei_pages') != 1 && Sensei()->get_page_id('course') < 1 && ! isset($_GET['install_sensei_pages']) && ! isset($_GET['skip_install_sensei_pages'])) {
416
+	    		add_action('admin_notices', array($this, 'admin_install_notice'));
417
+	    	} elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') {
418
+	    		add_action('admin_notices', array($this, 'admin_installed_notice'));
419 419
 	    	} // End If Statement
420 420
 
421 421
 	    } // End If Statement
422 422
 
423
-	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
424
-	    	add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
423
+	    if (Sensei_Language_Pack_Manager::has_language_pack_available()) {
424
+	    	add_action('admin_notices', array($this, 'language_pack_install_notice'));
425 425
 	    }
426 426
 
427 427
 	} // End admin_notices_styles()
@@ -432,17 +432,17 @@  discard block
 block discarded – undo
432 432
 	 * @param  object $post    Current post
433 433
 	 * @return array           Modified actions
434 434
 	 */
435
-	public function duplicate_action_link( $actions, $post ) {
436
-		switch( $post->post_type ) {
435
+	public function duplicate_action_link($actions, $post) {
436
+		switch ($post->post_type) {
437 437
 			case 'lesson':
438
-				$confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' );
439
-				$actions['duplicate'] = "<a onclick='return confirm(\"" . $confirm . "\");' href='" . $this->get_duplicate_link( $post->ID ) . "' title='" . esc_attr(__( 'Duplicate this lesson', 'woothemes-sensei' ) ) . "'>" .  __('Duplicate', 'woothemes-sensei' ) . "</a>";
438
+				$confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei');
439
+				$actions['duplicate'] = "<a onclick='return confirm(\"".$confirm."\");' href='".$this->get_duplicate_link($post->ID)."' title='".esc_attr(__('Duplicate this lesson', 'woothemes-sensei'))."'>".__('Duplicate', 'woothemes-sensei')."</a>";
440 440
 			break;
441 441
 
442 442
 			case 'course':
443
-				$confirm = __( 'This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei' );
444
-				$actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' .  __('Duplicate', 'woothemes-sensei' ) . '</a>';
445
-				$actions['duplicate_with_lessons'] = '<a onclick="return confirm(\'' . $confirm . '\');" href="' . $this->get_duplicate_link( $post->ID, true ) . '" title="' . esc_attr(__( 'Duplicate this course with its lessons', 'woothemes-sensei' ) ) . '">' .  __('Duplicate (with lessons)', 'woothemes-sensei' ) . '</a>';
443
+				$confirm = __('This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei');
444
+				$actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>';
445
+				$actions['duplicate_with_lessons'] = '<a onclick="return confirm(\''.$confirm.'\');" href="'.$this->get_duplicate_link($post->ID, true).'" title="'.esc_attr(__('Duplicate this course with its lessons', 'woothemes-sensei')).'">'.__('Duplicate (with lessons)', 'woothemes-sensei').'</a>';
446 446
 			break;
447 447
 		}
448 448
 
@@ -455,17 +455,17 @@  discard block
 block discarded – undo
455 455
 	 * @param  boolean $with_lessons Include lessons or not
456 456
 	 * @return string                Duplication link
457 457
 	 */
458
-	private function get_duplicate_link( $post_id = 0, $with_lessons = false ) {
458
+	private function get_duplicate_link($post_id = 0, $with_lessons = false) {
459 459
 
460
-		$post = get_post( $post_id );
460
+		$post = get_post($post_id);
461 461
 
462
-		$action = 'duplicate_' . $post->post_type;
462
+		$action = 'duplicate_'.$post->post_type;
463 463
 
464
-		if( 'course' == $post->post_type && $with_lessons ) {
464
+		if ('course' == $post->post_type && $with_lessons) {
465 465
 			$action .= '_with_lessons';
466 466
 		}
467 467
 
468
-		return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id );
468
+		return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id);
469 469
 	}
470 470
 
471 471
 	/**
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	 * @return void
474 474
 	 */
475 475
 	public function duplicate_lesson_action() {
476
-		$this->duplicate_content( 'lesson' );
476
+		$this->duplicate_content('lesson');
477 477
 	}
478 478
 
479 479
 	/**
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 * @return void
482 482
 	 */
483 483
 	public function duplicate_course_action() {
484
-		$this->duplicate_content( 'course' );
484
+		$this->duplicate_content('course');
485 485
 	}
486 486
 
487 487
 	/**
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 	 * @return void
490 490
 	 */
491 491
 	public function duplicate_course_with_lessons_action() {
492
-		$this->duplicate_content( 'course', true );
492
+		$this->duplicate_content('course', true);
493 493
 	}
494 494
 
495 495
 	/**
@@ -498,34 +498,34 @@  discard block
 block discarded – undo
498 498
 	 * @param  boolean $with_lessons Include lessons or not
499 499
 	 * @return void
500 500
 	 */
501
-	private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) {
502
-		if ( ! isset( $_GET['post'] ) ) {
503
-			wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type );
501
+	private function duplicate_content($post_type = 'lesson', $with_lessons = false) {
502
+		if ( ! isset($_GET['post'])) {
503
+			wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type);
504 504
 		}
505 505
 
506 506
 		$post_id = $_GET['post'];
507
-		$post = get_post( $post_id );
507
+		$post = get_post($post_id);
508 508
 
509
-		if( ! is_wp_error( $post ) ) {
509
+		if ( ! is_wp_error($post)) {
510 510
 
511
-			$new_post = $this->duplicate_post( $post );
511
+			$new_post = $this->duplicate_post($post);
512 512
 
513
-			if( $new_post && ! is_wp_error( $new_post ) ) {
513
+			if ($new_post && ! is_wp_error($new_post)) {
514 514
 
515
-				if( 'lesson' == $new_post->post_type ) {
516
-					$this->duplicate_lesson_quizzes( $post_id, $new_post->ID );
515
+				if ('lesson' == $new_post->post_type) {
516
+					$this->duplicate_lesson_quizzes($post_id, $new_post->ID);
517 517
 				}
518 518
 
519
-				if( 'course' == $new_post->post_type && $with_lessons ) {
520
-					$this->duplicate_course_lessons( $post_id, $new_post->ID );
519
+				if ('course' == $new_post->post_type && $with_lessons) {
520
+					$this->duplicate_course_lessons($post_id, $new_post->ID);
521 521
 				}
522 522
 
523
-				$redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' );
523
+				$redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit');
524 524
 			} else {
525
-				$redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' );
525
+				$redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed');
526 526
 			}
527 527
 
528
-			wp_safe_redirect( esc_url_raw( $redirect_url ) );
528
+			wp_safe_redirect(esc_url_raw($redirect_url));
529 529
 			exit;
530 530
 		}
531 531
 	}
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
 	 * @param  integer $new_lesson_id ID of duplicate lesson
537 537
 	 * @return void
538 538
 	 */
539
-	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) {
539
+	private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) {
540 540
 
541
-        $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
542
-        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
541
+        $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id);
542
+        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id);
543 543
 
544 544
         // duplicate the generic wp post information
545
-		$new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' );
545
+		$new_quiz = $this->duplicate_post(get_post($old_quiz_id), '');
546 546
 
547 547
 		//update the new lesson data
548
-        add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
548
+        add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID);
549 549
 
550 550
 		//update the new quiz data
551
-        add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
551
+        add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id);
552 552
         wp_update_post(
553 553
             array(
554 554
                 'ID' => $new_quiz->ID,
@@ -556,15 +556,15 @@  discard block
 block discarded – undo
556 556
             )
557 557
         );
558 558
 
559
-		foreach( $old_quiz_questions as $question ) {
559
+		foreach ($old_quiz_questions as $question) {
560 560
 
561 561
 			// copy the question order over to the new quiz
562
-			$old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true );
563
-            $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
564
-            add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
562
+			$old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true);
563
+            $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order);
564
+            add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order);
565 565
 
566 566
 			// Add question to quiz
567
-			add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false );
567
+			add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false);
568 568
 
569 569
 		}
570 570
 	}
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	 * @param  integer $new_course_id ID of duplicated course
576 576
 	 * @return void
577 577
 	 */
578
-	private function duplicate_course_lessons( $old_course_id, $new_course_id ) {
578
+	private function duplicate_course_lessons($old_course_id, $new_course_id) {
579 579
 		$lesson_args = array(
580 580
 			'post_type' => 'lesson',
581 581
 			'posts_per_page' => -1,
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 			'meta_value' => $old_course_id,
584 584
 			'suppress_filters' 	=> 0
585 585
 		);
586
-		$lessons = get_posts( $lesson_args );
586
+		$lessons = get_posts($lesson_args);
587 587
 
588
-		foreach( $lessons as $lesson ) {
589
-			$new_lesson = $this->duplicate_post( $lesson, '', true );
590
-			add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id );
588
+		foreach ($lessons as $lesson) {
589
+			$new_lesson = $this->duplicate_post($lesson, '', true);
590
+			add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id);
591 591
 
592
-			$this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID );
592
+			$this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID);
593 593
 		}
594 594
 	}
595 595
 
@@ -600,24 +600,24 @@  discard block
 block discarded – undo
600 600
 	 * @param  boolean $ignore_course Ignore lesson course when dulicating
601 601
 	 * @return object                 Duplicate post object
602 602
 	 */
603
-	private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) {
603
+	private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) {
604 604
 
605 605
 		$new_post = array();
606 606
 
607
-		foreach( $post as $k => $v ) {
608
-			if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) {
609
-				$new_post[ $k ] = $v;
607
+		foreach ($post as $k => $v) {
608
+			if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) {
609
+				$new_post[$k] = $v;
610 610
 			}
611 611
 		}
612 612
 
613
-		$new_post['post_title'] .= __( $suffix, 'woothemes-sensei' );
613
+		$new_post['post_title'] .= __($suffix, 'woothemes-sensei');
614 614
 
615
-		$new_post['post_date'] = current_time( 'mysql' );
616
-		$new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] );
615
+		$new_post['post_date'] = current_time('mysql');
616
+		$new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']);
617 617
 		$new_post['post_modified'] = $new_post['post_date'];
618 618
 		$new_post['post_modified_gmt'] = $new_post['post_date_gmt'];
619 619
 
620
-		switch( $post->post_type ) {
620
+		switch ($post->post_type) {
621 621
 			case 'course': $new_post['post_status'] = 'draft'; break;
622 622
 			case 'lesson': $new_post['post_status'] = 'draft'; break;
623 623
 			case 'quiz': $new_post['post_status'] = 'publish'; break;
@@ -625,45 +625,45 @@  discard block
 block discarded – undo
625 625
 		}
626 626
 
627 627
 		// As per wp_update_post() we need to escape the data from the db.
628
-		$new_post = wp_slash( $new_post );
628
+		$new_post = wp_slash($new_post);
629 629
 
630
-		$new_post_id = wp_insert_post( $new_post );
630
+		$new_post_id = wp_insert_post($new_post);
631 631
 
632
-		if( ! is_wp_error( $new_post_id ) ) {
632
+		if ( ! is_wp_error($new_post_id)) {
633 633
 
634
-			$post_meta = get_post_custom( $post->ID );
635
-			if( $post_meta && count( $post_meta ) > 0 ) {
634
+			$post_meta = get_post_custom($post->ID);
635
+			if ($post_meta && count($post_meta) > 0) {
636 636
 
637
-				$ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' );
637
+				$ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz');
638 638
 
639
-				if( $ignore_course ) {
639
+				if ($ignore_course) {
640 640
 					$ignore_meta[] = '_lesson_course';
641 641
 				}
642 642
 
643
-				foreach( $post_meta as $key => $meta ) {
644
-					foreach( $meta as $value ) {
645
-						$value = maybe_unserialize( $value );
646
-						if( ! in_array( $key, $ignore_meta ) ) {
647
-							add_post_meta( $new_post_id, $key, $value );
643
+				foreach ($post_meta as $key => $meta) {
644
+					foreach ($meta as $value) {
645
+						$value = maybe_unserialize($value);
646
+						if ( ! in_array($key, $ignore_meta)) {
647
+							add_post_meta($new_post_id, $key, $value);
648 648
 						}
649 649
 					}
650 650
 				}
651 651
 			}
652 652
 
653
-			add_post_meta( $new_post_id, '_duplicate', $post->ID );
653
+			add_post_meta($new_post_id, '_duplicate', $post->ID);
654 654
 
655
-			$taxonomies = get_object_taxonomies( $post->post_type, 'objects' );
655
+			$taxonomies = get_object_taxonomies($post->post_type, 'objects');
656 656
 
657
-			foreach ( $taxonomies as $slug => $tax ) {
658
-				$terms = get_the_terms( $post->ID, $slug );
659
-				if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) {
660
-					foreach( $terms as $term ) {
661
-						wp_set_object_terms( $new_post_id, $term->term_id, $slug, true );
657
+			foreach ($taxonomies as $slug => $tax) {
658
+				$terms = get_the_terms($post->ID, $slug);
659
+				if (isset($terms) && is_array($terms) && 0 < count($terms)) {
660
+					foreach ($terms as $term) {
661
+						wp_set_object_terms($new_post_id, $term->term_id, $slug, true);
662 662
 					}
663 663
 				}
664 664
 			}
665 665
 
666
-			$new_post = get_post( $new_post_id );
666
+			$new_post = get_post($new_post_id);
667 667
 
668 668
 			return $new_post;
669 669
 		}
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	public function lesson_filter_options() {
679 679
 		global $typenow;
680 680
 
681
-		if( is_admin() && 'lesson' == $typenow ) {
681
+		if (is_admin() && 'lesson' == $typenow) {
682 682
 
683 683
 			$args = array(
684 684
 				'post_type' => 'course',
@@ -688,16 +688,16 @@  discard block
 block discarded – undo
688 688
 				'orderby' => 'menu_order date',
689 689
 				'order' => 'ASC',
690 690
 			);
691
-			$courses = get_posts( $args );
691
+			$courses = get_posts($args);
692 692
 
693
-			$selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : '';
693
+			$selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : '';
694 694
 			$course_options = '';
695
-			foreach( $courses as $course ) {
696
-				$course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>';
695
+			foreach ($courses as $course) {
696
+				$course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>';
697 697
 			}
698 698
 
699 699
 			$output = '<select name="lesson_course" id="dropdown_lesson_course">';
700
-			$output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>';
700
+			$output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>';
701 701
 			$output .= $course_options;
702 702
 			$output .= '</select>';
703 703
 
@@ -710,13 +710,13 @@  discard block
 block discarded – undo
710 710
 	 * @param  array $request Current request
711 711
 	 * @return array          Modified request
712 712
 	 */
713
-	public function lesson_filter_actions( $request ) {
713
+	public function lesson_filter_actions($request) {
714 714
 		global $typenow;
715 715
 
716
-		if( is_admin() && 'lesson' == $typenow ) {
717
-			$lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : '';
716
+		if (is_admin() && 'lesson' == $typenow) {
717
+			$lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : '';
718 718
 
719
-			if( $lesson_course ) {
719
+			if ($lesson_course) {
720 720
 				$request['meta_key'] = '_lesson_course';
721 721
 				$request['meta_value'] = $lesson_course;
722 722
 				$request['meta_compare'] = '=';
@@ -731,27 +731,27 @@  discard block
 block discarded – undo
731 731
 	 * @param  array $items Existing items
732 732
 	 * @return array        Updated items
733 733
 	 */
734
-	public function glance_items( $items = array() ) {
734
+	public function glance_items($items = array()) {
735 735
 
736
-		$types = array( 'course', 'lesson', 'question' );
736
+		$types = array('course', 'lesson', 'question');
737 737
 
738
-		foreach( $types as $type ) {
739
-			if( ! post_type_exists( $type ) ) continue;
738
+		foreach ($types as $type) {
739
+			if ( ! post_type_exists($type)) continue;
740 740
 
741
-			$num_posts = wp_count_posts( $type );
741
+			$num_posts = wp_count_posts($type);
742 742
 
743
-			if( $num_posts ) {
743
+			if ($num_posts) {
744 744
 
745
-				$published = intval( $num_posts->publish );
746
-				$post_type = get_post_type_object( $type );
745
+				$published = intval($num_posts->publish);
746
+				$post_type = get_post_type_object($type);
747 747
 
748
-				$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' );
749
-				$text = sprintf( $text, number_format_i18n( $published ) );
748
+				$text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei');
749
+				$text = sprintf($text, number_format_i18n($published));
750 750
 
751
-				if ( current_user_can( $post_type->cap->edit_posts ) ) {
752
-					$items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n";
751
+				if (current_user_can($post_type->cap->edit_posts)) {
752
+					$items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n";
753 753
 				} else {
754
-					$items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n";
754
+					$items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n";
755 755
 				}
756 756
 			}
757 757
 		}
@@ -765,13 +765,13 @@  discard block
 block discarded – undo
765 765
 	 * @param  object  $post    Post object
766 766
 	 * @return void
767 767
 	 */
768
-	public function delete_content( $post_id, $post ) {
768
+	public function delete_content($post_id, $post) {
769 769
 
770 770
 		$type = $post->post_type;
771 771
 
772
-		if( in_array( $type, array( 'lesson', 'course' ) ) ) {
772
+		if (in_array($type, array('lesson', 'course'))) {
773 773
 
774
-			$meta_key = '_' . $type . '_prerequisite';
774
+			$meta_key = '_'.$type.'_prerequisite';
775 775
 
776 776
 			$args = array(
777 777
 				'post_type' => $type,
@@ -781,10 +781,10 @@  discard block
 block discarded – undo
781 781
 				'meta_value' => $post_id
782 782
 			);
783 783
 
784
-			$posts = get_posts( $args );
784
+			$posts = get_posts($args);
785 785
 
786
-			foreach( $posts as $post ) {
787
-				delete_post_meta( $post->ID, $meta_key );
786
+			foreach ($posts as $post) {
787
+				delete_post_meta($post->ID, $meta_key);
788 788
 			}
789 789
 		}
790 790
 	}
@@ -794,181 +794,181 @@  discard block
 block discarded – undo
794 794
 	 * @param  integer $user_id User ID
795 795
 	 * @return void
796 796
 	 */
797
-	public function delete_user_activity( $user_id = 0 ) {
798
-		if( $user_id ) {
799
-			Sensei_Utils::delete_all_user_activity( $user_id );
797
+	public function delete_user_activity($user_id = 0) {
798
+		if ($user_id) {
799
+			Sensei_Utils::delete_all_user_activity($user_id);
800 800
 		}
801 801
 	}
802 802
 
803
-	public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) {
803
+	public function render_settings($settings = array(), $post_id = 0, $group_id = '') {
804 804
 
805 805
 		$html = '';
806 806
 
807
-		if( 0 == count( $settings ) ) return $html;
807
+		if (0 == count($settings)) return $html;
808 808
 
809
-		$html .= '<div class="sensei-options-panel">' . "\n";
809
+		$html .= '<div class="sensei-options-panel">'."\n";
810 810
 
811
-			$html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n";
811
+			$html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n";
812 812
 
813
-				foreach( $settings as $field ) {
813
+				foreach ($settings as $field) {
814 814
 
815 815
 					$data = '';
816 816
 
817
-					if( $post_id ) {
818
-						$data = get_post_meta( $post_id, '_' . $field['id'], true );
819
-						if( ! $data && isset( $field['default'] ) ) {
817
+					if ($post_id) {
818
+						$data = get_post_meta($post_id, '_'.$field['id'], true);
819
+						if ( ! $data && isset($field['default'])) {
820 820
 							$data = $field['default'];
821 821
 						}
822 822
 					} else {
823
-						$option = get_option( $field['id'] );
824
-						if( isset( $field['default'] ) ) {
823
+						$option = get_option($field['id']);
824
+						if (isset($field['default'])) {
825 825
 							$data = $field['default'];
826
-							if( $option ) {
826
+							if ($option) {
827 827
 								$data = $option;
828 828
 							}
829 829
 						}
830 830
 					}
831 831
 
832 832
 					$disabled = '';
833
-					if( isset( $field['disabled'] ) && $field['disabled'] ) {
834
-						$disabled = disabled( $field['disabled'], true, false );
833
+					if (isset($field['disabled']) && $field['disabled']) {
834
+						$disabled = disabled($field['disabled'], true, false);
835 835
 					}
836 836
 
837
-					if( 'hidden' != $field['type'] ) {
837
+					if ('hidden' != $field['type']) {
838 838
 
839 839
 						$class_tail = '';
840 840
 
841
-						if( isset( $field['class'] ) ) {
841
+						if (isset($field['class'])) {
842 842
 							$class_tail .= $field['class'];
843 843
 						}
844 844
 
845
-						if( isset( $field['disabled'] ) && $field['disabled'] ) {
845
+						if (isset($field['disabled']) && $field['disabled']) {
846 846
 							$class_tail .= ' disabled';
847 847
 						}
848 848
 
849
-						$html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n";
849
+						$html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n";
850 850
 					}
851 851
 
852
-						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) {
853
-							$html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n";
852
+						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) {
853
+							$html .= '<label for="'.esc_attr($field['id']).'">'."\n";
854 854
 						}
855 855
 
856
-							if( $field['label'] ) {
857
-								$html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>';
856
+							if ($field['label']) {
857
+								$html .= '<span class="label">'.esc_html($field['label']).'</span>';
858 858
 							}
859 859
 
860
-							switch( $field['type'] ) {
860
+							switch ($field['type']) {
861 861
 								case 'text':
862 862
 								case 'password':
863
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n";
863
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n";
864 864
 								break;
865 865
 
866 866
 								case 'number':
867 867
 
868 868
 									$min = '';
869
-									if( isset( $field['min'] ) ) {
870
-										$min = 'min="' . esc_attr( $field['min'] ) . '"';
869
+									if (isset($field['min'])) {
870
+										$min = 'min="'.esc_attr($field['min']).'"';
871 871
 									}
872 872
 
873 873
 									$max = '';
874
-									if( isset( $field['max'] ) ) {
875
-										$max = 'max="' . esc_attr( $field['max'] ) . '"';
874
+									if (isset($field['max'])) {
875
+										$max = 'max="'.esc_attr($field['max']).'"';
876 876
 									}
877 877
 
878
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $min . '  ' . $max . ' class="small-text" ' . $disabled . ' />' . "\n";
878
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$min.'  '.$max.' class="small-text" '.$disabled.' />'."\n";
879 879
 								break;
880 880
 
881 881
 								case 'textarea':
882
-									$html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . $disabled . '>' . $data . '</textarea><br/>'. "\n";
882
+									$html .= '<textarea id="'.esc_attr($field['id']).'" rows="5" cols="50" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" '.$disabled.'>'.$data.'</textarea><br/>'."\n";
883 883
 								break;
884 884
 
885 885
 								case 'checkbox':
886 886
                                     //backwards compatibility
887
-                                    if( empty( $data ) || 'on' == $data ){
887
+                                    if (empty($data) || 'on' == $data) {
888 888
                                         $checked_value = 'on';
889
-                                    }elseif( 'yes' == $data  ) {
889
+                                    }elseif ('yes' == $data) {
890 890
 
891 891
                                         $checked_value = 'yes';
892 892
 
893
-                                    }elseif( 'auto' == $data  ) {
893
+                                    }elseif ('auto' == $data) {
894 894
 
895 895
                                         $checked_value = 'auto';
896 896
 
897 897
                                     } else {
898 898
                                         $checked_value = 1;
899
-                                        $data = intval( $data );
899
+                                        $data = intval($data);
900 900
                                     }
901
-									$checked = checked( $checked_value, $data, false );
902
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n";
901
+									$checked = checked($checked_value, $data, false);
902
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n";
903 903
 								break;
904 904
 
905 905
 								case 'checkbox_multi':
906
-									foreach( $field['options'] as $k => $v ) {
906
+									foreach ($field['options'] as $k => $v) {
907 907
 										$checked = false;
908
-										if( in_array( $k, $data ) ) {
908
+										if (in_array($k, $data)) {
909 909
 											$checked = true;
910 910
 										}
911
-										$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n";
911
+										$html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="checkbox" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'[]" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n";
912 912
 									}
913 913
 								break;
914 914
 
915 915
 								case 'radio':
916
-									foreach( $field['options'] as $k => $v ) {
916
+									foreach ($field['options'] as $k => $v) {
917 917
 										$checked = false;
918
-										if( $k == $data ) {
918
+										if ($k == $data) {
919 919
 											$checked = true;
920 920
 										}
921
-										$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n";
921
+										$html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="radio" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n";
922 922
 									}
923 923
 								break;
924 924
 
925 925
 								case 'select':
926
-									$html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n";
927
-									foreach( $field['options'] as $k => $v ) {
926
+									$html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n";
927
+									foreach ($field['options'] as $k => $v) {
928 928
 										$selected = false;
929
-										if( $k == $data ) {
929
+										if ($k == $data) {
930 930
 											$selected = true;
931 931
 										}
932
-										$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n";
932
+										$html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n";
933 933
 									}
934
-									$html .= '</select><br/>' . "\n";
934
+									$html .= '</select><br/>'."\n";
935 935
 								break;
936 936
 
937 937
 								case 'select_multi':
938
-									$html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n";
939
-									foreach( $field['options'] as $k => $v ) {
938
+									$html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n";
939
+									foreach ($field['options'] as $k => $v) {
940 940
 										$selected = false;
941
-										if( in_array( $k, $data ) ) {
941
+										if (in_array($k, $data)) {
942 942
 											$selected = true;
943 943
 										}
944
-										$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n";
944
+										$html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n";
945 945
 									}
946 946
 									$html .= '</select> . "\n"';
947 947
 								break;
948 948
 
949 949
 								case 'hidden':
950
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n";
950
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n";
951 951
 								break;
952 952
 
953 953
 							}
954 954
 
955
-							if( $field['description'] ) {
956
-								$html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n";
955
+							if ($field['description']) {
956
+								$html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n";
957 957
 							}
958 958
 
959
-						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) {
960
-							$html .= '</label>' . "\n";
959
+						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) {
960
+							$html .= '</label>'."\n";
961 961
 						}
962 962
 
963
-					if( 'hidden' != $field['type'] ) {
964
-						$html .= '</p>' . "\n";
963
+					if ('hidden' != $field['type']) {
964
+						$html .= '</p>'."\n";
965 965
 					}
966 966
 
967 967
 				}
968 968
 
969
-			$html .= '</div>' . "\n";
969
+			$html .= '</div>'."\n";
970 970
 
971
-		$html .= '</div>' . "\n";
971
+		$html .= '</div>'."\n";
972 972
 
973 973
 		return $html;
974 974
 	}
@@ -979,61 +979,61 @@  discard block
 block discarded – undo
979 979
 	 */
980 980
 	public function course_order_screen() {
981 981
 
982
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
983
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version );
982
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
983
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version);
984 984
 
985 985
 		?><div id="course-order" class="wrap course-order">
986
-		<h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php
986
+		<h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php
987 987
 
988 988
 		$html = '';
989 989
 
990
-		if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) {
991
-			$ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) );
990
+		if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) {
991
+			$ordered = $this->save_course_order(esc_attr($_POST['course-order']));
992 992
 
993
-			if( $ordered ) {
994
-				$html .= '<div class="updated fade">' . "\n";
995
-				$html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n";
996
-				$html .= '</div>' . "\n";
993
+			if ($ordered) {
994
+				$html .= '<div class="updated fade">'."\n";
995
+				$html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n";
996
+				$html .= '</div>'."\n";
997 997
 			}
998 998
 		}
999 999
 
1000 1000
 		$courses = Sensei()->course->get_all_courses();
1001 1001
 
1002
-		if( 0 < count( $courses ) ) {
1002
+		if (0 < count($courses)) {
1003 1003
 
1004 1004
             // order the courses as set by the users
1005 1005
             $all_course_ids = array();
1006
-            foreach( $courses as $course ){
1006
+            foreach ($courses as $course) {
1007 1007
 
1008
-                $all_course_ids[] = (string)$course->ID;
1008
+                $all_course_ids[] = (string) $course->ID;
1009 1009
 
1010 1010
             }
1011 1011
             $order_string = $this->get_course_order();
1012 1012
 
1013
-            if( !empty( $order_string ) ){
1014
-                $ordered_course_ids = explode(',' , $order_string );
1015
-                $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1013
+            if ( ! empty($order_string)) {
1014
+                $ordered_course_ids = explode(',', $order_string);
1015
+                $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids));
1016 1016
             }
1017 1017
 
1018 1018
 
1019
-			$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1020
-			$html .= '<ul class="sortable-course-list">' . "\n";
1019
+			$html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n";
1020
+			$html .= '<ul class="sortable-course-list">'."\n";
1021 1021
 			$count = 0;
1022
-			foreach ( $all_course_ids as $course_id ) {
1023
-                $course = get_post( $course_id );
1022
+			foreach ($all_course_ids as $course_id) {
1023
+                $course = get_post($course_id);
1024 1024
 				$count++;
1025 1025
 				$class = 'course';
1026
-				if ( $count == 1 ) { $class .= ' first'; }
1027
-				if ( $count == count( $course ) ) { $class .= ' last'; }
1028
-				if ( $count % 2 != 0 ) {
1026
+				if ($count == 1) { $class .= ' first'; }
1027
+				if ($count == count($course)) { $class .= ' last'; }
1028
+				if ($count % 2 != 0) {
1029 1029
 					$class .= ' alternate';
1030 1030
 				}
1031
-				$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n";
1031
+				$html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n";
1032 1032
 			}
1033
-			$html .= '</ul>' . "\n";
1033
+			$html .= '</ul>'."\n";
1034 1034
 
1035
-			$html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n";
1036
-			$html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n";
1035
+			$html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n";
1036
+			$html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n";
1037 1037
 		}
1038 1038
 
1039 1039
 		echo $html;
@@ -1042,25 +1042,25 @@  discard block
 block discarded – undo
1042 1042
 	}
1043 1043
 
1044 1044
 	public function get_course_order() {
1045
-		return get_option( 'sensei_course_order', '' );
1045
+		return get_option('sensei_course_order', '');
1046 1046
 	}
1047 1047
 
1048
-	public function save_course_order( $order_string = '' ) {
1049
-		$order = explode( ',', $order_string );
1048
+	public function save_course_order($order_string = '') {
1049
+		$order = explode(',', $order_string);
1050 1050
 
1051
-		update_option( 'sensei_course_order', $order_string );
1051
+		update_option('sensei_course_order', $order_string);
1052 1052
 
1053 1053
 		$i = 1;
1054
-		foreach( $order as $course_id ) {
1054
+		foreach ($order as $course_id) {
1055 1055
 
1056
-			if( $course_id ) {
1056
+			if ($course_id) {
1057 1057
 
1058 1058
 				$update_args = array(
1059 1059
 					'ID' => $course_id,
1060 1060
 					'menu_order' => $i,
1061 1061
 				);
1062 1062
 
1063
-				wp_update_post( $update_args );
1063
+				wp_update_post($update_args);
1064 1064
 
1065 1065
 				++$i;
1066 1066
 			}
@@ -1075,22 +1075,22 @@  discard block
 block discarded – undo
1075 1075
 	 */
1076 1076
 	public function lesson_order_screen() {
1077 1077
 
1078
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1079
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version );
1078
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1079
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version);
1080 1080
 
1081 1081
 		?><div id="lesson-order" class="wrap lesson-order">
1082
-		<h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php
1082
+		<h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php
1083 1083
 
1084 1084
 		$html = '';
1085 1085
 
1086
-		if( isset( $_POST['lesson-order'] ) ) {
1086
+		if (isset($_POST['lesson-order'])) {
1087 1087
 
1088
-			$ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) );
1088
+			$ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id']));
1089 1089
 
1090
-			if( $ordered ) {
1091
-				$html .= '<div class="updated fade">' . "\n";
1092
-				$html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n";
1093
-				$html .= '</div>' . "\n";
1090
+			if ($ordered) {
1091
+				$html .= '<div class="updated fade">'."\n";
1092
+				$html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n";
1093
+				$html .= '</div>'."\n";
1094 1094
 			}
1095 1095
 		}
1096 1096
 
@@ -1101,43 +1101,43 @@  discard block
 block discarded – undo
1101 1101
 			'orderby' => 'name',
1102 1102
 			'order' => 'ASC',
1103 1103
 		);
1104
-		$courses = get_posts( $args );
1104
+		$courses = get_posts($args);
1105 1105
 
1106
-		$html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n";
1107
-		$html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n";
1108
-		$html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n";
1109
-		$html .= '<select id="lesson-order-course" name="course_id">' . "\n";
1110
-		$html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n";
1106
+		$html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n";
1107
+		$html .= '<input type="hidden" name="post_type" value="lesson" />'."\n";
1108
+		$html .= '<input type="hidden" name="page" value="lesson-order" />'."\n";
1109
+		$html .= '<select id="lesson-order-course" name="course_id">'."\n";
1110
+		$html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n";
1111 1111
 
1112
-		foreach( $courses as $course ) {
1112
+		foreach ($courses as $course) {
1113 1113
 			$course_id = '';
1114
-			if( isset( $_GET['course_id'] ) ) {
1115
-				$course_id = intval( $_GET['course_id'] );
1114
+			if (isset($_GET['course_id'])) {
1115
+				$course_id = intval($_GET['course_id']);
1116 1116
 			}
1117
-			$html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n";
1117
+			$html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n";
1118 1118
 		}
1119 1119
 
1120
-		$html .= '</select>' . "\n";
1121
-		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n";
1122
-		$html .= '</form>' . "\n";
1120
+		$html .= '</select>'."\n";
1121
+		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n";
1122
+		$html .= '</form>'."\n";
1123 1123
 
1124
-		$html .= '<script type="text/javascript">' . "\n";
1125
-		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n";
1126
-		$html .= '</script>' . "\n";
1124
+		$html .= '<script type="text/javascript">'."\n";
1125
+		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n";
1126
+		$html .= '</script>'."\n";
1127 1127
 
1128
-		if( isset( $_GET['course_id'] ) ) {
1129
-			$course_id = intval( $_GET['course_id'] );
1130
-			if( $course_id > 0 ) {
1128
+		if (isset($_GET['course_id'])) {
1129
+			$course_id = intval($_GET['course_id']);
1130
+			if ($course_id > 0) {
1131 1131
 
1132
-				$order_string = $this->get_lesson_order( $course_id );
1132
+				$order_string = $this->get_lesson_order($course_id);
1133 1133
 
1134
-				$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1134
+				$html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n";
1135 1135
 
1136 1136
 				$displayed_lessons = array();
1137 1137
 
1138
-                $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1138
+                $modules = Sensei()->modules->get_course_modules(intval($course_id));
1139 1139
 
1140
-                foreach( $modules as $module ) {
1140
+                foreach ($modules as $module) {
1141 1141
 
1142 1142
                     $args = array(
1143 1143
                         'post_type' => 'lesson',
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
                         'meta_query' => array(
1147 1147
                             array(
1148 1148
                                 'key' => '_lesson_course',
1149
-                                'value' => intval( $course_id ),
1149
+                                'value' => intval($course_id),
1150 1150
                                 'compare' => '='
1151 1151
                             )
1152 1152
                         ),
@@ -1154,66 +1154,66 @@  discard block
 block discarded – undo
1154 1154
                             array(
1155 1155
                                 'taxonomy' => Sensei()->modules->taxonomy,
1156 1156
                                 'field' => 'id',
1157
-                                'terms' => intval( $module->term_id )
1157
+                                'terms' => intval($module->term_id)
1158 1158
                             )
1159 1159
                         ),
1160
-                        'meta_key' => '_order_module_' . $module->term_id,
1160
+                        'meta_key' => '_order_module_'.$module->term_id,
1161 1161
                         'orderby' => 'meta_value_num date',
1162 1162
                         'order' => 'ASC',
1163 1163
                         'suppress_filters' => 0
1164 1164
                     );
1165 1165
 
1166
-                    $lessons = get_posts( $args );
1166
+                    $lessons = get_posts($args);
1167 1167
 
1168
-                    if( count( $lessons ) > 0 ) {
1169
-                        $html .= '<h3>' . $module->name . '</h3>' . "\n";
1170
-                        $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1168
+                    if (count($lessons) > 0) {
1169
+                        $html .= '<h3>'.$module->name.'</h3>'."\n";
1170
+                        $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n";
1171 1171
 
1172 1172
                         $count = 0;
1173
-                        foreach( $lessons as $lesson ) {
1173
+                        foreach ($lessons as $lesson) {
1174 1174
                             $count++;
1175 1175
                             $class = 'lesson';
1176
-                            if ( $count == 1 ) { $class .= ' first'; }
1177
-                            if ( $count == count( $lesson ) ) { $class .= ' last'; }
1178
-                            if ( $count % 2 != 0 ) {
1176
+                            if ($count == 1) { $class .= ' first'; }
1177
+                            if ($count == count($lesson)) { $class .= ' last'; }
1178
+                            if ($count % 2 != 0) {
1179 1179
                                 $class .= ' alternate';
1180 1180
                             }
1181 1181
 
1182
-                            $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1182
+                            $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n";
1183 1183
 
1184 1184
                             $displayed_lessons[] = $lesson->ID;
1185 1185
                         }
1186 1186
 
1187
-                        $html .= '</ul>' . "\n";
1187
+                        $html .= '</ul>'."\n";
1188 1188
 
1189
-                        $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1189
+                        $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n";
1190 1190
                     }
1191 1191
                 }
1192 1192
 
1193 1193
 
1194
-                $lessons = Sensei()->course->course_lessons( $course_id );
1194
+                $lessons = Sensei()->course->course_lessons($course_id);
1195 1195
 
1196
-				if( 0 < count( $lessons ) ) {
1196
+				if (0 < count($lessons)) {
1197 1197
 
1198 1198
                     //get module term ids, will be used to exclude lessons
1199 1199
                     $module_items_ids = array();
1200
-                    if( ! empty( $modules ) ) {
1200
+                    if ( ! empty($modules)) {
1201 1201
                         foreach ($modules as $module) {
1202 1202
                             $module_items_ids[] = $module->term_id;
1203 1203
                         }
1204 1204
                     }
1205 1205
 
1206
-					if( 0 < count( $displayed_lessons ) ) {
1207
-						$html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n";
1206
+					if (0 < count($displayed_lessons)) {
1207
+						$html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n";
1208 1208
 					}
1209 1209
 
1210
-					$html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n";
1210
+					$html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n";
1211 1211
 					$count = 0;
1212
-					foreach ( $lessons as $lesson ) {
1212
+					foreach ($lessons as $lesson) {
1213 1213
 
1214 1214
                         // if lesson belongs to one fo the course modules then exclude it here
1215 1215
                         // as it is listed above
1216
-                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1216
+                        if (has_term($module_items_ids, 'module', $lesson->ID)) {
1217 1217
 
1218 1218
                             continue;
1219 1219
 
@@ -1221,28 +1221,28 @@  discard block
 block discarded – undo
1221 1221
 
1222 1222
 						$count++;
1223 1223
 						$class = 'lesson';
1224
-						if ( $count == 1 ) { $class .= ' first'; }
1225
-						if ( $count == count( $lesson ) ) { $class .= ' last'; }
1226
-						if ( $count % 2 != 0 ) {
1224
+						if ($count == 1) { $class .= ' first'; }
1225
+						if ($count == count($lesson)) { $class .= ' last'; }
1226
+						if ($count % 2 != 0) {
1227 1227
 
1228 1228
 							$class .= ' alternate';
1229 1229
 
1230 1230
 						}
1231
-						$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1231
+						$html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n";
1232 1232
 
1233 1233
 						$displayed_lessons[] = $lesson->ID;
1234 1234
 					}
1235
-					$html .= '</ul>' . "\n";
1235
+					$html .= '</ul>'."\n";
1236 1236
 				} else {
1237
-					if( 0 == count( $displayed_lessons ) ) {
1238
-						$html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>';
1237
+					if (0 == count($displayed_lessons)) {
1238
+						$html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>';
1239 1239
 					}
1240 1240
 				}
1241 1241
 
1242
-				if( 0 < count( $displayed_lessons ) ) {
1243
-					$html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n";
1244
-					$html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n";
1245
-					$html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n";
1242
+				if (0 < count($displayed_lessons)) {
1243
+					$html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n";
1244
+					$html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n";
1245
+					$html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n";
1246 1246
 				}
1247 1247
 			}
1248 1248
 		}
@@ -1252,29 +1252,29 @@  discard block
 block discarded – undo
1252 1252
 		?></div><?php
1253 1253
 	}
1254 1254
 
1255
-	public function get_lesson_order( $course_id = 0 ) {
1256
-		$order_string = get_post_meta( $course_id, '_lesson_order', true );
1255
+	public function get_lesson_order($course_id = 0) {
1256
+		$order_string = get_post_meta($course_id, '_lesson_order', true);
1257 1257
 		return $order_string;
1258 1258
 	}
1259 1259
 
1260
-	public function save_lesson_order( $order_string = '', $course_id = 0 ) {
1260
+	public function save_lesson_order($order_string = '', $course_id = 0) {
1261 1261
 
1262
-		if( $course_id ) {
1262
+		if ($course_id) {
1263 1263
 
1264
-            $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1264
+            $modules = Sensei()->modules->get_course_modules(intval($course_id));
1265 1265
 
1266
-            foreach( $modules as $module ) {
1266
+            foreach ($modules as $module) {
1267 1267
 
1268 1268
 
1269
-                if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] )
1270
-                    && $_POST[ 'lesson-order-module-' . $module->term_id ] ) {
1269
+                if (isset($_POST['lesson-order-module-'.$module->term_id])
1270
+                    && $_POST['lesson-order-module-'.$module->term_id]) {
1271 1271
 
1272
-                    $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] );
1272
+                    $order = explode(',', $_POST['lesson-order-module-'.$module->term_id]);
1273 1273
                     $i = 1;
1274
-                    foreach( $order as $lesson_id ) {
1274
+                    foreach ($order as $lesson_id) {
1275 1275
 
1276
-                        if( $lesson_id ) {
1277
-                            update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1276
+                        if ($lesson_id) {
1277
+                            update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i);
1278 1278
                             ++$i;
1279 1279
                         }
1280 1280
 
@@ -1285,15 +1285,15 @@  discard block
 block discarded – undo
1285 1285
             } // end for each modules
1286 1286
 
1287 1287
 
1288
-			if( $order_string ) {
1289
-				update_post_meta( $course_id, '_lesson_order', $order_string );
1288
+			if ($order_string) {
1289
+				update_post_meta($course_id, '_lesson_order', $order_string);
1290 1290
 
1291
-				$order = explode( ',', $order_string );
1291
+				$order = explode(',', $order_string);
1292 1292
 
1293 1293
 				$i = 1;
1294
-				foreach( $order as $lesson_id ) {
1295
-					if( $lesson_id ) {
1296
-						update_post_meta( $lesson_id, '_order_' . $course_id, $i );
1294
+				foreach ($order as $lesson_id) {
1295
+					if ($lesson_id) {
1296
+						update_post_meta($lesson_id, '_order_'.$course_id, $i);
1297 1297
 						++$i;
1298 1298
 					}
1299 1299
 				}
@@ -1308,54 +1308,54 @@  discard block
 block discarded – undo
1308 1308
 	function sensei_add_custom_menu_items() {
1309 1309
 		global $pagenow;
1310 1310
 
1311
-		if( 'nav-menus.php' == $pagenow ) {
1312
-			add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' );
1311
+		if ('nav-menus.php' == $pagenow) {
1312
+			add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low');
1313 1313
 		}
1314 1314
 	}
1315 1315
 
1316
-	function wp_nav_menu_item_sensei_links_meta_box( $object ) {
1316
+	function wp_nav_menu_item_sensei_links_meta_box($object) {
1317 1317
 		global $nav_menu_selected_id;
1318 1318
 
1319 1319
 		$menu_items = array(
1320
-			'#senseicourses' => __( 'Courses', 'woothemes-sensei' ),
1321
-			'#senseilessons' => __( 'Lessons', 'woothemes-sensei' ),
1322
-			'#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ),
1323
-			'#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ),
1324
-			'#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ),
1325
-			'#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' )
1320
+			'#senseicourses' => __('Courses', 'woothemes-sensei'),
1321
+			'#senseilessons' => __('Lessons', 'woothemes-sensei'),
1322
+			'#senseimycourses' => __('My Courses', 'woothemes-sensei'),
1323
+			'#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'),
1324
+			'#senseimymessages' => __('My Messages', 'woothemes-sensei'),
1325
+			'#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei')
1326 1326
 		);
1327 1327
 
1328 1328
 		$menu_items_obj = array();
1329
-		foreach ( $menu_items as $value => $title ) {
1329
+		foreach ($menu_items as $value => $title) {
1330 1330
 			$menu_items_obj[$title] = new stdClass;
1331
-			$menu_items_obj[$title]->object_id			= esc_attr( $value );
1332
-			$menu_items_obj[$title]->title				= esc_attr( $title );
1333
-			$menu_items_obj[$title]->url				= esc_attr( $value );
1334
-			$menu_items_obj[$title]->description 		= 'description';
1331
+			$menu_items_obj[$title]->object_id = esc_attr($value);
1332
+			$menu_items_obj[$title]->title = esc_attr($title);
1333
+			$menu_items_obj[$title]->url = esc_attr($value);
1334
+			$menu_items_obj[$title]->description = 'description';
1335 1335
 			$menu_items_obj[$title]->db_id 				= 0;
1336 1336
 			$menu_items_obj[$title]->object 			= 'sensei';
1337
-			$menu_items_obj[$title]->menu_item_parent 	= 0;
1338
-			$menu_items_obj[$title]->type 				= 'custom';
1337
+			$menu_items_obj[$title]->menu_item_parent = 0;
1338
+			$menu_items_obj[$title]->type = 'custom';
1339 1339
 			$menu_items_obj[$title]->target 			= '';
1340
-			$menu_items_obj[$title]->attr_title 		= '';
1341
-			$menu_items_obj[$title]->classes 			= array();
1342
-			$menu_items_obj[$title]->xfn 				= '';
1340
+			$menu_items_obj[$title]->attr_title = '';
1341
+			$menu_items_obj[$title]->classes = array();
1342
+			$menu_items_obj[$title]->xfn = '';
1343 1343
 		}
1344 1344
 
1345
-		$walker = new Walker_Nav_Menu_Checklist( array() );
1345
+		$walker = new Walker_Nav_Menu_Checklist(array());
1346 1346
 		?>
1347 1347
 
1348 1348
 		<div id="sensei-links" class="senseidiv taxonomydiv">
1349 1349
 			<div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active">
1350 1350
 
1351 1351
 				<ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear">
1352
-					<?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?>
1352
+					<?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?>
1353 1353
 				</ul>
1354 1354
 
1355 1355
 			</div>
1356 1356
 			<p class="button-controls">
1357 1357
 				<span class="add-to-menu">
1358
-					<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'woothemes-sensei' ); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" />
1358
+					<input type="submit"<?php disabled($nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu', 'woothemes-sensei'); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" />
1359 1359
 					<span class="spinner"></span>
1360 1360
 				</span>
1361 1361
 			</p>
@@ -1371,17 +1371,17 @@  discard block
 block discarded – undo
1371 1371
 	 */
1372 1372
 	public function theme_compatibility_notices() {
1373 1373
 
1374
-        if( isset( $_GET['sensei_hide_notice'] ) ) {
1375
-        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1376
-				case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break;
1377
-				case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break;
1374
+        if (isset($_GET['sensei_hide_notice'])) {
1375
+        	switch (esc_attr($_GET['sensei_hide_notice'])) {
1376
+				case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break;
1377
+				case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break;
1378 1378
 			}
1379 1379
         }
1380 1380
 
1381 1381
         // white list templates that are already support by default and do not show notice for them
1382
-        $template = get_option( 'template' );
1382
+        $template = get_option('template');
1383 1383
 
1384
-        $white_list = array(    'twentyeleven',
1384
+        $white_list = array('twentyeleven',
1385 1385
                                 'twentytwelve',
1386 1386
                                 'twentyfourteen',
1387 1387
                                 'twentyfifteen',
@@ -1389,43 +1389,43 @@  discard block
 block discarded – undo
1389 1389
                                 'storefront',
1390 1390
                                                 );
1391 1391
 
1392
-        if ( in_array( $template, $white_list ) ) {
1392
+        if (in_array($template, $white_list)) {
1393 1393
 
1394 1394
             return;
1395 1395
 
1396 1396
         }
1397 1397
 
1398 1398
         // don't show the notice if the user chose to hide it
1399
-        $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1400
-        if(  $hide_theme_check_notice ) {
1399
+        $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true);
1400
+        if ($hide_theme_check_notice) {
1401 1401
 
1402 1402
             return;
1403 1403
 
1404 1404
         }
1405 1405
 
1406 1406
         // show the notice for themes not supporting sensei
1407
-	    if ( ! current_theme_supports( 'sensei' ) ) {
1407
+	    if ( ! current_theme_supports('sensei')) {
1408 1408
             ?>
1409 1409
 
1410 1410
             <div id="message" class="error sensei-message sensei-connect">
1411 1411
                     <p>
1412 1412
                         <strong>
1413 1413
 
1414
-                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?>
1414
+                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?>
1415 1415
 
1416 1416
                         </strong> &#8211;
1417 1417
 
1418
-                        <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?>
1418
+                        <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?>
1419 1419
 
1420
-                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a>
1420
+                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e('Sensei theme', 'woothemes-sensei') ?> </a>
1421 1421
 
1422 1422
                         :)
1423 1423
 
1424 1424
                     </p>
1425 1425
                     <p class="submit">
1426
-                        <a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility' ) ); ?>" class="button-primary">
1426
+                        <a href="<?php echo esc_url(apply_filters('sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility')); ?>" class="button-primary">
1427 1427
 
1428
-                            <?php _e( 'Theme Integration Guide', 'woothemes-sensei' ); ?></a> <a class="skip button" href="<?php echo esc_url( add_query_arg( 'sensei_hide_notice', 'theme_check' ) ); ?>"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?>
1428
+                            <?php _e('Theme Integration Guide', 'woothemes-sensei'); ?></a> <a class="skip button" href="<?php echo esc_url(add_query_arg('sensei_hide_notice', 'theme_check')); ?>"><?php _e('Hide this notice', 'woothemes-sensei'); ?>
1429 1429
 
1430 1430
                         </a>
1431 1431
                     </p>
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 		wp_get_current_user();
1444 1444
         $user_id = $current_user->ID;
1445 1445
 
1446
-		delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' );
1446
+		delete_user_meta($user_id, 'sensei_hide_theme_check_notice');
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
@@ -1453,8 +1453,8 @@  discard block
 block discarded – undo
1453 1453
 	 * @param  bool $prevent_access
1454 1454
 	 * @return bool
1455 1455
 	 */
1456
-	public function admin_access( $prevent_access ) {
1457
-		if ( current_user_can( 'manage_sensei_grades' ) ) {
1456
+	public function admin_access($prevent_access) {
1457
+		if (current_user_can('manage_sensei_grades')) {
1458 1458
 			return false;
1459 1459
 		}
1460 1460
 
@@ -1469,12 +1469,12 @@  discard block
 block discarded – undo
1469 1469
      *
1470 1470
      * @since 1.8.7
1471 1471
      */
1472
-    public  static function install_pages(){
1472
+    public  static function install_pages() {
1473 1473
 
1474 1474
         // only fire on the settings page
1475
-        if( ! isset( $_GET['page'] )
1475
+        if ( ! isset($_GET['page'])
1476 1476
             || 'woothemes-sensei-settings' != $_GET['page']
1477
-            || 1 == get_option('skip_install_sensei_pages') ){
1477
+            || 1 == get_option('skip_install_sensei_pages')) {
1478 1478
 
1479 1479
             return;
1480 1480
 
@@ -1511,8 +1511,8 @@  discard block
 block discarded – undo
1511 1511
             // Set installed option
1512 1512
             update_option('sensei_installed', 0);
1513 1513
 
1514
-            $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1515
-            wp_redirect( $complete_url );
1514
+            $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url);
1515
+            wp_redirect($complete_url);
1516 1516
 
1517 1517
         }
1518 1518
 
@@ -1526,4 +1526,4 @@  discard block
 block discarded – undo
1526 1526
  * @since 1.9.0
1527 1527
  * @ignore
1528 1528
  */
1529
-class WooThemes_Sensei_Admin extends Sensei_Admin{ }
1529
+class WooThemes_Sensei_Admin extends Sensei_Admin { }
Please login to merge, or discard this patch.
includes/class-sensei-settings-api.php 1 patch
Spacing   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * A settings API (wrapping the WordPress Settings API).
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @access public
32 32
 	 * @since  1.0.0
33 33
 	 */
34
-	public function __construct () {
34
+	public function __construct() {
35 35
 
36 36
 		$this->token = 'woothemes-sensei-settings';
37 37
 		$this->page_slug = 'woothemes-sensei-settings-api';
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function register_hook_listener() {
59 59
 
60
-        add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 );
61
-		add_action( 'admin_init', array( $this, 'settings_fields' ) );
62
-        add_action( 'init', array( $this, 'general_init' ), 5 );
60
+        add_action('admin_menu', array($this, 'register_settings_screen'), 60);
61
+		add_action('admin_init', array($this, 'settings_fields'));
62
+        add_action('init', array($this, 'general_init'), 5);
63 63
 
64 64
 	} // End setup_settings()
65 65
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		$this->init_sections();
74 74
 		$this->init_fields();
75 75
 		$this->get_settings();
76
-		if ( $this->has_tabs == true ) {
76
+		if ($this->has_tabs == true) {
77 77
 			$this->create_tabs();
78 78
 		} // End If Statement
79 79
 	} // End general_init()
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @since  1.0.0
85 85
 	 * @return void
86 86
 	 */
87
-	public function init_sections () {
87
+	public function init_sections() {
88 88
 		// Override this function in your class and assign the array of sections to $this->sections.
89
-		_e( 'Override init_sections() in your class.', 'woothemes-sensei' );
89
+		_e('Override init_sections() in your class.', 'woothemes-sensei');
90 90
 	} // End init_sections()
91 91
 
92 92
 	/**
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	 * @since  1.0.0
96 96
 	 * @return void
97 97
 	 */
98
-	public function init_fields () {
98
+	public function init_fields() {
99 99
 		// Override this function in your class and assign the array of sections to $this->fields.
100
-		_e( 'Override init_fields() in your class.', 'woothemes-sensei' );
100
+		_e('Override init_fields() in your class.', 'woothemes-sensei');
101 101
 	} // End init_fields()
102 102
 
103 103
 	/**
@@ -106,34 +106,34 @@  discard block
 block discarded – undo
106 106
 	 * @since  1.1.0
107 107
 	 * @return void
108 108
 	 */
109
-	public function settings_tabs () {
109
+	public function settings_tabs() {
110 110
 
111
-		if ( ! $this->has_tabs ) { return; }
111
+		if ( ! $this->has_tabs) { return; }
112 112
 
113
-		if ( count( $this->tabs ) > 0 ) {
113
+		if (count($this->tabs) > 0) {
114 114
 			$html = '';
115 115
 
116
-			$html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n";
116
+			$html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">'."\n";
117 117
 
118 118
 			$sections = array(
119
-						'all' => array( 'href' => '#all', 'name' => __( 'All', 'woothemes-sensei' ), 'class' => 'current all tab' )
119
+						'all' => array('href' => '#all', 'name' => __('All', 'woothemes-sensei'), 'class' => 'current all tab')
120 120
 					);
121 121
 
122
-			foreach ( $this->tabs as $k => $v ) {
123
-				$sections[$k] = array( 'href' => '#' . esc_attr( $k ), 'name' => esc_attr( $v['name'] ), 'class' => 'tab' );
122
+			foreach ($this->tabs as $k => $v) {
123
+				$sections[$k] = array('href' => '#'.esc_attr($k), 'name' => esc_attr($v['name']), 'class' => 'tab');
124 124
 			}
125 125
 
126 126
 			$count = 1;
127
-			foreach ( $sections as $k => $v ) {
127
+			foreach ($sections as $k => $v) {
128 128
 				$count++;
129
-				$html .= '<li><a href="' . $v['href'] . '"';
130
-				if ( isset( $v['class'] ) && ( $v['class'] != '' ) ) { $html .= ' class="' . esc_attr( $v['class'] ) . '"'; }
131
-				$html .= '>' . esc_attr( $v['name'] ) . '</a>';
132
-				if ( $count <= count( $sections ) ) { $html .= ' | '; }
133
-				$html .= '</li>' . "\n";
129
+				$html .= '<li><a href="'.$v['href'].'"';
130
+				if (isset($v['class']) && ($v['class'] != '')) { $html .= ' class="'.esc_attr($v['class']).'"'; }
131
+				$html .= '>'.esc_attr($v['name']).'</a>';
132
+				if ($count <= count($sections)) { $html .= ' | '; }
133
+				$html .= '</li>'."\n";
134 134
 			}
135 135
 
136
-			$html .= '</ul><div class="clear"></div>' . "\n";
136
+			$html .= '</ul><div class="clear"></div>'."\n";
137 137
 
138 138
 			echo $html;
139 139
 		}
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 	 * @since  1.1.0
146 146
 	 * @return void
147 147
 	 */
148
-	private function create_tabs () {
149
-		if ( count( $this->sections ) > 0 ) {
148
+	private function create_tabs() {
149
+		if (count($this->sections) > 0) {
150 150
 			$tabs = array();
151
-			foreach ( $this->sections as $k => $v ) {
151
+			foreach ($this->sections as $k => $v) {
152 152
 				$tabs[$k] = $v;
153 153
 			}
154 154
 
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	 * @since  1.0.0
163 163
 	 * @return void
164 164
 	 */
165
-	public function create_sections () {
166
-		if ( count( $this->sections ) > 0 ) {
167
-			foreach ( $this->sections as $k => $v ) {
168
-				add_settings_section( $k, $v['name'], array( $this, 'section_description' ), $this->token );
165
+	public function create_sections() {
166
+		if (count($this->sections) > 0) {
167
+			foreach ($this->sections as $k => $v) {
168
+				add_settings_section($k, $v['name'], array($this, 'section_description'), $this->token);
169 169
 			}
170 170
 		}
171 171
 	} // End create_sections()
@@ -176,18 +176,18 @@  discard block
 block discarded – undo
176 176
 	 * @since  1.0.0
177 177
 	 * @return void
178 178
 	 */
179
-	public function create_fields () {
180
-		if ( count( $this->sections ) > 0 ) {
179
+	public function create_fields() {
180
+		if (count($this->sections) > 0) {
181 181
 			// $this->parse_fields( $this->fields );
182 182
 
183
-			foreach ( $this->fields as $k => $v ) {
184
-				$method = $this->determine_method( $v, 'form' );
183
+			foreach ($this->fields as $k => $v) {
184
+				$method = $this->determine_method($v, 'form');
185 185
 				$name = $v['name'];
186
-				if ( $v['type'] == 'info' ) { $name = ''; }
187
-				add_settings_field( $k, $name, $method, $this->token, $v['section'], array( 'key' => $k, 'data' => $v ) );
186
+				if ($v['type'] == 'info') { $name = ''; }
187
+				add_settings_field($k, $name, $method, $this->token, $v['section'], array('key' => $k, 'data' => $v));
188 188
 
189 189
 				// Let the API know that we have a colourpicker field.
190
-				if ( $v['type'] == 'range' && $this->has_range == false ) { $this->has_range = true; }
190
+				if ($v['type'] == 'range' && $this->has_range == false) { $this->has_range = true; }
191 191
 			}
192 192
 		}
193 193
 	} // End create_fields()
@@ -199,43 +199,43 @@  discard block
 block discarded – undo
199 199
 	 * @param  array $data
200 200
 	 * @return callable,  array or string
201 201
 	 */
202
-	protected function determine_method ( $data, $type = 'form' ) {
202
+	protected function determine_method($data, $type = 'form') {
203 203
 		$method = '';
204 204
 
205
-		if ( ! in_array( $type, array( 'form', 'validate', 'check' ) ) ) { return; }
205
+		if ( ! in_array($type, array('form', 'validate', 'check'))) { return; }
206 206
 
207 207
 		// Check for custom functions.
208
-		if ( isset( $data[$type] ) ) {
209
-			if ( function_exists( $data[$type] ) ) {
208
+		if (isset($data[$type])) {
209
+			if (function_exists($data[$type])) {
210 210
 				$method = $data[$type];
211 211
 			}
212 212
 
213
-			if ( $method == '' && method_exists( $this, $data[$type] ) ) {
214
-				if ( $type == 'form' ) {
215
-					$method = array( $this, $data[$type] );
213
+			if ($method == '' && method_exists($this, $data[$type])) {
214
+				if ($type == 'form') {
215
+					$method = array($this, $data[$type]);
216 216
 				} else {
217 217
 					$method = $data[$type];
218 218
 				}
219 219
 			}
220 220
 		}
221 221
 
222
-		if ( $method == '' && method_exists ( $this, $type . '_field_' . $data['type'] ) ) {
223
-			if ( $type == 'form' ) {
224
-				$method = array( $this, $type . '_field_' . $data['type'] );
222
+		if ($method == '' && method_exists($this, $type.'_field_'.$data['type'])) {
223
+			if ($type == 'form') {
224
+				$method = array($this, $type.'_field_'.$data['type']);
225 225
 			} else {
226
-				$method = $type . '_field_' . $data['type'];
226
+				$method = $type.'_field_'.$data['type'];
227 227
 			}
228 228
 		}
229 229
 
230
-		if ( $method == '' && function_exists ( $this->token . '_' . $type . '_field_' . $data['type'] ) ) {
231
-			$method = $this->token . '_' . $type . '_field_' . $data['type'];
230
+		if ($method == '' && function_exists($this->token.'_'.$type.'_field_'.$data['type'])) {
231
+			$method = $this->token.'_'.$type.'_field_'.$data['type'];
232 232
 		}
233 233
 
234
-		if ( $method == '' ) {
235
-			if ( $type == 'form' ) {
236
-				$method = array( $this, $type . '_field_text' );
234
+		if ($method == '') {
235
+			if ($type == 'form') {
236
+				$method = array($this, $type.'_field_text');
237 237
 			} else {
238
-				$method = $type . '_field_text';
238
+				$method = $type.'_field_text';
239 239
 			}
240 240
 		}
241 241
 
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 	 * @param  array $fields
250 250
 	 * @return void
251 251
 	 */
252
-	public function parse_fields ( $fields ) {
253
-		foreach ( $fields as $k => $v ) {
254
-			if ( isset( $v['section'] ) && ( $v['section'] != '' ) && ( isset( $this->sections[$v['section']] ) ) ) {
255
-				if ( ! isset( $this->sections[$v['section']]['fields'] ) ) {
252
+	public function parse_fields($fields) {
253
+		foreach ($fields as $k => $v) {
254
+			if (isset($v['section']) && ($v['section'] != '') && (isset($this->sections[$v['section']]))) {
255
+				if ( ! isset($this->sections[$v['section']]['fields'])) {
256 256
 					$this->sections[$v['section']]['fields'] = array();
257 257
 				}
258 258
 
@@ -269,19 +269,19 @@  discard block
 block discarded – undo
269 269
 	 * @since 1.0.0
270 270
 	 * @return void
271 271
 	 */
272
-	public function register_settings_screen () {
272
+	public function register_settings_screen() {
273 273
 
274
-		if ( current_user_can( 'manage_sensei' ) ) {
275
-			$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) );
274
+		if (current_user_can('manage_sensei')) {
275
+			$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen'));
276 276
 
277 277
 			$this->hook = $hook;
278 278
 		}
279 279
 
280
-		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
280
+		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
281 281
 
282
-			add_action( 'admin_notices', array( $this, 'settings_errors' ) );
283
-			add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
284
-			add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
282
+			add_action('admin_notices', array($this, 'settings_errors'));
283
+			add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
284
+			add_action('admin_print_styles', array($this, 'enqueue_styles'));
285 285
 
286 286
 		}
287 287
 	} // End register_settings_screen()
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
 	 * @since  1.0.0
293 293
 	 * @return void
294 294
 	 */
295
-	public function settings_screen ()
295
+	public function settings_screen()
296 296
     {
297 297
 
298 298
         ?>
299 299
         <div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>">
300 300
         <?php screen_icon('woothemes-sensei'); ?>
301 301
         <h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) {
302
-                echo ' <span class="version">' . $this->settings_version . '</span>';
302
+                echo ' <span class="version">'.$this->settings_version.'</span>';
303 303
             } ?></h2>
304 304
         <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/"
305 305
                                                                                    title="WooThemes"><img
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
         $page = 'woothemes-sensei-settings';
314 314
         foreach ($this->sections as $section_id => $section) {
315 315
 
316
-            echo '<section id="' . $section_id . '">';
316
+            echo '<section id="'.$section_id.'">';
317 317
 
318 318
             if ($section['name'])
319 319
                 echo "<h2>{$section['name']}</h2>\n";
320 320
 
321 321
             echo '<table class="form-table">';
322
-            do_settings_fields($page, $section_id );
322
+            do_settings_fields($page, $section_id);
323 323
             echo '</table>';
324 324
 
325 325
             echo '</section>';
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         submit_button();
330 330
         ?>
331 331
 	</form>
332
-	<?php do_action( 'settings_after_form' ); ?>
332
+	<?php do_action('settings_after_form'); ?>
333 333
 </div><!--/#woothemes-sensei-->
334 334
 <?php
335 335
 	} // End settings_screen()
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
 	 * @since  1.0.0
341 341
 	 * @return array
342 342
 	 */
343
-	public function get_settings () {
343
+	public function get_settings() {
344 344
 
345
-        $this->settings = get_option( $this->token, array() );
345
+        $this->settings = get_option($this->token, array());
346 346
 
347
-		foreach ( $this->fields as $k => $v ) {
348
-			if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) {
347
+		foreach ($this->fields as $k => $v) {
348
+			if ( ! isset($this->settings[$k]) && isset($v['default'])) {
349 349
 				$this->settings[$k] = $v['default'];
350 350
 			}
351
-			if ( $v['type'] == 'checkbox' && $this->settings[$k] != true ) {
351
+			if ($v['type'] == 'checkbox' && $this->settings[$k] != true) {
352 352
 				$this->settings[$k] = 0;
353 353
 			}
354 354
 		}
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 	 * @since  1.0.0
363 363
 	 * @return void
364 364
 	 */
365
-	public function settings_fields () {
366
-		register_setting( $this->token, $this->token, array( $this, 'validate_fields' ) );
365
+	public function settings_fields() {
366
+		register_setting($this->token, $this->token, array($this, 'validate_fields'));
367 367
 		$this->create_sections();
368 368
 		$this->create_fields();
369 369
 	} // End settings_fields()
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 	 * @since  1.0.0
375 375
 	 * @return void
376 376
 	 */
377
-	public function settings_errors () {
378
-        settings_errors( $this->token . '-errors' );
377
+	public function settings_errors() {
378
+        settings_errors($this->token.'-errors');
379 379
 	} // End settings_errors()
380 380
 
381 381
 	/**
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 	 * @since  1.0.0
385 385
 	 * @return void
386 386
 	 */
387
-	public function section_description ( $section ) {
388
-		if ( isset( $this->sections[$section['id']]['description'] ) ) {
389
-			echo wpautop( $this->sections[$section['id']]['description'] );
387
+	public function section_description($section) {
388
+		if (isset($this->sections[$section['id']]['description'])) {
389
+			echo wpautop($this->sections[$section['id']]['description']);
390 390
 		}
391 391
 	} // End section_description_main()
392 392
 
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 	 * @param  array $args
398 398
 	 * @return void
399 399
 	 */
400
-	public function form_field_text ( $args ) {
400
+	public function form_field_text($args) {
401 401
 		$options = $this->get_settings();
402 402
 
403
-		echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n";
404
-		if ( isset( $args['data']['description'] ) ) {
405
-			echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n";
403
+		echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" value="'.esc_attr($options[$args['key']]).'" />'."\n";
404
+		if (isset($args['data']['description'])) {
405
+			echo '<span class="description">'.$args['data']['description'].'</span>'."\n";
406 406
 		}
407 407
 	} // End form_field_text()
408 408
 
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	 * @param  array $args
414 414
 	 * @return void
415 415
 	 */
416
-	public function form_field_color ( $args ) {
416
+	public function form_field_color($args) {
417 417
 		$options = $this->get_settings();
418 418
 
419
-		echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" class="color" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n";
419
+		echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" class="color" value="'.esc_attr($options[$args['key']]).'" />'."\n";
420 420
 		echo '<div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div>';
421
-		if ( isset( $args['data']['description'] ) ) {
422
-			echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n";
421
+		if (isset($args['data']['description'])) {
422
+			echo '<span class="description">'.$args['data']['description'].'</span>'."\n";
423 423
 		}
424 424
 	} // End form_field_text()
425 425
 
@@ -430,22 +430,22 @@  discard block
 block discarded – undo
430 430
 	 * @param  array $args
431 431
 	 * @return void
432 432
 	 */
433
-	public function form_field_checkbox ( $args ) {
433
+	public function form_field_checkbox($args) {
434 434
 		$options = $this->get_settings();
435 435
 
436 436
 		$has_description = false;
437
-		if ( isset( $args['data']['description'] ) ) {
437
+		if (isset($args['data']['description'])) {
438 438
 			$has_description = true;
439
-			echo '<label for="' . esc_attr( $args['key'] ) . '">' . "\n";
439
+			echo '<label for="'.esc_attr($args['key']).'">'."\n";
440 440
 		}
441
-		echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n";
442
-		if ( $has_description ) {
443
-			echo wp_kses( $args['data']['description'], array( 'a' => array(
441
+		echo '<input id="'.$args['key'].'" name="'.$this->token.'['.esc_attr($args['key']).']" type="checkbox" value="1"'.checked(esc_attr($options[$args['key']]), '1', false).' />'."\n";
442
+		if ($has_description) {
443
+			echo wp_kses($args['data']['description'], array('a' => array(
444 444
 																	        'href' => array(),
445 445
 																	        'title' => array()
446 446
 																	    )
447 447
 															)
448
-						) . '</label>' . "\n";
448
+						).'</label>'."\n";
449 449
 		}
450 450
 	} // End form_field_checkbox()
451 451
 
@@ -456,12 +456,12 @@  discard block
 block discarded – undo
456 456
 	 * @param  array $args
457 457
 	 * @return void
458 458
 	 */
459
-	public function form_field_textarea ( $args ) {
459
+	public function form_field_textarea($args) {
460 460
 		$options = $this->get_settings();
461 461
 
462
-		echo '<textarea id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" cols="42" rows="5">' . esc_html( $options[$args['key']] ) . '</textarea>' . "\n";
463
-		if ( isset( $args['data']['description'] ) ) {
464
-			echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n";
462
+		echo '<textarea id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" cols="42" rows="5">'.esc_html($options[$args['key']]).'</textarea>'."\n";
463
+		if (isset($args['data']['description'])) {
464
+			echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n";
465 465
 		}
466 466
 	} // End form_field_textarea()
467 467
 
@@ -472,20 +472,20 @@  discard block
 block discarded – undo
472 472
 	 * @param  array $args
473 473
 	 * @return void
474 474
 	 */
475
-	public function form_field_select ( $args ) {
475
+	public function form_field_select($args) {
476 476
 		$options = $this->get_settings();
477 477
 
478
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
478
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
479 479
 			$html = '';
480
-			$html .= '<select class="" id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']">' . "\n";
481
-				foreach ( $args['data']['options'] as $k => $v ) {
482
-					$html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n";
480
+			$html .= '<select class="" id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']">'."\n";
481
+				foreach ($args['data']['options'] as $k => $v) {
482
+					$html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n";
483 483
 				}
484
-			$html .= '</select>' . "\n";
484
+			$html .= '</select>'."\n";
485 485
 			echo $html;
486 486
 
487
-			if ( isset( $args['data']['description'] ) ) {
488
-				echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n";
487
+			if (isset($args['data']['description'])) {
488
+				echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n";
489 489
 			}
490 490
 		}
491 491
 	} // End form_field_select()
@@ -497,18 +497,18 @@  discard block
 block discarded – undo
497 497
 	 * @param  array $args
498 498
 	 * @return void
499 499
 	 */
500
-	public function form_field_radio ( $args ) {
500
+	public function form_field_radio($args) {
501 501
 		$options = $this->get_settings();
502 502
 
503
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
503
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
504 504
 			$html = '';
505
-			foreach ( $args['data']['options'] as $k => $v ) {
506
-				$html .= '<input type="radio" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n";
505
+			foreach ($args['data']['options'] as $k => $v) {
506
+				$html .= '<input type="radio" name="'.$this->token.'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n";
507 507
 			}
508 508
 			echo $html;
509 509
 
510
-			if ( isset( $args['data']['description'] ) ) {
511
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
510
+			if (isset($args['data']['description'])) {
511
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
512 512
 			}
513 513
 		}
514 514
 	} // End form_field_radio()
@@ -520,28 +520,28 @@  discard block
 block discarded – undo
520 520
 	 * @param  array $args
521 521
 	 * @return void
522 522
 	 */
523
-	public function form_field_multicheck ( $args ) {
523
+	public function form_field_multicheck($args) {
524 524
 		$options = $this->get_settings();
525 525
 
526
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
527
-			$html = '<div class="multicheck-container" style="margin-bottom:10px;">' . "\n";
528
-			foreach ( $args['data']['options'] as $k => $v ) {
526
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
527
+			$html = '<div class="multicheck-container" style="margin-bottom:10px;">'."\n";
528
+			foreach ($args['data']['options'] as $k => $v) {
529 529
 				$checked = '';
530 530
 
531
-				if( isset( $options[ $args['key'] ] ) ) {
532
-					if ( in_array( $k, (array)$options[ $args['key'] ] ) ) { $checked = ' checked="checked"'; }
531
+				if (isset($options[$args['key']])) {
532
+					if (in_array($k, (array) $options[$args['key']])) { $checked = ' checked="checked"'; }
533 533
 				} else {
534
-					if ( in_array( $k, $args['data']['defaults'] ) ) { $checked = ' checked="checked"'; }
534
+					if (in_array($k, $args['data']['defaults'])) { $checked = ' checked="checked"'; }
535 535
 				}
536
-				$html .= '<label for="checkbox-' . esc_attr( $k ) . '">' . "\n";
537
-				$html .= '<input type="checkbox" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . '][]" class="multicheck multicheck-' . esc_attr( $args['key'] ) . '" value="' . esc_attr( $k ) . '" id="checkbox-' . esc_attr( $k ) . '" ' . $checked . ' /> ' . $v . "\n";
538
-				$html .= '</label><br />' . "\n";
536
+				$html .= '<label for="checkbox-'.esc_attr($k).'">'."\n";
537
+				$html .= '<input type="checkbox" name="'.esc_attr($this->token).'['.esc_attr($args['key']).'][]" class="multicheck multicheck-'.esc_attr($args['key']).'" value="'.esc_attr($k).'" id="checkbox-'.esc_attr($k).'" '.$checked.' /> '.$v."\n";
538
+				$html .= '</label><br />'."\n";
539 539
 			}
540
-			$html .= '</div>' . "\n";
540
+			$html .= '</div>'."\n";
541 541
 			echo $html;
542 542
 
543
-			if ( isset( $args['data']['description'] ) ) {
544
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
543
+			if (isset($args['data']['description'])) {
544
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
545 545
 			}
546 546
 		}
547 547
 	} // End form_field_multicheck()
@@ -553,20 +553,20 @@  discard block
 block discarded – undo
553 553
 	 * @param  array $args
554 554
 	 * @return void
555 555
 	 */
556
-	public function form_field_range ( $args ) {
556
+	public function form_field_range($args) {
557 557
 		$options = $this->get_settings();
558 558
 
559
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
559
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
560 560
 			$html = '';
561
-			$html .= '<select id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" class="range-input">' . "\n";
562
-				foreach ( $args['data']['options'] as $k => $v ) {
563
-					$html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n";
561
+			$html .= '<select id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" class="range-input">'."\n";
562
+				foreach ($args['data']['options'] as $k => $v) {
563
+					$html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n";
564 564
 				}
565
-			$html .= '</select>' . "\n";
565
+			$html .= '</select>'."\n";
566 566
 			echo $html;
567 567
 
568
-			if ( isset( $args['data']['description'] ) ) {
569
-				echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n";
568
+			if (isset($args['data']['description'])) {
569
+				echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n";
570 570
 			}
571 571
 		}
572 572
 	} // End form_field_range()
@@ -578,18 +578,18 @@  discard block
 block discarded – undo
578 578
 	 * @param  array $args
579 579
 	 * @return void
580 580
 	 */
581
-	public function form_field_images ( $args ) {
581
+	public function form_field_images($args) {
582 582
 		$options = $this->get_settings();
583 583
 
584
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
584
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
585 585
 			$html = '';
586
-			foreach ( $args['data']['options'] as $k => $v ) {
587
-				$html .= '<input type="radio" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n";
586
+			foreach ($args['data']['options'] as $k => $v) {
587
+				$html .= '<input type="radio" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n";
588 588
 			}
589 589
 			echo $html;
590 590
 
591
-			if ( isset( $args['data']['description'] ) ) {
592
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
591
+			if (isset($args['data']['description'])) {
592
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
593 593
 			}
594 594
 		}
595 595
 	} // End form_field_images()
@@ -601,19 +601,19 @@  discard block
 block discarded – undo
601 601
 	 * @param  array $args
602 602
 	 * @return void
603 603
 	 */
604
-	public function form_field_info ( $args ) {
604
+	public function form_field_info($args) {
605 605
 		$class = '';
606
-		if ( isset( $args['data']['class'] ) ) {
607
-			$class = ' ' . esc_attr( $args['data']['class'] );
606
+		if (isset($args['data']['class'])) {
607
+			$class = ' '.esc_attr($args['data']['class']);
608 608
 		}
609
-		$html = '<div id="' . $args['key'] . '" class="info-box' . $class . '">' . "\n";
610
-		if ( isset( $args['data']['name'] ) && ( $args['data']['name'] != '' ) ) {
611
-			$html .= '<h3 class="title">' . esc_html( $args['data']['name'] ) . '</h3>' . "\n";
609
+		$html = '<div id="'.$args['key'].'" class="info-box'.$class.'">'."\n";
610
+		if (isset($args['data']['name']) && ($args['data']['name'] != '')) {
611
+			$html .= '<h3 class="title">'.esc_html($args['data']['name']).'</h3>'."\n";
612 612
 		}
613
-		if ( isset( $args['data']['description'] ) && ( $args['data']['description'] != '' ) ) {
614
-			$html .= '<p>' . esc_html( $args['data']['description'] ) . '</p>' . "\n";
613
+		if (isset($args['data']['description']) && ($args['data']['description'] != '')) {
614
+			$html .= '<p>'.esc_html($args['data']['description']).'</p>'."\n";
615 615
 		}
616
-		$html .= '</div>' . "\n";
616
+		$html .= '</div>'."\n";
617 617
 
618 618
 		echo $html;
619 619
 	} // End form_field_info()
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
 	 * @since  1.9.0
626 626
 	 * @param  array $args
627 627
 	 */
628
-	public function form_field_button( $args ) {
628
+	public function form_field_button($args) {
629 629
 		$options = $this->get_settings();
630 630
 
631
-		if ( isset( $args['data']['target'] ) && isset( $args['data']['label'] ) ) {
632
-			printf( '<a href="%s" class="button button-secondary">%s</a> ', esc_url( $args['data']['target'] ), esc_html( $args['data']['label'] ) );
631
+		if (isset($args['data']['target']) && isset($args['data']['label'])) {
632
+			printf('<a href="%s" class="button button-secondary">%s</a> ', esc_url($args['data']['target']), esc_html($args['data']['label']));
633 633
 
634
-			if ( isset( $args['data']['description'] ) ) {
635
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
634
+			if (isset($args['data']['description'])) {
635
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
636 636
 			}
637 637
 		}
638 638
 	} // End form_field_button()
@@ -646,23 +646,23 @@  discard block
 block discarded – undo
646 646
 	 * @uses   $this->parse_errors()
647 647
 	 * @return array $options
648 648
 	 */
649
-	public function validate_fields ( $input ) {
649
+	public function validate_fields($input) {
650 650
 		$options = $this->get_settings();
651 651
 
652
-		foreach ( $this->fields as $k => $v ) {
652
+		foreach ($this->fields as $k => $v) {
653 653
 			// Make sure checkboxes are present even when false.
654
-			if ( $v['type'] == 'checkbox' && ! isset( $input[$k] ) ) { $input[$k] = false; }
655
-			if ( $v['type'] == 'multicheck' && ! isset( $input[$k] ) ) { $input[$k] = false; }
654
+			if ($v['type'] == 'checkbox' && ! isset($input[$k])) { $input[$k] = false; }
655
+			if ($v['type'] == 'multicheck' && ! isset($input[$k])) { $input[$k] = false; }
656 656
 
657
-			if ( isset( $input[$k] ) ) {
657
+			if (isset($input[$k])) {
658 658
 				// Perform checks on required fields.
659
-				if ( isset( $v['required'] ) && ( $v['required'] == true ) ) {
660
-					if ( in_array( $v['type'], $this->get_array_field_types() ) && ( count( (array) $input[$k] ) <= 0 ) ) {
661
-						$this->add_error( $k, $v );
659
+				if (isset($v['required']) && ($v['required'] == true)) {
660
+					if (in_array($v['type'], $this->get_array_field_types()) && (count((array) $input[$k]) <= 0)) {
661
+						$this->add_error($k, $v);
662 662
 						continue;
663 663
 					} else {
664
-						if ( $input[$k] == '' ) {
665
-							$this->add_error( $k, $v );
664
+						if ($input[$k] == '') {
665
+							$this->add_error($k, $v);
666 666
 							continue;
667 667
 						}
668 668
 					}
@@ -671,28 +671,28 @@  discard block
 block discarded – undo
671 671
 				$value = $input[$k];
672 672
 
673 673
 				// Check if the field is valid.
674
-				$method = $this->determine_method( $v, 'check' );
674
+				$method = $this->determine_method($v, 'check');
675 675
 
676
-				if ( function_exists ( $method ) ) {
677
-					$is_valid = $method( $value );
676
+				if (function_exists($method)) {
677
+					$is_valid = $method($value);
678 678
 				} else {
679
-					if ( method_exists( $this, $method ) ) {
680
-						$is_valid = $this->$method( $value );
679
+					if (method_exists($this, $method)) {
680
+						$is_valid = $this->$method($value);
681 681
 					}
682 682
 				}
683 683
 
684
-				if ( ! $is_valid ) {
685
-					$this->add_error( $k, $v );
684
+				if ( ! $is_valid) {
685
+					$this->add_error($k, $v);
686 686
 					continue;
687 687
 				}
688 688
 
689
-				$method = $this->determine_method( $v, 'validate' );
689
+				$method = $this->determine_method($v, 'validate');
690 690
 
691
-				if ( function_exists ( $method ) ) {
692
-					$options[$k] = $method( $value );
691
+				if (function_exists($method)) {
692
+					$options[$k] = $method($value);
693 693
 				} else {
694
-					if ( method_exists( $this, $method ) ) {
695
-						$options[$k] = $this->$method( $value );
694
+					if (method_exists($this, $method)) {
695
+						$options[$k] = $this->$method($value);
696 696
 					}
697 697
 				}
698 698
 			}
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
 	 * @param  string $input
711 711
 	 * @return string
712 712
 	 */
713
-	public function validate_field_text ( $input ) {
714
-		return trim( esc_attr( $input ) );
713
+	public function validate_field_text($input) {
714
+		return trim(esc_attr($input));
715 715
 	} // End validate_field_text()
716 716
 
717 717
 	/**
@@ -721,11 +721,11 @@  discard block
 block discarded – undo
721 721
 	 * @param  string $input
722 722
 	 * @return string
723 723
 	 */
724
-	public function validate_field_checkbox ( $input ) {
725
-		if ( ! isset( $input ) ) {
724
+	public function validate_field_checkbox($input) {
725
+		if ( ! isset($input)) {
726 726
 			return 0;
727 727
 		} else {
728
-			return (bool)$input;
728
+			return (bool) $input;
729 729
 		}
730 730
 	} // End validate_field_checkbox()
731 731
 
@@ -736,10 +736,10 @@  discard block
 block discarded – undo
736 736
 	 * @param  string $input
737 737
 	 * @return string
738 738
 	 */
739
-	public function validate_field_multicheck ( $input ) {
739
+	public function validate_field_multicheck($input) {
740 740
 		$input = (array) $input;
741 741
 
742
-		$input = array_map( 'esc_attr', $input );
742
+		$input = array_map('esc_attr', $input);
743 743
 
744 744
 		return $input;
745 745
 	} // End validate_field_multicheck()
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
 	 * @param  string $input
752 752
 	 * @return string
753 753
 	 */
754
-	public function validate_field_range ( $input ) {
755
-		$input = number_format( floatval( $input ), 0 );
754
+	public function validate_field_range($input) {
755
+		$input = number_format(floatval($input), 0);
756 756
 
757 757
 		return $input;
758 758
 	} // End validate_field_range()
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 	 * @param  string $input
765 765
 	 * @return string
766 766
 	 */
767
-	public function validate_field_url ( $input ) {
768
-		return trim( esc_url( $input ) );
767
+	public function validate_field_url($input) {
768
+		return trim(esc_url($input));
769 769
 	} // End validate_field_url()
770 770
 
771 771
 	/**
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * @since  1.1.0
775 775
 	 * @return boolean Is the value valid?
776 776
 	 */
777
-	public function check_field_text ( $input ) {
777
+	public function check_field_text($input) {
778 778
 		$is_valid = true;
779 779
 
780 780
 		return $is_valid;
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	 * @param  array $data
789 789
 	 * @return void
790 790
 	 */
791
-	protected function add_error ( $key, $data ) {
792
-		if ( isset( $data['error_message'] ) ) {
791
+	protected function add_error($key, $data) {
792
+		if (isset($data['error_message'])) {
793 793
 			$message = $data['error_message'];
794 794
 		} else {
795
-			$message = sprintf( __( '%s is a required field', 'woothemes-sensei' ), $data['name'] );
795
+			$message = sprintf(__('%s is a required field', 'woothemes-sensei'), $data['name']);
796 796
 		}
797 797
 		$this->errors[$key] = $message;
798 798
 	} // End add_error()
@@ -803,14 +803,14 @@  discard block
 block discarded – undo
803 803
 	 * @since   1.0.0
804 804
 	 * @return  void
805 805
 	 */
806
-	protected function parse_errors () {
807
-		if ( count ( $this->errors ) > 0 ) {
808
-			foreach ( $this->errors as $k => $v ) {
809
-				add_settings_error( $this->token . '-errors', $k, $v, 'error' );
806
+	protected function parse_errors() {
807
+		if (count($this->errors) > 0) {
808
+			foreach ($this->errors as $k => $v) {
809
+				add_settings_error($this->token.'-errors', $k, $v, 'error');
810 810
 			}
811 811
 		} else {
812
-			$message = sprintf( __( '%s updated', 'woothemes-sensei' ), $this->name );
813
-			add_settings_error( $this->token . '-errors', $this->token, $message, 'updated' );
812
+			$message = sprintf(__('%s updated', 'woothemes-sensei'), $this->name);
813
+			add_settings_error($this->token.'-errors', $this->token, $message, 'updated');
814 814
 		}
815 815
 	} // End parse_errors()
816 816
 
@@ -820,8 +820,8 @@  discard block
 block discarded – undo
820 820
 	 * @since  1.0.0
821 821
 	 * @return array
822 822
 	 */
823
-	protected function get_array_field_types () {
824
-		return array( 'multicheck' );
823
+	protected function get_array_field_types() {
824
+		return array('multicheck');
825 825
 	} // End get_array_field_types()
826 826
 
827 827
 	/**
@@ -830,21 +830,21 @@  discard block
 block discarded – undo
830 830
 	 * @since  1.0.0
831 831
 	 * @return void
832 832
 	 */
833
-	public function enqueue_scripts () {
833
+	public function enqueue_scripts() {
834 834
 
835
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
835
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
836 836
 
837
-		wp_enqueue_script( 'farbtastic' );
838
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version );
837
+		wp_enqueue_script('farbtastic');
838
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'farbtastic'), Sensei()->version);
839 839
 
840
-		if ( $this->has_range ) {
841
-			wp_enqueue_script( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/js/ranges' . $suffix . '.js' ), array( 'jquery-ui-slider' ), Sensei()->version );
840
+		if ($this->has_range) {
841
+			wp_enqueue_script('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/js/ranges'.$suffix.'.js'), array('jquery-ui-slider'), Sensei()->version);
842 842
 		}
843 843
 
844
-		wp_register_script( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/js/image-selectors' . $suffix . '.js' ), array( 'jquery' ), Sensei()->version );
844
+		wp_register_script('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/js/image-selectors'.$suffix.'.js'), array('jquery'), Sensei()->version);
845 845
 
846
-		if ( $this->has_imageselector ) {
847
-			wp_enqueue_script( 'woothemes-sensei-settings-imageselectors' );
846
+		if ($this->has_imageselector) {
847
+			wp_enqueue_script('woothemes-sensei-settings-imageselectors');
848 848
 		}
849 849
 
850 850
 	} // End enqueue_scripts()
@@ -855,12 +855,12 @@  discard block
 block discarded – undo
855 855
 	 * @since  1.0.0
856 856
 	 * @return void
857 857
 	 */
858
-	public function enqueue_styles () {
858
+	public function enqueue_styles() {
859 859
 
860
-		wp_enqueue_style( $this->token . '-admin' );
860
+		wp_enqueue_style($this->token.'-admin');
861 861
 
862
-		wp_enqueue_style( 'farbtastic' );
863
-		wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), array( 'farbtastic' ), Sensei()->version );
862
+		wp_enqueue_style('farbtastic');
863
+		wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), array('farbtastic'), Sensei()->version);
864 864
 
865 865
 		$this->enqueue_field_styles();
866 866
 	} // End enqueue_styles()
@@ -871,16 +871,16 @@  discard block
 block discarded – undo
871 871
 	 * @since  1.0.0
872 872
 	 * @return void
873 873
 	 */
874
-	public function enqueue_field_styles () {
874
+	public function enqueue_field_styles() {
875 875
 
876
-		if ( $this->has_range ) {
877
-			wp_enqueue_style( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/css/ranges.css' ), '', Sensei()->version );
876
+		if ($this->has_range) {
877
+			wp_enqueue_style('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/css/ranges.css'), '', Sensei()->version);
878 878
 		}
879 879
 
880
-		wp_register_style( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/css/image-selectors.css' ), '', Sensei()->version );
880
+		wp_register_style('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/css/image-selectors.css'), '', Sensei()->version);
881 881
 
882
-		if ( $this->has_imageselector ) {
883
-			wp_enqueue_style( 'woothemes-sensei-settings-imageselectors' );
882
+		if ($this->has_imageselector) {
883
+			wp_enqueue_style('woothemes-sensei-settings-imageselectors');
884 884
 		}
885 885
 	} // End enqueue_field_styles()
886 886
 } // End Class
@@ -890,4 +890,4 @@  discard block
 block discarded – undo
890 890
  * @ignore only for backward compatibility
891 891
  * @since 1.9.0
892 892
  */
893
-class WooThemes_Sensei_Settings_API extends Sensei_Settings_API{}
893
+class WooThemes_Sensei_Settings_API extends Sensei_Settings_API {}
Please login to merge, or discard this patch.
includes/class-sensei-analysis-overview-list-table.php 1 patch
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * Analysis Overview Data Table.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	 * @since  1.2.0
19 19
 	 * @return  void
20 20
 	 */
21
-	public function __construct ( $type = 'users' ) {
22
-		$this->type = in_array( $type, array( 'courses', 'lessons', 'users' ) ) ? $type : 'users';
21
+	public function __construct($type = 'users') {
22
+		$this->type = in_array($type, array('courses', 'lessons', 'users')) ? $type : 'users';
23 23
 
24 24
 		// Load Parent token into constructor
25
-		parent::__construct( 'analysis_overview' );
25
+		parent::__construct('analysis_overview');
26 26
 
27 27
 		// Actions
28
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
29
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
28
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
29
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
30 30
 
31
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
31
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
32 32
 	} // End __construct()
33 33
 
34 34
 	/**
@@ -38,41 +38,41 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	function get_columns() {
40 40
 
41
-		switch( $this->type ) {
41
+		switch ($this->type) {
42 42
 			case 'courses':
43 43
 				$columns = array(
44
-					'title' => __( 'Course', 'woothemes-sensei' ),
45
-					'students' => __( 'Learners', 'woothemes-sensei' ),
46
-					'lessons' => __( 'Lessons', 'woothemes-sensei' ),
47
-					'completions' => __( 'Completed', 'woothemes-sensei' ),
48
-					'average_percent' => __( 'Average Percentage', 'woothemes-sensei' ),
44
+					'title' => __('Course', 'woothemes-sensei'),
45
+					'students' => __('Learners', 'woothemes-sensei'),
46
+					'lessons' => __('Lessons', 'woothemes-sensei'),
47
+					'completions' => __('Completed', 'woothemes-sensei'),
48
+					'average_percent' => __('Average Percentage', 'woothemes-sensei'),
49 49
 				);
50 50
 				break;
51 51
 
52 52
 			case 'lessons':
53 53
 				$columns = array(
54
-					'title' => __( 'Lesson', 'woothemes-sensei' ),
55
-					'course' => __( 'Course', 'woothemes-sensei' ),
56
-					'students' => __( 'Learners', 'woothemes-sensei' ),
57
-					'completions' => __( 'Completed', 'woothemes-sensei' ),
58
-					'average_grade' => __( 'Average Grade', 'woothemes-sensei' ),
54
+					'title' => __('Lesson', 'woothemes-sensei'),
55
+					'course' => __('Course', 'woothemes-sensei'),
56
+					'students' => __('Learners', 'woothemes-sensei'),
57
+					'completions' => __('Completed', 'woothemes-sensei'),
58
+					'average_grade' => __('Average Grade', 'woothemes-sensei'),
59 59
 				);
60 60
 				break;
61 61
 
62 62
 			case 'users':
63 63
 			default:
64 64
 				$columns = array(
65
-					'title' => __( 'Learner', 'woothemes-sensei' ),
66
-					'registered' => __( 'Date Registered', 'woothemes-sensei' ),
67
-					'active_courses' => __( 'Active Courses', 'woothemes-sensei' ),
68
-					'completed_courses' => __( 'Completed Courses', 'woothemes-sensei' ),
69
-					'average_grade' => __( 'Average Grade', 'woothemes-sensei' ),
65
+					'title' => __('Learner', 'woothemes-sensei'),
66
+					'registered' => __('Date Registered', 'woothemes-sensei'),
67
+					'active_courses' => __('Active Courses', 'woothemes-sensei'),
68
+					'completed_courses' => __('Completed Courses', 'woothemes-sensei'),
69
+					'average_grade' => __('Average Grade', 'woothemes-sensei'),
70 70
 				);
71 71
 				break;
72 72
 		}
73 73
 		// Backwards compatible filter name, moving forward should have single filter name
74
-		$columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns', $columns, $this );
75
-		$columns = apply_filters( 'sensei_analysis_overview_columns', $columns, $this );
74
+		$columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns', $columns, $this);
75
+		$columns = apply_filters('sensei_analysis_overview_columns', $columns, $this);
76 76
 		return $columns;
77 77
 	}
78 78
 
@@ -83,41 +83,41 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	function get_sortable_columns() {
85 85
 
86
-		switch( $this->type ) {
86
+		switch ($this->type) {
87 87
 			case 'courses':
88 88
 				$columns = array(
89
-					'title' => array( 'title', false ),
90
-					'students' => array( 'students', false ),
91
-					'lessons' => array( 'lessons', false ),
92
-					'completions' => array( 'completions', false ),
93
-					'average_percent' => array( 'average_percent', false ),
89
+					'title' => array('title', false),
90
+					'students' => array('students', false),
91
+					'lessons' => array('lessons', false),
92
+					'completions' => array('completions', false),
93
+					'average_percent' => array('average_percent', false),
94 94
 				);
95 95
 				break;
96 96
 
97 97
 			case 'lessons':
98 98
 				$columns = array(
99
-					'title' => array( 'title', false ),
100
-					'course' => array( 'course', false ),
101
-					'students' => array( 'students', false ),
102
-					'completions' => array( 'completions', false ),
103
-					'average_grade' => array( 'average_grade', false ),
99
+					'title' => array('title', false),
100
+					'course' => array('course', false),
101
+					'students' => array('students', false),
102
+					'completions' => array('completions', false),
103
+					'average_grade' => array('average_grade', false),
104 104
 				);
105 105
 				break;
106 106
 
107 107
 			case 'users':
108 108
 			default:
109 109
 				$columns = array(
110
-					'title' => array( 'user_login', false ),
111
-					'registered' => array( 'registered', false ),
112
-					'active_courses' => array( 'active_courses', false ),
113
-					'completed_courses' => array( 'completed_courses', false ),
114
-					'average_grade' => array( 'average_grade', false )
110
+					'title' => array('user_login', false),
111
+					'registered' => array('registered', false),
112
+					'active_courses' => array('active_courses', false),
113
+					'completed_courses' => array('completed_courses', false),
114
+					'average_grade' => array('average_grade', false)
115 115
 				);
116 116
 				break;
117 117
 		}
118 118
 		// Backwards compatible filter name, moving forward should have single filter name
119
-		$columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns_sortable', $columns, $this );
120
-		$columns = apply_filters( 'sensei_analysis_overview_columns_sortable', $columns, $this );
119
+		$columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns_sortable', $columns, $this);
120
+		$columns = apply_filters('sensei_analysis_overview_columns_sortable', $columns, $this);
121 121
 		return $columns;
122 122
 	}
123 123
 
@@ -131,25 +131,25 @@  discard block
 block discarded – undo
131 131
 
132 132
 		// Handle orderby
133 133
 		$orderby = '';
134
-		if ( !empty( $_GET['orderby'] ) ) {
135
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
136
-				$orderby = esc_html( $_GET['orderby'] );
134
+		if ( ! empty($_GET['orderby'])) {
135
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
136
+				$orderby = esc_html($_GET['orderby']);
137 137
 			} // End If Statement
138 138
 		}
139 139
 
140 140
 		// Handle order
141 141
 		$order = 'ASC';
142
-		if ( !empty( $_GET['order'] ) ) {
143
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
142
+		if ( ! empty($_GET['order'])) {
143
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
144 144
 		}
145 145
 
146
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
147
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
146
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
147
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
148 148
 
149 149
 		$paged = $this->get_pagenum();
150 150
 		$offset = 0;
151
-		if ( !empty($paged) ) {
152
-			$offset = $per_page * ( $paged - 1 );
151
+		if ( ! empty($paged)) {
152
+			$offset = $per_page * ($paged - 1);
153 153
 		} // End If Statement
154 154
 
155 155
 		$args = array(
@@ -160,32 +160,32 @@  discard block
 block discarded – undo
160 160
 		);
161 161
 
162 162
         // Handle search
163
-        if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) {
164
-            $args['search'] = esc_html( $_GET['s'] );
163
+        if (isset($_GET['s']) && ! empty($_GET['s'])) {
164
+            $args['search'] = esc_html($_GET['s']);
165 165
         }
166 166
 
167
-		switch ( $this->type ) {
167
+		switch ($this->type) {
168 168
 			case 'courses':
169
-				$this->items = $this->get_courses( $args );
169
+				$this->items = $this->get_courses($args);
170 170
 				break;
171 171
 
172 172
 			case 'lessons':
173
-				$this->items = $this->get_lessons( $args );
173
+				$this->items = $this->get_lessons($args);
174 174
 				break;
175 175
 
176 176
 			case 'users':
177 177
 			default :
178
-				$this->items = $this->get_learners( $args );
178
+				$this->items = $this->get_learners($args);
179 179
 				break;
180 180
 		}
181 181
 
182 182
 		$total_items = $this->total_items;
183
-		$total_pages = ceil( $total_items / $per_page );
184
-		$this->set_pagination_args( array(
183
+		$total_pages = ceil($total_items / $per_page);
184
+		$this->set_pagination_args(array(
185 185
 			'total_items' => $total_items,
186 186
 			'total_pages' => $total_pages,
187 187
 			'per_page' => $per_page
188
-		) );
188
+		));
189 189
 	}
190 190
 
191 191
 	/**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @since  1.7.0
194 194
 	 * @return data
195 195
 	 */
196
-	public function generate_report( $report ) {
196
+	public function generate_report($report) {
197 197
 
198 198
 		$data = array();
199 199
 
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 
202 202
 		// Handle orderby
203 203
 		$orderby = '';
204
-		if ( !empty( $_GET['orderby'] ) ) {
205
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
206
-				$orderby = esc_html( $_GET['orderby'] );
204
+		if ( ! empty($_GET['orderby'])) {
205
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
206
+				$orderby = esc_html($_GET['orderby']);
207 207
 			} // End If Statement
208 208
 		}
209 209
 
210 210
 		// Handle order
211 211
 		$order = 'ASC';
212
-		if ( !empty( $_GET['order'] ) ) {
213
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
212
+		if ( ! empty($_GET['order'])) {
213
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
214 214
 		}
215 215
 
216 216
 		$args = array(
@@ -220,37 +220,37 @@  discard block
 block discarded – undo
220 220
 
221 221
 
222 222
         // Handle search
223
-        if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) {
224
-            $args['search'] = esc_html( $_GET['s'] );
223
+        if (isset($_GET['s']) && ! empty($_GET['s'])) {
224
+            $args['search'] = esc_html($_GET['s']);
225 225
         }
226 226
 
227 227
 
228 228
 		// Start the csv with the column headings
229 229
 		$column_headers = array();
230 230
 		$columns = $this->get_columns();
231
-		foreach( $columns AS $key => $title ) {
231
+		foreach ($columns AS $key => $title) {
232 232
 			$column_headers[] = $title;
233 233
 		}
234 234
 		$data[] = $column_headers;
235 235
 
236
-		switch ( $this->type ) {
236
+		switch ($this->type) {
237 237
 			case 'courses':
238
-				$this->items = $this->get_courses( $args );
238
+				$this->items = $this->get_courses($args);
239 239
 				break;
240 240
 
241 241
 			case 'lessons':
242
-				$this->items = $this->get_lessons( $args );
242
+				$this->items = $this->get_lessons($args);
243 243
 				break;
244 244
 
245 245
 			case 'users':
246 246
 			default :
247
-				$this->items = $this->get_learners( $args );
247
+				$this->items = $this->get_learners($args);
248 248
 				break;
249 249
 		}
250 250
 
251 251
 		// Process each row
252
-		foreach( $this->items AS $item) {
253
-			$data[] = $this->get_row_data( $item );
252
+		foreach ($this->items AS $item) {
253
+			$data[] = $this->get_row_data($item);
254 254
 		}
255 255
 
256 256
 		return $data;
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	 * @param object $item The current item
263 263
      * @return array $column_data;
264 264
 	 */
265
-	protected function get_row_data( $item ) {
265
+	protected function get_row_data($item) {
266 266
 
267
-		switch( $this->type ) {
267
+		switch ($this->type) {
268 268
 			case 'courses' :
269 269
 				// Get Learners (i.e. those who have started)
270 270
 				$course_args = array( 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 						'type' => 'sensei_course_status',
273 273
 						'status' => 'any',
274 274
 					);
275
-				$course_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_learners', $course_args, $item ) );
275
+				$course_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_learners', $course_args, $item));
276 276
 
277 277
 				// Get Course Completions
278 278
 				$course_args = array( 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 						'type' => 'sensei_course_status',
281 281
 						'status' => 'complete',
282 282
 					);
283
-				$course_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_completions', $course_args, $item ) );
283
+				$course_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_completions', $course_args, $item));
284 284
 
285 285
 				// Course Lessons
286
-				$course_lessons = Sensei()->lesson->lesson_count( array('publish', 'private'), $item->ID );
286
+				$course_lessons = Sensei()->lesson->lesson_count(array('publish', 'private'), $item->ID);
287 287
 
288 288
 				// Get Percent Complete
289 289
 				$grade_args = array( 
@@ -293,31 +293,31 @@  discard block
 block discarded – undo
293 293
 						'meta_key' => 'percent',
294 294
 					);
295 295
 
296
-				$percent_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_percentage', $grade_args, $item ), true ) );
297
-				$percent_total = Sensei_Grading::get_course_users_grades_sum( $item->ID );
296
+				$percent_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_percentage', $grade_args, $item), true));
297
+				$percent_total = Sensei_Grading::get_course_users_grades_sum($item->ID);
298 298
 
299 299
                 $course_average_percent = 0;
300
-                if( $percent_count > 0 && $percent_total > 0 ){
301
-                    $course_average_percent = abs( round( doubleval( $percent_total / $percent_count ), 2 ) );
300
+                if ($percent_count > 0 && $percent_total > 0) {
301
+                    $course_average_percent = abs(round(doubleval($percent_total / $percent_count), 2));
302 302
                 }
303 303
 
304 304
 
305 305
 				// Output course data
306
-				if ( $this->csv_output ) {
307
-					$course_title = apply_filters( 'the_title', $item->post_title, $item->ID );
306
+				if ($this->csv_output) {
307
+					$course_title = apply_filters('the_title', $item->post_title, $item->ID);
308 308
 				}
309 309
 				else {
310
-					$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID ), admin_url( 'admin.php' ) );
310
+					$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID), admin_url('admin.php'));
311 311
 
312
-					$course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
312
+					$course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>';
313 313
 					$course_average_percent .= '%';
314 314
 				} // End If Statement
315
-				$column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $course_title,
315
+				$column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $course_title,
316 316
 												'students' => $course_students,
317 317
 												'lessons' => $course_lessons,
318 318
 												'completions' => $course_completions,
319 319
 												'average_percent' => $course_average_percent,
320
-											), $item, $this );
320
+											), $item, $this);
321 321
 				break;
322 322
 
323 323
 			case 'lessons' :
@@ -327,65 +327,65 @@  discard block
 block discarded – undo
327 327
 						'type' => 'sensei_lesson_status',
328 328
 						'status' => 'any',
329 329
 					);
330
-				$lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) );
330
+				$lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item));
331 331
 
332 332
 				// Get Course Completions
333 333
 				$lesson_args = array( 
334 334
 						'post_id' => $item->ID,
335 335
 						'type' => 'sensei_lesson_status',
336
-						'status' => array( 'complete', 'graded', 'passed', 'failed' ),
336
+						'status' => array('complete', 'graded', 'passed', 'failed'),
337 337
 						'count' => true,
338 338
 					);
339
-				$lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) );
339
+				$lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item));
340 340
 
341 341
 				// Course 
342
-				$course_id = get_post_meta( $item->ID, '_lesson_course', true );
343
-				$course_title = $course_id ? get_the_title( $course_id ) : '';
342
+				$course_id = get_post_meta($item->ID, '_lesson_course', true);
343
+				$course_title = $course_id ? get_the_title($course_id) : '';
344 344
 
345 345
 				$lesson_average_grade = __('n/a', 'woothemes-sensei');
346
-				if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) {
346
+				if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) {
347 347
 					// Get Percent Complete
348 348
 					$grade_args = array( 
349 349
 							'post_id' => $item->ID,
350 350
 							'type' => 'sensei_lesson_status',
351
-							'status' => array( 'graded', 'passed', 'failed' ),
351
+							'status' => array('graded', 'passed', 'failed'),
352 352
 							'meta_key' => 'grade',
353 353
 						);
354 354
 
355
-					$grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true ));
356
-					$grade_total = Sensei_Grading::get_lessons_users_grades_sum( $item->ID );
355
+					$grade_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true));
356
+					$grade_total = Sensei_Grading::get_lessons_users_grades_sum($item->ID);
357 357
 
358 358
                     $lesson_average_grade = 0;
359
-                    if( $grade_total > 0 && $grade_count > 0 ){
360
-                        $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) );
359
+                    if ($grade_total > 0 && $grade_count > 0) {
360
+                        $lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2));
361 361
                     }
362 362
 
363 363
                 }
364 364
 				// Output lesson data
365
-				if ( $this->csv_output ) {
366
-					$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
365
+				if ($this->csv_output) {
366
+					$lesson_title = apply_filters('the_title', $item->post_title, $item->ID);
367 367
 				}
368 368
 				else {
369
-					$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
370
-					$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
369
+					$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php'));
370
+					$lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>';
371 371
 
372
-					if ( $course_id ) {
373
-						$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
374
-						$course_title = '<a href="' . esc_url( $url ) . '">' . $course_title . '</a>';
372
+					if ($course_id) {
373
+						$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
374
+						$course_title = '<a href="'.esc_url($url).'">'.$course_title.'</a>';
375 375
 					}
376 376
 					else {
377 377
 						$course_title = __('n/a', 'woothemes-sensei');
378 378
 					}
379
-					if ( is_numeric( $lesson_average_grade ) ) {
379
+					if (is_numeric($lesson_average_grade)) {
380 380
 						$lesson_average_grade .= '%';
381 381
 					}
382 382
 				} // End If Statement
383
-				$column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $lesson_title,
383
+				$column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $lesson_title,
384 384
 												'course' => $course_title,
385 385
 												'students' => $lesson_students,
386 386
 												'completions' => $lesson_completions,
387 387
 												'average_grade' => $lesson_average_grade,
388
-											), $item, $this );
388
+											), $item, $this);
389 389
 				break;
390 390
 
391 391
 			case 'users' :
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 						'type' => 'sensei_course_status',
397 397
 						'status' => 'any',
398 398
 					);
399
-				$user_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_started', $course_args, $item ) );
399
+				$user_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_started', $course_args, $item));
400 400
 
401 401
 				// Get Completed Courses
402 402
 				$course_args = array( 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 						'type' => 'sensei_course_status',
405 405
 						'status' => 'complete',
406 406
 					);
407
-				$user_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_ended', $course_args, $item ) );
407
+				$user_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_ended', $course_args, $item));
408 408
 
409 409
 				// Get Quiz Grades
410 410
 				$grade_args = array( 
@@ -414,29 +414,29 @@  discard block
 block discarded – undo
414 414
 						'meta_key' => 'grade',
415 415
 					);
416 416
 
417
-				$grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_lesson_grades', $grade_args, $item ), true ));
418
-				$grade_total = Sensei_Grading::get_user_graded_lessons_sum( $item->ID );
417
+				$grade_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_lesson_grades', $grade_args, $item), true));
418
+				$grade_total = Sensei_Grading::get_user_graded_lessons_sum($item->ID);
419 419
 
420 420
                 $user_average_grade = 0;
421
-                if( $grade_total > 0 && $grade_count > 0 ){
422
-                    $user_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) );
421
+                if ($grade_total > 0 && $grade_count > 0) {
422
+                    $user_average_grade = abs(round(doubleval($grade_total / $grade_count), 2));
423 423
                 }
424 424
 
425 425
 				// Output the users data
426
-				if ( $this->csv_output ) {
427
-                    $user_name = Sensei_Learner::get_full_name( $item->ID );
426
+				if ($this->csv_output) {
427
+                    $user_name = Sensei_Learner::get_full_name($item->ID);
428 428
                 }
429 429
 				else {
430
-					$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->ID ), admin_url( 'admin.php' ) );
431
-					$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $item->display_name . '</a></strong>';
430
+					$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->ID), admin_url('admin.php'));
431
+					$user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$item->display_name.'</a></strong>';
432 432
 					$user_average_grade .= '%';
433 433
 				} // End If Statement
434
-				$column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $user_name,
434
+				$column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $user_name,
435 435
 												'registered' => $item->user_registered,
436
-												'active_courses' => ( $user_courses_started - $user_courses_ended ),
436
+												'active_courses' => ($user_courses_started - $user_courses_ended),
437 437
 												'completed_courses' => $user_courses_ended,
438 438
 												'average_grade' => $user_average_grade,
439
-											), $item, $this );
439
+											), $item, $this);
440 440
 				break;
441 441
 		} // end switch
442 442
 		return $column_data;
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 * @since  1.7.0
448 448
 	 * @return array courses
449 449
 	 */
450
-	private function get_courses( $args ) {
450
+	private function get_courses($args) {
451 451
 		$course_args = array(
452 452
 			'post_type' => 'course',
453 453
 			'post_status' => array('publish', 'private'),
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 			'suppress_filters' => 0,
459 459
 		);
460 460
 
461
-		if ( $this->csv_output ) {
461
+		if ($this->csv_output) {
462 462
 			$course_args['posts_per_page'] = '-1';
463 463
 		}
464 464
 
465
-		if( isset( $args['search'] ) ) {
465
+		if (isset($args['search'])) {
466 466
 			$course_args['s'] = $args['search'];
467 467
 		}
468 468
 
469 469
 		// Using WP_Query as get_posts() doesn't support 'found_posts'
470
-		$courses_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_courses', $course_args ) );
470
+		$courses_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_courses', $course_args));
471 471
 		$this->total_items = $courses_query->found_posts;
472 472
 		return $courses_query->posts;
473 473
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @since  1.7.0
479 479
 	 * @return array lessons
480 480
 	 */
481
-	private function get_lessons( $args ) {
481
+	private function get_lessons($args) {
482 482
 		$lessons_args = array(
483 483
 			'post_type' => 'lesson',
484 484
 			'post_status' => array('publish', 'private'),
@@ -489,16 +489,16 @@  discard block
 block discarded – undo
489 489
 			'suppress_filters' => 0,
490 490
 		);
491 491
 
492
-		if ( $this->csv_output ) {
492
+		if ($this->csv_output) {
493 493
 			$lessons_args['posts_per_page'] = '-1';
494 494
 		}
495 495
 
496
-		if( isset( $args['search'] ) ) {
496
+		if (isset($args['search'])) {
497 497
 			$lessons_args['s'] = $args['search'];
498 498
 		}
499 499
 
500 500
 		// Using WP_Query as get_posts() doesn't support 'found_posts'
501
-		$lessons_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_lessons', $lessons_args ) );
501
+		$lessons_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_lessons', $lessons_args));
502 502
 		$this->total_items = $lessons_query->found_posts;
503 503
 		return $lessons_query->posts;
504 504
 	} // End get_lessons()
@@ -508,24 +508,24 @@  discard block
 block discarded – undo
508 508
 	 * @since  1.7.0
509 509
 	 * @return array learners
510 510
 	 */
511
-	private function get_learners( $args ) {
511
+	private function get_learners($args) {
512 512
 
513
-		if ( !empty($args['search']) ) {
513
+		if ( ! empty($args['search'])) {
514 514
 			$args = array(
515
-				'search' => '*' . trim( $args['search'], '*' ) . '*',
515
+				'search' => '*'.trim($args['search'], '*').'*',
516 516
 			);
517 517
 		}
518 518
 
519 519
 		// This stops the full meta data of each user being loaded
520
-		$args['fields'] = array( 'ID', 'user_login', 'user_email', 'user_registered', 'display_name' );
520
+		$args['fields'] = array('ID', 'user_login', 'user_email', 'user_registered', 'display_name');
521 521
 
522 522
         /**
523 523
          * Filter the WP_User_Query arguments
524 524
          * @since 1.6.0
525 525
          * @param $args
526 526
          */
527
-        $args = apply_filters( 'sensei_analysis_overview_filter_users', $args );
528
-		$wp_user_search = new WP_User_Query( $args );
527
+        $args = apply_filters('sensei_analysis_overview_filter_users', $args);
528
+		$wp_user_search = new WP_User_Query($args);
529 529
         $learners = $wp_user_search->get_results();
530 530
 		$this->total_items = $wp_user_search->get_total();
531 531
 
@@ -538,18 +538,18 @@  discard block
 block discarded – undo
538 538
 	 * @since  1.2.0
539 539
 	 * @return array $stats_to_render of stats boxes and values
540 540
 	 */
541
-	public function stats_boxes () {
541
+	public function stats_boxes() {
542 542
 
543 543
 		// Get the data required
544 544
 		$user_count = count_users();
545
-		$user_count = apply_filters( 'sensei_analysis_total_users', $user_count['total_users'], $user_count );
546
-		$total_courses = Sensei()->course->course_count( array('publish', 'private') );
547
-		$total_lessons = Sensei()->lesson->lesson_count( array('publish', 'private') );
545
+		$user_count = apply_filters('sensei_analysis_total_users', $user_count['total_users'], $user_count);
546
+		$total_courses = Sensei()->course->course_count(array('publish', 'private'));
547
+		$total_lessons = Sensei()->lesson->lesson_count(array('publish', 'private'));
548 548
 
549 549
         /**
550 550
          * filter the analysis tot grades query args
551 551
          */
552
-		$grade_args = apply_filters( 'sensei_analysis_total_quiz_grades', array(
552
+		$grade_args = apply_filters('sensei_analysis_total_quiz_grades', array(
553 553
 				'type' => 'sensei_lesson_status',
554 554
 				'status' => 'any',
555 555
 
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 		$total_grade_count = Sensei_Grading::get_graded_lessons_count();
560 560
 		$total_grade_total = Sensei_Grading::get_graded_lessons_sum();
561 561
 		$total_average_grade = 0;
562
-		if( $total_grade_total > 0 &&  $total_grade_count >0   ){
563
-			$total_average_grade = abs( round( doubleval( $total_grade_total / $total_grade_count ), 2 ) );
562
+		if ($total_grade_total > 0 && $total_grade_count > 0) {
563
+			$total_average_grade = abs(round(doubleval($total_grade_total / $total_grade_count), 2));
564 564
 		}
565 565
 
566 566
 
@@ -568,24 +568,24 @@  discard block
 block discarded – undo
568 568
 				'type' => 'sensei_course_status',
569 569
 				'status' => 'any',
570 570
 			);
571
-		$total_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_started', $course_args ) );
571
+		$total_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_started', $course_args));
572 572
 		$course_args = array( 
573 573
 				'type' => 'sensei_course_status',
574 574
 				'status' => 'complete',
575 575
 			);
576
-		$total_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_ended', $course_args ) );
577
-		$average_courses_per_learner = abs( round( doubleval( $total_courses_started / $user_count ), 2 ) );
576
+		$total_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_ended', $course_args));
577
+		$average_courses_per_learner = abs(round(doubleval($total_courses_started / $user_count), 2));
578 578
 
579 579
 		// Setup the boxes to render
580 580
 		$stats_to_render = array( 
581
-								__( 'Total Courses', 'woothemes-sensei' ) => $total_courses,
582
-								__( 'Total Lessons', 'woothemes-sensei' ) => $total_lessons,
583
-								__( 'Total Learners', 'woothemes-sensei' ) => $user_count,
584
-								__( 'Average Courses per Learner', 'woothemes-sensei' ) => $average_courses_per_learner,
585
-								__( 'Average Grade', 'woothemes-sensei' ) => $total_average_grade . '%',
586
-								__( 'Total Completed Courses', 'woothemes-sensei' ) => $total_courses_ended,
581
+								__('Total Courses', 'woothemes-sensei') => $total_courses,
582
+								__('Total Lessons', 'woothemes-sensei') => $total_lessons,
583
+								__('Total Learners', 'woothemes-sensei') => $user_count,
584
+								__('Average Courses per Learner', 'woothemes-sensei') => $average_courses_per_learner,
585
+								__('Average Grade', 'woothemes-sensei') => $total_average_grade.'%',
586
+								__('Total Completed Courses', 'woothemes-sensei') => $total_courses_ended,
587 587
 							);
588
-		return apply_filters( 'sensei_analysis_stats_boxes', $stats_to_render );
588
+		return apply_filters('sensei_analysis_stats_boxes', $stats_to_render);
589 589
 	} // End stats_boxes()
590 590
 
591 591
 	/**
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 	 * @return void
596 596
 	 */
597 597
 	public function no_items() {
598
-		if( ! $this->view || 'users' == $this->view ) {
598
+		if ( ! $this->view || 'users' == $this->view) {
599 599
 			$type = 'learners';
600 600
 		} else {
601 601
 			$type = $this->view;
602 602
 		}
603
-		echo  sprintf( __( '%1$sNo %2$s found%3$s', 'woothemes-sensei' ), '<em>', $type, '</em>' );
603
+		echo  sprintf(__('%1$sNo %2$s found%3$s', 'woothemes-sensei'), '<em>', $type, '</em>');
604 604
 	} // End no_items()
605 605
 
606 606
 	/**
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			'page' => $this->page_slug,
616 616
 		);
617 617
 		$learners_class = $courses_class = $lessons_class = '';
618
-		switch( $this->type ) {
618
+		switch ($this->type) {
619 619
 			case 'courses':
620 620
 				$courses_class = 'current';
621 621
 				break;
@@ -633,18 +633,18 @@  discard block
 block discarded – undo
633 633
 		$lesson_args['view'] = 'lessons';
634 634
 		$courses_args['view'] = 'courses';
635 635
 
636
-		$menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ). '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>';
637
-		$menu['courses'] = '<a class="' . $courses_class . '" href="' . esc_url ( add_query_arg( $courses_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Courses', 'woothemes-sensei' ) . '</a>';
638
-		$menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>';
636
+		$menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>';
637
+		$menu['courses'] = '<a class="'.$courses_class.'" href="'.esc_url(add_query_arg($courses_args, admin_url('admin.php'))).'">'.__('Courses', 'woothemes-sensei').'</a>';
638
+		$menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>';
639 639
 
640
-		$menu = apply_filters( 'sensei_analysis_overview_sub_menu', $menu );
641
-		if ( !empty($menu) ) {
642
-			echo '<ul class="subsubsub">' . "\n";
643
-			foreach ( $menu as $class => $item ) {
644
-				$menu[ $class ] = "\t<li class='$class'>$item";
640
+		$menu = apply_filters('sensei_analysis_overview_sub_menu', $menu);
641
+		if ( ! empty($menu)) {
642
+			echo '<ul class="subsubsub">'."\n";
643
+			foreach ($menu as $class => $item) {
644
+				$menu[$class] = "\t<li class='$class'>$item";
645 645
 			}
646
-			echo implode( " |</li>\n", $menu ) . "</li>\n";
647
-			echo '</ul>' . "\n";
646
+			echo implode(" |</li>\n", $menu)."</li>\n";
647
+			echo '</ul>'."\n";
648 648
 		}
649 649
 	} // End data_table_header()
650 650
 
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 	 * @return void
655 655
 	 */
656 656
 	public function data_table_footer() {
657
-		switch ( $this->type ) {
657
+		switch ($this->type) {
658 658
 			case 'courses':
659 659
 				$report = 'courses-overview';
660 660
 				break;
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 				$report = 'user-overview';
669 669
 			break;
670 670
 		} // End Switch Statement
671
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
672
-		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>';
671
+		$url = add_query_arg(array('page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report), admin_url('admin.php'));
672
+		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>';
673 673
 	} // End data_table_footer()
674 674
 
675 675
 	/**
@@ -677,19 +677,19 @@  discard block
 block discarded – undo
677 677
 	 * @since  1.7.0
678 678
 	 * @return string $text
679 679
 	 */
680
-	public function search_button( $text = '' ) {
681
-		switch( $this->type ) {
680
+	public function search_button($text = '') {
681
+		switch ($this->type) {
682 682
 			case 'courses':
683
-				$text = __( 'Search Courses', 'woothemes-sensei' );
683
+				$text = __('Search Courses', 'woothemes-sensei');
684 684
 			break;
685 685
 
686 686
 			case 'lessons':
687
-				$text = __( 'Search Lessons', 'woothemes-sensei' );
687
+				$text = __('Search Lessons', 'woothemes-sensei');
688 688
 			break;
689 689
 
690 690
 			case 'users':
691 691
 			default:
692
-				$text = __( 'Search Learners', 'woothemes-sensei' );
692
+				$text = __('Search Learners', 'woothemes-sensei');
693 693
 			break;
694 694
 		} // End Switch Statement
695 695
 
Please login to merge, or discard this patch.