@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Responsible for loading Sensei and setting up the Main WordPress hooks. |
@@ -147,22 +147,22 @@ discard block |
||
| 147 | 147 | * @param string $file The base file of the plugin. |
| 148 | 148 | * @since 1.0.0 |
| 149 | 149 | */ |
| 150 | - public function __construct ( $file ) { |
|
| 150 | + public function __construct($file) { |
|
| 151 | 151 | |
| 152 | 152 | // Setup object data |
| 153 | 153 | $this->file = $file; |
| 154 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
| 155 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
| 156 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
| 154 | + $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file)); |
|
| 155 | + $this->plugin_path = trailingslashit(dirname($file)); |
|
| 156 | + $this->template_url = apply_filters('sensei_template_url', '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(); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | * Load the foundations of Sensei. |
| 177 | 177 | * @since 1.9.0 |
| 178 | 178 | */ |
| 179 | - protected function init(){ |
|
| 179 | + protected function init() { |
|
| 180 | 180 | |
| 181 | 181 | // Localisation |
| 182 | 182 | $this->load_plugin_textdomain(); |
| 183 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
| 183 | + add_action('init', array($this, 'load_localisation'), 0); |
|
| 184 | 184 | |
| 185 | 185 | // Setup settings |
| 186 | 186 | $this->settings = new Sensei_Settings(); |
@@ -203,12 +203,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 242 | 242 | * @since 1.8.0 |
| 243 | 243 | */ |
| 244 | 244 | public function __clone() { |
| 245 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
| 245 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @since 1.8.0 |
| 251 | 251 | */ |
| 252 | 252 | public function __wakeup() { |
| 253 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
| 253 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -258,13 +258,13 @@ discard block |
||
| 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 | // Load Course Results Class |
| 270 | 270 | $this->course_results = new Sensei_Course_Results(); |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | $this->load_modules_class(); |
| 289 | 289 | |
| 290 | 290 | // Load Learner Management Functionality |
| 291 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
| 291 | + $this->learners = new Sensei_Learner_Management($this->file); |
|
| 292 | 292 | |
| 293 | 293 | // Differentiate between administration and frontend logic. |
| 294 | - if ( is_admin() ) { |
|
| 294 | + if (is_admin()) { |
|
| 295 | 295 | |
| 296 | 296 | // Load Admin Welcome class |
| 297 | 297 | new Sensei_Welcome(); |
| 298 | 298 | |
| 299 | 299 | // Load Admin Class |
| 300 | - $this->admin = new Sensei_Admin( $this->file ); |
|
| 300 | + $this->admin = new Sensei_Admin($this->file); |
|
| 301 | 301 | |
| 302 | 302 | // Load Analysis Reports |
| 303 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
| 303 | + $this->analysis = new Sensei_Analysis($this->file); |
|
| 304 | 304 | |
| 305 | 305 | } else { |
| 306 | 306 | |
@@ -317,10 +317,10 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | // Load Grading Functionality |
| 320 | - $this->grading = new Sensei_Grading( $this->file ); |
|
| 320 | + $this->grading = new Sensei_Grading($this->file); |
|
| 321 | 321 | |
| 322 | 322 | // Load Email Class |
| 323 | - $this->emails = new Sensei_Emails( $this->file ); |
|
| 323 | + $this->emails = new Sensei_Emails($this->file); |
|
| 324 | 324 | |
| 325 | 325 | // Load Learner Profiles Class |
| 326 | 326 | $this->learner_profiles = new Sensei_Learner_Profiles(); |
@@ -332,24 +332,24 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @since 1.9.0 |
| 334 | 334 | */ |
| 335 | - public function load_hooks(){ |
|
| 335 | + public function load_hooks() { |
|
| 336 | 336 | |
| 337 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
| 338 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
| 337 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
| 338 | + add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support')); |
|
| 339 | 339 | |
| 340 | 340 | // Filter comment counts |
| 341 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
| 341 | + add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2); |
|
| 342 | 342 | |
| 343 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
| 343 | + add_action('body_class', array($this, 'body_class')); |
|
| 344 | 344 | |
| 345 | 345 | // Check for and activate JetPack LaTeX support |
| 346 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
| 346 | + add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules |
|
| 347 | 347 | |
| 348 | 348 | // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
| 349 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
| 349 | + add_action('init', array($this, 'flush_rewrite_rules'), 101); |
|
| 350 | 350 | |
| 351 | 351 | // Add plugin action links filter |
| 352 | - add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), array( $this, 'plugin_action_links' ) ); |
|
| 352 | + add_filter('plugin_action_links_'.plugin_basename($this->file), array($this, 'plugin_action_links')); |
|
| 353 | 353 | |
| 354 | 354 | } |
| 355 | 355 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | public function run_updates() { |
| 363 | 363 | // Run updates if administrator |
| 364 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
| 364 | + if (current_user_can('manage_options') || current_user_can('manage_sensei')) { |
|
| 365 | 365 | |
| 366 | 366 | $this->updates->update(); |
| 367 | 367 | |
@@ -374,21 +374,21 @@ discard block |
||
| 374 | 374 | * @since 1.0.0 |
| 375 | 375 | * @return void |
| 376 | 376 | */ |
| 377 | - public function register_widgets () { |
|
| 377 | + public function register_widgets() { |
|
| 378 | 378 | // Widget List (key => value is filename => widget class). |
| 379 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
| 379 | + $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' => 'Course_Component', |
|
| 380 | 380 | 'lesson-component' => 'Lesson_Component', |
| 381 | 381 | 'course-categories' => 'Course_Categories', |
| 382 | - 'category-courses' => 'Category_Courses' ) |
|
| 382 | + 'category-courses' => 'Category_Courses') |
|
| 383 | 383 | ); |
| 384 | - foreach ( $widget_list as $key => $value ) { |
|
| 385 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
| 386 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
| 387 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
| 384 | + foreach ($widget_list as $key => $value) { |
|
| 385 | + if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php')) { |
|
| 386 | + require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php'); |
|
| 387 | + register_widget('WooThemes_Sensei_'.$value.'_Widget'); |
|
| 388 | 388 | } |
| 389 | 389 | } // End For Loop |
| 390 | 390 | |
| 391 | - do_action( 'sensei_register_widgets' ); |
|
| 391 | + do_action('sensei_register_widgets'); |
|
| 392 | 392 | |
| 393 | 393 | } // End register_widgets() |
| 394 | 394 | |
@@ -398,9 +398,9 @@ discard block |
||
| 398 | 398 | * @since 1.0.0 |
| 399 | 399 | * @return void |
| 400 | 400 | */ |
| 401 | - public function load_localisation () { |
|
| 401 | + public function load_localisation() { |
|
| 402 | 402 | |
| 403 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
| 403 | + load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/'); |
|
| 404 | 404 | |
| 405 | 405 | } // End load_localisation() |
| 406 | 406 | |
@@ -410,13 +410,13 @@ discard block |
||
| 410 | 410 | * @since 1.0.0 |
| 411 | 411 | * @return void |
| 412 | 412 | */ |
| 413 | - public function load_plugin_textdomain () { |
|
| 413 | + public function load_plugin_textdomain() { |
|
| 414 | 414 | |
| 415 | 415 | $domain = 'woothemes-sensei'; |
| 416 | 416 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
| 417 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
| 418 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
| 419 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
| 417 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
| 418 | + load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'); |
|
| 419 | + load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/'); |
|
| 420 | 420 | |
| 421 | 421 | } // End load_plugin_textdomain() |
| 422 | 422 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @since 1.0.0 |
| 427 | 427 | * @return void |
| 428 | 428 | */ |
| 429 | - public function activation () { |
|
| 429 | + public function activation() { |
|
| 430 | 430 | |
| 431 | 431 | $this->register_plugin_version(); |
| 432 | 432 | |
@@ -439,10 +439,10 @@ discard block |
||
| 439 | 439 | * @since 1.0.0 |
| 440 | 440 | * @return void |
| 441 | 441 | */ |
| 442 | - public function install () { |
|
| 442 | + public function install() { |
|
| 443 | 443 | |
| 444 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
| 445 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
| 444 | + register_activation_hook($this->file, array($this, 'activate_sensei')); |
|
| 445 | + register_activation_hook($this->file, 'flush_rewrite_rules'); |
|
| 446 | 446 | |
| 447 | 447 | } // End install() |
| 448 | 448 | |
@@ -453,10 +453,10 @@ discard block |
||
| 453 | 453 | * @since 1.0.0 |
| 454 | 454 | * @return void |
| 455 | 455 | */ |
| 456 | - public function activate_sensei () { |
|
| 456 | + public function activate_sensei() { |
|
| 457 | 457 | |
| 458 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
| 459 | - update_option( 'sensei_installed', 1 ); |
|
| 458 | + update_option('skip_install_sensei_pages', 0); |
|
| 459 | + update_option('sensei_installed', 1); |
|
| 460 | 460 | |
| 461 | 461 | } // End activate_sensei() |
| 462 | 462 | |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | * @since 1.0.0 |
| 467 | 467 | * @return void |
| 468 | 468 | */ |
| 469 | - private function register_plugin_version () { |
|
| 470 | - if ( $this->version != '' ) { |
|
| 469 | + private function register_plugin_version() { |
|
| 470 | + if ($this->version != '') { |
|
| 471 | 471 | |
| 472 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
| 472 | + update_option('woothemes-sensei-version', $this->version); |
|
| 473 | 473 | |
| 474 | 474 | } |
| 475 | 475 | } // End register_plugin_version() |
@@ -480,9 +480,9 @@ discard block |
||
| 480 | 480 | * @since 1.0.1 |
| 481 | 481 | * @return void |
| 482 | 482 | */ |
| 483 | - public function ensure_post_thumbnails_support () { |
|
| 483 | + public function ensure_post_thumbnails_support() { |
|
| 484 | 484 | |
| 485 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
| 485 | + if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); } |
|
| 486 | 486 | |
| 487 | 487 | } // End ensure_post_thumbnails_support() |
| 488 | 488 | |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | * @return void |
| 495 | 495 | * @deprecated |
| 496 | 496 | */ |
| 497 | - public function template_loader ( $template = '' ) { |
|
| 497 | + public function template_loader($template = '') { |
|
| 498 | 498 | |
| 499 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
| 500 | - Sensei_Templates::template_loader( $template ); |
|
| 499 | + _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead'); |
|
| 500 | + Sensei_Templates::template_loader($template); |
|
| 501 | 501 | |
| 502 | 502 | } // End template_loader() |
| 503 | 503 | |
@@ -507,15 +507,15 @@ discard block |
||
| 507 | 507 | * @since 1.0.0 |
| 508 | 508 | * @return string $sensei_plugin_path |
| 509 | 509 | */ |
| 510 | - public function plugin_path () { |
|
| 510 | + public function plugin_path() { |
|
| 511 | 511 | |
| 512 | - if ( $this->plugin_path ) { |
|
| 512 | + if ($this->plugin_path) { |
|
| 513 | 513 | |
| 514 | - $sensei_plugin_path = $this->plugin_path; |
|
| 514 | + $sensei_plugin_path = $this->plugin_path; |
|
| 515 | 515 | |
| 516 | - }else{ |
|
| 516 | + } else { |
|
| 517 | 517 | |
| 518 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
| 518 | + $sensei_plugin_path = plugin_dir_path(__FILE__); |
|
| 519 | 519 | |
| 520 | 520 | } |
| 521 | 521 | |
@@ -530,9 +530,9 @@ discard block |
||
| 530 | 530 | * @param string $page |
| 531 | 531 | * @return int |
| 532 | 532 | */ |
| 533 | - public function get_page_id ( $page ) { |
|
| 534 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
| 535 | - return ( $page ) ? $page : -1; |
|
| 533 | + public function get_page_id($page) { |
|
| 534 | + $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id')); |
|
| 535 | + return ($page) ? $page : -1; |
|
| 536 | 536 | } // End get_page_id() |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -543,48 +543,48 @@ discard block |
||
| 543 | 543 | * |
| 544 | 544 | * @return bool |
| 545 | 545 | */ |
| 546 | - public function check_user_permissions ( $page = '' ) { |
|
| 546 | + public function check_user_permissions($page = '') { |
|
| 547 | 547 | |
| 548 | 548 | global $current_user, $post; |
| 549 | 549 | |
| 550 | 550 | $user_allowed = false; |
| 551 | 551 | |
| 552 | - switch ( $page ) { |
|
| 552 | + switch ($page) { |
|
| 553 | 553 | case 'course-single': |
| 554 | 554 | // check for prerequisite course or lesson, |
| 555 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
| 556 | - $update_course = Sensei_WC::course_update( $post->ID ); |
|
| 555 | + $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true); |
|
| 556 | + $update_course = Sensei_WC::course_update($post->ID); |
|
| 557 | 557 | |
| 558 | 558 | // Count completed lessons |
| 559 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
| 559 | + if (0 < absint($course_prerequisite_id)) { |
|
| 560 | 560 | |
| 561 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
| 561 | + $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID); |
|
| 562 | 562 | |
| 563 | 563 | } else { |
| 564 | 564 | $prerequisite_complete = true; |
| 565 | 565 | } // End If Statement |
| 566 | 566 | |
| 567 | 567 | // Handles restrictions on the course |
| 568 | - if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) { |
|
| 568 | + if (( ! $prerequisite_complete && 0 < absint($course_prerequisite_id))) { |
|
| 569 | 569 | |
| 570 | 570 | $user_allowed = false; |
| 571 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
| 572 | - $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' ); |
|
| 571 | + $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
| 572 | + $this->notices->add_notice(sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link), 'info'); |
|
| 573 | 573 | |
| 574 | - } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
| 574 | + } elseif (Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable($post->ID) && ! Sensei_Utils::user_started_course($post->ID, $current_user->ID)) { |
|
| 575 | 575 | |
| 576 | - $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' ); |
|
| 577 | - $this->notices->add_notice( $message, 'info' ); |
|
| 576 | + $message = sprintf(__('Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei'), '<a href="'.sensei_user_login_url().'">', '</a>'); |
|
| 577 | + $this->notices->add_notice($message, 'info'); |
|
| 578 | 578 | |
| 579 | 579 | |
| 580 | - } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
| 580 | + } elseif ( ! Sensei_Utils::user_started_course($post->ID, $current_user->ID)) { |
|
| 581 | 581 | |
| 582 | 582 | // users who haven't started the course are allowed to view it |
| 583 | - $user_allowed = true; |
|
| 583 | + $user_allowed = true; |
|
| 584 | 584 | |
| 585 | 585 | |
| 586 | 586 | |
| 587 | - } else { |
|
| 587 | + } else { |
|
| 588 | 588 | |
| 589 | 589 | $user_allowed = true; |
| 590 | 590 | |
@@ -592,60 +592,60 @@ discard block |
||
| 592 | 592 | break; |
| 593 | 593 | case 'lesson-single': |
| 594 | 594 | // Check for WC purchase |
| 595 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
| 595 | + $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
| 596 | 596 | |
| 597 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
| 598 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
| 597 | + $update_course = Sensei_WC::course_update($lesson_course_id); |
|
| 598 | + $is_preview = Sensei_Utils::is_preview_lesson($post->ID); |
|
| 599 | 599 | |
| 600 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
| 600 | + if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
| 601 | 601 | $user_allowed = true; |
| 602 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
| 602 | + } elseif ($this->access_settings() && false == $is_preview) { |
|
| 603 | 603 | |
| 604 | 604 | $user_allowed = true; |
| 605 | 605 | |
| 606 | 606 | } else { |
| 607 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 608 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
| 609 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
| 610 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 611 | - if ( $is_preview ) { |
|
| 612 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
| 607 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 608 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
| 609 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
| 610 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
| 611 | + if ($is_preview) { |
|
| 612 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
| 613 | 613 | } else { |
| 614 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 614 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link); |
|
| 615 | 615 | } |
| 616 | 616 | } else { |
| 617 | - if ( $is_preview ) { |
|
| 618 | - $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 ); |
|
| 617 | + if ($is_preview) { |
|
| 618 | + $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); |
|
| 619 | 619 | } else { |
| 620 | 620 | /** This filter is documented in class-woothemes-sensei-frontend.php */ |
| 621 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 621 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
| 622 | 622 | } |
| 623 | 623 | } // End If Statement |
| 624 | 624 | } // End If Statement |
| 625 | 625 | break; |
| 626 | 626 | case 'quiz-single': |
| 627 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
| 628 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
| 627 | + $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true); |
|
| 628 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 629 | 629 | |
| 630 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
| 631 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
| 630 | + $update_course = Sensei_WC::course_update($lesson_course_id); |
|
| 631 | + if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) { |
|
| 632 | 632 | |
| 633 | 633 | // Check for prerequisite lesson for this quiz |
| 634 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
| 635 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
| 634 | + $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
| 635 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID); |
|
| 636 | 636 | |
| 637 | 637 | // Handle restrictions |
| 638 | - if( sensei_all_access() ) { |
|
| 638 | + if (sensei_all_access()) { |
|
| 639 | 639 | |
| 640 | 640 | $user_allowed = true; |
| 641 | 641 | |
| 642 | 642 | } else { |
| 643 | 643 | |
| 644 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
| 644 | + if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) { |
|
| 645 | 645 | |
| 646 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 647 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
| 648 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
| 646 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 647 | + $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>'; |
|
| 648 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link); |
|
| 649 | 649 | |
| 650 | 650 | } else { |
| 651 | 651 | |
@@ -653,27 +653,27 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | } // End If Statement |
| 655 | 655 | } // End If Statement |
| 656 | - } elseif( $this->access_settings() ) { |
|
| 656 | + } elseif ($this->access_settings()) { |
|
| 657 | 657 | // Check if the user has started the course |
| 658 | 658 | |
| 659 | - 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'] ) ) ) { |
|
| 659 | + 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']))) { |
|
| 660 | 660 | |
| 661 | 661 | $user_allowed = false; |
| 662 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 663 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
| 664 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
| 665 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 666 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
| 662 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 663 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
| 664 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
| 665 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
| 666 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
| 667 | 667 | } else { |
| 668 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
| 668 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
| 669 | 669 | } // End If Statement |
| 670 | 670 | } else { |
| 671 | 671 | $user_allowed = true; |
| 672 | 672 | } // End If Statement |
| 673 | 673 | } else { |
| 674 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 675 | - $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>'; |
|
| 676 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
| 674 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 675 | + $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>'; |
|
| 676 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link); |
|
| 677 | 677 | } // End If Statement |
| 678 | 678 | break; |
| 679 | 679 | default: |
@@ -695,11 +695,11 @@ discard block |
||
| 695 | 695 | * } |
| 696 | 696 | * @param string $post_id |
| 697 | 697 | */ |
| 698 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
| 698 | + $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID); |
|
| 699 | 699 | |
| 700 | 700 | // add the permissions message to the stack |
| 701 | 701 | |
| 702 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
| 702 | + if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) { |
|
| 703 | 703 | $user_allowed = true; |
| 704 | 704 | } |
| 705 | 705 | |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | * @param integer $user_id |
| 714 | 714 | * |
| 715 | 715 | */ |
| 716 | - return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID ); |
|
| 716 | + return apply_filters('sensei_access_permissions', $user_allowed, $current_user->ID); |
|
| 717 | 717 | |
| 718 | 718 | } // End get_placeholder_image() |
| 719 | 719 | |
@@ -724,12 +724,12 @@ discard block |
||
| 724 | 724 | * @access public |
| 725 | 725 | * @return bool |
| 726 | 726 | */ |
| 727 | - public function access_settings () { |
|
| 727 | + public function access_settings() { |
|
| 728 | 728 | |
| 729 | - if( sensei_all_access() ) return true; |
|
| 729 | + if (sensei_all_access()) return true; |
|
| 730 | 730 | |
| 731 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
| 732 | - if ( is_user_logged_in() ) { |
|
| 731 | + if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) { |
|
| 732 | + if (is_user_logged_in()) { |
|
| 733 | 733 | return true; |
| 734 | 734 | } else { |
| 735 | 735 | return false; |
@@ -745,9 +745,9 @@ discard block |
||
| 745 | 745 | * @access public |
| 746 | 746 | * @return void |
| 747 | 747 | */ |
| 748 | - public function load_class ( $class_name = '' ) { |
|
| 749 | - if ( '' != $class_name && '' != $this->token ) { |
|
| 750 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
| 748 | + public function load_class($class_name = '') { |
|
| 749 | + if ('' != $class_name && '' != $this->token) { |
|
| 750 | + require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php'); |
|
| 751 | 751 | } // End If Statement |
| 752 | 752 | } // End load_class() |
| 753 | 753 | |
@@ -759,44 +759,44 @@ discard block |
||
| 759 | 759 | * @param integer $post_id |
| 760 | 760 | * @return array |
| 761 | 761 | */ |
| 762 | - public function sensei_count_comments( $comments, $post_id ) { |
|
| 762 | + public function sensei_count_comments($comments, $post_id) { |
|
| 763 | 763 | global $wpdb; |
| 764 | 764 | |
| 765 | 765 | $post_id = (int) $post_id; |
| 766 | 766 | |
| 767 | 767 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
| 768 | 768 | |
| 769 | - if ( false !== $count ) { |
|
| 769 | + if (false !== $count) { |
|
| 770 | 770 | return $count; |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | - $statuses = array( '' ); // Default to the WP normal comments |
|
| 774 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
| 775 | - foreach ( (array) $stati AS $status ) { |
|
| 776 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
| 773 | + $statuses = array(''); // Default to the WP normal comments |
|
| 774 | + $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A); |
|
| 775 | + foreach ((array) $stati AS $status) { |
|
| 776 | + if ('sensei_' != substr($status['comment_type'], 0, 7)) { |
|
| 777 | 777 | $statuses[] = $status['comment_type']; |
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
| 780 | + $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')"; |
|
| 781 | 781 | |
| 782 | - if ( $post_id > 0 ) |
|
| 783 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
| 782 | + if ($post_id > 0) |
|
| 783 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
| 784 | 784 | |
| 785 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 785 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 786 | 786 | |
| 787 | 787 | $total = 0; |
| 788 | 788 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
| 789 | - foreach ( (array) $count as $row ) { |
|
| 789 | + foreach ((array) $count as $row) { |
|
| 790 | 790 | // Don't count post-trashed toward totals |
| 791 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
| 791 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
| 792 | 792 | $total += $row['num_comments']; |
| 793 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
| 793 | + if (isset($approved[$row['comment_approved']])) |
|
| 794 | 794 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | $stats['total_comments'] = $total; |
| 798 | - foreach ( $approved as $key ) { |
|
| 799 | - if ( empty($stats[$key]) ) |
|
| 798 | + foreach ($approved as $key) { |
|
| 799 | + if (empty($stats[$key])) |
|
| 800 | 800 | $stats[$key] = 0; |
| 801 | 801 | } |
| 802 | 802 | |
@@ -814,15 +814,15 @@ discard block |
||
| 814 | 814 | * @return void |
| 815 | 815 | */ |
| 816 | 816 | public function init_image_sizes() { |
| 817 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
| 818 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
| 819 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
| 820 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
| 821 | - |
|
| 822 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
| 823 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
| 824 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
| 825 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
| 817 | + $course_archive_thumbnail = $this->get_image_size('course_archive_image'); |
|
| 818 | + $course_single_thumbnail = $this->get_image_size('course_single_image'); |
|
| 819 | + $lesson_archive_thumbnail = $this->get_image_size('lesson_archive_image'); |
|
| 820 | + $lesson_single_thumbnail = $this->get_image_size('lesson_single_image'); |
|
| 821 | + |
|
| 822 | + add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']); |
|
| 823 | + add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']); |
|
| 824 | + add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']); |
|
| 825 | + add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
@@ -835,37 +835,37 @@ discard block |
||
| 835 | 835 | * @param mixed $image_size |
| 836 | 836 | * @return string |
| 837 | 837 | */ |
| 838 | - public function get_image_size( $image_size ) { |
|
| 838 | + public function get_image_size($image_size) { |
|
| 839 | 839 | |
| 840 | 840 | // Only return sizes we define in settings |
| 841 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
| 842 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
| 841 | + if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image'))) |
|
| 842 | + return apply_filters('sensei_get_image_size_'.$image_size, ''); |
|
| 843 | 843 | |
| 844 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
| 845 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
| 844 | + if ( ! isset($this->settings->settings[$image_size.'_width'])) { |
|
| 845 | + $this->settings->settings[$image_size.'_width'] = false; |
|
| 846 | 846 | } |
| 847 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
| 848 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
| 847 | + if ( ! isset($this->settings->settings[$image_size.'_height'])) { |
|
| 848 | + $this->settings->settings[$image_size.'_height'] = false; |
|
| 849 | 849 | } |
| 850 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
| 851 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
| 850 | + if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) { |
|
| 851 | + $this->settings->settings[$image_size.'_hard_crop'] = false; |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - $size = array_filter( array( |
|
| 855 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
| 856 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
| 857 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
| 858 | - ) ); |
|
| 854 | + $size = array_filter(array( |
|
| 855 | + 'width' => $this->settings->settings[$image_size.'_width'], |
|
| 856 | + 'height' => $this->settings->settings[$image_size.'_height'], |
|
| 857 | + 'crop' => $this->settings->settings[$image_size.'_hard_crop'] |
|
| 858 | + )); |
|
| 859 | 859 | |
| 860 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
| 861 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
| 862 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
| 860 | + $size['width'] = isset($size['width']) ? $size['width'] : '100'; |
|
| 861 | + $size['height'] = isset($size['height']) ? $size['height'] : '100'; |
|
| 862 | + $size['crop'] = isset($size['crop']) ? $size['crop'] : 0; |
|
| 863 | 863 | |
| 864 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
| 864 | + return apply_filters('sensei_get_image_size_'.$image_size, $size); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - public function body_class( $classes ) { |
|
| 868 | - if( is_sensei() ) { |
|
| 867 | + public function body_class($classes) { |
|
| 868 | + if (is_sensei()) { |
|
| 869 | 869 | $classes[] = 'sensei'; |
| 870 | 870 | } |
| 871 | 871 | return $classes; |
@@ -878,9 +878,9 @@ discard block |
||
| 878 | 878 | * @since 1.7.0 |
| 879 | 879 | */ |
| 880 | 880 | public function jetpack_latex_support() { |
| 881 | - if ( function_exists( 'latex_markup') ) { |
|
| 882 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
| 883 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
| 881 | + if (function_exists('latex_markup')) { |
|
| 882 | + add_filter('sensei_question_title', 'latex_markup'); |
|
| 883 | + add_filter('sensei_answer_text', 'latex_markup'); |
|
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | |
@@ -892,21 +892,21 @@ discard block |
||
| 892 | 892 | * |
| 893 | 893 | * @since 1.8.0 |
| 894 | 894 | */ |
| 895 | - public function load_modules_class(){ |
|
| 895 | + public function load_modules_class() { |
|
| 896 | 896 | global $sensei_modules; |
| 897 | 897 | |
| 898 | - if( !class_exists( 'Sensei_Modules' ) |
|
| 899 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
| 898 | + if ( ! class_exists('Sensei_Modules') |
|
| 899 | + && 'Sensei_Modules' != get_class($sensei_modules)) { |
|
| 900 | 900 | |
| 901 | 901 | //Load the modules class |
| 902 | - require_once( 'class-sensei-modules.php'); |
|
| 903 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
| 902 | + require_once('class-sensei-modules.php'); |
|
| 903 | + Sensei()->modules = new Sensei_Core_Modules($this->file); |
|
| 904 | 904 | |
| 905 | - }else{ |
|
| 905 | + } else { |
|
| 906 | 906 | // fallback for people still using the modules extension. |
| 907 | 907 | global $sensei_modules; |
| 908 | 908 | Sensei()->modules = $sensei_modules; |
| 909 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
| 909 | + add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30); |
|
| 910 | 910 | } |
| 911 | 911 | } |
| 912 | 912 | |
@@ -915,12 +915,12 @@ discard block |
||
| 915 | 915 | * |
| 916 | 916 | * @since 1.8.0 |
| 917 | 917 | */ |
| 918 | - public function disable_sensei_modules_extension(){ ?> |
|
| 918 | + public function disable_sensei_modules_extension() { ?> |
|
| 919 | 919 | <div class="notice updated fade"> |
| 920 | 920 | <p> |
| 921 | 921 | <?php |
| 922 | 922 | $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
| 923 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
| 923 | + $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> '; |
|
| 924 | 924 | ?> |
| 925 | 925 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
| 926 | 926 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
@@ -938,18 +938,18 @@ discard block |
||
| 938 | 938 | * |
| 939 | 939 | * @since 1.9.0 |
| 940 | 940 | */ |
| 941 | - public function flush_rewrite_rules(){ |
|
| 941 | + public function flush_rewrite_rules() { |
|
| 942 | 942 | |
| 943 | 943 | // ensures that the rewrite rules are flushed on the second |
| 944 | 944 | // attempt. This ensure that the settings for any other process |
| 945 | 945 | // have been completed and saved to the database before we refresh the |
| 946 | 946 | // rewrite rules. |
| 947 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
| 948 | - if( '1' == $option ) { |
|
| 947 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
| 948 | + if ('1' == $option) { |
|
| 949 | 949 | |
| 950 | 950 | update_option('sensei_flush_rewrite_rules', '2'); |
| 951 | 951 | |
| 952 | - }elseif( '2' == $option ) { |
|
| 952 | + }elseif ('2' == $option) { |
|
| 953 | 953 | |
| 954 | 954 | flush_rewrite_rules(); |
| 955 | 955 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * |
| 965 | 965 | * @since 1.9.0 |
| 966 | 966 | */ |
| 967 | - public function initiate_rewrite_rules_flush(){ |
|
| 967 | + public function initiate_rewrite_rules_flush() { |
|
| 968 | 968 | |
| 969 | 969 | update_option('sensei_flush_rewrite_rules', '1'); |
| 970 | 970 | |
@@ -981,9 +981,9 @@ discard block |
||
| 981 | 981 | * |
| 982 | 982 | * @return void |
| 983 | 983 | */ |
| 984 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
| 984 | + public function sensei_woocommerce_email_course_details($order) { |
|
| 985 | 985 | |
| 986 | - Sensei_WC::email_course_details( $order ); |
|
| 986 | + Sensei_WC::email_course_details($order); |
|
| 987 | 987 | |
| 988 | 988 | } // end func email course details |
| 989 | 989 | |
@@ -992,9 +992,9 @@ discard block |
||
| 992 | 992 | * @param $user_id |
| 993 | 993 | * @param $subscription_key |
| 994 | 994 | */ |
| 995 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){ |
|
| 995 | + public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) { |
|
| 996 | 996 | |
| 997 | - Sensei_WC::reactivate_subscription( $user_id, $subscription_key ); |
|
| 997 | + Sensei_WC::reactivate_subscription($user_id, $subscription_key); |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | /** |
@@ -1002,9 +1002,9 @@ discard block |
||
| 1002 | 1002 | * @param $user_id |
| 1003 | 1003 | * @param $subscription_key |
| 1004 | 1004 | */ |
| 1005 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){ |
|
| 1005 | + public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) { |
|
| 1006 | 1006 | |
| 1007 | - Sensei_WC::end_subscription( $user_id, $subscription_key ); |
|
| 1007 | + Sensei_WC::end_subscription($user_id, $subscription_key); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
| 1017 | 1017 | * |
| 1018 | 1018 | * @return void |
| 1019 | 1019 | */ |
| 1020 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
| 1020 | + public function sensei_woocommerce_complete_order($order_id = 0) { |
|
| 1021 | 1021 | |
| 1022 | - Sensei_WC::complete_order( $order_id ); |
|
| 1022 | + Sensei_WC::complete_order($order_id); |
|
| 1023 | 1023 | |
| 1024 | 1024 | } // End sensei_woocommerce_complete_order() |
| 1025 | 1025 | |
@@ -1032,9 +1032,9 @@ discard block |
||
| 1032 | 1032 | * @param integer $order_id order ID |
| 1033 | 1033 | * @return void |
| 1034 | 1034 | */ |
| 1035 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
| 1035 | + public function sensei_woocommerce_cancel_order($order_id) { |
|
| 1036 | 1036 | |
| 1037 | - Sensei_WC::cancel_order( $order_id ); |
|
| 1037 | + Sensei_WC::cancel_order($order_id); |
|
| 1038 | 1038 | |
| 1039 | 1039 | } // End sensei_woocommerce_cancel_order() |
| 1040 | 1040 | |
@@ -1046,9 +1046,9 @@ discard block |
||
| 1046 | 1046 | * @param integer $order_id order ID |
| 1047 | 1047 | * @return void |
| 1048 | 1048 | */ |
| 1049 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
| 1049 | + public function sensei_activate_subscription($order_id = 0) { |
|
| 1050 | 1050 | |
| 1051 | - Sensei_WC::activate_subscription( $order_id ); |
|
| 1051 | + Sensei_WC::activate_subscription($order_id); |
|
| 1052 | 1052 | |
| 1053 | 1053 | } // End sensei_activate_subscription() |
| 1054 | 1054 | |
@@ -1060,9 +1060,9 @@ discard block |
||
| 1060 | 1060 | * @param array/Object $order_user (default: array()) Specific user's data. |
| 1061 | 1061 | * @return bool|int |
| 1062 | 1062 | */ |
| 1063 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
| 1063 | + public function woocommerce_course_update($course_id = 0, $order_user = array()) { |
|
| 1064 | 1064 | |
| 1065 | - return Sensei_WC::course_update( $course_id, $order_user ); |
|
| 1065 | + return Sensei_WC::course_update($course_id, $order_user); |
|
| 1066 | 1066 | |
| 1067 | 1067 | } // End woocommerce_course_update() |
| 1068 | 1068 | |
@@ -1079,9 +1079,9 @@ discard block |
||
| 1079 | 1079 | * |
| 1080 | 1080 | * @return WC_Product $wc_product_object |
| 1081 | 1081 | */ |
| 1082 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
| 1082 | + public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') { |
|
| 1083 | 1083 | |
| 1084 | - return Sensei_WC::get_product_object( $wc_product_id, $product_type ); |
|
| 1084 | + return Sensei_WC::get_product_object($wc_product_id, $product_type); |
|
| 1085 | 1085 | |
| 1086 | 1086 | } // End sensei_get_woocommerce_product_object() |
| 1087 | 1087 | |
@@ -1103,9 +1103,9 @@ discard block |
||
| 1103 | 1103 | * @param boolean $guest_checkout Current guest checkout setting |
| 1104 | 1104 | * @return boolean Modified guest checkout setting |
| 1105 | 1105 | */ |
| 1106 | - public function disable_guest_checkout( $guest_checkout ) { |
|
| 1106 | + public function disable_guest_checkout($guest_checkout) { |
|
| 1107 | 1107 | |
| 1108 | - return Sensei_WC::disable_guest_checkout( $guest_checkout ); |
|
| 1108 | + return Sensei_WC::disable_guest_checkout($guest_checkout); |
|
| 1109 | 1109 | |
| 1110 | 1110 | }// end disable_guest_checkout |
| 1111 | 1111 | |
@@ -1119,9 +1119,9 @@ discard block |
||
| 1119 | 1119 | * @param int $order_id |
| 1120 | 1120 | * @return string |
| 1121 | 1121 | **/ |
| 1122 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
| 1122 | + public function virtual_order_payment_complete($order_status, $order_id) { |
|
| 1123 | 1123 | |
| 1124 | - return Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ); |
|
| 1124 | + return Sensei_WC::virtual_order_payment_complete($order_status, $order_id); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | /** |
@@ -1130,28 +1130,28 @@ discard block |
||
| 1130 | 1130 | * @param mixed $actions Plugin Actions Links |
| 1131 | 1131 | * @return array |
| 1132 | 1132 | */ |
| 1133 | - public function plugin_action_links( $actions ) { |
|
| 1133 | + public function plugin_action_links($actions) { |
|
| 1134 | 1134 | |
| 1135 | 1135 | $custom_actions = array(); |
| 1136 | 1136 | |
| 1137 | 1137 | // settings url(s) |
| 1138 | - if ( $this->get_settings_link( $this->get_id() ) ) { |
|
| 1139 | - $custom_actions['configure'] = $this->get_settings_link( $this->get_id() ); |
|
| 1138 | + if ($this->get_settings_link($this->get_id())) { |
|
| 1139 | + $custom_actions['configure'] = $this->get_settings_link($this->get_id()); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | // documentation url if any |
| 1143 | - if ( $this->get_documentation_url() ) { |
|
| 1143 | + if ($this->get_documentation_url()) { |
|
| 1144 | 1144 | /* translators: Docs as in Documentation */ |
| 1145 | - $custom_actions['docs'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__( 'Docs', 'woothemes-sensei' ) ); |
|
| 1145 | + $custom_actions['docs'] = sprintf('<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__('Docs', 'woothemes-sensei')); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | // support url if any |
| 1149 | - if ( $this->get_support_url() ) { |
|
| 1150 | - $custom_actions['support'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x( 'Support', 'noun', 'woothemes-sensei' ) ); |
|
| 1149 | + if ($this->get_support_url()) { |
|
| 1150 | + $custom_actions['support'] = sprintf('<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x('Support', 'noun', 'woothemes-sensei')); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | // add the links to the front of the actions list |
| 1154 | - return array_merge( $custom_actions, $actions ); |
|
| 1154 | + return array_merge($custom_actions, $actions); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | /** |
@@ -1160,10 +1160,10 @@ discard block |
||
| 1160 | 1160 | * |
| 1161 | 1161 | * @return string plugin configure link |
| 1162 | 1162 | */ |
| 1163 | - public function get_settings_link( $plugin_id = null ) { |
|
| 1164 | - $settings_url = $this->get_settings_url( $plugin_id ); |
|
| 1165 | - if ( $settings_url ) { |
|
| 1166 | - return sprintf( '<a href="%s">%s</a>', $settings_url, esc_html_x( 'Configure', 'plugin action link', 'woothemes-sensei' ) ); |
|
| 1163 | + public function get_settings_link($plugin_id = null) { |
|
| 1164 | + $settings_url = $this->get_settings_url($plugin_id); |
|
| 1165 | + if ($settings_url) { |
|
| 1166 | + return sprintf('<a href="%s">%s</a>', $settings_url, esc_html_x('Configure', 'plugin action link', 'woothemes-sensei')); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | // no settings |
@@ -1175,8 +1175,8 @@ discard block |
||
| 1175 | 1175 | * |
| 1176 | 1176 | * @return string plugin settings URL |
| 1177 | 1177 | */ |
| 1178 | - public function get_settings_url( $plugin_id = null ) { |
|
| 1179 | - return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
| 1178 | + public function get_settings_url($plugin_id = null) { |
|
| 1179 | + return admin_url('admin.php?page=woothemes-sensei-settings&tab=general'); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | /** |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | * @return string documentation URL |
| 1186 | 1186 | */ |
| 1187 | 1187 | public function get_documentation_url() { |
| 1188 | - return sprintf( 'https://docs.woothemes.com/documentation/plugins/sensei/' ); |
|
| 1188 | + return sprintf('https://docs.woothemes.com/documentation/plugins/sensei/'); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | * @return boolean true if the current page is the admin general configuration page |
| 1213 | 1213 | */ |
| 1214 | 1214 | public function is_general_configuration_page() { |
| 1215 | - return isset( $_GET['page'] ) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] ); |
|
| 1215 | + return isset($_GET['page']) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset($_GET['tab']) || 'general' == $_GET['tab']); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | * @return string admin configuration url for the admin general configuration page |
| 1223 | 1223 | */ |
| 1224 | 1224 | public function get_general_configuration_url() { |
| 1225 | - return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
| 1225 | + return admin_url('admin.php?page=woothemes-sensei-settings&tab=general'); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | } // End Class |
@@ -1232,4 +1232,4 @@ discard block |
||
| 1232 | 1232 | * @ignore only for backward compatibility |
| 1233 | 1233 | * @since 1.9.0 |
| 1234 | 1234 | */ |
| 1235 | -class Woothemes_Sensei extends Sensei_Main{ } |
|
| 1235 | +class Woothemes_Sensei extends Sensei_Main { } |
|