Completed
Push — master ( 80c0ca...82d23b )
by Dwain
04:32
created
includes/class-sensei.php 1 patch
Spacing   +305 added lines, -305 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_Main
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
      * @param  string $file The base file of the plugin.
147 147
      * @since  1.0.0
148 148
      */
149
-    public function __construct ( $file ) {
149
+    public function __construct($file) {
150 150
 
151 151
         // Setup object data
152 152
         $this->file = $file;
153
-        $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) );
154
-        $this->plugin_path = trailingslashit( dirname( $file ) );
155
-        $this->template_url	= apply_filters( 'sensei_template_url', 'sensei/' );
156
-        $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) );
153
+        $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file));
154
+        $this->plugin_path = trailingslashit(dirname($file));
155
+        $this->template_url = apply_filters('sensei_template_url', 'sensei/');
156
+        $this->permissions_message = array('title' => __('Permission Denied', 'woothemes-sensei'), 'message' => __('Unfortunately you do not have permissions to access this page.', 'woothemes-sensei'));
157 157
 
158 158
         // Initialize the core Sensei functionality
159 159
         $this->init();
160 160
 
161 161
         // Installation
162
-        if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install();
162
+        if (is_admin() && ! defined('DOING_AJAX')) $this->install();
163 163
 
164 164
         // Run this on activation.
165
-        register_activation_hook( $this->file, array( $this, 'activation' ) );
165
+        register_activation_hook($this->file, array($this, 'activation'));
166 166
 
167 167
         // Image Sizes
168 168
         $this->init_image_sizes();
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
      * Load the foundations of Sensei.
180 180
      * @since 1.9.0
181 181
      */
182
-    protected function init(){
182
+    protected function init() {
183 183
 
184 184
         // Localisation
185 185
         $this->load_plugin_textdomain();
186
-        add_action( 'init', array( $this, 'load_localisation' ), 0 );
186
+        add_action('init', array($this, 'load_localisation'), 0);
187 187
 
188 188
         // load the shortcode loader into memory, so as to listen to all for
189 189
         // all shortcodes on the front end
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public static function instance() {
205 205
 
206
-        if ( is_null( self::$_instance ) ) {
206
+        if (is_null(self::$_instance)) {
207 207
 
208 208
             //Sensei requires a reference to the main Sensei plugin file
209
-            $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php';
209
+            $sensei_main_plugin_file = dirname(dirname(__FILE__)).'/woothemes-sensei.php';
210 210
 
211
-            self::$_instance = new self( $sensei_main_plugin_file  );
211
+            self::$_instance = new self($sensei_main_plugin_file);
212 212
 
213 213
             // load the global class objects needed throughout Sensei
214 214
             self::$_instance->initialize_global_objects();
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
      *
228 228
      * @param $plugin
229 229
      */
230
-    public static function activation_flush_rules( $plugin ){
230
+    public static function activation_flush_rules($plugin) {
231 231
 
232
-        if( strpos( $plugin, '/woothemes-sensei.php' ) > 0  ){
232
+        if (strpos($plugin, '/woothemes-sensei.php') > 0) {
233 233
 
234 234
             flush_rewrite_rules(true);
235 235
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      * @since 1.8.0
243 243
      */
244 244
     public function __clone() {
245
-        _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woothemes-sensei' ), '1.8' );
245
+        _doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'woothemes-sensei'), '1.8');
246 246
     }
247 247
 
248 248
     /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @since 1.8.0
251 251
      */
252 252
     public function __wakeup() {
253
-        _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woothemes-sensei' ), '1.8' );
253
+        _doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'woothemes-sensei'), '1.8');
254 254
     }
255 255
 
256 256
     /**
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
      *
259 259
      * @since 1.9.0
260 260
      */
261
-    public function initialize_global_objects(){
261
+    public function initialize_global_objects() {
262 262
 
263 263
         // Setup post types.
264 264
         $this->post_types = new Sensei_PostTypes();
265 265
 
266 266
         // Lad the updates class
267
-        $this->updates = new Sensei_Updates( $this );
267
+        $this->updates = new Sensei_Updates($this);
268 268
 
269 269
         // Setup settings
270 270
         $this->settings = new Sensei_Settings();
@@ -288,22 +288,22 @@  discard block
 block discarded – undo
288 288
         $this->quiz = $this->post_types->quiz;
289 289
 
290 290
         // load the modules class after all plugsin are loaded
291
-        add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) );
291
+        add_action('plugins_loaded', array($this, 'load_modules_class'));
292 292
 
293 293
         // Load Learner Management Functionality
294
-        $this->learners = new Sensei_Learner_Management( $this->file );
294
+        $this->learners = new Sensei_Learner_Management($this->file);
295 295
 
296 296
         // Differentiate between administration and frontend logic.
297
-        if ( is_admin() ) {
297
+        if (is_admin()) {
298 298
 
299 299
             // Load Admin Welcome class
300 300
             new Sensei_Welcome();
301 301
 
302 302
             // Load Admin Class
303
-            $this->admin = new Sensei_Admin( $this->file );
303
+            $this->admin = new Sensei_Admin($this->file);
304 304
 
305 305
             // Load Analysis Reports
306
-            $this->analysis = new Sensei_Analysis( $this->file );
306
+            $this->analysis = new Sensei_Analysis($this->file);
307 307
 
308 308
         } else {
309 309
 
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
         }
321 321
 
322 322
         // Load Grading Functionality
323
-        $this->grading = new Sensei_Grading( $this->file );
323
+        $this->grading = new Sensei_Grading($this->file);
324 324
 
325 325
         // Load Email Class
326
-        $this->emails = new Sensei_Emails( $this->file );
326
+        $this->emails = new Sensei_Emails($this->file);
327 327
 
328 328
         // Load Learner Profiles Class
329 329
         $this->learner_profiles = new Sensei_Learner_Profiles();
@@ -335,40 +335,40 @@  discard block
 block discarded – undo
335 335
      *
336 336
      * @since 1.9.0
337 337
      */
338
-    public function load_hooks(){
338
+    public function load_hooks() {
339 339
 
340
-        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
341
-        add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) );
340
+        add_action('widgets_init', array($this, 'register_widgets'));
341
+        add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support'));
342 342
 
343 343
         // WooCommerce Payment Actions
344
-        add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) );
345
-        add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) );
346
-        add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) );
347
-        add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) );
348
-        add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) );
349
-        add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) );
350
-        add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) );
344
+        add_action('woocommerce_payment_complete', array($this, 'sensei_woocommerce_complete_order'));
345
+        add_action('woocommerce_thankyou', array($this, 'sensei_woocommerce_complete_order'));
346
+        add_action('woocommerce_order_status_completed', array($this, 'sensei_woocommerce_complete_order'));
347
+        add_action('woocommerce_order_status_processing', array($this, 'sensei_woocommerce_complete_order'));
348
+        add_action('woocommerce_order_status_cancelled', array($this, 'sensei_woocommerce_cancel_order'));
349
+        add_action('woocommerce_order_status_refunded', array($this, 'sensei_woocommerce_cancel_order'));
350
+        add_action('subscriptions_activated_for_order', array($this, 'sensei_activate_subscription'));
351 351
 
352 352
         // WooCommerce Subscriptions Actions
353
-        add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 );
354
-        add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 );
355
-        add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 );
356
-        add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 );
357
-        add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 );
353
+        add_action('reactivated_subscription', array($this, 'sensei_woocommerce_reactivate_subscription'), 10, 2);
354
+        add_action('subscription_expired', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2);
355
+        add_action('subscription_end_of_prepaid_term', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2);
356
+        add_action('cancelled_subscription', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2);
357
+        add_action('subscription_put_on-hold', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2);
358 358
 
359 359
         // Add Email link to course orders
360
-        add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 );
360
+        add_action('woocommerce_email_after_order_table', array($this, 'sensei_woocommerce_email_course_details'), 10, 1);
361 361
 
362 362
         // Filter comment counts
363
-        add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 );
363
+        add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2);
364 364
 
365
-        add_action( 'body_class', array( $this, 'body_class' ) );
365
+        add_action('body_class', array($this, 'body_class'));
366 366
 
367 367
         // Check for and activate JetPack LaTeX support
368
-        add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules
368
+        add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules
369 369
 
370 370
         // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1
371
-        add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 );
371
+        add_action('init', array($this, 'flush_rewrite_rules'), 101);
372 372
 
373 373
     }
374 374
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function run_updates() {
382 382
         // Run updates if administrator
383
-        if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) {
383
+        if (current_user_can('manage_options') || current_user_can('manage_sensei')) {
384 384
 
385 385
             $this->updates->update();
386 386
 
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
      */
398 398
     public function set_woocommerce_functionality() {
399 399
         // Disable guest checkout if a course is in the cart as we need a valid user to store data for
400
-        add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) );
400
+        add_filter('pre_option_woocommerce_enable_guest_checkout', array($this, 'disable_guest_checkout'));
401 401
 
402 402
         // Mark orders with virtual products as complete rather then stay processing
403
-        add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 );
403
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'virtual_order_payment_complete'), 10, 2);
404 404
 
405 405
     } // End set_woocommerce_functionality()
406 406
 
@@ -409,14 +409,14 @@  discard block
 block discarded – undo
409 409
      * @param  boolean $guest_checkout Current guest checkout setting
410 410
      * @return boolean                 Modified guest checkout setting
411 411
      */
412
-    public function disable_guest_checkout( $guest_checkout ) {
412
+    public function disable_guest_checkout($guest_checkout) {
413 413
         global $woocommerce;
414 414
 
415
-        if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
415
+        if ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
416 416
 
417
-            if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) {
418
-                foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) {
419
-                    if( isset( $product['product_id'] ) ) {
417
+            if (isset($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents) > 0) {
418
+                foreach ($woocommerce->cart->cart_contents as $cart_key => $product) {
419
+                    if (isset($product['product_id'])) {
420 420
                         $args = array(
421 421
                             'posts_per_page' => -1,
422 422
                             'post_type' => 'course',
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
                                 )
428 428
                             )
429 429
                         );
430
-                        $posts = get_posts( $args );
431
-                        if( $posts && count( $posts ) > 0 ) {
432
-                            foreach( $posts as $course ) {
430
+                        $posts = get_posts($args);
431
+                        if ($posts && count($posts) > 0) {
432
+                            foreach ($posts as $course) {
433 433
                                 $guest_checkout = '';
434 434
                                 break;
435 435
                             }
@@ -449,17 +449,17 @@  discard block
 block discarded – undo
449 449
      * @param int $order_id
450 450
      * @return string
451 451
      **/
452
-    public function virtual_order_payment_complete( $order_status, $order_id ) {
453
-        $order = new WC_Order( $order_id );
454
-        if ( ! isset ( $order ) ) return '';
455
-        if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) {
452
+    public function virtual_order_payment_complete($order_status, $order_id) {
453
+        $order = new WC_Order($order_id);
454
+        if ( ! isset ($order)) return '';
455
+        if ($order_status == 'wc-processing' && ($order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed')) {
456 456
             $virtual_order = true;
457 457
 
458
-            if ( count( $order->get_items() ) > 0 ) {
459
-                foreach( $order->get_items() as $item ) {
460
-                    if ( $item['product_id'] > 0 ) {
461
-                        $_product = $order->get_product_from_item( $item );
462
-                        if ( ! $_product->is_virtual() ) {
458
+            if (count($order->get_items()) > 0) {
459
+                foreach ($order->get_items() as $item) {
460
+                    if ($item['product_id'] > 0) {
461
+                        $_product = $order->get_product_from_item($item);
462
+                        if ( ! $_product->is_virtual()) {
463 463
                             $virtual_order = false;
464 464
                             break;
465 465
                         } // End If Statement
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             } // End If Statement
469 469
 
470 470
             // virtual order, mark as completed
471
-            if ( $virtual_order ) {
471
+            if ($virtual_order) {
472 472
                 return 'completed';
473 473
             } // End If Statement
474 474
         } // End If Statement
@@ -481,21 +481,21 @@  discard block
 block discarded – undo
481 481
      * @since  1.0.0
482 482
      * @return void
483 483
      */
484
-    public function register_widgets () {
484
+    public function register_widgets() {
485 485
         // Widget List (key => value is filename => widget class).
486
-        $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 	'course-component' 	=> 'Course_Component',
486
+        $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' 	=> 'Course_Component',
487 487
                 'lesson-component' 	=> 'Lesson_Component',
488 488
                 'course-categories' => 'Course_Categories',
489
-                'category-courses' 	=> 'Category_Courses' )
489
+                'category-courses' 	=> 'Category_Courses')
490 490
         );
491
-        foreach ( $widget_list as $key => $value ) {
492
-            if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' ) ) {
493
-                require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' );
494
-                register_widget( 'WooThemes_Sensei_' . $value . '_Widget' );
491
+        foreach ($widget_list as $key => $value) {
492
+            if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php')) {
493
+                require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php');
494
+                register_widget('WooThemes_Sensei_'.$value.'_Widget');
495 495
             }
496 496
         } // End For Loop
497 497
 
498
-        do_action( 'sensei_register_widgets' );
498
+        do_action('sensei_register_widgets');
499 499
 
500 500
     } // End register_widgets()
501 501
 
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
      * @since  1.0.0
506 506
      * @return void
507 507
      */
508
-    public function load_localisation () {
509
-        load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' );
508
+    public function load_localisation() {
509
+        load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/');
510 510
     } // End load_localisation()
511 511
 
512 512
     /**
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
      * @since   1.0.0
516 516
      * @return  void
517 517
      */
518
-    public function load_plugin_textdomain () {
518
+    public function load_plugin_textdomain() {
519 519
         $domain = 'woothemes-sensei';
520 520
         // The "plugin_locale" filter is also used in load_plugin_textdomain()
521
-        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
522
-        load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
523
-        load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' );
521
+        $locale = apply_filters('plugin_locale', get_locale(), $domain);
522
+        load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo');
523
+        load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/');
524 524
     } // End load_plugin_textdomain()
525 525
 
526 526
     /**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
      * @since  1.0.0
530 530
      * @return void
531 531
      */
532
-    public function activation () {
532
+    public function activation() {
533 533
         $this->register_plugin_version();
534 534
     } // End activation()
535 535
 
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
      * @since  1.0.0
541 541
      * @return void
542 542
      */
543
-    public function install () {
544
-        register_activation_hook( $this->file, array( $this, 'activate_sensei' ) );
545
-        register_activation_hook( $this->file, 'flush_rewrite_rules' );
543
+    public function install() {
544
+        register_activation_hook($this->file, array($this, 'activate_sensei'));
545
+        register_activation_hook($this->file, 'flush_rewrite_rules');
546 546
     } // End install()
547 547
 
548 548
 
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
      * @since  1.0.0
553 553
      * @return void
554 554
      */
555
-    public function activate_sensei () {
556
-        update_option( 'skip_install_sensei_pages', 0 );
557
-        update_option( 'sensei_installed', 1 );
555
+    public function activate_sensei() {
556
+        update_option('skip_install_sensei_pages', 0);
557
+        update_option('sensei_installed', 1);
558 558
     } // End activate_sensei()
559 559
 
560 560
     /**
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
      * @since  1.0.0
564 564
      * @return void
565 565
      */
566
-    private function register_plugin_version () {
567
-        if ( $this->version != '' ) {
566
+    private function register_plugin_version() {
567
+        if ($this->version != '') {
568 568
 
569 569
             // Check previous version to see if forced updates must run
570 570
             // $old_version = get_option( 'woothemes-sensei-version', false );
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             // 	delete_option( 'woothemes-sensei-force-updates' );
575 575
             // }
576 576
 
577
-            update_option( 'woothemes-sensei-version', $this->version );
577
+            update_option('woothemes-sensei-version', $this->version);
578 578
         }
579 579
     } // End register_plugin_version()
580 580
 
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
      * @since   1.0.1
585 585
      * @return  void
586 586
      */
587
-    public function ensure_post_thumbnails_support () {
588
-        if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); }
587
+    public function ensure_post_thumbnails_support() {
588
+        if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); }
589 589
     } // End ensure_post_thumbnails_support()
590 590
 
591 591
 
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
      * @return void
598 598
      * @deprecated
599 599
      */
600
-    public function template_loader ( $template = '' ) {
600
+    public function template_loader($template = '') {
601 601
 
602
-        _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' );
603
-        Sensei_Templates::template_loader( $template );
602
+        _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead');
603
+        Sensei_Templates::template_loader($template);
604 604
 
605 605
     } // End template_loader()
606 606
 
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
      * @since  1.0.0
611 611
      * @return string $sensei_plugin_path
612 612
      */
613
-    public function plugin_path () {
613
+    public function plugin_path() {
614 614
 
615
-        if ( $this->plugin_path ) {
615
+        if ($this->plugin_path) {
616 616
 
617
-            $sensei_plugin_path =  $this->plugin_path;
617
+            $sensei_plugin_path = $this->plugin_path;
618 618
 
619
-        }else{
619
+        } else {
620 620
 
621
-            $sensei_plugin_path = plugin_dir_path( __FILE__ );
621
+            $sensei_plugin_path = plugin_dir_path(__FILE__);
622 622
 
623 623
         }
624 624
 
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
      * @param  string $page
635 635
      * @return int
636 636
      */
637
-    public function get_page_id ( $page ) {
638
-        $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) );
639
-        return ( $page ) ? $page : -1;
637
+    public function get_page_id($page) {
638
+        $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id'));
639
+        return ($page) ? $page : -1;
640 640
     } // End get_page_id()
641 641
 
642 642
 
@@ -648,18 +648,18 @@  discard block
 block discarded – undo
648 648
      * @param  array/Object $order_user (default: array()) Specific user's data.
649 649
      * @return bool|int
650 650
      */
651
-    public function woocommerce_course_update ( $course_id = 0, $order_user = array()  ) {
651
+    public function woocommerce_course_update($course_id = 0, $order_user = array()) {
652 652
         global $current_user;
653 653
 
654
-        if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false;
654
+        if ( ! isset($current_user) || ! $current_user->ID > 0) return false;
655 655
 
656 656
         $data_update = false;
657 657
 
658 658
         // Get the product ID
659
-        $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true );
659
+        $wc_post_id = get_post_meta(intval($course_id), '_course_woocommerce_product', true);
660 660
 
661 661
         // Check if in the admin
662
-        if ( is_admin() ) {
662
+        if (is_admin()) {
663 663
             $user_login = $order_user['user_login'];
664 664
             $user_email = $order_user['user_email'];
665 665
             $user_url = $order_user['user_url'];
@@ -672,25 +672,25 @@  discard block
 block discarded – undo
672 672
         } // End If Statement
673 673
 
674 674
         // This doesn't appear to be purely WooCommerce related. Should it be in a separate function?
675
-        $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true );
676
-        if( 0 < absint( $course_prerequisite_id ) ) {
677
-            $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) );
678
-            if ( ! $prereq_course_complete ) {
675
+        $course_prerequisite_id = (int) get_post_meta($course_id, '_course_prerequisite', true);
676
+        if (0 < absint($course_prerequisite_id)) {
677
+            $prereq_course_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, intval($user_id));
678
+            if ( ! $prereq_course_complete) {
679 679
                 // Remove all course user meta
680
-                return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id );
680
+                return Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id);
681 681
             }
682 682
         }
683 683
 
684
-        $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) );
684
+        $is_user_taking_course = Sensei_Utils::user_started_course(intval($course_id), intval($user_id));
685 685
 
686
-        if( ! $is_user_taking_course ) {
686
+        if ( ! $is_user_taking_course) {
687 687
 
688
-            if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) {
688
+            if (Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product($user_email, $user_id, $wc_post_id) && (0 < $wc_post_id)) {
689 689
 
690
-                $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) );
690
+                $activity_logged = Sensei_Utils::user_start_course(intval($user_id), intval($course_id));
691 691
 
692 692
                 $is_user_taking_course = false;
693
-                if ( true == $activity_logged ) {
693
+                if (true == $activity_logged) {
694 694
                     $is_user_taking_course = true;
695 695
                 } // End If Statement
696 696
             } // End If Statement
@@ -708,14 +708,14 @@  discard block
 block discarded – undo
708 708
      *
709 709
      * @return bool
710 710
      */
711
-    public function check_user_permissions ( $page = '' ) {
711
+    public function check_user_permissions($page = '') {
712 712
         // REFACTOR
713 713
         global $current_user, $post;
714 714
 
715 715
         // if use is not logged in
716
-        if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') ){
717
-            $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' );
718
-            $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() );
716
+        if (empty($current_user->caps) && Sensei()->settings->get('access_permission')) {
717
+            $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei');
718
+            $this->permissions_message['message'] = sprintf(__('You must be logged in to view this %s'), get_post_type());
719 719
             return false;
720 720
         }
721 721
 
@@ -725,104 +725,104 @@  discard block
 block discarded – undo
725 725
 
726 726
         $user_allowed = false;
727 727
 
728
-        switch ( $page ) {
728
+        switch ($page) {
729 729
             case 'course-single':
730 730
                 // check for prerequisite course or lesson,
731
-                $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true);
732
-                $update_course = $this->woocommerce_course_update( $post->ID );
731
+                $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true);
732
+                $update_course = $this->woocommerce_course_update($post->ID);
733 733
                 // Count completed lessons
734
-                if ( 0 < absint( $course_prerequisite_id ) ) {
734
+                if (0 < absint($course_prerequisite_id)) {
735 735
 
736
-                    $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID );
736
+                    $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID);
737 737
 
738 738
                 }
739 739
                 else {
740 740
                     $prerequisite_complete = true;
741 741
                 } // End If Statement
742 742
                 // Handles restrictions
743
-                if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) {
744
-                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
745
-                    $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
746
-                    $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link );
743
+                if ( ! $prerequisite_complete && 0 < absint($course_prerequisite_id)) {
744
+                    $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei');
745
+                    $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>';
746
+                    $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link);
747 747
                 } else {
748 748
                     $user_allowed = true;
749 749
                 } // End If Statement
750 750
                 break;
751 751
             case 'lesson-single':
752 752
                 // Check for WC purchase
753
-                $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true );
753
+                $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true);
754 754
 
755
-                $update_course = $this->woocommerce_course_update( $lesson_course_id );
756
-                $is_preview = Sensei_Utils::is_preview_lesson( $post->ID );
757
-                if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
755
+                $update_course = $this->woocommerce_course_update($lesson_course_id);
756
+                $is_preview = Sensei_Utils::is_preview_lesson($post->ID);
757
+                if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
758 758
                     $user_allowed = true;
759
-                } elseif( $this->access_settings() && false == $is_preview ) {
759
+                } elseif ($this->access_settings() && false == $is_preview) {
760 760
 
761 761
                     $user_allowed = true;
762 762
                 } else {
763
-                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
764
-                    $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
765
-                    $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
766
-                    if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
767
-                        if ( $is_preview ) {
768
-                            $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
763
+                    $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei');
764
+                    $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>';
765
+                    $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true);
766
+                    if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) {
767
+                        if ($is_preview) {
768
+                            $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
769 769
                         } else {
770
-                            $this->permissions_message['message'] =  sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link );
770
+                            $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link);
771 771
                         }
772 772
                     } else {
773
-                        if ( $is_preview ) {
774
-                            $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
773
+                        if ($is_preview) {
774
+                            $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
775 775
                         } else {
776 776
                             /** This filter is documented in class-woothemes-sensei-frontend.php */
777
-                            $this->permissions_message['message'] =  sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
777
+                            $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
778 778
                         }
779 779
                     } // End If Statement
780 780
                 } // End If Statement
781 781
                 break;
782 782
             case 'quiz-single':
783
-                $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true );
784
-                $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true );
783
+                $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true);
784
+                $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
785 785
 
786
-                $update_course = $this->woocommerce_course_update( $lesson_course_id );
787
-                if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) {
786
+                $update_course = $this->woocommerce_course_update($lesson_course_id);
787
+                if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) {
788 788
 
789 789
                     // Check for prerequisite lesson for this quiz
790
-                    $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true);
791
-                    $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID);
790
+                    $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
791
+                    $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID);
792 792
 
793 793
                     // Handle restrictions
794
-                    if( sensei_all_access() ) {
794
+                    if (sensei_all_access()) {
795 795
                         $user_allowed = true;
796 796
                     } else {
797
-                        if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) {
798
-                            $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
799
-                            $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>';
800
-                            $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link );
797
+                        if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) {
798
+                            $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei');
799
+                            $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>';
800
+                            $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link);
801 801
                         } else {
802 802
                             $user_allowed = true;
803 803
                         } // End If Statement
804 804
                     } // End If Statement
805
-                } elseif( $this->access_settings() ) {
805
+                } elseif ($this->access_settings()) {
806 806
                     // Check if the user has started the course
807 807
 
808
-                    if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) {
808
+                    if (is_user_logged_in() && ! Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) && (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission']))) {
809 809
 
810 810
                         $user_allowed = false;
811
-                        $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
812
-                        $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
813
-                        $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
814
-                        if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
815
-                            $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
811
+                        $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei');
812
+                        $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>';
813
+                        $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true);
814
+                        if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) {
815
+                            $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link);
816 816
                         } else {
817
-                            $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
817
+                            $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link);
818 818
                         } // End If Statement
819 819
                     } else {
820 820
                         $user_allowed = true;
821 821
                     } // End If Statement
822 822
                 } else {
823
-                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
824
-                    $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
825
-                    $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link );
823
+                    $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei');
824
+                    $course_link = '<a href="'.esc_url(get_permalink(get_post_meta(get_post_meta($post->ID, '_quiz_lesson', true), '_lesson_course', true))).'">'.__('course', 'woothemes-sensei').'</a>';
825
+                    $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link);
826 826
                 } // End If Statement
827 827
                 break;
828 828
             default:
@@ -844,14 +844,14 @@  discard block
 block discarded – undo
844 844
          * }
845 845
          * @param string $post_id
846 846
          */
847
-        $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID );
847
+        $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID);
848 848
 
849 849
 
850
-        if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) {
850
+        if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) {
851 851
             $user_allowed = true;
852 852
         }
853 853
 
854
-        return apply_filters( 'sensei_access_permissions', $user_allowed );
854
+        return apply_filters('sensei_access_permissions', $user_allowed);
855 855
     } // End get_placeholder_image()
856 856
 
857 857
 
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
      * @access public
862 862
      * @return bool
863 863
      */
864
-    public function access_settings () {
864
+    public function access_settings() {
865 865
 
866
-        if( sensei_all_access() ) return true;
866
+        if (sensei_all_access()) return true;
867 867
 
868
-        if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) {
869
-            if ( is_user_logged_in() ) {
868
+        if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) {
869
+            if (is_user_logged_in()) {
870 870
                 return true;
871 871
             } else {
872 872
                 return false;
@@ -883,38 +883,38 @@  discard block
 block discarded – undo
883 883
      * @param   int $order_id WC order ID
884 884
      * @return  void
885 885
      */
886
-    public function sensei_woocommerce_complete_order ( $order_id = 0 ) {
886
+    public function sensei_woocommerce_complete_order($order_id = 0) {
887 887
         $order_user = array();
888 888
         // Check for WooCommerce
889
-        if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) {
889
+        if (Sensei_WC::is_woocommerce_active() && (0 < $order_id)) {
890 890
             // Get order object
891
-            $order = new WC_Order( $order_id );
892
-            $user = get_user_by( 'id', $order->get_user_id() );
891
+            $order = new WC_Order($order_id);
892
+            $user = get_user_by('id', $order->get_user_id());
893 893
             $order_user['ID'] = $user->ID;
894 894
             $order_user['user_login'] = $user->user_login;
895 895
             $order_user['user_email'] = $user->user_email;
896 896
             $order_user['user_url'] = $user->user_url;
897 897
             // Run through each product ordered
898
-            if ( 0 < sizeof( $order->get_items() ) ) {
899
-                foreach( $order->get_items() as $item ) {
898
+            if (0 < sizeof($order->get_items())) {
899
+                foreach ($order->get_items() as $item) {
900 900
                     $product_type = '';
901
-                    if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
901
+                    if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
902 902
                         $item_id = $item['variation_id'];
903 903
                         $product_type = 'variation';
904 904
                     } else {
905 905
                         $item_id = $item['product_id'];
906 906
                     } // End If Statement
907
-                    $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type );
907
+                    $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type);
908 908
                     // Get courses that use the WC product
909
-                    $courses = $this->post_types->course->get_product_courses( $_product->id );
909
+                    $courses = $this->post_types->course->get_product_courses($_product->id);
910 910
                     // Loop and update those courses
911
-                    foreach ( $courses as $course_item ) {
912
-                        $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user );
911
+                    foreach ($courses as $course_item) {
912
+                        $update_course = $this->woocommerce_course_update($course_item->ID, $order_user);
913 913
                     } // End For Loop
914 914
                 } // End For Loop
915 915
             } // End If Statement
916 916
             // Add meta to indicate that payment has been completed successfully
917
-            update_post_meta( $order_id, 'sensei_payment_complete', '1' );
917
+            update_post_meta($order_id, 'sensei_payment_complete', '1');
918 918
         } // End If Statement
919 919
     } // End sensei_woocommerce_complete_order()
920 920
 
@@ -925,36 +925,36 @@  discard block
 block discarded – undo
925 925
      * @param   integer $order_id order ID
926 926
      * @return  void
927 927
      */
928
-    public function sensei_woocommerce_cancel_order ( $order_id ) {
928
+    public function sensei_woocommerce_cancel_order($order_id) {
929 929
 
930 930
         // Get order object
931
-        $order = new WC_Order( $order_id );
931
+        $order = new WC_Order($order_id);
932 932
 
933 933
         // Run through each product ordered
934
-        if ( 0 < sizeof( $order->get_items() ) ) {
934
+        if (0 < sizeof($order->get_items())) {
935 935
 
936 936
             // Get order user
937
-            $user_id = $order->__get( 'user_id' );
937
+            $user_id = $order->__get('user_id');
938 938
 
939
-            foreach( $order->get_items() as $item ) {
939
+            foreach ($order->get_items() as $item) {
940 940
 
941 941
                 $product_type = '';
942
-                if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
942
+                if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
943 943
                     $item_id = $item['variation_id'];
944 944
                     $product_type = 'variation';
945 945
                 } else {
946 946
                     $item_id = $item['product_id'];
947 947
                 } // End If Statement
948
-                $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type );
948
+                $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type);
949 949
 
950 950
                 // Get courses that use the WC product
951 951
                 $courses = array();
952
-                $courses = $this->post_types->course->get_product_courses( $item_id );
952
+                $courses = $this->post_types->course->get_product_courses($item_id);
953 953
 
954 954
                 // Loop and update those courses
955
-                foreach ($courses as $course_item){
955
+                foreach ($courses as $course_item) {
956 956
                     // Check and Remove course from courses user meta
957
-                    $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id );
957
+                    $dataset_changes = Sensei_Utils::sensei_remove_user_from_course($course_item->ID, $user_id);
958 958
                 } // End For Loop
959 959
             } // End For Loop
960 960
         } // End If Statement
@@ -968,9 +968,9 @@  discard block
 block discarded – undo
968 968
      * @param   integer $subscription_key Subscription Unique Key
969 969
      * @return  void
970 970
      */
971
-    public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) {
972
-        $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key );
973
-        self::sensei_woocommerce_cancel_order( $subscription['order_id'] );
971
+    public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) {
972
+        $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key);
973
+        self::sensei_woocommerce_cancel_order($subscription['order_id']);
974 974
     }
975 975
 
976 976
     /**
@@ -981,18 +981,18 @@  discard block
 block discarded – undo
981 981
      * @param   integer $subscription_key Subscription Unique Key
982 982
      * @return  void
983 983
      */
984
-    public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) {
985
-        $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key );
986
-        $order = new WC_Order( $subscription['order_id'] );
987
-        $user = get_user_by( 'id', $order->get_user_id() );
984
+    public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) {
985
+        $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key);
986
+        $order = new WC_Order($subscription['order_id']);
987
+        $user = get_user_by('id', $order->get_user_id());
988 988
         $order_user = array();
989 989
         $order_user['ID'] = $user->ID;
990 990
         $order_user['user_login'] = $user->user_login;
991 991
         $order_user['user_email'] = $user->user_email;
992 992
         $order_user['user_url'] = $user->user_url;
993
-        $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] );
994
-        foreach ( $courses as $course_item ){
995
-            $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user );
993
+        $courses = $this->post_types->course->get_product_courses($subscription['product_id']);
994
+        foreach ($courses as $course_item) {
995
+            $update_course = $this->woocommerce_course_update($course_item->ID, $order_user);
996 996
         } // End For Loop
997 997
     } // End sensei_woocommerce_reactivate_subscription
998 998
 
@@ -1007,30 +1007,30 @@  discard block
 block discarded – undo
1007 1007
      * @param   string  $product_type  '' or 'variation'
1008 1008
      * @return   WC_Product $wc_product_object
1009 1009
      */
1010
-    public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) {
1010
+    public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') {
1011 1011
 
1012 1012
         $wc_product_object = false;
1013
-        if ( 0 < intval( $wc_product_id ) ) {
1013
+        if (0 < intval($wc_product_id)) {
1014 1014
 
1015 1015
             // Get the product
1016
-            if ( function_exists( 'wc_get_product' ) ) {
1016
+            if (function_exists('wc_get_product')) {
1017 1017
 
1018
-                $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3
1018
+                $wc_product_object = wc_get_product($wc_product_id); // Post WC 2.3
1019 1019
 
1020
-            } elseif ( function_exists( 'get_product' ) ) {
1020
+            } elseif (function_exists('get_product')) {
1021 1021
 
1022
-                $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0
1022
+                $wc_product_object = get_product($wc_product_id); // Post WC 2.0
1023 1023
 
1024 1024
             } else {
1025 1025
 
1026 1026
                 // Pre WC 2.0
1027
-                if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) {
1027
+                if ('variation' == $product_type || 'subscription_variation' == $product_type) {
1028 1028
 
1029
-                    $wc_product_object = new WC_Product_Variation( $wc_product_id );
1029
+                    $wc_product_object = new WC_Product_Variation($wc_product_id);
1030 1030
 
1031 1031
                 } else {
1032 1032
 
1033
-                    $wc_product_object = new WC_Product( $wc_product_id );
1033
+                    $wc_product_object = new WC_Product($wc_product_id);
1034 1034
 
1035 1035
                 } // End If Statement
1036 1036
 
@@ -1048,9 +1048,9 @@  discard block
 block discarded – undo
1048 1048
      * @access  public
1049 1049
      * @return  void
1050 1050
      */
1051
-    public function load_class ( $class_name = '' ) {
1052
-        if ( '' != $class_name && '' != $this->token ) {
1053
-            require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' );
1051
+    public function load_class($class_name = '') {
1052
+        if ('' != $class_name && '' != $this->token) {
1053
+            require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php');
1054 1054
         } // End If Statement
1055 1055
     } // End load_class()
1056 1056
 
@@ -1061,17 +1061,17 @@  discard block
 block discarded – undo
1061 1061
      * @param   integer $order_id order ID
1062 1062
      * @return  void
1063 1063
      */
1064
-    public function sensei_activate_subscription(  $order_id = 0 ) {
1065
-        if ( 0 < intval( $order_id ) ) {
1066
-            $order = new WC_Order( $order_id );
1064
+    public function sensei_activate_subscription($order_id = 0) {
1065
+        if (0 < intval($order_id)) {
1066
+            $order = new WC_Order($order_id);
1067 1067
             $user = get_user_by('id', $order->user_id);
1068 1068
             $order_user['ID'] = $user->ID;
1069 1069
             $order_user['user_login'] = $user->user_login;
1070 1070
             $order_user['user_email'] = $user->user_email;
1071 1071
             $order_user['user_url'] = $user->user_url;
1072 1072
             // Run through each product ordered
1073
-            if (sizeof($order->get_items())>0) {
1074
-                foreach($order->get_items() as $item) {
1073
+            if (sizeof($order->get_items()) > 0) {
1074
+                foreach ($order->get_items() as $item) {
1075 1075
                     $product_type = '';
1076 1076
                     if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1077 1077
                         $item_id = $item['variation_id'];
@@ -1079,15 +1079,15 @@  discard block
 block discarded – undo
1079 1079
                     } else {
1080 1080
                         $item_id = $item['product_id'];
1081 1081
                     } // End If Statement
1082
-                    $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type );
1082
+                    $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type);
1083 1083
                     // Get courses that use the WC product
1084 1084
                     $courses = array();
1085
-                    if ( $product_type == 'subscription_variation' ) {
1086
-                        $courses = $this->post_types->course->get_product_courses( $item_id );
1085
+                    if ($product_type == 'subscription_variation') {
1086
+                        $courses = $this->post_types->course->get_product_courses($item_id);
1087 1087
                     } // End If Statement
1088 1088
                     // Loop and update those courses
1089
-                    foreach ($courses as $course_item){
1090
-                        $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user );
1089
+                    foreach ($courses as $course_item) {
1090
+                        $update_course = $this->woocommerce_course_update($course_item->ID, $order_user);
1091 1091
                     } // End For Loop
1092 1092
                 } // End For Loop
1093 1093
             } // End If Statement
@@ -1101,12 +1101,12 @@  discard block
 block discarded – undo
1101 1101
      * @param   WC_Order $order
1102 1102
      * @return  void
1103 1103
      */
1104
-    public function sensei_woocommerce_email_course_details( $order ) {
1104
+    public function sensei_woocommerce_email_course_details($order) {
1105 1105
         global $woocommerce;
1106 1106
 
1107 1107
         // exit early if not wc-completed or wc-processing
1108
-        if( 'wc-completed' != $order->post_status
1109
-            && 'wc-processing' != $order->post_status  ) {
1108
+        if ('wc-completed' != $order->post_status
1109
+            && 'wc-processing' != $order->post_status) {
1110 1110
             return;
1111 1111
         }
1112 1112
 
@@ -1114,14 +1114,14 @@  discard block
 block discarded – undo
1114 1114
         $order_id = $order->id;
1115 1115
 
1116 1116
         //If object have items go through them all to find course
1117
-        if ( 0 < sizeof( $order_items ) ) {
1117
+        if (0 < sizeof($order_items)) {
1118 1118
 
1119
-        echo '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>';
1119
+        echo '<h2>'.__('Course details', 'woothemes-sensei').'</h2>';
1120 1120
 
1121
-        foreach ( $order_items as $item ) {
1121
+        foreach ($order_items as $item) {
1122 1122
 
1123 1123
                 $product_type = '';
1124
-                if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
1124
+                if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
1125 1125
                     // If item has variation_id then its from variation
1126 1126
                     $item_id = $item['variation_id'];
1127 1127
                     $product_type = 'variation';
@@ -1130,9 +1130,9 @@  discard block
 block discarded – undo
1130 1130
                     $item_id = $item['product_id'];
1131 1131
                 } // End If Statement
1132 1132
 
1133
-                $user_id = get_post_meta( $order_id, '_customer_user', true );
1133
+                $user_id = get_post_meta($order_id, '_customer_user', true);
1134 1134
 
1135
-                if( $user_id ) {
1135
+                if ($user_id) {
1136 1136
 
1137 1137
                     // Get all courses for product
1138 1138
                     $args = array(
@@ -1147,16 +1147,16 @@  discard block
 block discarded – undo
1147 1147
                         'orderby' => 'menu_order date',
1148 1148
                         'order' => 'ASC',
1149 1149
                     );
1150
-                    $courses = get_posts( $args );
1150
+                    $courses = get_posts($args);
1151 1151
 
1152
-                    if( $courses && count( $courses ) > 0 ) {
1152
+                    if ($courses && count($courses) > 0) {
1153 1153
 
1154
-                        foreach( $courses as $course ) {
1154
+                        foreach ($courses as $course) {
1155 1155
 
1156 1156
                             $title = $course->post_title;
1157
-                            $permalink = get_permalink( $course->ID );
1157
+                            $permalink = get_permalink($course->ID);
1158 1158
 
1159
-                            echo '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>';
1159
+                            echo '<p><strong>'.sprintf(__('View course: %1$s', 'woothemes-sensei'), '</strong><a href="'.esc_url($permalink).'">'.$title.'</a>').'</p>';
1160 1160
                         }
1161 1161
                     }
1162 1162
                 }
@@ -1172,44 +1172,44 @@  discard block
 block discarded – undo
1172 1172
      * @param  integer $post_id
1173 1173
      * @return array
1174 1174
      */
1175
-    public function sensei_count_comments( $comments, $post_id ) {
1175
+    public function sensei_count_comments($comments, $post_id) {
1176 1176
         global $wpdb;
1177 1177
 
1178 1178
         $post_id = (int) $post_id;
1179 1179
 
1180 1180
         $count = wp_cache_get("comments-{$post_id}", 'counts');
1181 1181
 
1182
-        if ( false !== $count ) {
1182
+        if (false !== $count) {
1183 1183
             return $count;
1184 1184
         }
1185 1185
 
1186
-        $statuses = array( '' ); // Default to the WP normal comments
1187
-        $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A );
1188
-        foreach ( (array) $stati AS $status ) {
1189
-            if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) {
1186
+        $statuses = array(''); // Default to the WP normal comments
1187
+        $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A);
1188
+        foreach ((array) $stati AS $status) {
1189
+            if ('sensei_' != substr($status['comment_type'], 0, 7)) {
1190 1190
                 $statuses[] = $status['comment_type'];
1191 1191
             }
1192 1192
         }
1193
-        $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')";
1193
+        $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')";
1194 1194
 
1195
-        if ( $post_id > 0 )
1196
-            $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id );
1195
+        if ($post_id > 0)
1196
+            $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id);
1197 1197
 
1198
-        $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1198
+        $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1199 1199
 
1200 1200
         $total = 0;
1201 1201
         $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
1202
-        foreach ( (array) $count as $row ) {
1202
+        foreach ((array) $count as $row) {
1203 1203
             // Don't count post-trashed toward totals
1204
-            if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
1204
+            if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'])
1205 1205
                 $total += $row['num_comments'];
1206
-            if ( isset( $approved[$row['comment_approved']] ) )
1206
+            if (isset($approved[$row['comment_approved']]))
1207 1207
                 $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1208 1208
         }
1209 1209
 
1210 1210
         $stats['total_comments'] = $total;
1211
-        foreach ( $approved as $key ) {
1212
-            if ( empty($stats[$key]) )
1211
+        foreach ($approved as $key) {
1212
+            if (empty($stats[$key]))
1213 1213
                 $stats[$key] = 0;
1214 1214
         }
1215 1215
 
@@ -1227,15 +1227,15 @@  discard block
 block discarded – undo
1227 1227
      * @return void
1228 1228
      */
1229 1229
     public function init_image_sizes() {
1230
-        $course_archive_thumbnail 	= $this->get_image_size( 'course_archive_image' );
1231
-        $course_single_thumbnail	= $this->get_image_size( 'course_single_image' );
1232
-        $lesson_archive_thumbnail 	= $this->get_image_size( 'lesson_archive_image' );
1233
-        $lesson_single_thumbnail	= $this->get_image_size( 'lesson_single_image' );
1234
-
1235
-        add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] );
1236
-        add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] );
1237
-        add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] );
1238
-        add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] );
1230
+        $course_archive_thumbnail 	= $this->get_image_size('course_archive_image');
1231
+        $course_single_thumbnail	= $this->get_image_size('course_single_image');
1232
+        $lesson_archive_thumbnail 	= $this->get_image_size('lesson_archive_image');
1233
+        $lesson_single_thumbnail	= $this->get_image_size('lesson_single_image');
1234
+
1235
+        add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']);
1236
+        add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']);
1237
+        add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']);
1238
+        add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']);
1239 1239
     }
1240 1240
 
1241 1241
     /**
@@ -1248,37 +1248,37 @@  discard block
 block discarded – undo
1248 1248
      * @param mixed $image_size
1249 1249
      * @return string
1250 1250
      */
1251
-    public function get_image_size( $image_size ) {
1251
+    public function get_image_size($image_size) {
1252 1252
 
1253 1253
         // Only return sizes we define in settings
1254
-        if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) )
1255
-            return apply_filters( 'sensei_get_image_size_' . $image_size, '' );
1254
+        if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image')))
1255
+            return apply_filters('sensei_get_image_size_'.$image_size, '');
1256 1256
 
1257
-        if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) {
1258
-            $this->settings->settings[ $image_size . '_width' ] = false;
1257
+        if ( ! isset($this->settings->settings[$image_size.'_width'])) {
1258
+            $this->settings->settings[$image_size.'_width'] = false;
1259 1259
         }
1260
-        if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) {
1261
-            $this->settings->settings[ $image_size . '_height' ] = false;
1260
+        if ( ! isset($this->settings->settings[$image_size.'_height'])) {
1261
+            $this->settings->settings[$image_size.'_height'] = false;
1262 1262
         }
1263
-        if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) {
1264
-            $this->settings->settings[ $image_size . '_hard_crop' ] = false;
1263
+        if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) {
1264
+            $this->settings->settings[$image_size.'_hard_crop'] = false;
1265 1265
         }
1266 1266
 
1267
-        $size = array_filter( array(
1268
-            'width' => $this->settings->settings[ $image_size . '_width' ],
1269
-            'height' => $this->settings->settings[ $image_size . '_height' ],
1270
-            'crop' => $this->settings->settings[ $image_size . '_hard_crop' ]
1271
-        ) );
1267
+        $size = array_filter(array(
1268
+            'width' => $this->settings->settings[$image_size.'_width'],
1269
+            'height' => $this->settings->settings[$image_size.'_height'],
1270
+            'crop' => $this->settings->settings[$image_size.'_hard_crop']
1271
+        ));
1272 1272
 
1273
-        $size['width'] 	= isset( $size['width'] ) ? $size['width'] : '100';
1274
-        $size['height'] = isset( $size['height'] ) ? $size['height'] : '100';
1275
-        $size['crop'] 	= isset( $size['crop'] ) ? $size['crop'] : 0;
1273
+        $size['width'] 	= isset($size['width']) ? $size['width'] : '100';
1274
+        $size['height'] = isset($size['height']) ? $size['height'] : '100';
1275
+        $size['crop'] = isset($size['crop']) ? $size['crop'] : 0;
1276 1276
 
1277
-        return apply_filters( 'sensei_get_image_size_' . $image_size, $size );
1277
+        return apply_filters('sensei_get_image_size_'.$image_size, $size);
1278 1278
     }
1279 1279
 
1280
-    public function body_class( $classes ) {
1281
-        if( is_sensei() ) {
1280
+    public function body_class($classes) {
1281
+        if (is_sensei()) {
1282 1282
             $classes[] = 'sensei';
1283 1283
         }
1284 1284
         return $classes;
@@ -1291,9 +1291,9 @@  discard block
 block discarded – undo
1291 1291
      * @since 1.7.0
1292 1292
      */
1293 1293
     public function jetpack_latex_support() {
1294
-        if ( function_exists( 'latex_markup') ) {
1295
-            add_filter( 'sensei_question_title', 'latex_markup' );
1296
-            add_filter( 'sensei_answer_text', 'latex_markup' );
1294
+        if (function_exists('latex_markup')) {
1295
+            add_filter('sensei_question_title', 'latex_markup');
1296
+            add_filter('sensei_answer_text', 'latex_markup');
1297 1297
         }
1298 1298
     }
1299 1299
 
@@ -1305,21 +1305,21 @@  discard block
 block discarded – undo
1305 1305
      *
1306 1306
      * @since 1.8.0
1307 1307
      */
1308
-    public function load_modules_class(){
1308
+    public function load_modules_class() {
1309 1309
         global $sensei_modules;
1310 1310
 
1311
-        if( !class_exists( 'Sensei_Modules' )
1312
-            &&  'Sensei_Modules' != get_class( $sensei_modules ) ) {
1311
+        if ( ! class_exists('Sensei_Modules')
1312
+            &&  'Sensei_Modules' != get_class($sensei_modules)) {
1313 1313
 
1314 1314
             //Load the modules class
1315
-            require_once( 'class-sensei-modules.php');
1316
-            Sensei()->modules = new Sensei_Core_Modules( $this->file );
1315
+            require_once('class-sensei-modules.php');
1316
+            Sensei()->modules = new Sensei_Core_Modules($this->file);
1317 1317
 
1318
-        }else{
1318
+        } else {
1319 1319
             // fallback for people still using the modules extension.
1320 1320
             global $sensei_modules;
1321 1321
             Sensei()->modules = $sensei_modules;
1322
-            add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 );
1322
+            add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30);
1323 1323
         }
1324 1324
     }
1325 1325
 
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
      *
1329 1329
      * @since 1.8.0
1330 1330
      */
1331
-    public function disable_sensei_modules_extension(){ ?>
1331
+    public function disable_sensei_modules_extension() { ?>
1332 1332
         <div class="notice updated fade">
1333 1333
             <p>
1334 1334
                 <?php
1335 1335
                 $plugin_manage_url = admin_url().'plugins.php#sensei-modules';
1336
-                $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> ';
1336
+                $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> ';
1337 1337
                 ?>
1338 1338
                 <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension.
1339 1339
                 Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules).
@@ -1351,18 +1351,18 @@  discard block
 block discarded – undo
1351 1351
      *
1352 1352
      * @since 1.9.0
1353 1353
      */
1354
-    public function flush_rewrite_rules(){
1354
+    public function flush_rewrite_rules() {
1355 1355
 
1356 1356
         // ensures that the rewrite rules are flushed on the second
1357 1357
         // attempt. This ensure that the settings for any other process
1358 1358
         // have been completed and saved to the database before we refresh the
1359 1359
         // rewrite rules.
1360
-        $option =  get_option('sensei_flush_rewrite_rules');
1361
-        if( '1' == $option ) {
1360
+        $option = get_option('sensei_flush_rewrite_rules');
1361
+        if ('1' == $option) {
1362 1362
 
1363 1363
             update_option('sensei_flush_rewrite_rules', '2');
1364 1364
 
1365
-        }elseif( '2' == $option ) {
1365
+        }elseif ('2' == $option) {
1366 1366
 
1367 1367
             flush_rewrite_rules();
1368 1368
             update_option('sensei_flush_rewrite_rules', '0');
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
      *
1378 1378
      * @since 1.9.0
1379 1379
      */
1380
-    public function initiate_rewrite_rules_flush(){
1380
+    public function initiate_rewrite_rules_flush() {
1381 1381
 
1382 1382
         update_option('sensei_flush_rewrite_rules', '1');
1383 1383
 
@@ -1390,4 +1390,4 @@  discard block
 block discarded – undo
1390 1390
  * for backward compatibility
1391 1391
  * @since 1.9.0
1392 1392
  */
1393
-class Woothemes_Sensei extends Sensei_Main{ }
1393
+class Woothemes_Sensei extends Sensei_Main { }
Please login to merge, or discard this patch.
includes/theme-integrations/theme-integration-loader.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @since 1.9.0
37 37
      */
38
-    private function setup_themes(){
38
+    private function setup_themes() {
39 39
 
40 40
         $this->themes = array(
41 41
             'twentyeleven',
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @since 1.9.0
56 56
      */
57
-    private function setup_currently_active_theme(){
57
+    private function setup_currently_active_theme() {
58 58
 
59 59
         $this->active_theme = get_option('template');
60 60
 
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @since 1.9.0
69 69
      */
70
-    private function possibly_load_supported_theme_wrappers(){
70
+    private function possibly_load_supported_theme_wrappers() {
71 71
 
72
-        if ( in_array( $this->active_theme, $this->themes ) ){
72
+        if (in_array($this->active_theme, $this->themes)) {
73 73
 
74 74
             // setup file and class names
75
-            $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php';
76
-            $supported_theme_class_name  = 'Sensei_'. ucfirst( $this->active_theme  );
75
+            $supported_theme_class_file = trailingslashit(Sensei()->plugin_path).'includes/theme-integrations/'.$this->active_theme.'.php';
76
+            $supported_theme_class_name = 'Sensei_'.ucfirst($this->active_theme);
77 77
 
78 78
             // load the file or exit if there is no file for this theme
79
-            if( ! file_exists( $supported_theme_class_file ) ){
79
+            if ( ! file_exists($supported_theme_class_file)) {
80 80
                 return;
81 81
             }
82
-            include_once( $supported_theme_class_file );
83
-            include_once( 'twentytwelve.php' );
82
+            include_once($supported_theme_class_file);
83
+            include_once('twentytwelve.php');
84 84
             //initialize the class or exit if there is no class for this theme
85
-            if( ! class_exists( $supported_theme_class_name ) ){
85
+            if ( ! class_exists($supported_theme_class_name)) {
86 86
                 return;
87 87
             }
88 88
             $supported_theme = new $supported_theme_class_name;
89 89
 
90 90
             // remove default wrappers
91
-            remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
92
-            remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
91
+            remove_action('sensei_before_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper'), 10);
92
+            remove_action('sensei_after_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper_end'), 10);
93 93
 
94 94
             // load the supported theme wrappers
95
-            add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 );
96
-            add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 );
95
+            add_action('sensei_before_main_content', array($supported_theme, 'wrapper_start'), 10);
96
+            add_action('sensei_after_main_content', array($supported_theme, 'wrapper_end'), 10);
97 97
         }
98 98
     }
99 99
 
Please login to merge, or discard this patch.
includes/theme-integrations/twentytwelve.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
     ?>
18 18
 
19 19
         <div id="primary" class="site-content">
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @since 1.9.0
28 28
      */
29
-    public function wrapper_end(){ ?>
29
+    public function wrapper_end() { ?>
30 30
 
31 31
 			</div>
32 32
 		</div>
Please login to merge, or discard this patch.
includes/theme-integrations/twentyfourteen.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
     ?>
18 18
 
19 19
         <div id="main-content" class="main-content">
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @since 1.9.0
30 30
      */
31
-    public function wrapper_end(){ ?>
31
+    public function wrapper_end() { ?>
32 32
 
33 33
 
34 34
                     </div>
Please login to merge, or discard this patch.
includes/theme-integrations/twentyfifteen.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
 
18 18
         // output inline styles
19 19
         $this->print_styles();
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @since 1.9.0
32 32
      */
33
-    private function print_styles(){?>
33
+    private function print_styles() {?>
34 34
 
35 35
         <style>
36 36
             @media screen and (min-width: 59.6875em){
Please login to merge, or discard this patch.
includes/theme-integrations/_s.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){ ?>
16
+    public function wrapper_start() { ?>
17 17
         <div id="primary" class="content-area">
18 18
             <main id="main" class="site-main" role="main">
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      *
25 25
      * @since 1.9.0
26 26
      */
27
-    public function wrapper_end(){ ?>
27
+    public function wrapper_end() { ?>
28 28
 
29 29
             </main> <!-- main-site -->
30 30
           </div> <!-- content-area -->
Please login to merge, or discard this patch.
includes/theme-integrations/twentyeleven.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
     ?>
18 18
 
19 19
         <div id="primary">
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @since 1.9.0
28 28
      */
29
-    public function wrapper_end(){ ?>
29
+    public function wrapper_end() { ?>
30 30
 
31 31
             </div>
32 32
         </div>
Please login to merge, or discard this patch.
includes/theme-integrations/twentythirteen.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
     ?>
18 18
 
19 19
         <div id="primary" class="site-content">
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @since 1.9.0
28 28
      */
29
-    public function wrapper_end(){ ?>
29
+    public function wrapper_end() { ?>
30 30
 
31 31
 			</div>
32 32
 		</div>
Please login to merge, or discard this patch.
includes/theme-integrations/twentysixteen.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
  *
8 8
  * @since 1.9.0
9 9
 */
10
-Class Sensei_Twentysixteen extends Sensei__S{ }
10
+Class Sensei_Twentysixteen extends Sensei__S { }
Please login to merge, or discard this patch.