@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Frontend Class |
@@ -20,78 +20,78 @@ discard block |
||
| 20 | 20 | * Constructor. |
| 21 | 21 | * @since 1.0.0 |
| 22 | 22 | */ |
| 23 | - public function __construct () { |
|
| 23 | + public function __construct() { |
|
| 24 | 24 | |
| 25 | 25 | // Template output actions |
| 26 | - add_action( 'sensei_before_main_content', array( $this, 'sensei_output_content_wrapper' ), 10 ); |
|
| 27 | - add_action( 'sensei_after_main_content', array( $this, 'sensei_output_content_wrapper_end' ), 10 ); |
|
| 28 | - add_action( 'sensei_lesson_archive_lesson_title', array( $this, 'sensei_lesson_archive_lesson_title' ), 10 ); |
|
| 26 | + add_action('sensei_before_main_content', array($this, 'sensei_output_content_wrapper'), 10); |
|
| 27 | + add_action('sensei_after_main_content', array($this, 'sensei_output_content_wrapper_end'), 10); |
|
| 28 | + add_action('sensei_lesson_archive_lesson_title', array($this, 'sensei_lesson_archive_lesson_title'), 10); |
|
| 29 | 29 | |
| 30 | 30 | // 1.2.1 |
| 31 | - add_action( 'wp_head', array( $this, 'sensei_complete_lesson' ), 10 ); |
|
| 32 | - add_action( 'wp_head', array( $this, 'sensei_complete_course' ), 10 ); |
|
| 33 | - add_action( 'sensei_frontend_messages', array( $this, 'sensei_frontend_messages' ) ); |
|
| 34 | - add_action( 'sensei_lesson_video', array( $this, 'sensei_lesson_video' ), 10, 1 ); |
|
| 35 | - add_action( 'sensei_complete_lesson_button', array( $this, 'sensei_complete_lesson_button' ) ); |
|
| 36 | - add_action( 'sensei_reset_lesson_button', array( $this, 'sensei_reset_lesson_button' ) ); |
|
| 31 | + add_action('wp_head', array($this, 'sensei_complete_lesson'), 10); |
|
| 32 | + add_action('wp_head', array($this, 'sensei_complete_course'), 10); |
|
| 33 | + add_action('sensei_frontend_messages', array($this, 'sensei_frontend_messages')); |
|
| 34 | + add_action('sensei_lesson_video', array($this, 'sensei_lesson_video'), 10, 1); |
|
| 35 | + add_action('sensei_complete_lesson_button', array($this, 'sensei_complete_lesson_button')); |
|
| 36 | + add_action('sensei_reset_lesson_button', array($this, 'sensei_reset_lesson_button')); |
|
| 37 | 37 | |
| 38 | - add_action( 'sensei_course_archive_meta', array( $this, 'sensei_course_archive_meta' ) ); |
|
| 38 | + add_action('sensei_course_archive_meta', array($this, 'sensei_course_archive_meta')); |
|
| 39 | 39 | |
| 40 | - add_action( 'sensei_lesson_tag_main_content', array( $this, 'sensei_lesson_archive_main_content' ), 10 ); |
|
| 41 | - add_action( 'sensei_no_permissions_main_content', array( $this, 'sensei_no_permissions_main_content' ), 10 ); |
|
| 40 | + add_action('sensei_lesson_tag_main_content', array($this, 'sensei_lesson_archive_main_content'), 10); |
|
| 41 | + add_action('sensei_no_permissions_main_content', array($this, 'sensei_no_permissions_main_content'), 10); |
|
| 42 | 42 | |
| 43 | - add_action( 'sensei_lesson_meta', array( $this, 'sensei_lesson_meta' ), 10 ); |
|
| 44 | - add_action( 'sensei_single_course_content_inside_before', array( $this, 'sensei_course_start' ), 10 ); |
|
| 43 | + add_action('sensei_lesson_meta', array($this, 'sensei_lesson_meta'), 10); |
|
| 44 | + add_action('sensei_single_course_content_inside_before', array($this, 'sensei_course_start'), 10); |
|
| 45 | 45 | |
| 46 | 46 | // add_filter( 'get_comments_number', array( $this, 'sensei_lesson_comment_count' ), 1 ); |
| 47 | - add_filter( 'the_title', array( $this, 'sensei_lesson_preview_title' ), 10, 2 ); |
|
| 47 | + add_filter('the_title', array($this, 'sensei_lesson_preview_title'), 10, 2); |
|
| 48 | 48 | |
| 49 | 49 | //1.6.2 |
| 50 | - add_filter( 'wp_login_failed', array( $this, 'sensei_login_fail_redirect' ), 10 ); |
|
| 51 | - add_filter( 'init', array( $this, 'sensei_handle_login_request' ), 10 ); |
|
| 50 | + add_filter('wp_login_failed', array($this, 'sensei_login_fail_redirect'), 10); |
|
| 51 | + add_filter('init', array($this, 'sensei_handle_login_request'), 10); |
|
| 52 | 52 | //1.6.3 |
| 53 | - add_action( 'init', array( $this, 'sensei_process_registration' ), 2 ); |
|
| 53 | + add_action('init', array($this, 'sensei_process_registration'), 2); |
|
| 54 | 54 | //1.7.0 |
| 55 | - add_action( 'sensei_pagination', array( $this, 'sensei_breadcrumb' ), 80, 1 ); |
|
| 55 | + add_action('sensei_pagination', array($this, 'sensei_breadcrumb'), 80, 1); |
|
| 56 | 56 | |
| 57 | 57 | // Fix pagination for course archive pages when filtering by course type |
| 58 | - add_filter( 'pre_get_posts', array( $this, 'sensei_course_archive_pagination' ) ); |
|
| 58 | + add_filter('pre_get_posts', array($this, 'sensei_course_archive_pagination')); |
|
| 59 | 59 | |
| 60 | 60 | // Scripts and Styles |
| 61 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
|
| 62 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 61 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); |
|
| 62 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
| 63 | 63 | |
| 64 | 64 | // Custom Menu Item filters |
| 65 | - add_filter( 'wp_setup_nav_menu_item', array( $this, 'sensei_setup_nav_menu_item' ) ); |
|
| 66 | - add_filter( 'wp_nav_menu_objects', array( $this, 'sensei_wp_nav_menu_objects' ) ); |
|
| 65 | + add_filter('wp_setup_nav_menu_item', array($this, 'sensei_setup_nav_menu_item')); |
|
| 66 | + add_filter('wp_nav_menu_objects', array($this, 'sensei_wp_nav_menu_objects')); |
|
| 67 | 67 | // Search Results filters |
| 68 | - add_filter( 'post_class', array( $this, 'sensei_search_results_classes' ), 10 ); |
|
| 68 | + add_filter('post_class', array($this, 'sensei_search_results_classes'), 10); |
|
| 69 | 69 | // Only show course & lesson excerpts in search results |
| 70 | - add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) ); |
|
| 70 | + add_filter('the_content', array($this, 'sensei_search_results_excerpt')); |
|
| 71 | 71 | |
| 72 | 72 | //Use WooCommerce filter to show admin bar to Teachers. |
| 73 | - add_action( 'init', array( $this, 'sensei_show_admin_bar') ); |
|
| 73 | + add_action('init', array($this, 'sensei_show_admin_bar')); |
|
| 74 | 74 | |
| 75 | 75 | // Remove course from active courses if an order is cancelled or refunded |
| 76 | - add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
| 77 | - add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
| 78 | - add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
| 79 | - add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
| 80 | - add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
| 81 | - add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
| 76 | + add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
| 77 | + add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
| 78 | + add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
| 79 | + add_action('woocommerce_order_status_processing_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
| 80 | + add_action('woocommerce_order_status_completed_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
| 81 | + add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
| 82 | 82 | |
| 83 | 83 | // Make sure correct courses are marked as active for users |
| 84 | - add_action( 'sensei_before_my_courses', array( $this, 'activate_purchased_courses' ), 10, 1 ); |
|
| 85 | - add_action( 'sensei_single_course_content_inside_before', array( $this, 'activate_purchased_single_course' ), 10 ); |
|
| 84 | + add_action('sensei_before_my_courses', array($this, 'activate_purchased_courses'), 10, 1); |
|
| 85 | + add_action('sensei_single_course_content_inside_before', array($this, 'activate_purchased_single_course'), 10); |
|
| 86 | 86 | |
| 87 | 87 | // Lesson tags |
| 88 | - add_action( 'sensei_lesson_meta_extra', array( $this, 'lesson_tags_display' ), 10, 1 ); |
|
| 89 | - add_action( 'pre_get_posts', array( $this, 'lesson_tag_archive_filter' ), 10, 1 ); |
|
| 90 | - add_filter( 'sensei_lessons_archive_text', array( $this, 'lesson_tag_archive_header' ) ); |
|
| 91 | - add_action( 'sensei_loop_lesson_inside_before', array( $this, 'lesson_tag_archive_description' ), 11 ); |
|
| 88 | + add_action('sensei_lesson_meta_extra', array($this, 'lesson_tags_display'), 10, 1); |
|
| 89 | + add_action('pre_get_posts', array($this, 'lesson_tag_archive_filter'), 10, 1); |
|
| 90 | + add_filter('sensei_lessons_archive_text', array($this, 'lesson_tag_archive_header')); |
|
| 91 | + add_action('sensei_loop_lesson_inside_before', array($this, 'lesson_tag_archive_description'), 11); |
|
| 92 | 92 | |
| 93 | 93 | // Hide Sensei activity comments from lesson and course pages |
| 94 | - add_filter( 'wp_list_comments_args', array( $this, 'hide_sensei_activity' ) ); |
|
| 94 | + add_filter('wp_list_comments_args', array($this, 'hide_sensei_activity')); |
|
| 95 | 95 | } // End __construct() |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | * @since 1.7.3 |
| 102 | 102 | * @return array|mixed |
| 103 | 103 | */ |
| 104 | - public function __get( $key ) { |
|
| 104 | + public function __get($key) { |
|
| 105 | 105 | |
| 106 | - if ( 'lesson' == $key || 'course' == $key ) { |
|
| 107 | - if ( WP_DEBUG ) { |
|
| 108 | - trigger_error( sprintf( 'Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3' ) ); |
|
| 106 | + if ('lesson' == $key || 'course' == $key) { |
|
| 107 | + if (WP_DEBUG) { |
|
| 108 | + trigger_error(sprintf('Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3')); |
|
| 109 | 109 | } |
| 110 | 110 | return Sensei()->$key; |
| 111 | 111 | } |
@@ -118,32 +118,32 @@ discard block |
||
| 118 | 118 | * @since 1.0.0 |
| 119 | 119 | * @return void |
| 120 | 120 | */ |
| 121 | - public function enqueue_scripts () { |
|
| 121 | + public function enqueue_scripts() { |
|
| 122 | 122 | |
| 123 | 123 | $disable_js = false; |
| 124 | - if ( isset( Sensei()->settings->settings[ 'js_disable' ] ) ) { |
|
| 125 | - $disable_js = Sensei()->settings->settings[ 'js_disable' ]; |
|
| 124 | + if (isset(Sensei()->settings->settings['js_disable'])) { |
|
| 125 | + $disable_js = Sensei()->settings->settings['js_disable']; |
|
| 126 | 126 | } // End If Statement |
| 127 | - if ( ! $disable_js ) { |
|
| 127 | + if ( ! $disable_js) { |
|
| 128 | 128 | |
| 129 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 129 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 130 | 130 | |
| 131 | 131 | // My Courses tabs script |
| 132 | - wp_register_script( Sensei()->token . '-user-dashboard', esc_url( Sensei()->plugin_url . 'assets/js/user-dashboard' . $suffix . '.js' ), array( 'jquery-ui-tabs' ), Sensei()->version, true ); |
|
| 133 | - wp_enqueue_script( Sensei()->token . '-user-dashboard' ); |
|
| 132 | + wp_register_script(Sensei()->token.'-user-dashboard', esc_url(Sensei()->plugin_url.'assets/js/user-dashboard'.$suffix.'.js'), array('jquery-ui-tabs'), Sensei()->version, true); |
|
| 133 | + wp_enqueue_script(Sensei()->token.'-user-dashboard'); |
|
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | // Course Archive javascript |
| 137 | - if( is_post_type_archive( 'course' ) ){ |
|
| 137 | + if (is_post_type_archive('course')) { |
|
| 138 | 138 | |
| 139 | - wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true ); |
|
| 140 | - wp_enqueue_script( 'sensei-course-archive-js' ); |
|
| 139 | + wp_register_script('sensei-course-archive-js', esc_url(Sensei()->plugin_url.'assets/js/frontend/course-archive'.$suffix.'.js'), array('jquery'), '1', true); |
|
| 140 | + wp_enqueue_script('sensei-course-archive-js'); |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | // Allow additional scripts to be loaded |
| 146 | - do_action( 'sensei_additional_scripts' ); |
|
| 146 | + do_action('sensei_additional_scripts'); |
|
| 147 | 147 | |
| 148 | 148 | } // End If Statement |
| 149 | 149 | |
@@ -154,23 +154,23 @@ discard block |
||
| 154 | 154 | * @since 1.0.0 |
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | - public function enqueue_styles () { |
|
| 157 | + public function enqueue_styles() { |
|
| 158 | 158 | |
| 159 | 159 | $disable_styles = false; |
| 160 | - if ( isset( Sensei()->settings->settings[ 'styles_disable' ] ) ) { |
|
| 161 | - $disable_styles = Sensei()->settings->settings[ 'styles_disable' ]; |
|
| 160 | + if (isset(Sensei()->settings->settings['styles_disable'])) { |
|
| 161 | + $disable_styles = Sensei()->settings->settings['styles_disable']; |
|
| 162 | 162 | } // End If Statement |
| 163 | 163 | |
| 164 | 164 | // Add filter for theme overrides |
| 165 | - $disable_styles = apply_filters( 'sensei_disable_styles', $disable_styles ); |
|
| 165 | + $disable_styles = apply_filters('sensei_disable_styles', $disable_styles); |
|
| 166 | 166 | |
| 167 | - if ( ! $disable_styles ) { |
|
| 167 | + if ( ! $disable_styles) { |
|
| 168 | 168 | |
| 169 | - wp_register_style( Sensei()->token . '-frontend', Sensei()->plugin_url . 'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen' ); |
|
| 170 | - wp_enqueue_style( Sensei()->token . '-frontend' ); |
|
| 169 | + wp_register_style(Sensei()->token.'-frontend', Sensei()->plugin_url.'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen'); |
|
| 170 | + wp_enqueue_style(Sensei()->token.'-frontend'); |
|
| 171 | 171 | |
| 172 | 172 | // Allow additional stylesheets to be loaded |
| 173 | - do_action( 'sensei_additional_styles' ); |
|
| 173 | + do_action('sensei_additional_styles'); |
|
| 174 | 174 | |
| 175 | 175 | } // End If Statement |
| 176 | 176 | |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | * @param string $name (default: '') |
| 187 | 187 | * @return void |
| 188 | 188 | */ |
| 189 | - function sensei_get_template_part( $slug, $name = '' ) { |
|
| 189 | + function sensei_get_template_part($slug, $name = '') { |
|
| 190 | 190 | |
| 191 | - _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' ); |
|
| 192 | - Sensei_Templates::get_part( $slug, $name ); |
|
| 191 | + _deprecated_function('class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part'); |
|
| 192 | + Sensei_Templates::get_part($slug, $name); |
|
| 193 | 193 | |
| 194 | 194 | } // End sensei_get_template_part() |
| 195 | 195 | |
@@ -204,10 +204,10 @@ discard block |
||
| 204 | 204 | * @param string $default_path (default: '') |
| 205 | 205 | * @return void |
| 206 | 206 | */ |
| 207 | - function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 207 | + function sensei_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 208 | 208 | |
| 209 | - _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' ); |
|
| 210 | - Sensei_Templates::get_template($template_name, $args, $template_path, $default_path ); |
|
| 209 | + _deprecated_function('sensei_get_template', '1.9.0', 'Sensei_Templates::get_template'); |
|
| 210 | + Sensei_Templates::get_template($template_name, $args, $template_path, $default_path); |
|
| 211 | 211 | |
| 212 | 212 | } // End sensei_get_template() |
| 213 | 213 | |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | * @param string $default_path (default: '') |
| 222 | 222 | * @return void |
| 223 | 223 | */ |
| 224 | - function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 224 | + function sensei_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 225 | 225 | |
| 226 | - _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' ); |
|
| 227 | - Sensei_Templates::locate_template( $template_name, $template_path, $default_path ); |
|
| 226 | + _deprecated_function('sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template'); |
|
| 227 | + Sensei_Templates::locate_template($template_name, $template_path, $default_path); |
|
| 228 | 228 | |
| 229 | 229 | } // End sensei_locate_template() |
| 230 | 230 | |
@@ -238,20 +238,20 @@ discard block |
||
| 238 | 238 | function sensei_output_content_wrapper() { |
| 239 | 239 | |
| 240 | 240 | // backwards compatibility check for old location under the wrappers directory of the active theme |
| 241 | - $backwards_compatible_wrapper_location = array( |
|
| 242 | - Sensei()->template_url . 'wrappers/wrapper-start.php', |
|
| 241 | + $backwards_compatible_wrapper_location = array( |
|
| 242 | + Sensei()->template_url.'wrappers/wrapper-start.php', |
|
| 243 | 243 | 'wrappers/wrapper-start.php' |
| 244 | 244 | ); |
| 245 | 245 | |
| 246 | - $template = locate_template( $backwards_compatible_wrapper_location ); |
|
| 247 | - if( !empty( $template ) ){ |
|
| 246 | + $template = locate_template($backwards_compatible_wrapper_location); |
|
| 247 | + if ( ! empty($template)) { |
|
| 248 | 248 | |
| 249 | - Sensei_Templates::get_template( 'wrappers/wrapper-start.php' ); |
|
| 249 | + Sensei_Templates::get_template('wrappers/wrapper-start.php'); |
|
| 250 | 250 | return; |
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - Sensei_Templates::get_template( 'globals/wrapper-start.php' ); |
|
| 254 | + Sensei_Templates::get_template('globals/wrapper-start.php'); |
|
| 255 | 255 | |
| 256 | 256 | } // End sensei_output_content_wrapper() |
| 257 | 257 | |
@@ -265,21 +265,21 @@ discard block |
||
| 265 | 265 | function sensei_output_content_wrapper_end() { |
| 266 | 266 | |
| 267 | 267 | // backwards compatibility check for old location under the wrappers directory of the active theme |
| 268 | - $backwards_compatible_wrapper_location = array( |
|
| 269 | - Sensei()->template_url . 'wrappers/wrapper-end.php', |
|
| 268 | + $backwards_compatible_wrapper_location = array( |
|
| 269 | + Sensei()->template_url.'wrappers/wrapper-end.php', |
|
| 270 | 270 | 'wrappers/wrapper-end.php' |
| 271 | 271 | ); |
| 272 | 272 | |
| 273 | - $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location ); |
|
| 274 | - if( !empty( $backwards_compatible_template ) ){ |
|
| 273 | + $backwards_compatible_template = locate_template($backwards_compatible_wrapper_location); |
|
| 274 | + if ( ! empty($backwards_compatible_template)) { |
|
| 275 | 275 | |
| 276 | - Sensei_Templates::get_template( 'wrappers/wrapper-end.php' ); |
|
| 276 | + Sensei_Templates::get_template('wrappers/wrapper-end.php'); |
|
| 277 | 277 | return; |
| 278 | 278 | |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
| 282 | - Sensei_Templates::get_template( 'globals/wrapper-end.php' ); |
|
| 282 | + Sensei_Templates::get_template('globals/wrapper-end.php'); |
|
| 283 | 283 | |
| 284 | 284 | } // End sensei_output_content_wrapper_end() |
| 285 | 285 | |
@@ -292,57 +292,57 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public static function load_content_pagination() { |
| 294 | 294 | |
| 295 | - if( is_singular('course') ) { |
|
| 295 | + if (is_singular('course')) { |
|
| 296 | 296 | |
| 297 | 297 | // backwards compatibility check for old location under the wrappers directory of the active theme |
| 298 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) ); |
|
| 299 | - if( !empty( $template ) ){ |
|
| 298 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-posts.php')); |
|
| 299 | + if ( ! empty($template)) { |
|
| 300 | 300 | |
| 301 | - Sensei_Templates::get_template( 'wrappers/pagination-posts.php' ); |
|
| 301 | + Sensei_Templates::get_template('wrappers/pagination-posts.php'); |
|
| 302 | 302 | return; |
| 303 | 303 | |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - Sensei_Templates::get_template( 'globals/pagination-posts.php' ); |
|
| 306 | + Sensei_Templates::get_template('globals/pagination-posts.php'); |
|
| 307 | 307 | |
| 308 | - } elseif( is_singular('lesson') ) { |
|
| 308 | + } elseif (is_singular('lesson')) { |
|
| 309 | 309 | |
| 310 | 310 | // backwards compatibility check for old location under the wrappers directory of the active theme |
| 311 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) ); |
|
| 312 | - if( !empty( $template ) ){ |
|
| 311 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-lesson.php')); |
|
| 312 | + if ( ! empty($template)) { |
|
| 313 | 313 | |
| 314 | - Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' ); |
|
| 314 | + Sensei_Templates::get_template('wrappers/pagination-lesson.php'); |
|
| 315 | 315 | return; |
| 316 | 316 | |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - Sensei_Templates::get_template( 'globals/pagination-lesson.php' ); |
|
| 319 | + Sensei_Templates::get_template('globals/pagination-lesson.php'); |
|
| 320 | 320 | |
| 321 | - } elseif( is_singular('quiz') ) { |
|
| 321 | + } elseif (is_singular('quiz')) { |
|
| 322 | 322 | |
| 323 | 323 | // backwards compatibility check for old location under the wrappers directory of the active theme |
| 324 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) ); |
|
| 325 | - if( !empty( $template ) ){ |
|
| 324 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-quiz.php')); |
|
| 325 | + if ( ! empty($template)) { |
|
| 326 | 326 | |
| 327 | - Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' ); |
|
| 327 | + Sensei_Templates::get_template('wrappers/pagination-quiz.php'); |
|
| 328 | 328 | return; |
| 329 | 329 | |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - Sensei_Templates::get_template( 'globals/pagination-quiz.php' ); |
|
| 332 | + Sensei_Templates::get_template('globals/pagination-quiz.php'); |
|
| 333 | 333 | |
| 334 | 334 | } else { |
| 335 | 335 | |
| 336 | 336 | // backwards compatibility check for old location under the wrappers directory of the active theme |
| 337 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) ); |
|
| 338 | - if( !empty( $template ) ){ |
|
| 337 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination.php')); |
|
| 338 | + if ( ! empty($template)) { |
|
| 339 | 339 | |
| 340 | - Sensei_Templates::get_template( 'wrappers/pagination.php' ); |
|
| 340 | + Sensei_Templates::get_template('wrappers/pagination.php'); |
|
| 341 | 341 | return; |
| 342 | 342 | |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - Sensei_Templates::get_template( 'globals/pagination.php' ); |
|
| 345 | + Sensei_Templates::get_template('globals/pagination.php'); |
|
| 346 | 346 | |
| 347 | 347 | } // End If Statement |
| 348 | 348 | |
@@ -368,21 +368,21 @@ discard block |
||
| 368 | 368 | * @param object $item |
| 369 | 369 | * @return object $item |
| 370 | 370 | */ |
| 371 | - public function sensei_setup_nav_menu_item( $item ) { |
|
| 371 | + public function sensei_setup_nav_menu_item($item) { |
|
| 372 | 372 | global $pagenow, $wp_rewrite; |
| 373 | 373 | |
| 374 | - if( 'nav-menus.php' != $pagenow && !defined('DOING_AJAX') && isset( $item->url ) && 'custom' == $item->type ) { |
|
| 374 | + if ('nav-menus.php' != $pagenow && ! defined('DOING_AJAX') && isset($item->url) && 'custom' == $item->type) { |
|
| 375 | 375 | |
| 376 | 376 | // Set up Sensei menu links |
| 377 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
| 378 | - $my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] ); |
|
| 377 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
| 378 | + $my_account_page_id = intval(Sensei()->settings->settings['my_course_page']); |
|
| 379 | 379 | |
| 380 | 380 | $course_page_url = Sensei_Course::get_courses_page_url(); |
| 381 | - $lesson_archive_url = get_post_type_archive_link( 'lesson' ); |
|
| 382 | - $my_courses_url = get_permalink( $my_account_page_id ); |
|
| 383 | - $my_messages_url = get_post_type_archive_link( 'sensei_message' ); |
|
| 381 | + $lesson_archive_url = get_post_type_archive_link('lesson'); |
|
| 382 | + $my_courses_url = get_permalink($my_account_page_id); |
|
| 383 | + $my_messages_url = get_post_type_archive_link('sensei_message'); |
|
| 384 | 384 | |
| 385 | - switch ( $item->url ) { |
|
| 385 | + switch ($item->url) { |
|
| 386 | 386 | case '#senseicourses': |
| 387 | 387 | $item->url = $course_page_url; |
| 388 | 388 | break; |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $item->url = $my_messages_url; |
| 400 | 400 | // if no archive link exist for sensei_message |
| 401 | 401 | // set it back to the place holder |
| 402 | - if( ! $item->url ){ |
|
| 402 | + if ( ! $item->url) { |
|
| 403 | 403 | |
| 404 | 404 | $item->url = '#senseimymessages'; |
| 405 | 405 | |
@@ -407,21 +407,21 @@ discard block |
||
| 407 | 407 | break; |
| 408 | 408 | |
| 409 | 409 | case '#senseilearnerprofile': |
| 410 | - $item->url = esc_url( Sensei()->learner_profiles->get_permalink() ); |
|
| 410 | + $item->url = esc_url(Sensei()->learner_profiles->get_permalink()); |
|
| 411 | 411 | break; |
| 412 | 412 | |
| 413 | 413 | case '#senseiloginlogout': |
| 414 | - $logout_url = wp_logout_url( home_url() ); |
|
| 414 | + $logout_url = wp_logout_url(home_url()); |
|
| 415 | 415 | // Login link links to the My Courses page, to avoid the WP dashboard. |
| 416 | 416 | $login_url = $my_courses_url; |
| 417 | 417 | |
| 418 | - $item->url = ( is_user_logged_in() ? $logout_url : $login_url ); |
|
| 418 | + $item->url = (is_user_logged_in() ? $logout_url : $login_url); |
|
| 419 | 419 | |
| 420 | 420 | // determine the menu title login or logout |
| 421 | - if ( is_user_logged_in() ) { |
|
| 422 | - $menu_title = __( 'Logout' ,'woothemes-sensei'); |
|
| 421 | + if (is_user_logged_in()) { |
|
| 422 | + $menu_title = __('Logout', 'woothemes-sensei'); |
|
| 423 | 423 | } else { |
| 424 | - $menu_title = __( 'Login' ,'woothemes-sensei'); |
|
| 424 | + $menu_title = __('Login', 'woothemes-sensei'); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * |
| 432 | 432 | * @param $menu_title |
| 433 | 433 | */ |
| 434 | - $item->title = apply_filters( 'sensei_login_logout_menu_title', $menu_title ); |
|
| 434 | + $item->title = apply_filters('sensei_login_logout_menu_title', $menu_title); |
|
| 435 | 435 | |
| 436 | 436 | break; |
| 437 | 437 | |
@@ -439,12 +439,12 @@ discard block |
||
| 439 | 439 | break; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); |
|
| 443 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); |
|
| 444 | - $item_url = untrailingslashit( $item->url ); |
|
| 445 | - $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); |
|
| 442 | + $_root_relative_current = untrailingslashit($_SERVER['REQUEST_URI']); |
|
| 443 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_root_relative_current); |
|
| 444 | + $item_url = untrailingslashit($item->url); |
|
| 445 | + $_indexless_current = untrailingslashit(preg_replace('/'.preg_quote($wp_rewrite->index, '/').'$/', '', $current_url)); |
|
| 446 | 446 | // Highlight current menu item |
| 447 | - if ( $item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) { |
|
| 447 | + if ($item_url && in_array($item_url, array($current_url, $_indexless_current, $_root_relative_current))) { |
|
| 448 | 448 | $item->classes[] = 'current-menu-item current_page_item'; |
| 449 | 449 | } |
| 450 | 450 | |
@@ -463,26 +463,26 @@ discard block |
||
| 463 | 463 | * @param object $sorted_menu_items |
| 464 | 464 | * @return object $sorted_menu_items |
| 465 | 465 | */ |
| 466 | - public function sensei_wp_nav_menu_objects( $sorted_menu_items ) { |
|
| 466 | + public function sensei_wp_nav_menu_objects($sorted_menu_items) { |
|
| 467 | 467 | |
| 468 | - foreach( $sorted_menu_items as $k=>$item ) { |
|
| 468 | + foreach ($sorted_menu_items as $k=>$item) { |
|
| 469 | 469 | |
| 470 | 470 | // Remove the My Messages link for logged out users or if Private Messages are disabled |
| 471 | - if( ! get_post_type_archive_link( 'sensei_message' ) |
|
| 472 | - && '#senseimymessages' == $item->url ) { |
|
| 471 | + if ( ! get_post_type_archive_link('sensei_message') |
|
| 472 | + && '#senseimymessages' == $item->url) { |
|
| 473 | 473 | |
| 474 | - if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) { |
|
| 474 | + if ( ! is_user_logged_in() || (isset(Sensei()->settings->settings['messages_disable']) && Sensei()->settings->settings['messages_disable'])) { |
|
| 475 | 475 | |
| 476 | - unset( $sorted_menu_items[$k] ); |
|
| 476 | + unset($sorted_menu_items[$k]); |
|
| 477 | 477 | |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | // Remove the My Profile link for logged out users. |
| 481 | - if( Sensei()->learner_profiles->get_permalink() == $item->url ) { |
|
| 481 | + if (Sensei()->learner_profiles->get_permalink() == $item->url) { |
|
| 482 | 482 | |
| 483 | - if ( !is_user_logged_in() || ! ( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) ) { |
|
| 483 | + if ( ! is_user_logged_in() || ! (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable'])) { |
|
| 484 | 484 | |
| 485 | - unset( $sorted_menu_items[$k] ); |
|
| 485 | + unset($sorted_menu_items[$k]); |
|
| 486 | 486 | |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | function sensei_search_results_classes($classes) { |
| 495 | 495 | global $post; |
| 496 | 496 | // Handle Search Classes for Courses, Lessons, and WC Products |
| 497 | - if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) { |
|
| 497 | + if (isset($post->post_type) && (('course' == $post->post_type) || ('lesson' == $post->post_type) || ('product' == $post->post_type))) { |
|
| 498 | 498 | $classes[] = 'post'; |
| 499 | 499 | } // End If Statement |
| 500 | 500 | return $classes; |
@@ -522,16 +522,16 @@ discard block |
||
| 522 | 522 | * @param bool|false $return |
| 523 | 523 | * @return string|void |
| 524 | 524 | */ |
| 525 | - function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) { |
|
| 525 | + function sensei_course_image($course_id, $width = '100', $height = '100', $return = false) { |
|
| 526 | 526 | |
| 527 | - if ( ! $return ) { |
|
| 527 | + if ( ! $return) { |
|
| 528 | 528 | |
| 529 | - echo Sensei()->course->course_image( $course_id, $width, $height ); |
|
| 529 | + echo Sensei()->course->course_image($course_id, $width, $height); |
|
| 530 | 530 | return ''; |
| 531 | 531 | |
| 532 | 532 | } // End If Statement |
| 533 | 533 | |
| 534 | - return Sensei()->course->course_image( $course_id, $width, $height ); |
|
| 534 | + return Sensei()->course->course_image($course_id, $width, $height); |
|
| 535 | 535 | |
| 536 | 536 | } // End sensei_course_image() |
| 537 | 537 | |
@@ -546,15 +546,15 @@ discard block |
||
| 546 | 546 | * @param bool|false $widget |
| 547 | 547 | * @return string |
| 548 | 548 | */ |
| 549 | - function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) { |
|
| 549 | + function sensei_lesson_image($lesson_id, $width = '100', $height = '100', $return = false, $widget = false) { |
|
| 550 | 550 | |
| 551 | - if( ! $return ){ |
|
| 551 | + if ( ! $return) { |
|
| 552 | 552 | |
| 553 | - echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
| 553 | + echo Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget); |
|
| 554 | 554 | return ''; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
| 557 | + return Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget); |
|
| 558 | 558 | |
| 559 | 559 | } // End sensei_lesson_image() |
| 560 | 560 | |
@@ -562,20 +562,20 @@ discard block |
||
| 562 | 562 | * @since 1.0.0 |
| 563 | 563 | * @param WP_Query $query |
| 564 | 564 | */ |
| 565 | - function sensei_course_archive_pagination( $query ) { |
|
| 565 | + function sensei_course_archive_pagination($query) { |
|
| 566 | 566 | |
| 567 | - if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) { |
|
| 567 | + if ( ! is_admin() && $query->is_main_query() && isset($_GET['action']) && in_array($_GET['action'], array('newcourses', 'featuredcourses', 'freecourses', 'paidcourses'))) { |
|
| 568 | 568 | |
| 569 | 569 | $amount = 0; |
| 570 | - if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
|
| 571 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
| 570 | + if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { |
|
| 571 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if( $amount ) { |
|
| 575 | - $query->set( 'posts_per_page', $amount ); |
|
| 574 | + if ($amount) { |
|
| 575 | + $query->set('posts_per_page', $amount); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $query->set( 'orderby', 'menu_order date' ); |
|
| 578 | + $query->set('orderby', 'menu_order date'); |
|
| 579 | 579 | |
| 580 | 580 | } |
| 581 | 581 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | function sensei_course_archive_header( ) { |
| 592 | 592 | |
| 593 | 593 | trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header '); |
| 594 | - WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' ); |
|
| 594 | + WooThemes_Sensei_Course::archive_header('', '<header class="archive-header"><h1>', '</h1></header>'); |
|
| 595 | 595 | |
| 596 | 596 | } // sensei_course_archive_header() |
| 597 | 597 | |
@@ -604,15 +604,15 @@ discard block |
||
| 604 | 604 | * @return void |
| 605 | 605 | */ |
| 606 | 606 | public function sensei_lesson_archive_header( ) { |
| 607 | - _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' ); |
|
| 607 | + _deprecated_function('WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header'); |
|
| 608 | 608 | Sensei()->lesson->the_archive_header(); |
| 609 | 609 | } // sensei_course_archive_header() |
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | 612 | * @deprecated since 1.9.0 |
| 613 | 613 | */ |
| 614 | - public function sensei_message_archive_header( ){ |
|
| 615 | - _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense'); |
|
| 614 | + public function sensei_message_archive_header( ) { |
|
| 615 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_header', 'Please use: Sense'); |
|
| 616 | 616 | Sensei_Messages::the_archive_header(); |
| 617 | 617 | } // sensei_message_archive_header() |
| 618 | 618 | |
@@ -622,15 +622,15 @@ discard block |
||
| 622 | 622 | * @param WP_Post $post_item |
| 623 | 623 | * @return void |
| 624 | 624 | */ |
| 625 | - function sensei_course_archive_course_title( $post_item ) { |
|
| 626 | - if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) { |
|
| 627 | - $post_id = absint( $post_item->ID ); |
|
| 625 | + function sensei_course_archive_course_title($post_item) { |
|
| 626 | + if (isset($post_item->ID) && (0 < $post_item->ID)) { |
|
| 627 | + $post_id = absint($post_item->ID); |
|
| 628 | 628 | $post_title = $post_item->post_title; |
| 629 | 629 | } else { |
| 630 | 630 | $post_id = get_the_ID(); |
| 631 | 631 | $post_title = get_the_title(); |
| 632 | 632 | } // End If Statement |
| 633 | - ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
| 633 | + ?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
| 634 | 634 | } // End sensei_course_archive_course_title() |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | public function sensei_lesson_archive_lesson_title() { |
| 642 | 642 | $post_id = get_the_ID(); |
| 643 | 643 | $post_title = get_the_title(); |
| 644 | - ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
| 644 | + ?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
| 645 | 645 | } // End sensei_lesson_archive_lesson_title() |
| 646 | 646 | |
| 647 | 647 | /** |
@@ -650,40 +650,40 @@ discard block |
||
| 650 | 650 | * @param integer $id course, lesson or quiz id |
| 651 | 651 | * @return void |
| 652 | 652 | */ |
| 653 | - public function sensei_breadcrumb( $id = 0 ) { |
|
| 653 | + public function sensei_breadcrumb($id = 0) { |
|
| 654 | 654 | |
| 655 | 655 | // Only output on lesson, quiz and taxonomy (module) pages |
| 656 | - if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return; |
|
| 656 | + if ( ! (is_tax('module') || is_singular('lesson') || is_singular('quiz'))) return; |
|
| 657 | 657 | |
| 658 | - if( empty( $id ) ){ |
|
| 658 | + if (empty($id)) { |
|
| 659 | 659 | |
| 660 | 660 | $id = get_the_ID(); |
| 661 | 661 | |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - $sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' ); |
|
| 665 | - $separator = apply_filters( 'sensei_breadcrumb_separator', '>' ); |
|
| 664 | + $sensei_breadcrumb_prefix = __('Back to: ', 'woothemes-sensei'); |
|
| 665 | + $separator = apply_filters('sensei_breadcrumb_separator', '>'); |
|
| 666 | 666 | |
| 667 | - $html = '<section class="sensei-breadcrumb">' . $sensei_breadcrumb_prefix; |
|
| 667 | + $html = '<section class="sensei-breadcrumb">'.$sensei_breadcrumb_prefix; |
|
| 668 | 668 | // Lesson |
| 669 | - if ( is_singular( 'lesson' ) && 0 < intval( $id ) ) { |
|
| 670 | - $course_id = intval( get_post_meta( $id, '_lesson_course', true ) ); |
|
| 671 | - if( ! $course_id ) { |
|
| 669 | + if (is_singular('lesson') && 0 < intval($id)) { |
|
| 670 | + $course_id = intval(get_post_meta($id, '_lesson_course', true)); |
|
| 671 | + if ( ! $course_id) { |
|
| 672 | 672 | return; |
| 673 | 673 | } |
| 674 | - $html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>'; |
|
| 674 | + $html .= '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Back to the course', 'woothemes-sensei').'">'.get_the_title($course_id).'</a>'; |
|
| 675 | 675 | } // End If Statement |
| 676 | 676 | // Quiz |
| 677 | - if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) { |
|
| 678 | - $lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) ); |
|
| 679 | - if( ! $lesson_id ) { |
|
| 677 | + if (is_singular('quiz') && 0 < intval($id)) { |
|
| 678 | + $lesson_id = intval(get_post_meta($id, '_quiz_lesson', true)); |
|
| 679 | + if ( ! $lesson_id) { |
|
| 680 | 680 | return; |
| 681 | 681 | } |
| 682 | - $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' . __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>'; |
|
| 682 | + $html .= '<a href="'.esc_url(get_permalink($lesson_id)).'" title="'.__('Back to the lesson', 'woothemes-sensei').'">'.get_the_title($lesson_id).'</a>'; |
|
| 683 | 683 | } // End If Statement |
| 684 | 684 | |
| 685 | 685 | // Allow other plugins to filter html |
| 686 | - $html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator ); |
|
| 686 | + $html = apply_filters('sensei_breadcrumb_output', $html, $separator); |
|
| 687 | 687 | $html .= '</section>'; |
| 688 | 688 | |
| 689 | 689 | echo $html; |
@@ -695,25 +695,25 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | public function sensei_lesson_course_signup_link( ) { |
| 697 | 697 | |
| 698 | - _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' ); |
|
| 698 | + _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link'); |
|
| 699 | 699 | WooThemes_Sensei_Lesson::course_signup_link(); |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - public function lesson_tags_display( $lesson_id = 0 ) { |
|
| 703 | - if( $lesson_id ) { |
|
| 704 | - $tags = wp_get_post_terms( $lesson_id, 'lesson-tag' ); |
|
| 705 | - if( $tags && count( $tags ) > 0 ) { |
|
| 702 | + public function lesson_tags_display($lesson_id = 0) { |
|
| 703 | + if ($lesson_id) { |
|
| 704 | + $tags = wp_get_post_terms($lesson_id, 'lesson-tag'); |
|
| 705 | + if ($tags && count($tags) > 0) { |
|
| 706 | 706 | $tag_list = ''; |
| 707 | - foreach( $tags as $tag ) { |
|
| 708 | - $tag_link = get_term_link( $tag, 'lesson-tag' ); |
|
| 709 | - if( ! is_wp_error( $tag_link ) ) { |
|
| 710 | - if( $tag_list ) { $tag_list .= ', '; } |
|
| 711 | - $tag_list .= '<a href="' . $tag_link . '">' . $tag->name . '</a>'; |
|
| 707 | + foreach ($tags as $tag) { |
|
| 708 | + $tag_link = get_term_link($tag, 'lesson-tag'); |
|
| 709 | + if ( ! is_wp_error($tag_link)) { |
|
| 710 | + if ($tag_list) { $tag_list .= ', '; } |
|
| 711 | + $tag_list .= '<a href="'.$tag_link.'">'.$tag->name.'</a>'; |
|
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | - if( $tag_list ) { |
|
| 714 | + if ($tag_list) { |
|
| 715 | 715 | ?><section class="lesson-tags"> |
| 716 | - <?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?> |
|
| 716 | + <?php printf(__('Lesson tags: %1$s', 'woothemes-sensei'), $tag_list); ?> |
|
| 717 | 717 | </section><?php |
| 718 | 718 | } |
| 719 | 719 | } |
@@ -723,51 +723,51 @@ discard block |
||
| 723 | 723 | /** |
| 724 | 724 | * @param WP_Query $query |
| 725 | 725 | */ |
| 726 | - public function lesson_tag_archive_filter( $query ) { |
|
| 727 | - if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) { |
|
| 726 | + public function lesson_tag_archive_filter($query) { |
|
| 727 | + if (is_tax('lesson-tag') && $query->is_main_query()) { |
|
| 728 | 728 | // Limit to lessons only |
| 729 | - $query->set( 'post_type', 'lesson' ); |
|
| 729 | + $query->set('post_type', 'lesson'); |
|
| 730 | 730 | |
| 731 | 731 | // Set order of lessons |
| 732 | - $query->set( 'orderby', 'menu_order' ); |
|
| 733 | - $query->set( 'order', 'ASC' ); |
|
| 732 | + $query->set('orderby', 'menu_order'); |
|
| 733 | + $query->set('order', 'ASC'); |
|
| 734 | 734 | |
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - public function lesson_tag_archive_header( $title ) { |
|
| 739 | - if( is_tax( 'lesson-tag' ) ) { |
|
| 740 | - $title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) ); |
|
| 738 | + public function lesson_tag_archive_header($title) { |
|
| 739 | + if (is_tax('lesson-tag')) { |
|
| 740 | + $title = sprintf(__('Lesson tag: %1$s', 'woothemes-sensei'), apply_filters('sensei_lesson_tag_archive_title', get_queried_object()->name)); |
|
| 741 | 741 | } |
| 742 | 742 | return $title; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | public function lesson_tag_archive_description() { |
| 746 | - if( is_tax( 'lesson-tag' ) ) { |
|
| 746 | + if (is_tax('lesson-tag')) { |
|
| 747 | 747 | $tag = get_queried_object(); |
| 748 | - echo '<p class="archive-description lesson-description">' . apply_filters( 'sensei_lesson_tag_archive_description', nl2br( $tag->description ), $tag->term_id ) . '</p>'; |
|
| 748 | + echo '<p class="archive-description lesson-description">'.apply_filters('sensei_lesson_tag_archive_description', nl2br($tag->description), $tag->term_id).'</p>'; |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | public function sensei_complete_lesson() { |
| 753 | - global $post, $current_user; |
|
| 753 | + global $post, $current_user; |
|
| 754 | 754 | // Handle Quiz Completion |
| 755 | - if ( isset( $_POST['quiz_action'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_lesson_noonce' ], 'woothemes_sensei_complete_lesson_noonce' ) ) { |
|
| 755 | + if (isset($_POST['quiz_action']) && wp_verify_nonce($_POST['woothemes_sensei_complete_lesson_noonce'], 'woothemes_sensei_complete_lesson_noonce')) { |
|
| 756 | 756 | |
| 757 | - $sanitized_submit = esc_html( $_POST['quiz_action'] ); |
|
| 757 | + $sanitized_submit = esc_html($_POST['quiz_action']); |
|
| 758 | 758 | |
| 759 | 759 | switch ($sanitized_submit) { |
| 760 | 760 | case 'lesson-complete': |
| 761 | 761 | |
| 762 | - Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true ); |
|
| 762 | + Sensei_Utils::sensei_start_lesson($post->ID, $current_user->ID, $complete = true); |
|
| 763 | 763 | |
| 764 | 764 | break; |
| 765 | 765 | |
| 766 | 766 | case 'lesson-reset': |
| 767 | 767 | |
| 768 | - Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID ); |
|
| 768 | + Sensei_Utils::sensei_remove_user_from_lesson($post->ID, $current_user->ID); |
|
| 769 | 769 | |
| 770 | - $this->messages = '<div class="sensei-message note">' . __( 'Lesson Reset Successfully.', 'woothemes-sensei' ) . '</div>'; |
|
| 770 | + $this->messages = '<div class="sensei-message note">'.__('Lesson Reset Successfully.', 'woothemes-sensei').'</div>'; |
|
| 771 | 771 | break; |
| 772 | 772 | |
| 773 | 773 | default: |
@@ -781,14 +781,14 @@ discard block |
||
| 781 | 781 | } // End sensei_complete_lesson() |
| 782 | 782 | |
| 783 | 783 | public function sensei_complete_course() { |
| 784 | - global $post, $current_user, $wp_query; |
|
| 785 | - if ( isset( $_POST['course_complete'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_course_noonce' ], 'woothemes_sensei_complete_course_noonce' ) ) { |
|
| 784 | + global $post, $current_user, $wp_query; |
|
| 785 | + if (isset($_POST['course_complete']) && wp_verify_nonce($_POST['woothemes_sensei_complete_course_noonce'], 'woothemes_sensei_complete_course_noonce')) { |
|
| 786 | 786 | |
| 787 | - $sanitized_submit = esc_html( $_POST['course_complete'] ); |
|
| 788 | - $sanitized_course_id = absint( esc_html( $_POST['course_complete_id'] ) ); |
|
| 787 | + $sanitized_submit = esc_html($_POST['course_complete']); |
|
| 788 | + $sanitized_course_id = absint(esc_html($_POST['course_complete_id'])); |
|
| 789 | 789 | // Handle submit data |
| 790 | 790 | switch ($sanitized_submit) { |
| 791 | - case __( 'Mark as Complete', 'woothemes-sensei' ): |
|
| 791 | + case __('Mark as Complete', 'woothemes-sensei'): |
|
| 792 | 792 | |
| 793 | 793 | // Add user to course |
| 794 | 794 | $course_metadata = array( |
@@ -796,15 +796,15 @@ discard block |
||
| 796 | 796 | 'percent' => 0, // No completed lessons yet |
| 797 | 797 | 'complete' => 0, |
| 798 | 798 | ); |
| 799 | - $activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata ); |
|
| 799 | + $activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata); |
|
| 800 | 800 | |
| 801 | - if ( $activity_logged ) { |
|
| 801 | + if ($activity_logged) { |
|
| 802 | 802 | // Get all course lessons |
| 803 | - $course_lesson_ids = Sensei()->course->course_lessons( $sanitized_course_id, 'any', 'ids' ); |
|
| 803 | + $course_lesson_ids = Sensei()->course->course_lessons($sanitized_course_id, 'any', 'ids'); |
|
| 804 | 804 | // Mark all quiz user meta lessons as complete |
| 805 | - foreach ( $course_lesson_ids as $lesson_item_id ){ |
|
| 805 | + foreach ($course_lesson_ids as $lesson_item_id) { |
|
| 806 | 806 | // Mark lesson as complete |
| 807 | - $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_item_id, $current_user->ID, $complete = true ); |
|
| 807 | + $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_item_id, $current_user->ID, $complete = true); |
|
| 808 | 808 | } // End For Loop |
| 809 | 809 | |
| 810 | 810 | // Update with final stats |
@@ -812,22 +812,22 @@ discard block |
||
| 812 | 812 | 'percent' => 100, |
| 813 | 813 | 'complete' => count($course_lesson_ids), |
| 814 | 814 | ); |
| 815 | - $activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'complete', $course_metadata ); |
|
| 815 | + $activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'complete', $course_metadata); |
|
| 816 | 816 | |
| 817 | - do_action( 'sensei_user_course_end', $current_user->ID, $sanitized_course_id ); |
|
| 817 | + do_action('sensei_user_course_end', $current_user->ID, $sanitized_course_id); |
|
| 818 | 818 | |
| 819 | 819 | // Success message |
| 820 | - $this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s marked as complete.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>'; |
|
| 820 | + $this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s marked as complete.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>'; |
|
| 821 | 821 | } // End If Statement |
| 822 | 822 | |
| 823 | 823 | break; |
| 824 | 824 | |
| 825 | - case __( 'Delete Course', 'woothemes-sensei' ): |
|
| 825 | + case __('Delete Course', 'woothemes-sensei'): |
|
| 826 | 826 | |
| 827 | - Sensei_Utils::sensei_remove_user_from_course( $sanitized_course_id, $current_user->ID ); |
|
| 827 | + Sensei_Utils::sensei_remove_user_from_course($sanitized_course_id, $current_user->ID); |
|
| 828 | 828 | |
| 829 | 829 | // Success message |
| 830 | - $this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s deleted.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>'; |
|
| 830 | + $this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s deleted.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>'; |
|
| 831 | 831 | break; |
| 832 | 832 | |
| 833 | 833 | default: |
@@ -843,25 +843,25 @@ discard block |
||
| 843 | 843 | * @param int $lesson_id |
| 844 | 844 | * @return array |
| 845 | 845 | */ |
| 846 | - public function sensei_get_user_quiz_answers( $lesson_id = 0 ) { |
|
| 846 | + public function sensei_get_user_quiz_answers($lesson_id = 0) { |
|
| 847 | 847 | global $current_user; |
| 848 | 848 | |
| 849 | 849 | $user_answers = array(); |
| 850 | 850 | |
| 851 | - if ( 0 < intval( $lesson_id ) ) { |
|
| 852 | - $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $lesson_id ); |
|
| 853 | - foreach( $lesson_quiz_questions as $question ) { |
|
| 854 | - $answer = maybe_unserialize( base64_decode( Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content' ) ) ) ); |
|
| 855 | - $user_answers[ $question->ID ] = $answer; |
|
| 851 | + if (0 < intval($lesson_id)) { |
|
| 852 | + $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($lesson_id); |
|
| 853 | + foreach ($lesson_quiz_questions as $question) { |
|
| 854 | + $answer = maybe_unserialize(base64_decode(Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content')))); |
|
| 855 | + $user_answers[$question->ID] = $answer; |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | return $user_answers; |
| 860 | 860 | } // End sensei_get_user_quiz_answers() |
| 861 | 861 | |
| 862 | - public function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { |
|
| 863 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); |
|
| 864 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); |
|
| 862 | + public function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { |
|
| 863 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); |
|
| 864 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); |
|
| 865 | 865 | } // End sensei_has_user_completed_lesson() |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -871,14 +871,14 @@ discard block |
||
| 871 | 871 | Sensei()->notices->print_notices(); |
| 872 | 872 | } // End sensei_frontend_messages() |
| 873 | 873 | |
| 874 | - public function sensei_lesson_video( $post_id = 0 ) { |
|
| 875 | - if ( 0 < intval( $post_id ) ) { |
|
| 876 | - $lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true ); |
|
| 877 | - if ( 'http' == substr( $lesson_video_embed, 0, 4) ) { |
|
| 874 | + public function sensei_lesson_video($post_id = 0) { |
|
| 875 | + if (0 < intval($post_id)) { |
|
| 876 | + $lesson_video_embed = get_post_meta($post_id, '_lesson_video_embed', true); |
|
| 877 | + if ('http' == substr($lesson_video_embed, 0, 4)) { |
|
| 878 | 878 | // V2 - make width and height a setting for video embed |
| 879 | - $lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ ); |
|
| 879 | + $lesson_video_embed = wp_oembed_get(esc_url($lesson_video_embed)/*, array( 'width' => 100 , 'height' => 100)*/); |
|
| 880 | 880 | } // End If Statement |
| 881 | - if ( '' != $lesson_video_embed ) { |
|
| 881 | + if ('' != $lesson_video_embed) { |
|
| 882 | 882 | ?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php |
| 883 | 883 | } // End If Statement |
| 884 | 884 | } // End If Statement |
@@ -890,19 +890,19 @@ discard block |
||
| 890 | 890 | $quiz_id = 0; |
| 891 | 891 | |
| 892 | 892 | // Lesson quizzes |
| 893 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID ); |
|
| 893 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post->ID); |
|
| 894 | 894 | $pass_required = true; |
| 895 | - if( $quiz_id ) { |
|
| 895 | + if ($quiz_id) { |
|
| 896 | 896 | // Get quiz pass setting |
| 897 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
| 897 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
| 898 | 898 | } |
| 899 | - if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) { |
|
| 899 | + if ( ! $quiz_id || ($quiz_id && ! $pass_required)) { |
|
| 900 | 900 | ?> |
| 901 | - <form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
| 901 | + <form class="lesson_button_form" method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
| 902 | 902 | <input type="hidden" |
| 903 | 903 | name="woothemes_sensei_complete_lesson_noonce" |
| 904 | 904 | id="woothemes_sensei_complete_lesson_noonce" |
| 905 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" |
|
| 905 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" |
|
| 906 | 906 | /> |
| 907 | 907 | |
| 908 | 908 | <input type="hidden" name="quiz_action" value="lesson-complete" /> |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | <input type="submit" |
| 911 | 911 | name="quiz_complete" |
| 912 | 912 | class="quiz-submit complete" |
| 913 | - value="<?php _e( 'Complete Lesson', 'woothemes-sensei' ); ?>"/> |
|
| 913 | + value="<?php _e('Complete Lesson', 'woothemes-sensei'); ?>"/> |
|
| 914 | 914 | |
| 915 | 915 | </form> |
| 916 | 916 | <?php |
@@ -923,25 +923,25 @@ discard block |
||
| 923 | 923 | $quiz_id = 0; |
| 924 | 924 | |
| 925 | 925 | // Lesson quizzes |
| 926 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID ); |
|
| 926 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post->ID); |
|
| 927 | 927 | $reset_allowed = true; |
| 928 | - if( $quiz_id ) { |
|
| 928 | + if ($quiz_id) { |
|
| 929 | 929 | // Get quiz pass setting |
| 930 | - $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
| 930 | + $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true); |
|
| 931 | 931 | } |
| 932 | - if ( ! $quiz_id || !empty($reset_allowed) ) { |
|
| 932 | + if ( ! $quiz_id || ! empty($reset_allowed)) { |
|
| 933 | 933 | ?> |
| 934 | - <form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
| 934 | + <form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
| 935 | 935 | |
| 936 | 936 | <input |
| 937 | 937 | type="hidden" |
| 938 | - name="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>" |
|
| 939 | - id="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>" |
|
| 940 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" /> |
|
| 938 | + name="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>" |
|
| 939 | + id="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>" |
|
| 940 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" /> |
|
| 941 | 941 | |
| 942 | 942 | <input type="hidden" name="quiz_action" value="lesson-reset" /> |
| 943 | 943 | |
| 944 | - <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e( 'Reset Lesson', 'woothemes-sensei' ); ?>"/> |
|
| 944 | + <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e('Reset Lesson', 'woothemes-sensei'); ?>"/> |
|
| 945 | 945 | |
| 946 | 946 | </form> |
| 947 | 947 | <?php |
@@ -964,23 +964,23 @@ discard block |
||
| 964 | 964 | $post_title = get_the_title(); |
| 965 | 965 | $author_display_name = get_the_author(); |
| 966 | 966 | $author_id = get_the_author_meta('ID'); |
| 967 | - $category_output = get_the_term_list( $post_id, 'course-category', '', ', ', '' ); |
|
| 968 | - $free_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $post_id ) ); |
|
| 967 | + $category_output = get_the_term_list($post_id, 'course-category', '', ', ', ''); |
|
| 968 | + $free_lesson_count = intval(Sensei()->course->course_lesson_preview_count($post_id)); |
|
| 969 | 969 | ?><section class="entry"> |
| 970 | 970 | <p class="sensei-course-meta"> |
| 971 | - <?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?> |
|
| 972 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span> |
|
| 971 | + <?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?> |
|
| 972 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span> |
|
| 973 | 973 | <?php } // End If Statement ?> |
| 974 | - <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . ' ' . __( 'Lessons', 'woothemes-sensei' ); ?></span> |
|
| 975 | - <?php if ( '' != $category_output ) { ?> |
|
| 976 | - <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span> |
|
| 974 | + <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).' '.__('Lessons', 'woothemes-sensei'); ?></span> |
|
| 975 | + <?php if ('' != $category_output) { ?> |
|
| 976 | + <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span> |
|
| 977 | 977 | <?php } // End If Statement ?> |
| 978 | - <?php sensei_simple_course_price( $post_id ); ?> |
|
| 978 | + <?php sensei_simple_course_price($post_id); ?> |
|
| 979 | 979 | </p> |
| 980 | 980 | <p class="course-excerpt"><?php the_excerpt(); ?></p> |
| 981 | - <?php if ( 0 < $free_lesson_count ) { |
|
| 982 | - $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?> |
|
| 983 | - <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p> |
|
| 981 | + <?php if (0 < $free_lesson_count) { |
|
| 982 | + $free_lessons = sprintf(__('You can access %d of this course\'s lessons for free', 'woothemes-sensei'), $free_lesson_count); ?> |
|
| 983 | + <p class="sensei-free-lessons"><a href="<?php echo get_permalink($post_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?></a> - <?php echo $free_lessons; ?></p> |
|
| 984 | 984 | <?php } ?> |
| 985 | 985 | </section><?php |
| 986 | 986 | } // End sensei_course_archive_meta() |
@@ -1003,33 +1003,33 @@ discard block |
||
| 1003 | 1003 | * @deprecated since 1.9.0 |
| 1004 | 1004 | */ |
| 1005 | 1005 | public function sensei_message_archive_main_content() { |
| 1006 | - _deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' ); |
|
| 1006 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed'); |
|
| 1007 | 1007 | } // End sensei_lesson_archive_main_content() |
| 1008 | 1008 | |
| 1009 | 1009 | /** |
| 1010 | 1010 | * @deprecated since 1.9.0 |
| 1011 | 1011 | */ |
| 1012 | 1012 | public function sensei_no_permissions_main_content() { |
| 1013 | - _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' ); |
|
| 1013 | + _deprecated_function('Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed'); |
|
| 1014 | 1014 | } // End sensei_no_permissions_main_content() |
| 1015 | 1015 | |
| 1016 | 1016 | public function sensei_course_category_main_content() { |
| 1017 | 1017 | global $post; |
| 1018 | - if ( have_posts() ) { ?> |
|
| 1018 | + if (have_posts()) { ?> |
|
| 1019 | 1019 | |
| 1020 | 1020 | <section id="main-course" class="course-container"> |
| 1021 | 1021 | |
| 1022 | - <?php do_action( 'sensei_course_archive_header' ); ?> |
|
| 1022 | + <?php do_action('sensei_course_archive_header'); ?> |
|
| 1023 | 1023 | |
| 1024 | - <?php while ( have_posts() ) { the_post(); ?> |
|
| 1024 | + <?php while (have_posts()) { the_post(); ?> |
|
| 1025 | 1025 | |
| 1026 | - <article class="<?php echo join( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ); ?>"> |
|
| 1026 | + <article class="<?php echo join(' ', get_post_class(array('course', 'post'), get_the_ID())); ?>"> |
|
| 1027 | 1027 | |
| 1028 | - <?php sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', get_the_ID() ); ?> |
|
| 1028 | + <?php sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', get_the_ID()); ?> |
|
| 1029 | 1029 | |
| 1030 | - <?php sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before', $post ); ?> |
|
| 1030 | + <?php sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before', $post); ?> |
|
| 1031 | 1031 | |
| 1032 | - <?php do_action( 'sensei_course_archive_meta' ); ?> |
|
| 1032 | + <?php do_action('sensei_course_archive_meta'); ?> |
|
| 1033 | 1033 | |
| 1034 | 1034 | </article> |
| 1035 | 1035 | |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | |
| 1042 | 1042 | <p> |
| 1043 | 1043 | |
| 1044 | - <?php _e( 'No courses found that match your selection.', 'woothemes-sensei' ); ?> |
|
| 1044 | + <?php _e('No courses found that match your selection.', 'woothemes-sensei'); ?> |
|
| 1045 | 1045 | |
| 1046 | 1046 | </p> |
| 1047 | 1047 | |
@@ -1058,12 +1058,12 @@ discard block |
||
| 1058 | 1058 | <div class="col-1"> |
| 1059 | 1059 | <?php |
| 1060 | 1060 | // output the actual form markup |
| 1061 | - Sensei_Templates::get_template( 'user/login-form.php'); |
|
| 1061 | + Sensei_Templates::get_template('user/login-form.php'); |
|
| 1062 | 1062 | ?> |
| 1063 | 1063 | </div> |
| 1064 | 1064 | |
| 1065 | 1065 | <?php |
| 1066 | - if ( get_option('users_can_register') ) { |
|
| 1066 | + if (get_option('users_can_register')) { |
|
| 1067 | 1067 | |
| 1068 | 1068 | // get current url |
| 1069 | 1069 | $action_url = get_permalink(); |
@@ -1071,38 +1071,38 @@ discard block |
||
| 1071 | 1071 | ?> |
| 1072 | 1072 | |
| 1073 | 1073 | <div class="col-2"> |
| 1074 | - <h2><?php _e( 'Register', 'woothemes-sensei' ); ?></h2> |
|
| 1074 | + <h2><?php _e('Register', 'woothemes-sensei'); ?></h2> |
|
| 1075 | 1075 | |
| 1076 | - <form method="post" class="register" action="<?php echo esc_url( $action_url ); ?>" > |
|
| 1076 | + <form method="post" class="register" action="<?php echo esc_url($action_url); ?>" > |
|
| 1077 | 1077 | |
| 1078 | - <?php do_action( 'sensei_register_form_start' ); ?> |
|
| 1078 | + <?php do_action('sensei_register_form_start'); ?> |
|
| 1079 | 1079 | |
| 1080 | 1080 | <p class="form-row form-row-wide"> |
| 1081 | - <label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
| 1082 | - <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" /> |
|
| 1081 | + <label for="sensei_reg_username"><?php _e('Username', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
| 1082 | + <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty($_POST['sensei_reg_username'])) esc_attr_e($_POST['sensei_reg_username']); ?>" /> |
|
| 1083 | 1083 | </p> |
| 1084 | 1084 | |
| 1085 | 1085 | <p class="form-row form-row-wide"> |
| 1086 | - <label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
| 1087 | - <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" /> |
|
| 1086 | + <label for="sensei_reg_email"><?php _e('Email address', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
| 1087 | + <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty($_POST['sensei_reg_email'])) esc_attr_e($_POST['sensei_reg_email']); ?>" /> |
|
| 1088 | 1088 | </p> |
| 1089 | 1089 | |
| 1090 | 1090 | <p class="form-row form-row-wide"> |
| 1091 | - <label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
| 1092 | - <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" /> |
|
| 1091 | + <label for="sensei_reg_password"><?php _e('Password', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
| 1092 | + <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty($_POST['sensei_reg_password'])) esc_attr_e($_POST['sensei_reg_password']); ?>" /> |
|
| 1093 | 1093 | </p> |
| 1094 | 1094 | |
| 1095 | 1095 | <!-- Spam Trap --> |
| 1096 | - <div style="left:-999em; position:absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woothemes-sensei' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> |
|
| 1096 | + <div style="left:-999em; position:absolute;"><label for="trap"><?php _e('Anti-spam', 'woothemes-sensei'); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> |
|
| 1097 | 1097 | |
| 1098 | - <?php do_action( 'sensei_register_form_fields' ); ?> |
|
| 1099 | - <?php do_action( 'register_form' ); ?> |
|
| 1098 | + <?php do_action('sensei_register_form_fields'); ?> |
|
| 1099 | + <?php do_action('register_form'); ?> |
|
| 1100 | 1100 | |
| 1101 | 1101 | <p class="form-row"> |
| 1102 | - <input type="submit" class="button" name="register" value="<?php _e( 'Register', 'woothemes-sensei' ); ?>" /> |
|
| 1102 | + <input type="submit" class="button" name="register" value="<?php _e('Register', 'woothemes-sensei'); ?>" /> |
|
| 1103 | 1103 | </p> |
| 1104 | 1104 | |
| 1105 | - <?php do_action( 'sensei_register_form_end' ); ?> |
|
| 1105 | + <?php do_action('sensei_register_form_end'); ?> |
|
| 1106 | 1106 | |
| 1107 | 1107 | </form> |
| 1108 | 1108 | </div> |
@@ -1115,17 +1115,17 @@ discard block |
||
| 1115 | 1115 | <?php |
| 1116 | 1116 | } // End sensei_login_form() |
| 1117 | 1117 | |
| 1118 | - public function sensei_lesson_meta( $post_id = 0 ) { |
|
| 1118 | + public function sensei_lesson_meta($post_id = 0) { |
|
| 1119 | 1119 | global $post; |
| 1120 | - if ( 0 < intval( $post_id ) ) { |
|
| 1121 | - $lesson_course_id = absint( get_post_meta( $post_id, '_lesson_course', true ) ); |
|
| 1120 | + if (0 < intval($post_id)) { |
|
| 1121 | + $lesson_course_id = absint(get_post_meta($post_id, '_lesson_course', true)); |
|
| 1122 | 1122 | ?><section class="entry"> |
| 1123 | 1123 | <p class="sensei-course-meta"> |
| 1124 | - <?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?> |
|
| 1125 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span> |
|
| 1124 | + <?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?> |
|
| 1125 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span> |
|
| 1126 | 1126 | <?php } ?> |
| 1127 | - <?php if ( 0 < intval( $lesson_course_id ) ) { ?> |
|
| 1128 | - <span class="lesson-course"><?php echo ' ' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . __( 'View course', 'woothemes-sensei' ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span> |
|
| 1127 | + <?php if (0 < intval($lesson_course_id)) { ?> |
|
| 1128 | + <span class="lesson-course"><?php echo ' '.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.__('View course', 'woothemes-sensei').'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span> |
|
| 1129 | 1129 | <?php } ?> |
| 1130 | 1130 | </p> |
| 1131 | 1131 | <p class="lesson-excerpt"><?php the_excerpt( ); ?></p> |
@@ -1133,36 +1133,36 @@ discard block |
||
| 1133 | 1133 | } // End If Statement |
| 1134 | 1134 | } // sensei_lesson_meta() |
| 1135 | 1135 | |
| 1136 | - public function sensei_lesson_preview_title_text( $course_id ) { |
|
| 1136 | + public function sensei_lesson_preview_title_text($course_id) { |
|
| 1137 | 1137 | |
| 1138 | - $preview_text = __( ' (Preview)', 'woothemes-sensei' ); |
|
| 1138 | + $preview_text = __(' (Preview)', 'woothemes-sensei'); |
|
| 1139 | 1139 | |
| 1140 | 1140 | //if this is a paid course |
| 1141 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 1142 | - $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
| 1143 | - if ( 0 < $wc_post_id ) { |
|
| 1144 | - $preview_text = __( ' (Free Preview)', 'woothemes-sensei' ); |
|
| 1141 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 1142 | + $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true); |
|
| 1143 | + if (0 < $wc_post_id) { |
|
| 1144 | + $preview_text = __(' (Free Preview)', 'woothemes-sensei'); |
|
| 1145 | 1145 | } // End If Statement |
| 1146 | 1146 | } |
| 1147 | 1147 | return $preview_text; |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - public function sensei_lesson_preview_title( $title = '', $id = 0 ) { |
|
| 1150 | + public function sensei_lesson_preview_title($title = '', $id = 0) { |
|
| 1151 | 1151 | global $post, $current_user; |
| 1152 | 1152 | |
| 1153 | 1153 | // Limit to lessons and check if lesson ID matches filtered post ID |
| 1154 | 1154 | // @see https://github.com/woothemes/sensei/issues/574 |
| 1155 | - if( isset( $post->ID ) && $id == $post->ID && 'lesson' == get_post_type( $post ) ) { |
|
| 1155 | + if (isset($post->ID) && $id == $post->ID && 'lesson' == get_post_type($post)) { |
|
| 1156 | 1156 | |
| 1157 | 1157 | // Limit to main query only |
| 1158 | - if( is_main_query() ) { |
|
| 1158 | + if (is_main_query()) { |
|
| 1159 | 1159 | |
| 1160 | 1160 | // Get the course ID |
| 1161 | - $course_id = get_post_meta( $post->ID, '_lesson_course', true ); |
|
| 1161 | + $course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
| 1162 | 1162 | |
| 1163 | 1163 | // Check if the user is taking the course |
| 1164 | - if( is_singular( 'lesson' ) && Sensei_Utils::is_preview_lesson( $post->ID ) && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID ) && $post->ID == $id ) { |
|
| 1165 | - $title .= ' ' . $this->sensei_lesson_preview_title_text( $course_id ); |
|
| 1164 | + if (is_singular('lesson') && Sensei_Utils::is_preview_lesson($post->ID) && ! Sensei_Utils::user_started_course($course_id, $current_user->ID) && $post->ID == $id) { |
|
| 1165 | + $title .= ' '.$this->sensei_lesson_preview_title_text($course_id); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
@@ -1173,23 +1173,23 @@ discard block |
||
| 1173 | 1173 | global $post, $current_user; |
| 1174 | 1174 | |
| 1175 | 1175 | // Check if the user is taking the course |
| 1176 | - $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
| 1176 | + $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID); |
|
| 1177 | 1177 | // Handle user starting the course |
| 1178 | - if ( isset( $_POST['course_start'] ) |
|
| 1179 | - && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' ) |
|
| 1180 | - && !$is_user_taking_course ) { |
|
| 1178 | + if (isset($_POST['course_start']) |
|
| 1179 | + && wp_verify_nonce($_POST['woothemes_sensei_start_course_noonce'], 'woothemes_sensei_start_course_noonce') |
|
| 1180 | + && ! $is_user_taking_course) { |
|
| 1181 | 1181 | |
| 1182 | 1182 | // Start the course |
| 1183 | - $activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID ); |
|
| 1183 | + $activity_logged = Sensei_Utils::user_start_course($current_user->ID, $post->ID); |
|
| 1184 | 1184 | $this->data = new stdClass(); |
| 1185 | 1185 | $this->data->is_user_taking_course = false; |
| 1186 | - if ( $activity_logged ) { |
|
| 1186 | + if ($activity_logged) { |
|
| 1187 | 1187 | $this->data->is_user_taking_course = true; |
| 1188 | 1188 | |
| 1189 | 1189 | // Refresh page to avoid re-posting |
| 1190 | 1190 | ?> |
| 1191 | 1191 | |
| 1192 | - <script type="text/javascript"> window.location = '<?php echo get_permalink( $post->ID ); ?>'; </script> |
|
| 1192 | + <script type="text/javascript"> window.location = '<?php echo get_permalink($post->ID); ?>'; </script> |
|
| 1193 | 1193 | |
| 1194 | 1194 | <?php |
| 1195 | 1195 | } // End If Statement |
@@ -1200,15 +1200,15 @@ discard block |
||
| 1200 | 1200 | * @deprecated since 1.9.0 |
| 1201 | 1201 | */ |
| 1202 | 1202 | public function sensei_course_meta() { |
| 1203 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' ); |
|
| 1204 | - Sensei()->course->the_course_meta( get_post() ); |
|
| 1203 | + _deprecated_function('Sensei_Frontend::sensei_course_meta', '1.9.0', 'Sensei_Course::the_course_meta()'); |
|
| 1204 | + Sensei()->course->the_course_meta(get_post()); |
|
| 1205 | 1205 | } // End sensei_course_meta() |
| 1206 | 1206 | |
| 1207 | 1207 | /** |
| 1208 | 1208 | * @deprecated since 1.9.0 |
| 1209 | 1209 | */ |
| 1210 | 1210 | public function sensei_course_meta_video() { |
| 1211 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' ); |
|
| 1211 | + _deprecated_function('Sensei_Frontend::sensei_course_meta_video', '1.9.0', 'Sensei_Course::the_course_video()'); |
|
| 1212 | 1212 | Sensei_Course::the_course_video(); |
| 1213 | 1213 | } // End sensei_course_meta_video() |
| 1214 | 1214 | |
@@ -1223,12 +1223,12 @@ discard block |
||
| 1223 | 1223 | public function sensei_woocommerce_in_cart_message() { |
| 1224 | 1224 | global $post, $woocommerce; |
| 1225 | 1225 | |
| 1226 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 1227 | - $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() ); |
|
| 1228 | - if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) { |
|
| 1226 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
| 1227 | + $user_course_status_id = Sensei_Utils::user_started_course($post->ID, get_current_user_id()); |
|
| 1228 | + if (0 < intval($wc_post_id) && ! $user_course_status_id) { |
|
| 1229 | 1229 | |
| 1230 | - if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) { |
|
| 1231 | - echo '<div class="sensei-message info">' . sprintf( __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' ); |
|
| 1230 | + if (Sensei_WC::is_product_in_cart($wc_post_id)) { |
|
| 1231 | + echo '<div class="sensei-message info">'.sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei').'</div>', '<a class="cart-complete" href="'.$woocommerce->cart->get_checkout_url().'" title="'.__('complete the purchase', 'woothemes-sensei').'">'.__('complete the purchase', 'woothemes-sensei').'</a>'); |
|
| 1232 | 1232 | } // End If Statement |
| 1233 | 1233 | |
| 1234 | 1234 | } // End If Statement |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | } // End sensei_woocommerce_in_cart_message() |
| 1237 | 1237 | |
| 1238 | 1238 | // Deprecated |
| 1239 | - public function sensei_lesson_comment_count( $count ) { |
|
| 1239 | + public function sensei_lesson_comment_count($count) { |
|
| 1240 | 1240 | return $count; |
| 1241 | 1241 | } // End sensei_lesson_comment_count() |
| 1242 | 1242 | |
@@ -1245,11 +1245,11 @@ discard block |
||
| 1245 | 1245 | * @param string $content Original content |
| 1246 | 1246 | * @return string Modified content |
| 1247 | 1247 | */ |
| 1248 | - public function sensei_search_results_excerpt( $content ) { |
|
| 1248 | + public function sensei_search_results_excerpt($content) { |
|
| 1249 | 1249 | global $post; |
| 1250 | 1250 | |
| 1251 | - if( is_search() && in_array( $post->post_type, array( 'course', 'lesson' ) ) ) { |
|
| 1252 | - $content = '<p class="course-excerpt">' . the_excerpt( ) . '</p>'; |
|
| 1251 | + if (is_search() && in_array($post->post_type, array('course', 'lesson'))) { |
|
| 1252 | + $content = '<p class="course-excerpt">'.the_excerpt( ).'</p>'; |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | return $content; |
@@ -1260,11 +1260,11 @@ discard block |
||
| 1260 | 1260 | * @param integer $order_id ID of order |
| 1261 | 1261 | * @return void |
| 1262 | 1262 | */ |
| 1263 | - public function remove_active_course( $order_id ) { |
|
| 1264 | - $order = new WC_Order( $order_id ); |
|
| 1263 | + public function remove_active_course($order_id) { |
|
| 1264 | + $order = new WC_Order($order_id); |
|
| 1265 | 1265 | |
| 1266 | - foreach ( $order->get_items() as $item ) { |
|
| 1267 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
| 1266 | + foreach ($order->get_items() as $item) { |
|
| 1267 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
| 1268 | 1268 | // If item has variation_id then its a variation of the product |
| 1269 | 1269 | $item_id = $item['variation_id']; |
| 1270 | 1270 | } else { |
@@ -1272,11 +1272,11 @@ discard block |
||
| 1272 | 1272 | $item_id = $item['product_id']; |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | - if ( $item_id > 0 ) { |
|
| 1275 | + if ($item_id > 0) { |
|
| 1276 | 1276 | |
| 1277 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
| 1277 | + $user_id = get_post_meta($order_id, '_customer_user', true); |
|
| 1278 | 1278 | |
| 1279 | - if( $user_id ) { |
|
| 1279 | + if ($user_id) { |
|
| 1280 | 1280 | |
| 1281 | 1281 | // Get all courses for product |
| 1282 | 1282 | $args = array( |
@@ -1292,13 +1292,13 @@ discard block |
||
| 1292 | 1292 | 'order' => 'ASC', |
| 1293 | 1293 | 'fields' => 'ids', |
| 1294 | 1294 | ); |
| 1295 | - $course_ids = get_posts( $args ); |
|
| 1295 | + $course_ids = get_posts($args); |
|
| 1296 | 1296 | |
| 1297 | - if( $course_ids && count( $course_ids ) > 0 ) { |
|
| 1298 | - foreach( $course_ids as $course_id ) { |
|
| 1297 | + if ($course_ids && count($course_ids) > 0) { |
|
| 1298 | + foreach ($course_ids as $course_id) { |
|
| 1299 | 1299 | |
| 1300 | 1300 | // Remove all course user meta |
| 1301 | - Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
| 1301 | + Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id); |
|
| 1302 | 1302 | |
| 1303 | 1303 | } // End For Loop |
| 1304 | 1304 | } // End If Statement |
@@ -1314,16 +1314,16 @@ discard block |
||
| 1314 | 1314 | * @param integer $user_id User ID |
| 1315 | 1315 | * @return void |
| 1316 | 1316 | */ |
| 1317 | - public function activate_purchased_courses( $user_id = 0 ) { |
|
| 1317 | + public function activate_purchased_courses($user_id = 0) { |
|
| 1318 | 1318 | |
| 1319 | - if( $user_id ) { |
|
| 1319 | + if ($user_id) { |
|
| 1320 | 1320 | |
| 1321 | - if( Sensei_WC::is_woocommerce_active() ) { |
|
| 1321 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 1322 | 1322 | |
| 1323 | 1323 | // Get all user's orders |
| 1324 | 1324 | $order_args = array( |
| 1325 | 1325 | 'post_type' => 'shop_order', |
| 1326 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
| 1326 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
| 1327 | 1327 | 'posts_per_page' => -1, |
| 1328 | 1328 | 'meta_query' => array( |
| 1329 | 1329 | array( |
@@ -1333,25 +1333,25 @@ discard block |
||
| 1333 | 1333 | ), |
| 1334 | 1334 | ); |
| 1335 | 1335 | |
| 1336 | - $orders = get_posts( $order_args ); |
|
| 1336 | + $orders = get_posts($order_args); |
|
| 1337 | 1337 | |
| 1338 | 1338 | $product_ids = array(); |
| 1339 | 1339 | $order_ids = array(); |
| 1340 | 1340 | |
| 1341 | - foreach( $orders as $post_id ) { |
|
| 1341 | + foreach ($orders as $post_id) { |
|
| 1342 | 1342 | |
| 1343 | 1343 | // Only process each order once |
| 1344 | - $processed = get_post_meta( $post_id, 'sensei_products_processed', true ); |
|
| 1344 | + $processed = get_post_meta($post_id, 'sensei_products_processed', true); |
|
| 1345 | 1345 | |
| 1346 | - if( $processed && $processed == 'processed' ) { |
|
| 1346 | + if ($processed && $processed == 'processed') { |
|
| 1347 | 1347 | continue; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | 1350 | // Get course product IDs from order |
| 1351 | - $order = new WC_Order( $post_id ); |
|
| 1351 | + $order = new WC_Order($post_id); |
|
| 1352 | 1352 | |
| 1353 | 1353 | $items = $order->get_items(); |
| 1354 | - foreach( $items as $item ) { |
|
| 1354 | + foreach ($items as $item) { |
|
| 1355 | 1355 | if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
| 1356 | 1356 | $item_id = $item['variation_id']; |
| 1357 | 1357 | $product_type = 'variation'; |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | $order_ids[] = $post_id; |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | - if( count( $product_ids ) > 0 ) { |
|
| 1368 | + if (count($product_ids) > 0) { |
|
| 1369 | 1369 | |
| 1370 | 1370 | // Get all courses from user's orders |
| 1371 | 1371 | $course_args = array( |
@@ -1382,31 +1382,31 @@ discard block |
||
| 1382 | 1382 | 'order' => 'ASC', |
| 1383 | 1383 | 'fields' => 'ids', |
| 1384 | 1384 | ); |
| 1385 | - $course_ids = get_posts( $course_args ); |
|
| 1385 | + $course_ids = get_posts($course_args); |
|
| 1386 | 1386 | |
| 1387 | - foreach( $course_ids as $course_id ) { |
|
| 1387 | + foreach ($course_ids as $course_id) { |
|
| 1388 | 1388 | |
| 1389 | - $user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id ); |
|
| 1389 | + $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id); |
|
| 1390 | 1390 | |
| 1391 | 1391 | // Ignore course if already completed |
| 1392 | - if( Sensei_Utils::user_completed_course( $user_course_status ) ) { |
|
| 1392 | + if (Sensei_Utils::user_completed_course($user_course_status)) { |
|
| 1393 | 1393 | continue; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | 1396 | // Ignore course if already started |
| 1397 | - if( $user_course_status ) { |
|
| 1397 | + if ($user_course_status) { |
|
| 1398 | 1398 | continue; |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | // Mark course as started by user |
| 1402 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
| 1402 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | - if( count( $order_ids ) > 0 ) { |
|
| 1407 | - foreach( $order_ids as $order_id ) { |
|
| 1406 | + if (count($order_ids) > 0) { |
|
| 1407 | + foreach ($order_ids as $order_id) { |
|
| 1408 | 1408 | // Mark order as processed |
| 1409 | - update_post_meta( $order_id, 'sensei_products_processed', 'processed' ); |
|
| 1409 | + update_post_meta($order_id, 'sensei_products_processed', 'processed'); |
|
| 1410 | 1410 | } |
| 1411 | 1411 | } |
| 1412 | 1412 | } |
@@ -1420,28 +1420,28 @@ discard block |
||
| 1420 | 1420 | public function activate_purchased_single_course() { |
| 1421 | 1421 | global $post, $current_user; |
| 1422 | 1422 | |
| 1423 | - if( Sensei_WC::is_woocommerce_active() ) { |
|
| 1423 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 1424 | 1424 | |
| 1425 | - if( ! is_user_logged_in() ) return; |
|
| 1426 | - if( ! isset( $post->ID ) ) return; |
|
| 1425 | + if ( ! is_user_logged_in()) return; |
|
| 1426 | + if ( ! isset($post->ID)) return; |
|
| 1427 | 1427 | |
| 1428 | 1428 | $user_id = $current_user->ID; |
| 1429 | 1429 | $course_id = $post->ID; |
| 1430 | - $course_product_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
| 1431 | - if( ! $course_product_id ) { |
|
| 1430 | + $course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true); |
|
| 1431 | + if ( ! $course_product_id) { |
|
| 1432 | 1432 | return; |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | - $user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id ); |
|
| 1435 | + $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id); |
|
| 1436 | 1436 | |
| 1437 | 1437 | // Ignore course if already completed |
| 1438 | - if( Sensei_Utils::user_completed_course( $user_course_status ) ) { |
|
| 1438 | + if (Sensei_Utils::user_completed_course($user_course_status)) { |
|
| 1439 | 1439 | |
| 1440 | 1440 | return; |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | 1443 | // Ignore course if already started |
| 1444 | - if( $user_course_status ) { |
|
| 1444 | + if ($user_course_status) { |
|
| 1445 | 1445 | return; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
@@ -1449,7 +1449,7 @@ discard block |
||
| 1449 | 1449 | $order_args = array( |
| 1450 | 1450 | 'post_type' => 'shop_order', |
| 1451 | 1451 | 'posts_per_page' => -1, |
| 1452 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
| 1452 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
| 1453 | 1453 | 'meta_query' => array( |
| 1454 | 1454 | array( |
| 1455 | 1455 | 'key' => '_customer_user', |
@@ -1458,28 +1458,28 @@ discard block |
||
| 1458 | 1458 | ), |
| 1459 | 1459 | 'fields' => 'ids', |
| 1460 | 1460 | ); |
| 1461 | - $orders = get_posts( $order_args ); |
|
| 1461 | + $orders = get_posts($order_args); |
|
| 1462 | 1462 | |
| 1463 | - foreach( $orders as $order_post_id ) { |
|
| 1463 | + foreach ($orders as $order_post_id) { |
|
| 1464 | 1464 | |
| 1465 | 1465 | // Get course product IDs from order |
| 1466 | - $order = new WC_Order( $order_post_id ); |
|
| 1466 | + $order = new WC_Order($order_post_id); |
|
| 1467 | 1467 | |
| 1468 | 1468 | $items = $order->get_items(); |
| 1469 | - foreach( $items as $item ) { |
|
| 1469 | + foreach ($items as $item) { |
|
| 1470 | 1470 | |
| 1471 | - $product = wc_get_product( $item['product_id'] ); |
|
| 1471 | + $product = wc_get_product($item['product_id']); |
|
| 1472 | 1472 | |
| 1473 | 1473 | // handle product bundles |
| 1474 | - if( is_object( $product ) && $product->is_type('bundle') ){ |
|
| 1474 | + if (is_object($product) && $product->is_type('bundle')) { |
|
| 1475 | 1475 | |
| 1476 | - $bundled_product = new WC_Product_Bundle( $product->id ); |
|
| 1476 | + $bundled_product = new WC_Product_Bundle($product->id); |
|
| 1477 | 1477 | $bundled_items = $bundled_product->get_bundled_items(); |
| 1478 | 1478 | |
| 1479 | - foreach( $bundled_items as $bundled_item ){ |
|
| 1479 | + foreach ($bundled_items as $bundled_item) { |
|
| 1480 | 1480 | |
| 1481 | - if( $bundled_item->product_id == $course_product_id ) { |
|
| 1482 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
| 1481 | + if ($bundled_item->product_id == $course_product_id) { |
|
| 1482 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
| 1483 | 1483 | return; |
| 1484 | 1484 | } |
| 1485 | 1485 | |
@@ -1488,8 +1488,8 @@ discard block |
||
| 1488 | 1488 | } else { |
| 1489 | 1489 | |
| 1490 | 1490 | // handle regular products |
| 1491 | - if( $item['product_id'] == $course_product_id ) { |
|
| 1492 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
| 1491 | + if ($item['product_id'] == $course_product_id) { |
|
| 1492 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
| 1493 | 1493 | return; |
| 1494 | 1494 | } |
| 1495 | 1495 | |
@@ -1505,9 +1505,9 @@ discard block |
||
| 1505 | 1505 | * @param array $args Default arguments |
| 1506 | 1506 | * @return array Modified arguments |
| 1507 | 1507 | */ |
| 1508 | - public function hide_sensei_activity( $args = array() ) { |
|
| 1508 | + public function hide_sensei_activity($args = array()) { |
|
| 1509 | 1509 | |
| 1510 | - if( is_singular( 'lesson' ) || is_singular( 'course' ) ) { |
|
| 1510 | + if (is_singular('lesson') || is_singular('course')) { |
|
| 1511 | 1511 | $args['type'] = 'comment'; |
| 1512 | 1512 | } |
| 1513 | 1513 | |
@@ -1524,9 +1524,9 @@ discard block |
||
| 1524 | 1524 | |
| 1525 | 1525 | //if not posted from the sensei login form let |
| 1526 | 1526 | // WordPress or any other party handle the failed request |
| 1527 | - if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form'] ){ |
|
| 1527 | + if ( ! isset($_REQUEST['form']) || 'sensei-login' != $_REQUEST['form']) { |
|
| 1528 | 1528 | |
| 1529 | - return ; |
|
| 1529 | + return; |
|
| 1530 | 1530 | |
| 1531 | 1531 | } |
| 1532 | 1532 | |
@@ -1534,9 +1534,9 @@ discard block |
||
| 1534 | 1534 | $referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']); |
| 1535 | 1535 | |
| 1536 | 1536 | // if there's a valid referrer, and it's not the default log-in screen |
| 1537 | - if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){ |
|
| 1537 | + if ( ! empty($referrer) && ! strstr($referrer, 'wp-login') && ! strstr($referrer, 'wp-admin')) { |
|
| 1538 | 1538 | // let's append some information (login=failed) to the URL for the theme to use |
| 1539 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
| 1539 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
| 1540 | 1540 | exit; |
| 1541 | 1541 | } |
| 1542 | 1542 | }// End sensei_login_fail_redirect_to_front_end_login |
@@ -1549,10 +1549,10 @@ discard block |
||
| 1549 | 1549 | function sensei_handle_login_request( ) { |
| 1550 | 1550 | |
| 1551 | 1551 | // Check that it is a sensei login request and if it has a valid nonce |
| 1552 | - if( isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) { |
|
| 1552 | + if (isset($_REQUEST['form']) && 'sensei-login' == $_REQUEST['form']) { |
|
| 1553 | 1553 | |
| 1554 | 1554 | // Validate the login request nonce |
| 1555 | - if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){ |
|
| 1555 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'sensei-login')) { |
|
| 1556 | 1556 | return; |
| 1557 | 1557 | } |
| 1558 | 1558 | |
@@ -1560,48 +1560,48 @@ discard block |
||
| 1560 | 1560 | $referrer = $_REQUEST['_wp_http_referer']; |
| 1561 | 1561 | //$redirect = $_REQUEST['_sensei_redirect']; |
| 1562 | 1562 | |
| 1563 | - if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) ) |
|
| 1564 | - && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){ |
|
| 1563 | + if ((isset($_REQUEST['log']) && ! empty($_REQUEST['log'])) |
|
| 1564 | + && (isset($_REQUEST['pwd']) && ! empty($_REQUEST['pwd']))) { |
|
| 1565 | 1565 | |
| 1566 | 1566 | // when the user has entered a password or username do the sensei login |
| 1567 | 1567 | $creds = array(); |
| 1568 | 1568 | |
| 1569 | 1569 | // check if the requests login is an email address |
| 1570 | - if( is_email( trim( $_REQUEST['log'] ) ) ){ |
|
| 1570 | + if (is_email(trim($_REQUEST['log']))) { |
|
| 1571 | 1571 | // query wordpress for the users details |
| 1572 | - $user = get_user_by( 'email', sanitize_email( $_REQUEST['log'] ) ); |
|
| 1572 | + $user = get_user_by('email', sanitize_email($_REQUEST['log'])); |
|
| 1573 | 1573 | |
| 1574 | 1574 | // validate the user object |
| 1575 | - if( !$user ){ |
|
| 1575 | + if ( ! $user) { |
|
| 1576 | 1576 | |
| 1577 | 1577 | // the email doesnt exist |
| 1578 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
| 1578 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
| 1579 | 1579 | exit; |
| 1580 | 1580 | |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | 1583 | //assigne the username to the creds array for further processing |
| 1584 | - $creds['user_login'] = $user->user_login ; |
|
| 1584 | + $creds['user_login'] = $user->user_login; |
|
| 1585 | 1585 | |
| 1586 | - }else{ |
|
| 1586 | + } else { |
|
| 1587 | 1587 | |
| 1588 | 1588 | // process this as a default username login |
| 1589 | - $creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ; |
|
| 1589 | + $creds['user_login'] = sanitize_text_field($_REQUEST['log']); |
|
| 1590 | 1590 | |
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | // get setup the rest of the creds array |
| 1594 | - $creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] ); |
|
| 1595 | - $creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ; |
|
| 1594 | + $creds['user_password'] = sanitize_text_field($_REQUEST['pwd']); |
|
| 1595 | + $creds['remember'] = isset($_REQUEST['rememberme']) ? true : false; |
|
| 1596 | 1596 | |
| 1597 | 1597 | //attempt logging in with the given details |
| 1598 | 1598 | $secure_cookie = is_ssl() ? true : false; |
| 1599 | - $user = wp_signon( $creds, $secure_cookie ); |
|
| 1599 | + $user = wp_signon($creds, $secure_cookie); |
|
| 1600 | 1600 | |
| 1601 | - if ( is_wp_error($user) ){ // on login failure |
|
| 1602 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
| 1601 | + if (is_wp_error($user)) { // on login failure |
|
| 1602 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
| 1603 | 1603 | exit; |
| 1604 | - }else{ // on login success |
|
| 1604 | + } else { // on login success |
|
| 1605 | 1605 | |
| 1606 | 1606 | /** |
| 1607 | 1607 | * change the redirect url programatically |
@@ -1611,21 +1611,21 @@ discard block |
||
| 1611 | 1611 | * @param string $referrer the page where the current url wheresensei login form was posted from |
| 1612 | 1612 | */ |
| 1613 | 1613 | |
| 1614 | - $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) ); |
|
| 1614 | + $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg('login', $referrer)); |
|
| 1615 | 1615 | |
| 1616 | - wp_redirect( esc_url_raw( $success_redirect_url ) ); |
|
| 1616 | + wp_redirect(esc_url_raw($success_redirect_url)); |
|
| 1617 | 1617 | exit; |
| 1618 | 1618 | |
| 1619 | 1619 | } // end is_wp_error($user) |
| 1620 | 1620 | |
| 1621 | - }else{ // if username or password is empty |
|
| 1621 | + } else { // if username or password is empty |
|
| 1622 | 1622 | |
| 1623 | - wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) ); |
|
| 1623 | + wp_redirect(esc_url_raw(add_query_arg('login', 'emptyfields', $referrer))); |
|
| 1624 | 1624 | exit; |
| 1625 | 1625 | |
| 1626 | 1626 | } // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty |
| 1627 | 1627 | |
| 1628 | - }elseif( ( isset( $_GET['login'] ) ) ) { |
|
| 1628 | + }elseif ((isset($_GET['login']))) { |
|
| 1629 | 1629 | // else if this request is a redircect from a previously faile login request |
| 1630 | 1630 | $this->login_message_process(); |
| 1631 | 1631 | |
@@ -1644,87 +1644,87 @@ discard block |
||
| 1644 | 1644 | * @return void redirect |
| 1645 | 1645 | * |
| 1646 | 1646 | */ |
| 1647 | - public function sensei_process_registration(){ |
|
| 1647 | + public function sensei_process_registration() { |
|
| 1648 | 1648 | global $current_user; |
| 1649 | 1649 | // check the for the sensei specific registration requests |
| 1650 | - if( !isset( $_POST['sensei_reg_username'] ) && ! isset( $_POST['sensei_reg_email'] ) && !isset( $_POST['sensei_reg_password'] )){ |
|
| 1650 | + if ( ! isset($_POST['sensei_reg_username']) && ! isset($_POST['sensei_reg_email']) && ! isset($_POST['sensei_reg_password'])) { |
|
| 1651 | 1651 | // exit if this is not a sensei registration request |
| 1652 | - return ; |
|
| 1652 | + return; |
|
| 1653 | 1653 | } |
| 1654 | 1654 | // check for spam throw cheating huh |
| 1655 | - if( isset( $_POST['email_2'] ) && '' !== $_POST['email_2'] ){ |
|
| 1655 | + if (isset($_POST['email_2']) && '' !== $_POST['email_2']) { |
|
| 1656 | 1656 | $message = 'Error: The spam field should be empty'; |
| 1657 | - Sensei()->notices->add_notice( $message, 'alert'); |
|
| 1657 | + Sensei()->notices->add_notice($message, 'alert'); |
|
| 1658 | 1658 | return; |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | // retreive form variables |
| 1662 | - $new_user_name = sanitize_user( $_POST['sensei_reg_username'] ); |
|
| 1663 | - $new_user_email = $_POST['sensei_reg_email']; |
|
| 1664 | - $new_user_password = $_POST['sensei_reg_password']; |
|
| 1662 | + $new_user_name = sanitize_user($_POST['sensei_reg_username']); |
|
| 1663 | + $new_user_email = $_POST['sensei_reg_email']; |
|
| 1664 | + $new_user_password = $_POST['sensei_reg_password']; |
|
| 1665 | 1665 | |
| 1666 | 1666 | // Check the username |
| 1667 | 1667 | $username_error_notice = ''; |
| 1668 | - if ( $new_user_name == '' ) { |
|
| 1669 | - $username_error_notice = __( '<strong>ERROR</strong>: Please enter a username.' ); |
|
| 1670 | - } elseif ( ! validate_username( $new_user_name ) ) { |
|
| 1671 | - $username_error_notice = __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ); |
|
| 1672 | - } elseif ( username_exists( $new_user_name ) ) { |
|
| 1673 | - $username_error_notice = __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ); |
|
| 1668 | + if ($new_user_name == '') { |
|
| 1669 | + $username_error_notice = __('<strong>ERROR</strong>: Please enter a username.'); |
|
| 1670 | + } elseif ( ! validate_username($new_user_name)) { |
|
| 1671 | + $username_error_notice = __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.'); |
|
| 1672 | + } elseif (username_exists($new_user_name)) { |
|
| 1673 | + $username_error_notice = __('<strong>ERROR</strong>: This username is already registered. Please choose another one.'); |
|
| 1674 | 1674 | } |
| 1675 | 1675 | |
| 1676 | 1676 | // exit on username error |
| 1677 | - if( '' !== $username_error_notice ){ |
|
| 1678 | - Sensei()->notices->add_notice( $username_error_notice , 'alert'); |
|
| 1677 | + if ('' !== $username_error_notice) { |
|
| 1678 | + Sensei()->notices->add_notice($username_error_notice, 'alert'); |
|
| 1679 | 1679 | return; |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | // Check the e-mail address |
| 1683 | 1683 | $email_error_notice = ''; |
| 1684 | - if ( $new_user_email == '' ) { |
|
| 1685 | - $email_error_notice = __( '<strong>ERROR</strong>: Please type your e-mail address.' ); |
|
| 1686 | - } elseif ( ! is_email( $new_user_email ) ) { |
|
| 1687 | - $email_error_notice = __( '<strong>ERROR</strong>: The email address isn’t correct.' ); |
|
| 1688 | - } elseif ( email_exists( $new_user_email ) ) { |
|
| 1689 | - $email_error_notice = __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ); |
|
| 1684 | + if ($new_user_email == '') { |
|
| 1685 | + $email_error_notice = __('<strong>ERROR</strong>: Please type your e-mail address.'); |
|
| 1686 | + } elseif ( ! is_email($new_user_email)) { |
|
| 1687 | + $email_error_notice = __('<strong>ERROR</strong>: The email address isn’t correct.'); |
|
| 1688 | + } elseif (email_exists($new_user_email)) { |
|
| 1689 | + $email_error_notice = __('<strong>ERROR</strong>: This email is already registered, please choose another one.'); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | // exit on email address error |
| 1693 | - if( '' !== $email_error_notice ){ |
|
| 1694 | - Sensei()->notices->add_notice( $email_error_notice , 'alert'); |
|
| 1693 | + if ('' !== $email_error_notice) { |
|
| 1694 | + Sensei()->notices->add_notice($email_error_notice, 'alert'); |
|
| 1695 | 1695 | return; |
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | //check user password |
| 1699 | 1699 | |
| 1700 | 1700 | // exit on email address error |
| 1701 | - if( empty( $new_user_password ) ){ |
|
| 1702 | - Sensei()->notices->add_notice( __( '<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.' ) , 'alert'); |
|
| 1701 | + if (empty($new_user_password)) { |
|
| 1702 | + Sensei()->notices->add_notice(__('<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.'), 'alert'); |
|
| 1703 | 1703 | return; |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | 1706 | // register user |
| 1707 | - $user_id = wp_create_user( $new_user_name, $new_user_password, $new_user_email ); |
|
| 1708 | - if ( ! $user_id || is_wp_error( $user_id ) ) { |
|
| 1709 | - Sensei()->notices->add_notice( sprintf( __( '<strong>ERROR</strong>: Couldn\'t register you… please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ), 'alert'); |
|
| 1707 | + $user_id = wp_create_user($new_user_name, $new_user_password, $new_user_email); |
|
| 1708 | + if ( ! $user_id || is_wp_error($user_id)) { |
|
| 1709 | + Sensei()->notices->add_notice(sprintf(__('<strong>ERROR</strong>: Couldn\'t register you… please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')), 'alert'); |
|
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | // notify the user |
| 1713 | - wp_new_user_notification( $user_id, $new_user_password ); |
|
| 1713 | + wp_new_user_notification($user_id, $new_user_password); |
|
| 1714 | 1714 | |
| 1715 | 1715 | // set global current user aka log the user in |
| 1716 | - $current_user = get_user_by( 'id', $user_id ); |
|
| 1717 | - wp_set_auth_cookie( $user_id, true ); |
|
| 1716 | + $current_user = get_user_by('id', $user_id); |
|
| 1717 | + wp_set_auth_cookie($user_id, true); |
|
| 1718 | 1718 | |
| 1719 | 1719 | // Redirect |
| 1720 | 1720 | global $wp; |
| 1721 | - if ( wp_get_referer() ) { |
|
| 1722 | - $redirect = esc_url( wp_get_referer() ); |
|
| 1721 | + if (wp_get_referer()) { |
|
| 1722 | + $redirect = esc_url(wp_get_referer()); |
|
| 1723 | 1723 | } else { |
| 1724 | - $redirect = esc_url( home_url( $wp->request ) ); |
|
| 1724 | + $redirect = esc_url(home_url($wp->request)); |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | - wp_redirect( apply_filters( 'sensei_registration_redirect', $redirect ) ); |
|
| 1727 | + wp_redirect(apply_filters('sensei_registration_redirect', $redirect)); |
|
| 1728 | 1728 | exit; |
| 1729 | 1729 | |
| 1730 | 1730 | } // end sensei_process_registration)() |
@@ -1735,23 +1735,23 @@ discard block |
||
| 1735 | 1735 | * @return void redirect |
| 1736 | 1736 | * @since 1.7.0 |
| 1737 | 1737 | */ |
| 1738 | - public function login_message_process(){ |
|
| 1738 | + public function login_message_process() { |
|
| 1739 | 1739 | |
| 1740 | 1740 | // setup the message variables |
| 1741 | 1741 | $message = ''; |
| 1742 | 1742 | |
| 1743 | 1743 | //only output message if the url contains login=failed and login=emptyfields |
| 1744 | 1744 | |
| 1745 | - if( $_GET['login'] == 'failed' ){ |
|
| 1745 | + if ($_GET['login'] == 'failed') { |
|
| 1746 | 1746 | |
| 1747 | - $message = __('Incorrect login details', 'woothemes-sensei' ); |
|
| 1747 | + $message = __('Incorrect login details', 'woothemes-sensei'); |
|
| 1748 | 1748 | |
| 1749 | - }elseif( $_GET['login'] == 'emptyfields' ){ |
|
| 1749 | + }elseif ($_GET['login'] == 'emptyfields') { |
|
| 1750 | 1750 | |
| 1751 | - $message= __('Please enter your username and password', 'woothemes-sensei' ); |
|
| 1751 | + $message = __('Please enter your username and password', 'woothemes-sensei'); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | - Sensei()->notices->add_notice( $message, 'alert'); |
|
| 1754 | + Sensei()->notices->add_notice($message, 'alert'); |
|
| 1755 | 1755 | |
| 1756 | 1756 | }// end login_message_process |
| 1757 | 1757 | |
@@ -1763,11 +1763,11 @@ discard block |
||
| 1763 | 1763 | * @return void redirect |
| 1764 | 1764 | * |
| 1765 | 1765 | */ |
| 1766 | - public function sensei_show_admin_bar () { |
|
| 1766 | + public function sensei_show_admin_bar() { |
|
| 1767 | 1767 | |
| 1768 | 1768 | if (current_user_can('edit_courses')) { |
| 1769 | 1769 | |
| 1770 | - add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
| 1770 | + add_filter('woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
| 1771 | 1771 | |
| 1772 | 1772 | } |
| 1773 | 1773 | |
@@ -1780,4 +1780,4 @@ discard block |
||
| 1780 | 1780 | * @ignore only for backward compatibility |
| 1781 | 1781 | * @since 1.9.0 |
| 1782 | 1782 | */ |
| 1783 | -class WooThemes_Sensei_Frontend extends Sensei_Frontend{} |
|
| 1783 | +class WooThemes_Sensei_Frontend extends Sensei_Frontend {} |
|
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Grading Class |
@@ -23,30 +23,30 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param $file |
| 25 | 25 | */ |
| 26 | - public function __construct ( $file ) { |
|
| 27 | - $this->name = __( 'Grading', 'woothemes-sensei' ); |
|
| 26 | + public function __construct($file) { |
|
| 27 | + $this->name = __('Grading', 'woothemes-sensei'); |
|
| 28 | 28 | $this->file = $file; |
| 29 | 29 | $this->page_slug = 'sensei_grading'; |
| 30 | 30 | |
| 31 | 31 | // Admin functions |
| 32 | - if ( is_admin() ) { |
|
| 33 | - add_action( 'admin_menu', array( $this, 'grading_admin_menu' ), 20); |
|
| 34 | - add_action( 'grading_wrapper_container', array( $this, 'wrapper_container' ) ); |
|
| 35 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 36 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 37 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 32 | + if (is_admin()) { |
|
| 33 | + add_action('admin_menu', array($this, 'grading_admin_menu'), 20); |
|
| 34 | + add_action('grading_wrapper_container', array($this, 'wrapper_container')); |
|
| 35 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 36 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 37 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - add_action( 'admin_init', array( $this, 'admin_process_grading_submission' ) ); |
|
| 40 | + add_action('admin_init', array($this, 'admin_process_grading_submission')); |
|
| 41 | 41 | |
| 42 | - add_action( 'admin_notices', array( $this, 'add_grading_notices' ) ); |
|
| 42 | + add_action('admin_notices', array($this, 'add_grading_notices')); |
|
| 43 | 43 | // add_action( 'sensei_grading_notices', array( $this, 'sensei_grading_notices' ) ); |
| 44 | 44 | } // End If Statement |
| 45 | 45 | |
| 46 | 46 | // Ajax functions |
| 47 | - if ( is_admin() ) { |
|
| 48 | - add_action( 'wp_ajax_get_lessons_dropdown', array( $this, 'get_lessons_dropdown' ) ); |
|
| 49 | - add_action( 'wp_ajax_get_redirect_url', array( $this, 'get_redirect_url' ) ); |
|
| 47 | + if (is_admin()) { |
|
| 48 | + add_action('wp_ajax_get_lessons_dropdown', array($this, 'get_lessons_dropdown')); |
|
| 49 | + add_action('wp_ajax_get_redirect_url', array($this, 'get_redirect_url')); |
|
| 50 | 50 | } // End If Statement |
| 51 | 51 | } // End __construct() |
| 52 | 52 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | public function grading_admin_menu() { |
| 60 | 60 | global $menu; |
| 61 | 61 | |
| 62 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 63 | - $grading_page = add_submenu_page('sensei', __('Grading', 'woothemes-sensei'), __('Grading', 'woothemes-sensei') , 'manage_sensei_grades', $this->page_slug, array( $this, 'grading_page' ) ); |
|
| 62 | + if (current_user_can('manage_sensei_grades')) { |
|
| 63 | + $grading_page = add_submenu_page('sensei', __('Grading', 'woothemes-sensei'), __('Grading', 'woothemes-sensei'), 'manage_sensei_grades', $this->page_slug, array($this, 'grading_page')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | } // End grading_admin_menu() |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * @since 1.3.0 |
| 74 | 74 | * @return void |
| 75 | 75 | */ |
| 76 | - public function enqueue_scripts () { |
|
| 76 | + public function enqueue_scripts() { |
|
| 77 | 77 | |
| 78 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 78 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 79 | 79 | |
| 80 | 80 | // Load Grading JS |
| 81 | - wp_enqueue_script( 'sensei-grading-general', Sensei()->plugin_url . 'assets/js/grading-general' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
| 81 | + wp_enqueue_script('sensei-grading-general', Sensei()->plugin_url.'assets/js/grading-general'.$suffix.'.js', array('jquery'), Sensei()->version); |
|
| 82 | 82 | |
| 83 | 83 | } // End enqueue_scripts() |
| 84 | 84 | |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | * @since 1.0.0 |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | - public function enqueue_styles () { |
|
| 93 | + public function enqueue_styles() { |
|
| 94 | 94 | |
| 95 | - wp_enqueue_style( Sensei()->token . '-admin' ); |
|
| 95 | + wp_enqueue_style(Sensei()->token.'-admin'); |
|
| 96 | 96 | |
| 97 | - wp_enqueue_style( 'woothemes-sensei-settings-api', Sensei()->plugin_url . 'assets/css/settings.css', '', Sensei()->version ); |
|
| 97 | + wp_enqueue_style('woothemes-sensei-settings-api', Sensei()->plugin_url.'assets/css/settings.css', '', Sensei()->version); |
|
| 98 | 98 | |
| 99 | 99 | } // End enqueue_styles() |
| 100 | 100 | |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | public function load_data_table_files() { |
| 107 | 107 | |
| 108 | 108 | // Load Grading Classes |
| 109 | - $classes_to_load = array( 'list-table', |
|
| 109 | + $classes_to_load = array('list-table', |
|
| 110 | 110 | 'grading-main', |
| 111 | 111 | 'grading-user-quiz' |
| 112 | 112 | ); |
| 113 | - foreach ( $classes_to_load as $class_file ) { |
|
| 114 | - Sensei()->load_class( $class_file ); |
|
| 113 | + foreach ($classes_to_load as $class_file) { |
|
| 114 | + Sensei()->load_class($class_file); |
|
| 115 | 115 | } // End For Loop |
| 116 | 116 | } // End load_data_table_files() |
| 117 | 117 | |
@@ -123,16 +123,16 @@ discard block |
||
| 123 | 123 | * @param undefined $optional_data optional constructor arguments |
| 124 | 124 | * @return object class instance object |
| 125 | 125 | */ |
| 126 | - public function load_data_object( $name = '', $data = 0, $optional_data = null ) { |
|
| 126 | + public function load_data_object($name = '', $data = 0, $optional_data = null) { |
|
| 127 | 127 | // Load Analysis data |
| 128 | - $object_name = 'WooThemes_Sensei_Grading_' . $name; |
|
| 129 | - if ( is_null($optional_data) ) { |
|
| 130 | - $sensei_grading_object = new $object_name( $data ); |
|
| 128 | + $object_name = 'WooThemes_Sensei_Grading_'.$name; |
|
| 129 | + if (is_null($optional_data)) { |
|
| 130 | + $sensei_grading_object = new $object_name($data); |
|
| 131 | 131 | } |
| 132 | 132 | else { |
| 133 | - $sensei_grading_object = new $object_name( $data, $optional_data ); |
|
| 133 | + $sensei_grading_object = new $object_name($data, $optional_data); |
|
| 134 | 134 | } // End If Statement |
| 135 | - if ( 'Main' == $name ) { |
|
| 135 | + if ('Main' == $name) { |
|
| 136 | 136 | $sensei_grading_object->prepare_items(); |
| 137 | 137 | } // End If Statement |
| 138 | 138 | return $sensei_grading_object; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function grading_page() { |
| 148 | 148 | |
| 149 | - if ( isset( $_GET['quiz_id'] ) && 0 < intval( $_GET['quiz_id'] ) && isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) { |
|
| 149 | + if (isset($_GET['quiz_id']) && 0 < intval($_GET['quiz_id']) && isset($_GET['user']) && 0 < intval($_GET['user'])) { |
|
| 150 | 150 | $this->grading_user_quiz_view(); |
| 151 | 151 | } |
| 152 | 152 | else { |
@@ -162,23 +162,23 @@ discard block |
||
| 162 | 162 | public function grading_default_view() { |
| 163 | 163 | |
| 164 | 164 | // Load Grading data |
| 165 | - if( !empty( $_GET['course_id'] ) ) { |
|
| 166 | - $course_id = intval( $_GET['course_id'] ); |
|
| 165 | + if ( ! empty($_GET['course_id'])) { |
|
| 166 | + $course_id = intval($_GET['course_id']); |
|
| 167 | 167 | } |
| 168 | - if( !empty( $_GET['lesson_id'] ) ) { |
|
| 169 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 168 | + if ( ! empty($_GET['lesson_id'])) { |
|
| 169 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 170 | 170 | } |
| 171 | - if( !empty( $_GET['user_id'] ) ) { |
|
| 172 | - $user_id = intval( $_GET['user_id'] ); |
|
| 171 | + if ( ! empty($_GET['user_id'])) { |
|
| 172 | + $user_id = intval($_GET['user_id']); |
|
| 173 | 173 | } |
| 174 | - if( !empty( $_GET['view'] ) ) { |
|
| 175 | - $view = esc_html( $_GET['view'] ); |
|
| 174 | + if ( ! empty($_GET['view'])) { |
|
| 175 | + $view = esc_html($_GET['view']); |
|
| 176 | 176 | } |
| 177 | - $sensei_grading_overview = $this->load_data_object( 'Main', compact( 'course_id', 'lesson_id', 'user_id', 'view' ) ); |
|
| 177 | + $sensei_grading_overview = $this->load_data_object('Main', compact('course_id', 'lesson_id', 'user_id', 'view')); |
|
| 178 | 178 | |
| 179 | 179 | // Wrappers |
| 180 | - do_action( 'grading_before_container' ); |
|
| 181 | - do_action( 'grading_wrapper_container', 'top' ); |
|
| 180 | + do_action('grading_before_container'); |
|
| 181 | + do_action('grading_wrapper_container', 'top'); |
|
| 182 | 182 | $this->grading_headers(); |
| 183 | 183 | ?> |
| 184 | 184 | <div id="poststuff" class="sensei-grading-wrap"> |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | <?php $sensei_grading_overview->display(); ?> |
| 187 | 187 | </div> |
| 188 | 188 | <div class="sensei-grading-extra"> |
| 189 | - <?php do_action( 'sensei_grading_extra' ); ?> |
|
| 189 | + <?php do_action('sensei_grading_extra'); ?> |
|
| 190 | 190 | </div> |
| 191 | 191 | </div> |
| 192 | 192 | <?php |
| 193 | - do_action( 'grading_wrapper_container', 'bottom' ); |
|
| 194 | - do_action( 'grading_after_container' ); |
|
| 193 | + do_action('grading_wrapper_container', 'bottom'); |
|
| 194 | + do_action('grading_after_container'); |
|
| 195 | 195 | } // End grading_default_view() |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -204,17 +204,17 @@ discard block |
||
| 204 | 204 | // Load Grading data |
| 205 | 205 | $user_id = 0; |
| 206 | 206 | $quiz_id = 0; |
| 207 | - if( isset( $_GET['user'] ) ) { |
|
| 208 | - $user_id = intval( $_GET['user'] ); |
|
| 207 | + if (isset($_GET['user'])) { |
|
| 208 | + $user_id = intval($_GET['user']); |
|
| 209 | 209 | } |
| 210 | - if( isset( $_GET['quiz_id'] ) ) { |
|
| 211 | - $quiz_id = intval( $_GET['quiz_id'] ); |
|
| 210 | + if (isset($_GET['quiz_id'])) { |
|
| 211 | + $quiz_id = intval($_GET['quiz_id']); |
|
| 212 | 212 | } |
| 213 | - $sensei_grading_user_profile = $this->load_data_object( 'User_Quiz', $user_id, $quiz_id ); |
|
| 213 | + $sensei_grading_user_profile = $this->load_data_object('User_Quiz', $user_id, $quiz_id); |
|
| 214 | 214 | // Wrappers |
| 215 | - do_action( 'grading_before_container' ); |
|
| 216 | - do_action( 'grading_wrapper_container', 'top' ); |
|
| 217 | - $this->grading_headers( array( 'nav' => 'user_quiz' ) ); |
|
| 215 | + do_action('grading_before_container'); |
|
| 216 | + do_action('grading_wrapper_container', 'top'); |
|
| 217 | + $this->grading_headers(array('nav' => 'user_quiz')); |
|
| 218 | 218 | ?> |
| 219 | 219 | <div id="poststuff" class="sensei-grading-wrap user-profile"> |
| 220 | 220 | <div class="sensei-grading-main"> |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | </div> |
| 224 | 224 | </div> |
| 225 | 225 | <?php |
| 226 | - do_action( 'grading_wrapper_container', 'bottom' ); |
|
| 227 | - do_action( 'grading_after_container' ); |
|
| 226 | + do_action('grading_wrapper_container', 'bottom'); |
|
| 227 | + do_action('grading_after_container'); |
|
| 228 | 228 | } // End grading_user_quiz_view() |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | * @param array $args |
| 234 | 234 | * @return void |
| 235 | 235 | */ |
| 236 | - public function grading_headers( $args = array( 'nav' => 'default' ) ) { |
|
| 236 | + public function grading_headers($args = array('nav' => 'default')) { |
|
| 237 | 237 | |
| 238 | - $function = 'grading_' . $args['nav'] . '_nav'; |
|
| 238 | + $function = 'grading_'.$args['nav'].'_nav'; |
|
| 239 | 239 | $this->$function(); |
| 240 | 240 | ?> |
| 241 | - <p class="powered-by-woo"><?php _e( 'Powered by', 'woothemes-sensei' ); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p> |
|
| 241 | + <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p> |
|
| 242 | 242 | <?php |
| 243 | - do_action( 'sensei_grading_after_headers' ); |
|
| 243 | + do_action('sensei_grading_after_headers'); |
|
| 244 | 244 | } // End grading_headers() |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | * @param $which string |
| 250 | 250 | * @return void |
| 251 | 251 | */ |
| 252 | - public function wrapper_container( $which ) { |
|
| 253 | - if ( 'top' == $which ) { |
|
| 252 | + public function wrapper_container($which) { |
|
| 253 | + if ('top' == $which) { |
|
| 254 | 254 | ?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php |
| 255 | - } elseif ( 'bottom' == $which ) { |
|
| 255 | + } elseif ('bottom' == $which) { |
|
| 256 | 256 | ?></div><!--/#woothemes-sensei--><?php |
| 257 | 257 | } // End If Statement |
| 258 | 258 | } // End wrapper_container() |
@@ -265,29 +265,29 @@ discard block |
||
| 265 | 265 | public function grading_default_nav() { |
| 266 | 266 | global $wp_version; |
| 267 | 267 | |
| 268 | - $title = sprintf( '<a href="%s">%s</a>', esc_url(add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ) ), esc_html( $this->name ) ); |
|
| 269 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 270 | - $course_id = intval( $_GET['course_id'] ); |
|
| 271 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
| 272 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 273 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 268 | + $title = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('page' => $this->page_slug), admin_url('admin.php'))), esc_html($this->name)); |
|
| 269 | + if (isset($_GET['course_id'])) { |
|
| 270 | + $course_id = intval($_GET['course_id']); |
|
| 271 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
| 272 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 273 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 274 | 274 | } |
| 275 | 275 | else { |
| 276 | - $title .= sprintf( ' <span class="course-title">> %s</span>', get_the_title( $course_id ) ); |
|
| 276 | + $title .= sprintf(' <span class="course-title">> %s</span>', get_the_title($course_id)); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | - if ( isset( $_GET['lesson_id'] ) ) { |
|
| 280 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 281 | - $title .= ' <span class="lesson-title">> ' . get_the_title( intval( $lesson_id ) ) . '</span>'; |
|
| 279 | + if (isset($_GET['lesson_id'])) { |
|
| 280 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 281 | + $title .= ' <span class="lesson-title">> '.get_the_title(intval($lesson_id)).'</span>'; |
|
| 282 | 282 | } |
| 283 | - if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) { |
|
| 283 | + if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) { |
|
| 284 | 284 | |
| 285 | - $user_name = Sensei_Learner::get_full_name( $_GET['user_id'] ); |
|
| 286 | - $title .= ' <span class="user-title">> ' . $user_name . '</span>'; |
|
| 285 | + $user_name = Sensei_Learner::get_full_name($_GET['user_id']); |
|
| 286 | + $title .= ' <span class="user-title">> '.$user_name.'</span>'; |
|
| 287 | 287 | |
| 288 | 288 | } // End If Statement |
| 289 | 289 | ?> |
| 290 | - <h2><?php echo apply_filters( 'sensei_grading_nav_title', $title ); ?></h2> |
|
| 290 | + <h2><?php echo apply_filters('sensei_grading_nav_title', $title); ?></h2> |
|
| 291 | 291 | <?php |
| 292 | 292 | } // End grading_default_nav() |
| 293 | 293 | |
@@ -299,29 +299,29 @@ discard block |
||
| 299 | 299 | public function grading_user_quiz_nav() { |
| 300 | 300 | global $wp_version; |
| 301 | 301 | |
| 302 | - $title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) ); |
|
| 303 | - if ( isset( $_GET['quiz_id'] ) ) { |
|
| 304 | - $quiz_id = intval( $_GET['quiz_id'] ); |
|
| 305 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 306 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 307 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
| 308 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 309 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 302 | + $title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name)); |
|
| 303 | + if (isset($_GET['quiz_id'])) { |
|
| 304 | + $quiz_id = intval($_GET['quiz_id']); |
|
| 305 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 306 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 307 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
| 308 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 309 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 310 | 310 | } |
| 311 | 311 | else { |
| 312 | - $title .= sprintf( ' <span class="course-title">> %s</span>', get_the_title( $course_id ) ); |
|
| 312 | + $title .= sprintf(' <span class="course-title">> %s</span>', get_the_title($course_id)); |
|
| 313 | 313 | } |
| 314 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id ), admin_url( 'admin.php' ) ); |
|
| 315 | - $title .= sprintf( ' <span class="lesson-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $lesson_id ) ); |
|
| 314 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id), admin_url('admin.php')); |
|
| 315 | + $title .= sprintf(' <span class="lesson-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($lesson_id)); |
|
| 316 | 316 | } |
| 317 | - if ( isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) { |
|
| 317 | + if (isset($_GET['user']) && 0 < intval($_GET['user'])) { |
|
| 318 | 318 | |
| 319 | - $user_name = Sensei_Learner::get_full_name( $_GET['user'] ); |
|
| 320 | - $title .= ' <span class="user-title">> ' . $user_name . '</span>'; |
|
| 319 | + $user_name = Sensei_Learner::get_full_name($_GET['user']); |
|
| 320 | + $title .= ' <span class="user-title">> '.$user_name.'</span>'; |
|
| 321 | 321 | |
| 322 | 322 | } // End If Statement |
| 323 | 323 | ?> |
| 324 | - <h2><?php echo apply_filters( 'sensei_grading_nav_title', $title ); ?></h2> |
|
| 324 | + <h2><?php echo apply_filters('sensei_grading_nav_title', $title); ?></h2> |
|
| 325 | 325 | <?php |
| 326 | 326 | } // End grading_user_quiz_nav() |
| 327 | 327 | |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | * @since 1.7.0 |
| 331 | 331 | * @return array |
| 332 | 332 | */ |
| 333 | - public function get_stati( $type ) { |
|
| 333 | + public function get_stati($type) { |
|
| 334 | 334 | $statuses = array(); |
| 335 | - switch( $type ) { |
|
| 335 | + switch ($type) { |
|
| 336 | 336 | case 'course' : |
| 337 | 337 | $statuses = array( |
| 338 | 338 | 'in-progress', |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @param array $args (default: array()) |
| 363 | 363 | * @return object |
| 364 | 364 | */ |
| 365 | - public function count_statuses( $args = array() ) { |
|
| 365 | + public function count_statuses($args = array()) { |
|
| 366 | 366 | global $wpdb; |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -373,71 +373,71 @@ discard block |
||
| 373 | 373 | * @since 1.8.0 |
| 374 | 374 | * @param array $args |
| 375 | 375 | */ |
| 376 | - $args = apply_filters( 'sensei_count_statuses_args', $args ); |
|
| 376 | + $args = apply_filters('sensei_count_statuses_args', $args); |
|
| 377 | 377 | |
| 378 | - if ( 'course' == $args['type'] ) { |
|
| 378 | + if ('course' == $args['type']) { |
|
| 379 | 379 | $type = 'sensei_course_status'; |
| 380 | 380 | } |
| 381 | 381 | else { |
| 382 | 382 | $type = 'sensei_lesson_status'; |
| 383 | 383 | } |
| 384 | - $cache_key = 'sensei-' . $args['type'] . '-statuses'; |
|
| 384 | + $cache_key = 'sensei-'.$args['type'].'-statuses'; |
|
| 385 | 385 | |
| 386 | 386 | $query = "SELECT comment_approved, COUNT( * ) AS total FROM {$wpdb->comments} WHERE comment_type = %s "; |
| 387 | 387 | |
| 388 | 388 | // Restrict to specific posts |
| 389 | - if ( isset( $args['post__in'] ) && !empty( $args['post__in'] ) && is_array( $args['post__in'] ) ) { |
|
| 390 | - $query .= ' AND comment_post_ID IN (' . implode( ',', array_map( 'absint', $args['post__in'] ) ) . ')'; |
|
| 389 | + if (isset($args['post__in']) && ! empty($args['post__in']) && is_array($args['post__in'])) { |
|
| 390 | + $query .= ' AND comment_post_ID IN ('.implode(',', array_map('absint', $args['post__in'])).')'; |
|
| 391 | 391 | } |
| 392 | - elseif ( !empty( $args['post_id'] ) ) { |
|
| 393 | - $query .= $wpdb->prepare( ' AND comment_post_ID = %d', $args['post_id'] ); |
|
| 392 | + elseif ( ! empty($args['post_id'])) { |
|
| 393 | + $query .= $wpdb->prepare(' AND comment_post_ID = %d', $args['post_id']); |
|
| 394 | 394 | } |
| 395 | 395 | // Restrict to specific users |
| 396 | - if ( isset( $args['user_id'] ) && is_array( $args['user_id'] ) ) { |
|
| 397 | - $query .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $args['user_id'] ) ) . ')'; |
|
| 396 | + if (isset($args['user_id']) && is_array($args['user_id'])) { |
|
| 397 | + $query .= ' AND user_id IN ('.implode(',', array_map('absint', $args['user_id'])).')'; |
|
| 398 | 398 | } |
| 399 | - elseif ( !empty( $args['user_id'] ) ) { |
|
| 400 | - $query .= $wpdb->prepare( ' AND user_id = %d', $args['user_id'] ); |
|
| 399 | + elseif ( ! empty($args['user_id'])) { |
|
| 400 | + $query .= $wpdb->prepare(' AND user_id = %d', $args['user_id']); |
|
| 401 | 401 | } |
| 402 | 402 | $query .= ' GROUP BY comment_approved'; |
| 403 | 403 | |
| 404 | - $counts = wp_cache_get( $cache_key, 'counts' ); |
|
| 405 | - if ( false === $counts ) { |
|
| 406 | - $sql = $wpdb->prepare( $query, $type ); |
|
| 407 | - $results = (array) $wpdb->get_results( $sql, ARRAY_A ); |
|
| 408 | - $counts = array_fill_keys( $this->get_stati( $type ), 0 ); |
|
| 404 | + $counts = wp_cache_get($cache_key, 'counts'); |
|
| 405 | + if (false === $counts) { |
|
| 406 | + $sql = $wpdb->prepare($query, $type); |
|
| 407 | + $results = (array) $wpdb->get_results($sql, ARRAY_A); |
|
| 408 | + $counts = array_fill_keys($this->get_stati($type), 0); |
|
| 409 | 409 | |
| 410 | - foreach ( $results as $row ) { |
|
| 411 | - $counts[ $row['comment_approved'] ] = $row['total']; |
|
| 410 | + foreach ($results as $row) { |
|
| 411 | + $counts[$row['comment_approved']] = $row['total']; |
|
| 412 | 412 | } |
| 413 | - wp_cache_set( $cache_key, $counts, 'counts' ); |
|
| 413 | + wp_cache_set($cache_key, $counts, 'counts'); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if( ! isset( $counts['graded'] ) ) { |
|
| 416 | + if ( ! isset($counts['graded'])) { |
|
| 417 | 417 | $counts['graded'] = 0; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if( ! isset( $counts['ungraded'] ) ) { |
|
| 420 | + if ( ! isset($counts['ungraded'])) { |
|
| 421 | 421 | $counts['ungraded'] = 0; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if( ! isset( $counts['passed'] ) ) { |
|
| 424 | + if ( ! isset($counts['passed'])) { |
|
| 425 | 425 | $counts['passed'] = 0; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if( ! isset( $counts['failed'] ) ) { |
|
| 428 | + if ( ! isset($counts['failed'])) { |
|
| 429 | 429 | $counts['failed'] = 0; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if( ! isset( $counts['in-progress'] ) ) { |
|
| 432 | + if ( ! isset($counts['in-progress'])) { |
|
| 433 | 433 | $counts['in-progress'] = 0; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if( ! isset( $counts['complete'] ) ) { |
|
| 436 | + if ( ! isset($counts['complete'])) { |
|
| 437 | 437 | $counts['complete'] = 0; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - return apply_filters( 'sensei_count_statuses', $counts, $type ); |
|
| 440 | + return apply_filters('sensei_count_statuses', $counts, $type); |
|
| 441 | 441 | } // End sensei_count_statuses() |
| 442 | 442 | |
| 443 | 443 | /** |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | * @since 1.7.0 |
| 446 | 446 | * @return string |
| 447 | 447 | */ |
| 448 | - public function courses_drop_down_html( $selected_course_id = 0 ) { |
|
| 448 | + public function courses_drop_down_html($selected_course_id = 0) { |
|
| 449 | 449 | |
| 450 | 450 | $html = ''; |
| 451 | 451 | |
| 452 | - $course_args = array( 'post_type' => 'course', |
|
| 452 | + $course_args = array('post_type' => 'course', |
|
| 453 | 453 | 'posts_per_page' => -1, |
| 454 | 454 | 'orderby' => 'title', |
| 455 | 455 | 'order' => 'ASC', |
@@ -457,12 +457,12 @@ discard block |
||
| 457 | 457 | 'suppress_filters' => 0, |
| 458 | 458 | 'fields' => 'ids', |
| 459 | 459 | ); |
| 460 | - $courses = get_posts( apply_filters( 'sensei_grading_filter_courses', $course_args ) ); |
|
| 460 | + $courses = get_posts(apply_filters('sensei_grading_filter_courses', $course_args)); |
|
| 461 | 461 | |
| 462 | - $html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>'; |
|
| 463 | - if ( count( $courses ) > 0 ) { |
|
| 464 | - foreach ($courses as $course_id){ |
|
| 465 | - $html .= '<option value="' . esc_attr( absint( $course_id ) ) . '" ' . selected( $course_id, $selected_course_id, false ) . '>' . esc_html( get_the_title( $course_id ) ) . '</option>' . "\n"; |
|
| 462 | + $html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'; |
|
| 463 | + if (count($courses) > 0) { |
|
| 464 | + foreach ($courses as $course_id) { |
|
| 465 | + $html .= '<option value="'.esc_attr(absint($course_id)).'" '.selected($course_id, $selected_course_id, false).'>'.esc_html(get_the_title($course_id)).'</option>'."\n"; |
|
| 466 | 466 | } // End For Loop |
| 467 | 467 | } // End If Statement |
| 468 | 468 | |
@@ -483,20 +483,20 @@ discard block |
||
| 483 | 483 | $course_data = array(); |
| 484 | 484 | parse_str($data, $course_data); |
| 485 | 485 | |
| 486 | - $course_id = intval( $course_data['course_id'] ); |
|
| 486 | + $course_id = intval($course_data['course_id']); |
|
| 487 | 487 | |
| 488 | - $html = $this->lessons_drop_down_html( $course_id ); |
|
| 488 | + $html = $this->lessons_drop_down_html($course_id); |
|
| 489 | 489 | |
| 490 | 490 | echo $html; |
| 491 | 491 | die(); // WordPress may print out a spurious zero without this can be particularly bad if using JSON |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - public function lessons_drop_down_html( $course_id = 0, $selected_lesson_id = 0 ) { |
|
| 494 | + public function lessons_drop_down_html($course_id = 0, $selected_lesson_id = 0) { |
|
| 495 | 495 | |
| 496 | 496 | $html = ''; |
| 497 | - if ( 0 < intval( $course_id ) ) { |
|
| 497 | + if (0 < intval($course_id)) { |
|
| 498 | 498 | |
| 499 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 499 | + $lesson_args = array('post_type' => 'lesson', |
|
| 500 | 500 | 'posts_per_page' => -1, |
| 501 | 501 | 'orderby' => 'title', |
| 502 | 502 | 'order' => 'ASC', |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | 'suppress_filters' => 0, |
| 507 | 507 | 'fields' => 'ids', |
| 508 | 508 | ); |
| 509 | - $lessons = get_posts( apply_filters( 'sensei_grading_filter_lessons', $lesson_args ) ); |
|
| 509 | + $lessons = get_posts(apply_filters('sensei_grading_filter_lessons', $lesson_args)); |
|
| 510 | 510 | |
| 511 | - $html .= '<option value="">' . __( 'Select a lesson', 'woothemes-sensei' ) . '</option>'; |
|
| 512 | - if ( count( $lessons ) > 0 ) { |
|
| 513 | - foreach ( $lessons as $lesson_id ){ |
|
| 514 | - $html .= '<option value="' . esc_attr( absint( $lesson_id ) ) . '" ' . selected( $lesson_id, $selected_lesson_id, false ) . '>' . esc_html( get_the_title( $lesson_id ) ) . '</option>' . "\n"; |
|
| 511 | + $html .= '<option value="">'.__('Select a lesson', 'woothemes-sensei').'</option>'; |
|
| 512 | + if (count($lessons) > 0) { |
|
| 513 | + foreach ($lessons as $lesson_id) { |
|
| 514 | + $html .= '<option value="'.esc_attr(absint($lesson_id)).'" '.selected($lesson_id, $selected_lesson_id, false).'>'.esc_html(get_the_title($lesson_id)).'</option>'."\n"; |
|
| 515 | 515 | } // End For Loop |
| 516 | 516 | } // End If Statement |
| 517 | 517 | |
@@ -532,10 +532,10 @@ discard block |
||
| 532 | 532 | public function admin_process_grading_submission() { |
| 533 | 533 | |
| 534 | 534 | // NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry |
| 535 | - if( ! isset( $_POST['sensei_manual_grade'] ) |
|
| 536 | - || ! wp_verify_nonce( $_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading' ) |
|
| 537 | - || ! isset( $_GET['quiz_id'] ) |
|
| 538 | - || $_GET['quiz_id'] != $_POST['sensei_manual_grade'] ) { |
|
| 535 | + if ( ! isset($_POST['sensei_manual_grade']) |
|
| 536 | + || ! wp_verify_nonce($_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading') |
|
| 537 | + || ! isset($_GET['quiz_id']) |
|
| 538 | + || $_GET['quiz_id'] != $_POST['sensei_manual_grade']) { |
|
| 539 | 539 | |
| 540 | 540 | return false; //exit and do not grade |
| 541 | 541 | |
@@ -545,30 +545,30 @@ discard block |
||
| 545 | 545 | $user_id = $_GET['user']; |
| 546 | 546 | |
| 547 | 547 | |
| 548 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); |
|
| 549 | - $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 548 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); |
|
| 549 | + $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id); |
|
| 550 | 550 | $quiz_grade = 0; |
| 551 | 551 | $count = 0; |
| 552 | 552 | $quiz_grade_total = $_POST['quiz_grade_total']; |
| 553 | 553 | $all_question_grades = array(); |
| 554 | 554 | $all_answers_feedback = array(); |
| 555 | 555 | |
| 556 | - foreach( $questions as $question ) { |
|
| 556 | + foreach ($questions as $question) { |
|
| 557 | 557 | |
| 558 | 558 | ++$count; |
| 559 | 559 | $question_id = $question->ID; |
| 560 | 560 | |
| 561 | - if( isset( $_POST[ 'question_' . $question_id ] ) ) { |
|
| 561 | + if (isset($_POST['question_'.$question_id])) { |
|
| 562 | 562 | |
| 563 | 563 | $question_grade = 0; |
| 564 | - if( $_POST[ 'question_' . $question_id ] == 'right' ) { |
|
| 564 | + if ($_POST['question_'.$question_id] == 'right') { |
|
| 565 | 565 | |
| 566 | - $question_grade = $_POST[ 'question_' . $question_id . '_grade' ]; |
|
| 566 | + $question_grade = $_POST['question_'.$question_id.'_grade']; |
|
| 567 | 567 | |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // add data to the array that will, after the loop, be stored on the lesson status |
| 571 | - $all_question_grades[ $question_id ] = $question_grade; |
|
| 571 | + $all_question_grades[$question_id] = $question_grade; |
|
| 572 | 572 | |
| 573 | 573 | // tally up the total quiz grade |
| 574 | 574 | $quiz_grade += $question_grade; |
@@ -577,41 +577,41 @@ discard block |
||
| 577 | 577 | |
| 578 | 578 | // Question answer feedback / notes |
| 579 | 579 | $question_feedback = ''; |
| 580 | - if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){ |
|
| 580 | + if (isset($_POST['questions_feedback'][$question_id])) { |
|
| 581 | 581 | |
| 582 | - $question_feedback = wp_unslash( $_POST[ 'questions_feedback' ][ $question_id ] ); |
|
| 582 | + $question_feedback = wp_unslash($_POST['questions_feedback'][$question_id]); |
|
| 583 | 583 | |
| 584 | 584 | } |
| 585 | - $all_answers_feedback[ $question_id ] = $question_feedback; |
|
| 585 | + $all_answers_feedback[$question_id] = $question_feedback; |
|
| 586 | 586 | |
| 587 | 587 | } // end for each $questions |
| 588 | 588 | |
| 589 | 589 | //store all question grades on the lesson status |
| 590 | - Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id ); |
|
| 590 | + Sensei()->quiz->set_user_grades($all_question_grades, $quiz_lesson_id, $user_id); |
|
| 591 | 591 | |
| 592 | 592 | //store the feedback from grading |
| 593 | - Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id ); |
|
| 593 | + Sensei()->quiz->save_user_answers_feedback($all_answers_feedback, $quiz_lesson_id, $user_id); |
|
| 594 | 594 | |
| 595 | 595 | // $_POST['all_questions_graded'] is set when all questions have been graded |
| 596 | 596 | // in the class sensei grading user quiz -> display() |
| 597 | - if( $_POST['all_questions_graded'] == 'yes' ) { |
|
| 597 | + if ($_POST['all_questions_graded'] == 'yes') { |
|
| 598 | 598 | |
| 599 | 599 | // set the users total quiz grade |
| 600 | - if ( 0 < intval( $quiz_grade_total ) ) { |
|
| 601 | - $grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) ); |
|
| 600 | + if (0 < intval($quiz_grade_total)) { |
|
| 601 | + $grade = abs(round((doubleval($quiz_grade) * 100) / ($quiz_grade_total), 2)); |
|
| 602 | 602 | } |
| 603 | 603 | else { |
| 604 | 604 | $grade = 0; |
| 605 | 605 | } |
| 606 | - Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id ); |
|
| 606 | + Sensei_Utils::sensei_grade_quiz($quiz_id, $grade, $user_id); |
|
| 607 | 607 | |
| 608 | 608 | // Duplicating what Frontend->sensei_complete_quiz() does |
| 609 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
| 610 | - $quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) ); |
|
| 609 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
| 610 | + $quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2)); |
|
| 611 | 611 | $lesson_metadata = array(); |
| 612 | - if ( $pass_required ) { |
|
| 612 | + if ($pass_required) { |
|
| 613 | 613 | // Student has reached the pass mark and lesson is complete |
| 614 | - if ( $quiz_passmark <= $grade ) { |
|
| 614 | + if ($quiz_passmark <= $grade) { |
|
| 615 | 615 | $lesson_status = 'passed'; |
| 616 | 616 | } |
| 617 | 617 | else { |
@@ -624,9 +624,9 @@ discard block |
||
| 624 | 624 | } |
| 625 | 625 | $lesson_metadata['grade'] = $grade; // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above |
| 626 | 626 | |
| 627 | - Sensei_Utils::update_lesson_status( $user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata ); |
|
| 627 | + Sensei_Utils::update_lesson_status($user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata); |
|
| 628 | 628 | |
| 629 | - if( in_array( $lesson_status, array( 'passed', 'graded' ) ) ) { |
|
| 629 | + if (in_array($lesson_status, array('passed', 'graded'))) { |
|
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | 632 | * Summary. |
@@ -638,27 +638,27 @@ discard block |
||
| 638 | 638 | * @param int $user_id |
| 639 | 639 | * @param int $quiz_lesson_id |
| 640 | 640 | */ |
| 641 | - do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id ); |
|
| 641 | + do_action('sensei_user_lesson_end', $user_id, $quiz_lesson_id); |
|
| 642 | 642 | |
| 643 | 643 | } // end if in_array |
| 644 | 644 | |
| 645 | 645 | }// end if $_POST['all_que... |
| 646 | 646 | |
| 647 | - if( isset( $_POST['sensei_grade_next_learner'] ) && strlen( $_POST['sensei_grade_next_learner'] ) > 0 ) { |
|
| 647 | + if (isset($_POST['sensei_grade_next_learner']) && strlen($_POST['sensei_grade_next_learner']) > 0) { |
|
| 648 | 648 | |
| 649 | - $load_url = add_query_arg( array( 'message' => 'graded' ) ); |
|
| 649 | + $load_url = add_query_arg(array('message' => 'graded')); |
|
| 650 | 650 | |
| 651 | - } elseif ( isset( $_POST['_wp_http_referer'] ) ) { |
|
| 651 | + } elseif (isset($_POST['_wp_http_referer'])) { |
|
| 652 | 652 | |
| 653 | - $load_url = add_query_arg( array( 'message' => 'graded' ), $_POST['_wp_http_referer'] ); |
|
| 653 | + $load_url = add_query_arg(array('message' => 'graded'), $_POST['_wp_http_referer']); |
|
| 654 | 654 | |
| 655 | 655 | } else { |
| 656 | 656 | |
| 657 | - $load_url = add_query_arg( array( 'message' => 'graded' ) ); |
|
| 657 | + $load_url = add_query_arg(array('message' => 'graded')); |
|
| 658 | 658 | |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - wp_safe_redirect( esc_url_raw( $load_url ) ); |
|
| 661 | + wp_safe_redirect(esc_url_raw($load_url)); |
|
| 662 | 662 | exit; |
| 663 | 663 | |
| 664 | 664 | } // end admin_process_grading_submission |
@@ -669,13 +669,13 @@ discard block |
||
| 669 | 669 | $lesson_data = array(); |
| 670 | 670 | parse_str($data, $lesson_data); |
| 671 | 671 | |
| 672 | - $lesson_id = intval( $lesson_data['lesson_id'] ); |
|
| 673 | - $course_id = intval( $lesson_data['course_id'] ); |
|
| 674 | - $grading_view = sanitize_text_field( $lesson_data['view'] ); |
|
| 672 | + $lesson_id = intval($lesson_data['lesson_id']); |
|
| 673 | + $course_id = intval($lesson_data['course_id']); |
|
| 674 | + $grading_view = sanitize_text_field($lesson_data['view']); |
|
| 675 | 675 | |
| 676 | 676 | $redirect_url = ''; |
| 677 | - if ( 0 < $lesson_id && 0 < $course_id ) { |
|
| 678 | - $redirect_url = esc_url_raw( apply_filters( 'sensei_ajax_redirect_url', add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id, 'course_id' => $course_id, 'view' => $grading_view ), admin_url( 'admin.php' ) ) ) ); |
|
| 677 | + if (0 < $lesson_id && 0 < $course_id) { |
|
| 678 | + $redirect_url = esc_url_raw(apply_filters('sensei_ajax_redirect_url', add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id, 'course_id' => $course_id, 'view' => $grading_view), admin_url('admin.php')))); |
|
| 679 | 679 | } // End If Statement |
| 680 | 680 | |
| 681 | 681 | echo $redirect_url; |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | public function add_grading_notices() { |
| 686 | - if( isset( $_GET['page'] ) && $this->page_slug == $_GET['page'] && isset( $_GET['message'] ) && $_GET['message'] ) { |
|
| 687 | - if( 'graded' == $_GET['message'] ) { |
|
| 686 | + if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) { |
|
| 687 | + if ('graded' == $_GET['message']) { |
|
| 688 | 688 | $msg = array( |
| 689 | 689 | 'updated', |
| 690 | - __( 'Quiz Graded Successfully!', 'woothemes-sensei' ), |
|
| 690 | + __('Quiz Graded Successfully!', 'woothemes-sensei'), |
|
| 691 | 691 | ); |
| 692 | 692 | } |
| 693 | 693 | ?> |
@@ -699,9 +699,9 @@ discard block |
||
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | public function sensei_grading_notices() { |
| 702 | - if ( isset( $_GET['action'] ) && 'graded' == $_GET['action'] ) { |
|
| 702 | + if (isset($_GET['action']) && 'graded' == $_GET['action']) { |
|
| 703 | 703 | echo '<div class="grading-notice updated">'; |
| 704 | - echo '<p>' . __( 'Quiz Graded Successfully!', 'woothemes-sensei' ) . '</p>'; |
|
| 704 | + echo '<p>'.__('Quiz Graded Successfully!', 'woothemes-sensei').'</p>'; |
|
| 705 | 705 | echo '</div>'; |
| 706 | 706 | } // End If Statement |
| 707 | 707 | } // End sensei_grading_notices() |
@@ -724,16 +724,16 @@ discard block |
||
| 724 | 724 | * |
| 725 | 725 | * @return int $quiz_grade total sum of all question grades |
| 726 | 726 | */ |
| 727 | - public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) { |
|
| 727 | + public static function grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') { |
|
| 728 | 728 | |
| 729 | - if( ! ( intval( $quiz_id ) > 0 ) || ! $submitted |
|
| 730 | - || $quiz_grade_type != 'auto' ) { |
|
| 729 | + if ( ! (intval($quiz_id) > 0) || ! $submitted |
|
| 730 | + || $quiz_grade_type != 'auto') { |
|
| 731 | 731 | return false; // exit early |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | |
| 735 | 735 | $user_id = get_current_user_id(); |
| 736 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ) ; |
|
| 736 | + $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id); |
|
| 737 | 737 | $quiz_autogradable = true; |
| 738 | 738 | |
| 739 | 739 | /** |
@@ -747,23 +747,23 @@ discard block |
||
| 747 | 747 | * 'gap-fill'. |
| 748 | 748 | * } |
| 749 | 749 | */ |
| 750 | - $autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) ); |
|
| 750 | + $autogradable_question_types = apply_filters('sensei_autogradable_question_types', array('multiple-choice', 'boolean', 'gap-fill')); |
|
| 751 | 751 | |
| 752 | 752 | $grade_total = 0; |
| 753 | 753 | $all_question_grades = array(); |
| 754 | - foreach( $submitted as $question_id => $answer ) { |
|
| 754 | + foreach ($submitted as $question_id => $answer) { |
|
| 755 | 755 | |
| 756 | 756 | // check if the question is autogradable, either by type, or because the grade is 0 |
| 757 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 758 | - $achievable_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 757 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 758 | + $achievable_grade = Sensei()->question->get_question_grade($question_id); |
|
| 759 | 759 | // Question has a zero grade, so skip grading |
| 760 | - if ( 0 == $achievable_grade ) { |
|
| 761 | - $all_question_grades[ $question_id ] = $achievable_grade; |
|
| 760 | + if (0 == $achievable_grade) { |
|
| 761 | + $all_question_grades[$question_id] = $achievable_grade; |
|
| 762 | 762 | } |
| 763 | - elseif ( in_array( $question_type, $autogradable_question_types ) ) { |
|
| 763 | + elseif (in_array($question_type, $autogradable_question_types)) { |
|
| 764 | 764 | // Get user question grade |
| 765 | - $question_grade = Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id ); |
|
| 766 | - $all_question_grades[ $question_id ] = $question_grade; |
|
| 765 | + $question_grade = Sensei_Utils::sensei_grade_question_auto($question_id, $question_type, $answer, $user_id); |
|
| 766 | + $all_question_grades[$question_id] = $question_grade; |
|
| 767 | 767 | $grade_total += $question_grade; |
| 768 | 768 | |
| 769 | 769 | } else { |
@@ -776,27 +776,27 @@ discard block |
||
| 776 | 776 | }// end for each question |
| 777 | 777 | |
| 778 | 778 | // Only if the whole quiz was autogradable do we set a grade |
| 779 | - if ( $quiz_autogradable ) { |
|
| 779 | + if ($quiz_autogradable) { |
|
| 780 | 780 | |
| 781 | - $quiz_total = Sensei_Utils::sensei_get_quiz_total( $quiz_id ); |
|
| 781 | + $quiz_total = Sensei_Utils::sensei_get_quiz_total($quiz_id); |
|
| 782 | 782 | // Check for zero total from grades |
| 783 | - if ( 0 < $quiz_total ) { |
|
| 784 | - $grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) ); |
|
| 783 | + if (0 < $quiz_total) { |
|
| 784 | + $grade = abs(round((doubleval($grade_total) * 100) / ($quiz_total), 2)); |
|
| 785 | 785 | } |
| 786 | 786 | else { |
| 787 | 787 | $grade = 0; |
| 788 | 788 | } |
| 789 | - Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type ); |
|
| 789 | + Sensei_Utils::sensei_grade_quiz($quiz_id, $grade, $user_id, $quiz_grade_type); |
|
| 790 | 790 | |
| 791 | 791 | } else { |
| 792 | 792 | |
| 793 | - $grade = new WP_Error( 'autograde', __( 'This quiz is not able to be automatically graded.', 'woothemes-sensei' ) ); |
|
| 793 | + $grade = new WP_Error('autograde', __('This quiz is not able to be automatically graded.', 'woothemes-sensei')); |
|
| 794 | 794 | |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | // store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default |
| 798 | 798 | // when doing manual grading. |
| 799 | - Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id ); |
|
| 799 | + Sensei()->quiz-> set_user_grades($all_question_grades, $lesson_id, $user_id); |
|
| 800 | 800 | |
| 801 | 801 | return $grade; |
| 802 | 802 | |
@@ -816,22 +816,22 @@ discard block |
||
| 816 | 816 | * |
| 817 | 817 | * @return int $question_grade |
| 818 | 818 | */ |
| 819 | - public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) { |
|
| 819 | + public static function grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) { |
|
| 820 | 820 | |
| 821 | - if( intval( $user_id ) == 0 ) { |
|
| 821 | + if (intval($user_id) == 0) { |
|
| 822 | 822 | |
| 823 | 823 | $user_id = get_current_user_id(); |
| 824 | 824 | |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - if( ! ( intval( $question_id ) > 0 ) ) { |
|
| 827 | + if ( ! (intval($question_id) > 0)) { |
|
| 828 | 828 | |
| 829 | 829 | return false; |
| 830 | 830 | |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | |
| 834 | - Sensei()->question->get_question_type( $question_id ); |
|
| 834 | + Sensei()->question->get_question_type($question_id); |
|
| 835 | 835 | |
| 836 | 836 | /** |
| 837 | 837 | * Applying a grade before the auto grading takes place. |
@@ -845,42 +845,42 @@ discard block |
||
| 845 | 845 | * @param string $question_type one of the Sensei question type. |
| 846 | 846 | * @param string $answer user supplied question answer |
| 847 | 847 | */ |
| 848 | - $question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer ); |
|
| 848 | + $question_grade = apply_filters('sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer); |
|
| 849 | 849 | |
| 850 | - if ( false !== $question_grade ) { |
|
| 850 | + if (false !== $question_grade) { |
|
| 851 | 851 | |
| 852 | 852 | return $question_grade; |
| 853 | 853 | |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | // auto grading core |
| 857 | - if( in_array( $question_type , array( 'multiple-choice' , 'boolean' ) ) ){ |
|
| 857 | + if (in_array($question_type, array('multiple-choice', 'boolean'))) { |
|
| 858 | 858 | |
| 859 | - $right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true ); |
|
| 859 | + $right_answer = (array) get_post_meta($question_id, '_question_right_answer', true); |
|
| 860 | 860 | |
| 861 | - if( 0 == get_magic_quotes_gpc() ) { |
|
| 862 | - $answer = wp_unslash( $answer ); |
|
| 861 | + if (0 == get_magic_quotes_gpc()) { |
|
| 862 | + $answer = wp_unslash($answer); |
|
| 863 | 863 | } |
| 864 | 864 | $answer = (array) $answer; |
| 865 | - if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) { |
|
| 865 | + if (is_array($right_answer) && count($right_answer) == count($answer)) { |
|
| 866 | 866 | // Loop through all answers ensure none are 'missing' |
| 867 | 867 | $all_correct = true; |
| 868 | - foreach ( $answer as $check_answer ) { |
|
| 869 | - if ( !in_array( $check_answer, $right_answer ) ) { |
|
| 868 | + foreach ($answer as $check_answer) { |
|
| 869 | + if ( ! in_array($check_answer, $right_answer)) { |
|
| 870 | 870 | $all_correct = false; |
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | // If all correct then grade |
| 874 | - if ( $all_correct ) { |
|
| 875 | - $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 874 | + if ($all_correct) { |
|
| 875 | + $question_grade = Sensei()->question->get_question_grade($question_id); |
|
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - } elseif( 'gap-fill' == $question_type ){ |
|
| 879 | + } elseif ('gap-fill' == $question_type) { |
|
| 880 | 880 | |
| 881 | - $question_grade = self::grade_gap_fill_question( $question_id ,$answer ); |
|
| 881 | + $question_grade = self::grade_gap_fill_question($question_id, $answer); |
|
| 882 | 882 | |
| 883 | - } else{ |
|
| 883 | + } else { |
|
| 884 | 884 | |
| 885 | 885 | /** |
| 886 | 886 | * Grading questions that are not auto gradable. |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | * @param string $question_type one of the Sensei question type. |
| 894 | 894 | * @param string $answer user supplied question answer |
| 895 | 895 | */ |
| 896 | - $question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer ); |
|
| 896 | + $question_grade = (int) apply_filters('sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer); |
|
| 897 | 897 | |
| 898 | 898 | } // end if $question_type |
| 899 | 899 | |
@@ -909,13 +909,13 @@ discard block |
||
| 909 | 909 | * |
| 910 | 910 | * @return bool | int false or the grade given to the user answer |
| 911 | 911 | */ |
| 912 | - public static function grade_gap_fill_question( $question_id, $user_answer ){ |
|
| 912 | + public static function grade_gap_fill_question($question_id, $user_answer) { |
|
| 913 | 913 | |
| 914 | - $right_answer = get_post_meta( $question_id, '_question_right_answer', true ); |
|
| 915 | - $gapfill_array = explode( '||', $right_answer ); |
|
| 914 | + $right_answer = get_post_meta($question_id, '_question_right_answer', true); |
|
| 915 | + $gapfill_array = explode('||', $right_answer); |
|
| 916 | 916 | |
| 917 | - if( 0 == get_magic_quotes_gpc() ) { // deprecated from PHP 5.4 but we still support PHP 5.2 |
|
| 918 | - $user_answer = wp_unslash( $user_answer ); |
|
| 917 | + if (0 == get_magic_quotes_gpc()) { // deprecated from PHP 5.4 but we still support PHP 5.2 |
|
| 918 | + $user_answer = wp_unslash($user_answer); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -928,53 +928,53 @@ discard block |
||
| 928 | 928 | * |
| 929 | 929 | * @since 1.9.0 |
| 930 | 930 | */ |
| 931 | - $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false ); |
|
| 931 | + $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false); |
|
| 932 | 932 | |
| 933 | - if( $do_case_sensitive_comparison ){ |
|
| 933 | + if ($do_case_sensitive_comparison) { |
|
| 934 | 934 | |
| 935 | 935 | // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer |
| 936 | - if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) { |
|
| 936 | + if (trim(($gapfill_array[1])) == trim($user_answer)) { |
|
| 937 | 937 | |
| 938 | - return Sensei()->question->get_question_grade( $question_id ); |
|
| 938 | + return Sensei()->question->get_question_grade($question_id); |
|
| 939 | 939 | |
| 940 | - } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) { |
|
| 940 | + } else if (@preg_match('/'.$gapfill_array[1].'/i', null) !== FALSE) { |
|
| 941 | 941 | |
| 942 | - if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) { |
|
| 942 | + if (preg_match('/'.$gapfill_array[1].'/i', $user_answer)) { |
|
| 943 | 943 | |
| 944 | 944 | return Sensei()->question->get_question_grade($question_id); |
| 945 | 945 | |
| 946 | - }else{ |
|
| 946 | + } else { |
|
| 947 | 947 | |
| 948 | 948 | return false; |
| 949 | 949 | |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - }else{ |
|
| 952 | + } else { |
|
| 953 | 953 | |
| 954 | 954 | return false; |
| 955 | 955 | |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - }else{ |
|
| 958 | + } else { |
|
| 959 | 959 | |
| 960 | 960 | // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer |
| 961 | - if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) { |
|
| 961 | + if (trim(strtolower($gapfill_array[1])) == trim(strtolower($user_answer))) { |
|
| 962 | 962 | |
| 963 | - return Sensei()->question->get_question_grade( $question_id ); |
|
| 963 | + return Sensei()->question->get_question_grade($question_id); |
|
| 964 | 964 | |
| 965 | - } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) { |
|
| 965 | + } else if (@preg_match('/'.$gapfill_array[1].'/i', null) !== FALSE) { |
|
| 966 | 966 | |
| 967 | - if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) { |
|
| 967 | + if (preg_match('/'.$gapfill_array[1].'/i', $user_answer)) { |
|
| 968 | 968 | |
| 969 | - return Sensei()->question->get_question_grade( $question_id ); |
|
| 969 | + return Sensei()->question->get_question_grade($question_id); |
|
| 970 | 970 | |
| 971 | - }else{ |
|
| 971 | + } else { |
|
| 972 | 972 | |
| 973 | 973 | return false; |
| 974 | 974 | |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | - }else{ |
|
| 977 | + } else { |
|
| 978 | 978 | |
| 979 | 979 | return false; |
| 980 | 980 | |
@@ -990,17 +990,17 @@ discard block |
||
| 990 | 990 | * @since 1.9.0 |
| 991 | 991 | * @return int $number_of_graded_lessons |
| 992 | 992 | */ |
| 993 | - public static function get_graded_lessons_count(){ |
|
| 993 | + public static function get_graded_lessons_count() { |
|
| 994 | 994 | |
| 995 | 995 | global $wpdb; |
| 996 | 996 | |
| 997 | - $comment_query_piece[ 'select'] = "SELECT COUNT(*) AS total"; |
|
| 998 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 999 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1000 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 997 | + $comment_query_piece['select'] = "SELECT COUNT(*) AS total"; |
|
| 998 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 999 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1000 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1001 | 1001 | |
| 1002 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1003 | - $number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1002 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1003 | + $number_of_graded_lessons = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1004 | 1004 | |
| 1005 | 1005 | return $number_of_graded_lessons; |
| 1006 | 1006 | } |
@@ -1011,17 +1011,17 @@ discard block |
||
| 1011 | 1011 | * @since 1.9.0 |
| 1012 | 1012 | * @return double $sum_of_all_grades |
| 1013 | 1013 | */ |
| 1014 | - public static function get_graded_lessons_sum(){ |
|
| 1014 | + public static function get_graded_lessons_sum() { |
|
| 1015 | 1015 | |
| 1016 | 1016 | global $wpdb; |
| 1017 | 1017 | |
| 1018 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1019 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1020 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1021 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1018 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1019 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1020 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1021 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1022 | 1022 | |
| 1023 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1024 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1023 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1024 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1025 | 1025 | |
| 1026 | 1026 | return $sum_of_all_grades; |
| 1027 | 1027 | |
@@ -1034,17 +1034,17 @@ discard block |
||
| 1034 | 1034 | * @param $user_id |
| 1035 | 1035 | * @return double |
| 1036 | 1036 | */ |
| 1037 | - public static function get_user_graded_lessons_sum( $user_id ){ |
|
| 1037 | + public static function get_user_graded_lessons_sum($user_id) { |
|
| 1038 | 1038 | global $wpdb; |
| 1039 | 1039 | |
| 1040 | - $clean_user_id = esc_sql( $user_id); |
|
| 1041 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1042 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1043 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} "; |
|
| 1044 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1040 | + $clean_user_id = esc_sql($user_id); |
|
| 1041 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1042 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1043 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} "; |
|
| 1044 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1045 | 1045 | |
| 1046 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1047 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1046 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1047 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1048 | 1048 | |
| 1049 | 1049 | return $sum_of_all_grades; |
| 1050 | 1050 | } |
@@ -1057,18 +1057,18 @@ discard block |
||
| 1057 | 1057 | * @param int lesson_id |
| 1058 | 1058 | * @return double |
| 1059 | 1059 | */ |
| 1060 | - public static function get_lessons_users_grades_sum( $lesson_id ){ |
|
| 1060 | + public static function get_lessons_users_grades_sum($lesson_id) { |
|
| 1061 | 1061 | |
| 1062 | 1062 | global $wpdb; |
| 1063 | 1063 | |
| 1064 | - $clean_lesson_id = esc_sql( $lesson_id); |
|
| 1065 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1066 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1067 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} "; |
|
| 1068 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1064 | + $clean_lesson_id = esc_sql($lesson_id); |
|
| 1065 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1066 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1067 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} "; |
|
| 1068 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1069 | 1069 | |
| 1070 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1071 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1070 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1071 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1072 | 1072 | |
| 1073 | 1073 | return $sum_of_all_grades; |
| 1074 | 1074 | |
@@ -1082,18 +1082,18 @@ discard block |
||
| 1082 | 1082 | * @param int $course_id |
| 1083 | 1083 | * @return double |
| 1084 | 1084 | */ |
| 1085 | - public static function get_course_users_grades_sum( $course_id ){ |
|
| 1085 | + public static function get_course_users_grades_sum($course_id) { |
|
| 1086 | 1086 | |
| 1087 | 1087 | global $wpdb; |
| 1088 | 1088 | |
| 1089 | - $clean_course_id = esc_sql( $course_id); |
|
| 1090 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1091 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1092 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} "; |
|
| 1093 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1089 | + $clean_course_id = esc_sql($course_id); |
|
| 1090 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1091 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1092 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} "; |
|
| 1093 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1094 | 1094 | |
| 1095 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1096 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1095 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1096 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1097 | 1097 | |
| 1098 | 1098 | return $sum_of_all_grades; |
| 1099 | 1099 | |
@@ -1106,4 +1106,4 @@ discard block |
||
| 1106 | 1106 | * @ignore only for backward compatibility |
| 1107 | 1107 | * @since 1.9.0 |
| 1108 | 1108 | */ |
| 1109 | -class WooThemes_Sensei_Grading extends Sensei_Grading{} |
|
| 1109 | +class WooThemes_Sensei_Grading extends Sensei_Grading {} |
|
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | * show the WooCommerce course filter links above the courses |
| 8 | 8 | * @since 1.9.0 |
| 9 | 9 | */ |
| 10 | -add_filter( 'sensei_archive_course_filter_by_options', array( 'Sensei_WC', 'add_course_archive_wc_filter_links' ) ); |
|
| 10 | +add_filter('sensei_archive_course_filter_by_options', array('Sensei_WC', 'add_course_archive_wc_filter_links')); |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * filter the queries for paid and free course based on the users selection. |
| 14 | 14 | * @since 1.9.0 |
| 15 | 15 | */ |
| 16 | -add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_free')); |
|
| 17 | -add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_paid')); |
|
| 16 | +add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_free')); |
|
| 17 | +add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_paid')); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Add woocommerce action above single course the action |
| 21 | 21 | * @since 1.9.0 |
| 22 | 22 | */ |
| 23 | -add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action') ,50) ; |
|
| 23 | +add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action'), 50); |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /****************************** |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * Single Lesson Hooks |
| 29 | 29 | * |
| 30 | 30 | ******************************/ |
| 31 | -add_filter( 'sensei_can_user_view_lesson', array( 'Sensei_WC','alter_can_user_view_lesson' ), 20, 3 ); |
|
| 31 | +add_filter('sensei_can_user_view_lesson', array('Sensei_WC', 'alter_can_user_view_lesson'), 20, 3); |
|
| 32 | 32 | |
| 33 | 33 | /****************************** |
| 34 | 34 | * |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | ******************************/ |
| 38 | 38 | // add a notice on the checkout page to tell users about the course they've purchase |
| 39 | -add_action( 'template_redirect', array( 'Sensei_WC','course_link_from_order' ) ); |
|
| 39 | +add_action('template_redirect', array('Sensei_WC', 'course_link_from_order')); |
|
| 40 | 40 | |
| 41 | 41 | /****************************** |
| 42 | 42 | * |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ******************************/ |
| 46 | 46 | //@since 1.9.0 |
| 47 | 47 | //show a notice if the user has already added the current course to their cart |
| 48 | -add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_WC', 'course_in_cart_message' ), 20 ); |
|
| 48 | +add_action('sensei_single_course_content_inside_before', array('Sensei_WC', 'course_in_cart_message'), 20); |
|
| 49 | 49 | |
| 50 | 50 | /****************************** |
| 51 | 51 | * |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | ******************************/ |
| 55 | 55 | //@since 1.9.0 |
| 56 | 56 | // alter the no permissions message to show the woocommerce message instead |
| 57 | -add_filter( 'sensei_the_no_permissions_message', array( 'Sensei_WC', 'alter_no_permissions_message' ), 20, 2 ); |
|
| 57 | +add_filter('sensei_the_no_permissions_message', array('Sensei_WC', 'alter_no_permissions_message'), 20, 2); |
|
| 58 | 58 | |
| 59 | 59 | // @since 1.9.0 |
| 60 | 60 | // add woocommerce class to the the no permission body class to ensure WooCommerce elements are styled |
| 61 | -add_filter( 'body_class', array( 'Sensei_WC', 'add_woocommerce_body_class' ), 20, 1); |
|
| 61 | +add_filter('body_class', array('Sensei_WC', 'add_woocommerce_body_class'), 20, 1); |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | /************************************ |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | ************************************/ |
| 69 | 69 | // Add Email link to course orders |
| 70 | -add_action( 'woocommerce_email_after_order_table', array( 'Sensei_WC', 'email_course_details' ), 10, 1 ); |
|
| 70 | +add_action('woocommerce_email_after_order_table', array('Sensei_WC', 'email_course_details'), 10, 1); |
|
| 71 | 71 | |
| 72 | 72 | /************************************ |
| 73 | 73 | * |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | ************************************/ |
| 77 | 77 | //add_action( 'woocommerce_payment_complete', array( 'Sensei_WC', 'complete_order' ) ); |
| 78 | 78 | //add_action( 'woocommerce_thankyou' , array( 'Sensei_WC', 'complete_order' ) ); |
| 79 | -add_action( 'woocommerce_delete_shop_order_transients', array( 'Sensei_WC', 'complete_order' ) ); |
|
| 80 | -add_action( 'woocommerce_delete_shop_order_transients', array( 'Sensei_WC', 'cancel_order' ) ); |
|
| 79 | +add_action('woocommerce_delete_shop_order_transients', array('Sensei_WC', 'complete_order')); |
|
| 80 | +add_action('woocommerce_delete_shop_order_transients', array('Sensei_WC', 'cancel_order')); |
|
| 81 | 81 | // Disable guest checkout if a course is in the cart as we need a valid user to store data for |
| 82 | -add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( 'Sensei_WC', 'disable_guest_checkout' ) ); |
|
| 82 | +add_filter('pre_option_woocommerce_enable_guest_checkout', array('Sensei_WC', 'disable_guest_checkout')); |
|
| 83 | 83 | // Mark orders with virtual products as complete rather then stay processing |
| 84 | -add_filter( 'woocommerce_payment_complete_order_status', array( 'Sensei_WC', 'virtual_order_payment_complete' ), 10, 2 ); |
|
| 84 | +add_filter('woocommerce_payment_complete_order_status', array('Sensei_WC', 'virtual_order_payment_complete'), 10, 2); |
|
| 85 | 85 | |
| 86 | 86 | /************************************ |
| 87 | 87 | * |
| 88 | 88 | * WooCommerce Subscriptions |
| 89 | 89 | * |
| 90 | 90 | ************************************/ |
| 91 | -add_action( 'woocommerce_subscription_status_pending_to_active', array( 'Sensei_WC', 'activate_subscription' ), 50, 3 ); |
|
| 91 | +add_action('woocommerce_subscription_status_pending_to_active', array('Sensei_WC', 'activate_subscription'), 50, 3); |
|
| 92 | 92 | // filter the user permission of the subscription is not valid |
| 93 | -add_filter( 'sensei_access_permissions', array( 'Sensei_WC', 'get_subscription_permission' ), 10, 2 ); |
|
| 93 | +add_filter('sensei_access_permissions', array('Sensei_WC', 'get_subscription_permission'), 10, 2); |
|
@@ -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 | * All functionality pertaining to the course results pages in Sensei. |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | * Constructor. |
| 21 | 21 | * @since 1.4.0 |
| 22 | 22 | */ |
| 23 | - public function __construct () { |
|
| 23 | + public function __construct() { |
|
| 24 | 24 | |
| 25 | 25 | // Setup learner profile URL base |
| 26 | - $this->courses_url_base = apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url slug', 'woothemes-sensei' ) ); |
|
| 26 | + $this->courses_url_base = apply_filters('sensei_course_slug', _x('course', 'post type single url slug', 'woothemes-sensei')); |
|
| 27 | 27 | |
| 28 | 28 | // Setup permalink structure for course results |
| 29 | - add_action( 'init', array( $this, 'setup_permastruct' ) ); |
|
| 30 | - add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 ); |
|
| 29 | + add_action('init', array($this, 'setup_permastruct')); |
|
| 30 | + add_filter('wp_title', array($this, 'page_title'), 10, 2); |
|
| 31 | 31 | |
| 32 | 32 | // Load course results |
| 33 | - add_action( 'sensei_course_results_content_inside_before', array( $this, 'deprecate_course_result_info_hook' ), 10 ); |
|
| 33 | + add_action('sensei_course_results_content_inside_before', array($this, 'deprecate_course_result_info_hook'), 10); |
|
| 34 | 34 | |
| 35 | 35 | // Add class to body tag |
| 36 | - add_filter( 'body_class', array( $this, 'body_class' ), 10, 1 ); |
|
| 36 | + add_filter('body_class', array($this, 'body_class'), 10, 1); |
|
| 37 | 37 | |
| 38 | 38 | } // End __construct() |
| 39 | 39 | |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | 45 | public function setup_permastruct() { |
| 46 | - add_rewrite_rule( '^' . $this->courses_url_base . '/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top' ); |
|
| 47 | - add_rewrite_tag( '%course_results%', '([^&]+)' ); |
|
| 46 | + add_rewrite_rule('^'.$this->courses_url_base.'/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top'); |
|
| 47 | + add_rewrite_tag('%course_results%', '([^&]+)'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | * @param string $sep Seeparator string |
| 54 | 54 | * @return string Modified title |
| 55 | 55 | */ |
| 56 | - public function page_title( $title, $sep = null ) { |
|
| 56 | + public function page_title($title, $sep = null) { |
|
| 57 | 57 | global $wp_query; |
| 58 | - if( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 59 | - $course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' ); |
|
| 60 | - $title = __( 'Course Results: ', 'woothemes-sensei' ) . $course->post_title . ' ' . $sep . ' '; |
|
| 58 | + if (isset($wp_query->query_vars['course_results'])) { |
|
| 59 | + $course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course'); |
|
| 60 | + $title = __('Course Results: ', 'woothemes-sensei').$course->post_title.' '.$sep.' '; |
|
| 61 | 61 | } |
| 62 | 62 | return $title; |
| 63 | 63 | } |
@@ -68,18 +68,18 @@ discard block |
||
| 68 | 68 | * @param integer $course_id ID of course |
| 69 | 69 | * @return string The course results page permalink |
| 70 | 70 | */ |
| 71 | - public function get_permalink( $course_id = 0 ) { |
|
| 71 | + public function get_permalink($course_id = 0) { |
|
| 72 | 72 | |
| 73 | 73 | $permalink = ''; |
| 74 | 74 | |
| 75 | - if( $course_id > 0 ) { |
|
| 75 | + if ($course_id > 0) { |
|
| 76 | 76 | |
| 77 | - $course = get_post( $course_id ); |
|
| 77 | + $course = get_post($course_id); |
|
| 78 | 78 | |
| 79 | - if ( get_option('permalink_structure') ) { |
|
| 80 | - $permalink = trailingslashit( get_home_url() ) . $this->courses_url_base . '/' . $course->post_name . '/results/'; |
|
| 79 | + if (get_option('permalink_structure')) { |
|
| 80 | + $permalink = trailingslashit(get_home_url()).$this->courses_url_base.'/'.$course->post_name.'/results/'; |
|
| 81 | 81 | } else { |
| 82 | - $permalink = trailingslashit( get_home_url() ) . '?course_results=' . $course->post_name; |
|
| 82 | + $permalink = trailingslashit(get_home_url()).'?course_results='.$course->post_name; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | * @return void |
| 93 | 93 | */ |
| 94 | 94 | public function content() { |
| 95 | - global $wp_query, $current_user; |
|
| 95 | + global $wp_query, $current_user; |
|
| 96 | 96 | |
| 97 | - if( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 98 | - Sensei_Templates::get_template( 'course-results/course-info.php' ); |
|
| 97 | + if (isset($wp_query->query_vars['course_results'])) { |
|
| 98 | + Sensei_Templates::get_template('course-results/course-info.php'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | global $course; |
| 111 | 111 | |
| 112 | - Sensei_Utils::sensei_user_course_status_message( $course->ID, get_current_user_id()); |
|
| 112 | + Sensei_Utils::sensei_user_course_status_message($course->ID, get_current_user_id()); |
|
| 113 | 113 | |
| 114 | - sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course ); |
|
| 114 | + sensei_do_deprecated_action('sensei_course_results_lessons', '1.9.', 'sensei_course_results_content_inside_after', $course); |
|
| 115 | 115 | |
| 116 | - sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID ); |
|
| 116 | + sensei_do_deprecated_action('sensei_course_results_bottom', '1.9.', 'sensei_course_results_content_inside_after', $course->ID); |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | public function course_lessons() { |
| 127 | 127 | |
| 128 | 128 | global $course; |
| 129 | - _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' ); |
|
| 129 | + _deprecated_function('Sensei_modules course_lessons ', '1.9.0'); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | * @param array $classes Existing classes |
| 136 | 136 | * @return array Modified classes |
| 137 | 137 | */ |
| 138 | - public function body_class( $classes ) { |
|
| 138 | + public function body_class($classes) { |
|
| 139 | 139 | global $wp_query; |
| 140 | - if( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 140 | + if (isset($wp_query->query_vars['course_results'])) { |
|
| 141 | 141 | $classes[] = 'course-results'; |
| 142 | 142 | } |
| 143 | 143 | return $classes; |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @deprecated since 1.9.0 |
| 150 | 150 | */ |
| 151 | - public static function deprecate_sensei_course_results_content_hook(){ |
|
| 151 | + public static function deprecate_sensei_course_results_content_hook() { |
|
| 152 | 152 | |
| 153 | - sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before'); |
|
| 153 | + sensei_do_deprecated_action('sensei_course_results_content', '1.9.0', 'sensei_course_results_content_before'); |
|
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @since 1.9.0 |
| 161 | 161 | */ |
| 162 | - public static function fire_sensei_message_hook(){ |
|
| 162 | + public static function fire_sensei_message_hook() { |
|
| 163 | 163 | |
| 164 | - do_action( 'sensei_frontend_messages' ); |
|
| 164 | + do_action('sensei_frontend_messages'); |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @since 1.9.0 |
| 172 | 172 | */ |
| 173 | - public static function deprecate_course_result_info_hook(){ |
|
| 173 | + public static function deprecate_course_result_info_hook() { |
|
| 174 | 174 | |
| 175 | - sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' ); |
|
| 175 | + sensei_do_deprecated_action('sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before'); |
|
| 176 | 176 | |
| 177 | 177 | } |
| 178 | 178 | |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @deprecate since 1.9.0 |
| 183 | 183 | */ |
| 184 | - public static function deprecate_course_results_top_hook(){ |
|
| 184 | + public static function deprecate_course_results_top_hook() { |
|
| 185 | 185 | |
| 186 | 186 | global $course; |
| 187 | - sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID ); |
|
| 187 | + sensei_do_deprecated_action('sensei_course_results_top', '1.9.0', 'sensei_course_results_content_inside_before', $course->ID); |
|
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @since 1.8.0 |
| 195 | 195 | */ |
| 196 | - public static function fire_course_image_hook(){ |
|
| 196 | + public static function fire_course_image_hook() { |
|
| 197 | 197 | |
| 198 | 198 | global $course; |
| 199 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
| 199 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID())); |
|
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | |
@@ -207,4 +207,4 @@ discard block |
||
| 207 | 207 | * @ignore only for backward compatibility |
| 208 | 208 | * @since 1.9.0 |
| 209 | 209 | */ |
| 210 | -class WooThemes_Sensei_Course_Results extends Sensei_Course_Results{} |
|
| 210 | +class WooThemes_Sensei_Course_Results extends Sensei_Course_Results {} |
|
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Notices Class |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @since 1.6.3 |
| 13 | 13 | */ |
| 14 | -class Sensei_Notices{ |
|
| 14 | +class Sensei_Notices { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * @var $notices |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * constructor |
| 28 | 28 | */ |
| 29 | - public function __construct(){ |
|
| 29 | + public function __construct() { |
|
| 30 | 30 | //initialize the notices variable |
| 31 | 31 | $this->notices = array(); |
| 32 | 32 | $this->has_printed = false; |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | - public function add_notice( $content , $type = 'alert' ){ |
|
| 45 | + public function add_notice($content, $type = 'alert') { |
|
| 46 | 46 | // append the new notice |
| 47 | - $this->notices[] = array('content' => $content , 'type'=> $type ); |
|
| 47 | + $this->notices[] = array('content' => $content, 'type'=> $type); |
|
| 48 | 48 | |
| 49 | 49 | // if a notice is added after we've printed print it immediately. |
| 50 | - if( $this->has_printed ){ |
|
| 50 | + if ($this->has_printed) { |
|
| 51 | 51 | $this->maybe_print_notices(); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | - public function maybe_print_notices(){ |
|
| 63 | - if( count( $this->notices ) > 0 ){ |
|
| 62 | + public function maybe_print_notices() { |
|
| 63 | + if (count($this->notices) > 0) { |
|
| 64 | 64 | foreach ($this->notices as $notice) { |
| 65 | 65 | |
| 66 | - $classes = 'sensei-message '. $notice['type']; |
|
| 67 | - $html = '<div class="'. $classes . '">'. $notice['content'] . '</div>'; |
|
| 66 | + $classes = 'sensei-message '.$notice['type']; |
|
| 67 | + $html = '<div class="'.$classes.'">'.$notice['content'].'</div>'; |
|
| 68 | 68 | |
| 69 | 69 | echo $html; |
| 70 | 70 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return void |
| 85 | 85 | */ |
| 86 | - public function clear_notices(){ |
|
| 86 | + public function clear_notices() { |
|
| 87 | 87 | // assign an empty array to clear all existing notices |
| 88 | 88 | $this->notices = array(); |
| 89 | 89 | } // end clear_notices() |
@@ -95,4 +95,4 @@ discard block |
||
| 95 | 95 | * @ignore only for backward compatibility |
| 96 | 96 | * @since 1.9.0 |
| 97 | 97 | */ |
| 98 | -class Woothemes_Sensei_Notices extends Sensei_Notices{} |
|
| 98 | +class Woothemes_Sensei_Notices extends Sensei_Notices {} |
|
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP |
|
| 3 | 3 | /** |
| 4 | 4 | * Sensei Template Class |
| 5 | 5 | * |
@@ -21,38 +21,38 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | - public static function get_part( $slug, $name = '' ){ |
|
| 24 | + public static function get_part($slug, $name = '') { |
|
| 25 | 25 | |
| 26 | 26 | $template = ''; |
| 27 | 27 | $plugin_template_url = Sensei()->template_url; |
| 28 | - $plugin_template_path = Sensei()->plugin_path() . "/templates/"; |
|
| 28 | + $plugin_template_path = Sensei()->plugin_path()."/templates/"; |
|
| 29 | 29 | |
| 30 | 30 | // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php |
| 31 | - if ( $name ){ |
|
| 31 | + if ($name) { |
|
| 32 | 32 | |
| 33 | - $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) ); |
|
| 33 | + $template = locate_template(array("{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php")); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Get default slug-name.php |
| 38 | - if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){ |
|
| 38 | + if ( ! $template && $name && file_exists($plugin_template_path."{$slug}-{$name}.php")) { |
|
| 39 | 39 | |
| 40 | - $template = $plugin_template_path . "{$slug}-{$name}.php"; |
|
| 40 | + $template = $plugin_template_path."{$slug}-{$name}.php"; |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php |
| 46 | - if ( !$template ){ |
|
| 46 | + if ( ! $template) { |
|
| 47 | 47 | |
| 48 | - $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) ); |
|
| 48 | + $template = locate_template(array("{$slug}.php", "{$plugin_template_url}{$slug}.php")); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - if ( $template ){ |
|
| 53 | + if ($template) { |
|
| 54 | 54 | |
| 55 | - load_template( $template, false ); |
|
| 55 | + load_template($template, false); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -68,20 +68,20 @@ discard block |
||
| 68 | 68 | * @param string $template_path |
| 69 | 69 | * @param string $default_path |
| 70 | 70 | */ |
| 71 | - public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 71 | + public static function get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 72 | 72 | |
| 73 | - if ( $args && is_array($args) ) |
|
| 74 | - extract( $args ); |
|
| 73 | + if ($args && is_array($args)) |
|
| 74 | + extract($args); |
|
| 75 | 75 | |
| 76 | - $located = self::locate_template( $template_name, $template_path, $default_path ); |
|
| 76 | + $located = self::locate_template($template_name, $template_path, $default_path); |
|
| 77 | 77 | |
| 78 | - if( ! empty( $located ) ){ |
|
| 78 | + if ( ! empty($located)) { |
|
| 79 | 79 | |
| 80 | - do_action( 'sensei_before_template_part', $template_name, $template_path, $located ); |
|
| 80 | + do_action('sensei_before_template_part', $template_name, $template_path, $located); |
|
| 81 | 81 | |
| 82 | - include( $located ); |
|
| 82 | + include($located); |
|
| 83 | 83 | |
| 84 | - do_action( 'sensei_after_template_part', $template_name, $template_path, $located ); |
|
| 84 | + do_action('sensei_after_template_part', $template_name, $template_path, $located); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
@@ -98,32 +98,32 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return mixed|void |
| 100 | 100 | */ |
| 101 | - public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 101 | + public static function locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 102 | 102 | |
| 103 | - if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 104 | - if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 103 | + if ( ! $template_path) $template_path = Sensei()->template_url; |
|
| 104 | + if ( ! $default_path) $default_path = Sensei()->plugin_path().'/templates/'; |
|
| 105 | 105 | |
| 106 | 106 | // Look within passed path within the theme - this is priority |
| 107 | 107 | $template = locate_template( |
| 108 | 108 | array( |
| 109 | - $template_path . $template_name, |
|
| 109 | + $template_path.$template_name, |
|
| 110 | 110 | $template_name |
| 111 | 111 | ) |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | 114 | // Get default template |
| 115 | - if ( ! $template ){ |
|
| 115 | + if ( ! $template) { |
|
| 116 | 116 | |
| 117 | - $template = $default_path . $template_name; |
|
| 117 | + $template = $default_path.$template_name; |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | // return nothing for file that do not exist |
| 121 | - if( !file_exists( $template ) ){ |
|
| 121 | + if ( ! file_exists($template)) { |
|
| 122 | 122 | $template = ''; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // Return what we found |
| 126 | - return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path ); |
|
| 126 | + return apply_filters('sensei_locate_template', $template, $template_name, $template_path); |
|
| 127 | 127 | |
| 128 | 128 | } // end locate |
| 129 | 129 | |
@@ -136,122 +136,122 @@ discard block |
||
| 136 | 136 | * @param string $template |
| 137 | 137 | * @return string $template |
| 138 | 138 | */ |
| 139 | - public static function template_loader ( $template = '' ) { |
|
| 139 | + public static function template_loader($template = '') { |
|
| 140 | 140 | |
| 141 | 141 | global $wp_query, $email_template; |
| 142 | 142 | |
| 143 | - $find = array( 'woothemes-sensei.php' ); |
|
| 143 | + $find = array('woothemes-sensei.php'); |
|
| 144 | 144 | $file = ''; |
| 145 | 145 | |
| 146 | - if ( isset( $email_template ) && $email_template ) { |
|
| 146 | + if (isset($email_template) && $email_template) { |
|
| 147 | 147 | |
| 148 | - $file = 'emails/' . $email_template; |
|
| 148 | + $file = 'emails/'.$email_template; |
|
| 149 | 149 | $find[] = $file; |
| 150 | - $find[] = Sensei()->template_url . $file; |
|
| 150 | + $find[] = Sensei()->template_url.$file; |
|
| 151 | 151 | |
| 152 | - } elseif ( is_single() && get_post_type() == 'course' ) { |
|
| 152 | + } elseif (is_single() && get_post_type() == 'course') { |
|
| 153 | 153 | |
| 154 | 154 | // possible backward compatible template include if theme overrides content-single-course.php |
| 155 | 155 | // this template was removed in 1.9.0 and code all moved into the main single-course.php file |
| 156 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true ); |
|
| 156 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-course.php', true); |
|
| 157 | 157 | |
| 158 | - $file = 'single-course.php'; |
|
| 158 | + $file = 'single-course.php'; |
|
| 159 | 159 | $find[] = $file; |
| 160 | - $find[] = Sensei()->template_url . $file; |
|
| 160 | + $find[] = Sensei()->template_url.$file; |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | - } elseif ( is_single() && get_post_type() == 'lesson' ) { // check |
|
| 163 | + } elseif (is_single() && get_post_type() == 'lesson') { // check |
|
| 164 | 164 | |
| 165 | 165 | // possible backward compatible template include if theme overrides content-single-lesson.php |
| 166 | 166 | // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file |
| 167 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true ); |
|
| 167 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-lesson.php', true); |
|
| 168 | 168 | |
| 169 | - $file = 'single-lesson.php'; |
|
| 169 | + $file = 'single-lesson.php'; |
|
| 170 | 170 | $find[] = $file; |
| 171 | - $find[] = Sensei()->template_url . $file; |
|
| 171 | + $find[] = Sensei()->template_url.$file; |
|
| 172 | 172 | |
| 173 | - } elseif ( is_single() && get_post_type() == 'quiz' ) { // check |
|
| 173 | + } elseif (is_single() && get_post_type() == 'quiz') { // check |
|
| 174 | 174 | |
| 175 | 175 | // possible backward compatible template include if theme overrides content-single-quiz.php |
| 176 | 176 | // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file |
| 177 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true); |
|
| 177 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-quiz.php', true); |
|
| 178 | 178 | |
| 179 | - $file = 'single-quiz.php'; |
|
| 179 | + $file = 'single-quiz.php'; |
|
| 180 | 180 | $find[] = $file; |
| 181 | - $find[] = Sensei()->template_url . $file; |
|
| 181 | + $find[] = Sensei()->template_url.$file; |
|
| 182 | 182 | |
| 183 | 183 | |
| 184 | - } elseif ( is_single() && get_post_type() == 'sensei_message' ) { //// check |
|
| 184 | + } elseif (is_single() && get_post_type() == 'sensei_message') { //// check |
|
| 185 | 185 | |
| 186 | 186 | // possible backward compatible template include if theme overrides content-single-message.php |
| 187 | 187 | // this template was removed in 1.9.0 and code all moved into the main single-message.php file |
| 188 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true ); |
|
| 188 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-message.php', true); |
|
| 189 | 189 | |
| 190 | - $file = 'single-message.php'; |
|
| 190 | + $file = 'single-message.php'; |
|
| 191 | 191 | $find[] = $file; |
| 192 | - $find[] = Sensei()->template_url . $file; |
|
| 192 | + $find[] = Sensei()->template_url.$file; |
|
| 193 | 193 | |
| 194 | - } elseif ( is_post_type_archive( 'course' ) |
|
| 195 | - || is_page( Sensei()->get_page_id( 'courses' ) ) |
|
| 196 | - || is_tax( 'course-category' )) { |
|
| 194 | + } elseif (is_post_type_archive('course') |
|
| 195 | + || is_page(Sensei()->get_page_id('courses')) |
|
| 196 | + || is_tax('course-category')) { |
|
| 197 | 197 | |
| 198 | 198 | // possible backward compatible template include if theme overrides 'taxonomy-course-category' |
| 199 | 199 | // this template was removed in 1.9.0 and replaced by archive-course.php |
| 200 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php'); |
|
| 200 | + self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-course-category.php'); |
|
| 201 | 201 | |
| 202 | - $file = 'archive-course.php'; |
|
| 202 | + $file = 'archive-course.php'; |
|
| 203 | 203 | $find[] = $file; |
| 204 | - $find[] = Sensei()->template_url . $file; |
|
| 204 | + $find[] = Sensei()->template_url.$file; |
|
| 205 | 205 | |
| 206 | - } elseif ( is_post_type_archive( 'sensei_message' ) ) { |
|
| 206 | + } elseif (is_post_type_archive('sensei_message')) { |
|
| 207 | 207 | |
| 208 | - $file = 'archive-message.php'; |
|
| 208 | + $file = 'archive-message.php'; |
|
| 209 | 209 | $find[] = $file; |
| 210 | - $find[] = Sensei()->template_url . $file; |
|
| 210 | + $find[] = Sensei()->template_url.$file; |
|
| 211 | 211 | |
| 212 | - } elseif( is_tax( 'lesson-tag' ) ) { |
|
| 212 | + } elseif (is_tax('lesson-tag')) { |
|
| 213 | 213 | |
| 214 | 214 | // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php' |
| 215 | 215 | // this template was removed in 1.9.0 and replaced by archive-lesson.php |
| 216 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' ); |
|
| 216 | + self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-lesson-tag.php'); |
|
| 217 | 217 | |
| 218 | - $file = 'archive-lesson.php'; |
|
| 218 | + $file = 'archive-lesson.php'; |
|
| 219 | 219 | $find[] = $file; |
| 220 | - $find[] = Sensei()->template_url . $file; |
|
| 220 | + $find[] = Sensei()->template_url.$file; |
|
| 221 | 221 | |
| 222 | - } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 222 | + } elseif (isset($wp_query->query_vars['learner_profile'])) { |
|
| 223 | 223 | |
| 224 | 224 | // Override for sites with static home page |
| 225 | 225 | $wp_query->is_home = false; |
| 226 | 226 | |
| 227 | - $file = 'learner-profile.php'; |
|
| 227 | + $file = 'learner-profile.php'; |
|
| 228 | 228 | $find[] = $file; |
| 229 | - $find[] = Sensei()->template_url . $file; |
|
| 229 | + $find[] = Sensei()->template_url.$file; |
|
| 230 | 230 | |
| 231 | - } elseif ( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 231 | + } elseif (isset($wp_query->query_vars['course_results'])) { |
|
| 232 | 232 | |
| 233 | 233 | // Override for sites with static home page |
| 234 | 234 | $wp_query->is_home = false; |
| 235 | 235 | |
| 236 | 236 | $file = 'course-results.php'; |
| 237 | 237 | $find[] = $file; |
| 238 | - $find[] = Sensei()->template_url . $file; |
|
| 238 | + $find[] = Sensei()->template_url.$file; |
|
| 239 | 239 | |
| 240 | - }elseif( is_author() |
|
| 241 | - && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
|
| 242 | - && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
|
| 240 | + }elseif (is_author() |
|
| 241 | + && Sensei_Teacher::is_a_teacher(get_query_var('author')) |
|
| 242 | + && ! user_can(get_query_var('author'), 'manage_options')) { |
|
| 243 | 243 | |
| 244 | 244 | $file = 'teacher-archive.php'; |
| 245 | 245 | $find[] = $file; |
| 246 | - $find[] = Sensei()->template_url . $file; |
|
| 246 | + $find[] = Sensei()->template_url.$file; |
|
| 247 | 247 | |
| 248 | 248 | } // Load the template file |
| 249 | 249 | |
| 250 | 250 | // if file is present set it to be loaded otherwise continue with the initial template given by WP |
| 251 | - if ( $file ) { |
|
| 251 | + if ($file) { |
|
| 252 | 252 | |
| 253 | - $template = locate_template( $find ); |
|
| 254 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 253 | + $template = locate_template($find); |
|
| 254 | + if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file; |
|
| 255 | 255 | |
| 256 | 256 | } // End If Statement |
| 257 | 257 | |
@@ -271,21 +271,21 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @since 1.9.0 |
| 273 | 273 | */ |
| 274 | - public static function get_no_permission_template( ){ |
|
| 274 | + public static function get_no_permission_template( ) { |
|
| 275 | 275 | |
| 276 | 276 | // possible backward compatible template loading |
| 277 | 277 | // this template was removed in 1.9.0 and code all moved into the no-permissions.php file |
| 278 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true ); |
|
| 278 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-no-permissions.php', true); |
|
| 279 | 279 | |
| 280 | - $file = 'no-permissions.php'; |
|
| 280 | + $file = 'no-permissions.php'; |
|
| 281 | 281 | $find[] = $file; |
| 282 | - $find[] = Sensei()->template_url . $file; |
|
| 282 | + $find[] = Sensei()->template_url.$file; |
|
| 283 | 283 | |
| 284 | - $template = locate_template( $find ); |
|
| 285 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 284 | + $template = locate_template($find); |
|
| 285 | + if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file; |
|
| 286 | 286 | |
| 287 | 287 | // set a global constant so that we know that we're in this template |
| 288 | - define('SENSEI_NO_PERMISSION', true ); |
|
| 288 | + define('SENSEI_NO_PERMISSION', true); |
|
| 289 | 289 | |
| 290 | 290 | return $template; |
| 291 | 291 | |
@@ -304,20 +304,20 @@ discard block |
||
| 304 | 304 | * @param string $template |
| 305 | 305 | * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true |
| 306 | 306 | */ |
| 307 | - public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){ |
|
| 307 | + public static function locate_and_load_template_overrides($template = '', $load_header_footer = false) { |
|
| 308 | 308 | |
| 309 | - $found_template = locate_template( array( $template ) ); |
|
| 310 | - if( $found_template ){ |
|
| 309 | + $found_template = locate_template(array($template)); |
|
| 310 | + if ($found_template) { |
|
| 311 | 311 | |
| 312 | - if( $load_header_footer ){ |
|
| 312 | + if ($load_header_footer) { |
|
| 313 | 313 | |
| 314 | 314 | get_sensei_header(); |
| 315 | - include( $found_template ); |
|
| 315 | + include($found_template); |
|
| 316 | 316 | get_sensei_footer(); |
| 317 | 317 | |
| 318 | - }else{ |
|
| 318 | + } else { |
|
| 319 | 319 | |
| 320 | - include( $found_template ); |
|
| 320 | + include($found_template); |
|
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | * |
| 335 | 335 | * @deprecated since 1.9.0 |
| 336 | 336 | */ |
| 337 | - public static function deprecated_archive_course_content_hook(){ |
|
| 337 | + public static function deprecated_archive_course_content_hook() { |
|
| 338 | 338 | |
| 339 | - sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' ); |
|
| 339 | + sensei_do_deprecated_action('sensei_course_archive_main_content', '1.9.0', 'sensei_loop_course_before'); |
|
| 340 | 340 | |
| 341 | 341 | }// end deprecated_archive_hook |
| 342 | 342 | |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | * @since 1.9.0 |
| 347 | 347 | * @param WP_Post $post |
| 348 | 348 | */ |
| 349 | - public static function the_title( $post ){ |
|
| 349 | + public static function the_title($post) { |
|
| 350 | 350 | |
| 351 | 351 | // ID passed in |
| 352 | - if( is_numeric( $post ) ){ |
|
| 353 | - $post = get_post( $post ); |
|
| 352 | + if (is_numeric($post)) { |
|
| 353 | + $post = get_post($post); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @param $title_html_tag default is 'h3' |
| 362 | 362 | */ |
| 363 | - $title_html_tag = apply_filters('sensei_the_title_html_tag','h3'); |
|
| 363 | + $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3'); |
|
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * Filter the title classes |
@@ -368,14 +368,14 @@ discard block |
||
| 368 | 368 | * @since 1.9.0 |
| 369 | 369 | * @param string $title_classes defaults to $post_type-title |
| 370 | 370 | */ |
| 371 | - $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' ); |
|
| 371 | + $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title'); |
|
| 372 | 372 | |
| 373 | - $html= ''; |
|
| 374 | - $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >'; |
|
| 375 | - $html .= '<a href="' . get_permalink( $post->ID ) . '" >'; |
|
| 376 | - $html .= $post->post_title ; |
|
| 373 | + $html = ''; |
|
| 374 | + $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >'; |
|
| 375 | + $html .= '<a href="'.get_permalink($post->ID).'" >'; |
|
| 376 | + $html .= $post->post_title; |
|
| 377 | 377 | $html .= '</a>'; |
| 378 | - $html .= '</'. $title_html_tag. '>'; |
|
| 378 | + $html .= '</'.$title_html_tag.'>'; |
|
| 379 | 379 | echo $html; |
| 380 | 380 | |
| 381 | 381 | }// end the title |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | * @since 1.9.0 |
| 388 | 388 | * @deprecated 1.9.0 |
| 389 | 389 | */ |
| 390 | - public static function deprecated_single_course_inside_before_hooks(){ |
|
| 390 | + public static function deprecated_single_course_inside_before_hooks() { |
|
| 391 | 391 | |
| 392 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
| 393 | - sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 394 | - sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 392 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID())); |
|
| 393 | + sensei_do_deprecated_action('sensei_course_single_title', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 394 | + sensei_do_deprecated_action('sensei_course_single_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 395 | 395 | |
| 396 | 396 | }// end deprecated_single_course_inside_before_hooks |
| 397 | 397 | |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | * @since 1.9.0 |
| 403 | 403 | * @deprecated 1.9.0 |
| 404 | 404 | */ |
| 405 | - public static function deprecate_sensei_course_single_lessons_hook(){ |
|
| 405 | + public static function deprecate_sensei_course_single_lessons_hook() { |
|
| 406 | 406 | |
| 407 | - sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 407 | + sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 408 | 408 | |
| 409 | 409 | }// deprecate_sensei_course_single_lessons_hook |
| 410 | 410 | |
@@ -416,13 +416,13 @@ discard block |
||
| 416 | 416 | * @since 1.9.0 |
| 417 | 417 | * @deprecated 1.9.0 |
| 418 | 418 | */ |
| 419 | - public static function deprecated_single_main_content_hook(){ |
|
| 419 | + public static function deprecated_single_main_content_hook() { |
|
| 420 | 420 | |
| 421 | - if( is_singular( 'course' ) ) { |
|
| 421 | + if (is_singular('course')) { |
|
| 422 | 422 | |
| 423 | 423 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after'); |
| 424 | 424 | |
| 425 | - } elseif( is_singular( 'message' ) ){ |
|
| 425 | + } elseif (is_singular('message')) { |
|
| 426 | 426 | |
| 427 | 427 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after'); |
| 428 | 428 | } |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | * @since 1.9.0 |
| 435 | 435 | * @deprecated since 1.9.0 |
| 436 | 436 | */ |
| 437 | - public static function deprecate_module_before_hook(){ |
|
| 437 | + public static function deprecate_module_before_hook() { |
|
| 438 | 438 | |
| 439 | - sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' ); |
|
| 439 | + sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after'); |
|
| 440 | 440 | |
| 441 | 441 | } |
| 442 | 442 | |
@@ -445,9 +445,9 @@ discard block |
||
| 445 | 445 | * @since 1.9.0 |
| 446 | 446 | * @deprecated since 1.9.0 |
| 447 | 447 | */ |
| 448 | - public static function deprecate_module_after_hook(){ |
|
| 448 | + public static function deprecate_module_after_hook() { |
|
| 449 | 449 | |
| 450 | - sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' ); |
|
| 450 | + sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after'); |
|
| 451 | 451 | |
| 452 | 452 | } |
| 453 | 453 | |
@@ -457,11 +457,11 @@ discard block |
||
| 457 | 457 | * @since 1.9.0 |
| 458 | 458 | * @deprecated since 1.9.0 |
| 459 | 459 | */ |
| 460 | - public static function deprecate_all_post_type_single_title_hooks(){ |
|
| 460 | + public static function deprecate_all_post_type_single_title_hooks() { |
|
| 461 | 461 | |
| 462 | - if( is_singular( 'sensei_message' ) ){ |
|
| 462 | + if (is_singular('sensei_message')) { |
|
| 463 | 463 | |
| 464 | - sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' ); |
|
| 464 | + sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before'); |
|
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | |
@@ -477,10 +477,10 @@ discard block |
||
| 477 | 477 | public static function deprecate_course_single_meta_hooks() { |
| 478 | 478 | |
| 479 | 479 | // deprecate all these hooks |
| 480 | - sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 481 | - sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 482 | - sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 483 | - sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 480 | + sensei_do_deprecated_action('sensei_course_start', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 481 | + sensei_do_deprecated_action('sensei_woocommerce_in_cart_message', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 482 | + sensei_do_deprecated_action('sensei_course_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 483 | + sensei_do_deprecated_action('sensei_course_meta_video', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 484 | 484 | |
| 485 | 485 | } // End deprecate_course_single_meta_hooks |
| 486 | 486 | |
@@ -490,10 +490,10 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() { |
| 492 | 492 | |
| 493 | - if( is_singular( 'lesson' ) ){ |
|
| 493 | + if (is_singular('lesson')) { |
|
| 494 | 494 | |
| 495 | - sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 496 | - sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 495 | + sensei_do_deprecated_action('sensei_breadcrumb', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
| 496 | + sensei_do_deprecated_action('sensei_comments', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
| 497 | 497 | |
| 498 | 498 | } |
| 499 | 499 | |
@@ -507,14 +507,14 @@ discard block |
||
| 507 | 507 | * |
| 508 | 508 | * @deprecated since 1.9.0 |
| 509 | 509 | */ |
| 510 | - public static function deprecate_sensei_lesson_course_signup_hook(){ |
|
| 510 | + public static function deprecate_sensei_lesson_course_signup_hook() { |
|
| 511 | 511 | |
| 512 | - $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true ); |
|
| 513 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 512 | + $lesson_course_id = get_post_meta(get_the_ID(), '_lesson_course', true); |
|
| 513 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()); |
|
| 514 | 514 | |
| 515 | - if( !$user_taking_course ) { |
|
| 515 | + if ( ! $user_taking_course) { |
|
| 516 | 516 | |
| 517 | - sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id ); |
|
| 517 | + sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id); |
|
| 518 | 518 | |
| 519 | 519 | } |
| 520 | 520 | }// end deprecate_sensei_lesson_course_signup_hook |
@@ -525,11 +525,11 @@ discard block |
||
| 525 | 525 | * @since 1.9.0 |
| 526 | 526 | * @deprecated since 1.9.0 |
| 527 | 527 | */ |
| 528 | - public static function deprecate_sensei_lesson_single_meta_hook(){ |
|
| 528 | + public static function deprecate_sensei_lesson_single_meta_hook() { |
|
| 529 | 529 | |
| 530 | - if ( sensei_can_user_view_lesson() ) { |
|
| 530 | + if (sensei_can_user_view_lesson()) { |
|
| 531 | 531 | |
| 532 | - sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' ); |
|
| 532 | + sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after'); |
|
| 533 | 533 | |
| 534 | 534 | |
| 535 | 535 | } |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | * Deprecate the sensei lesson single title hook |
| 541 | 541 | * @deprecated since 1.9.0 |
| 542 | 542 | */ |
| 543 | - public static function deprecate_sensei_lesson_single_title(){ |
|
| 543 | + public static function deprecate_sensei_lesson_single_title() { |
|
| 544 | 544 | |
| 545 | - sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 545 | + sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
| 546 | 546 | |
| 547 | 547 | }// end deprecate_sensei_lesson_single_title |
| 548 | 548 | |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | * hook in the deperecated single main content to the lesson |
| 551 | 551 | * @deprecated since 1.9.0 |
| 552 | 552 | */ |
| 553 | - public static function deprecate_lesson_single_main_content_hook(){ |
|
| 553 | + public static function deprecate_lesson_single_main_content_hook() { |
|
| 554 | 554 | |
| 555 | - sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' ); |
|
| 555 | + sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before'); |
|
| 556 | 556 | |
| 557 | 557 | }// end sensei_deprecate_lesson_single_main_content_hook |
| 558 | 558 | |
@@ -560,9 +560,9 @@ discard block |
||
| 560 | 560 | * hook in the deperecated single main content to the lesson |
| 561 | 561 | * @deprecated since 1.9.0 |
| 562 | 562 | */ |
| 563 | - public static function deprecate_lesson_image_hook(){ |
|
| 563 | + public static function deprecate_lesson_image_hook() { |
|
| 564 | 564 | |
| 565 | - sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 565 | + sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
| 566 | 566 | |
| 567 | 567 | }// end sensei_deprecate_lesson_single_main_content_hook |
| 568 | 568 | |
@@ -573,9 +573,9 @@ discard block |
||
| 573 | 573 | * @since 1.9.0 |
| 574 | 574 | * @deprecated since 1.9.0 |
| 575 | 575 | */ |
| 576 | - public static function deprecate_sensei_login_form_hook(){ |
|
| 576 | + public static function deprecate_sensei_login_form_hook() { |
|
| 577 | 577 | |
| 578 | - sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' ); |
|
| 578 | + sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before'); |
|
| 579 | 579 | |
| 580 | 580 | } // end deprecate_sensei_login_form_hook |
| 581 | 581 | |
@@ -588,9 +588,9 @@ discard block |
||
| 588 | 588 | * |
| 589 | 589 | * @since 1.9.0 |
| 590 | 590 | */ |
| 591 | - public static function fire_sensei_complete_course_hook(){ |
|
| 591 | + public static function fire_sensei_complete_course_hook() { |
|
| 592 | 592 | |
| 593 | - do_action( 'sensei_complete_course' ); |
|
| 593 | + do_action('sensei_complete_course'); |
|
| 594 | 594 | |
| 595 | 595 | } //fire_sensei_complete_course_hook |
| 596 | 596 | |
@@ -599,9 +599,9 @@ discard block |
||
| 599 | 599 | * |
| 600 | 600 | * @since 1.9.0 |
| 601 | 601 | */ |
| 602 | - public static function fire_frontend_messages_hook(){ |
|
| 602 | + public static function fire_frontend_messages_hook() { |
|
| 603 | 603 | |
| 604 | - do_action( 'sensei_frontend_messages' ); |
|
| 604 | + do_action('sensei_frontend_messages'); |
|
| 605 | 605 | |
| 606 | 606 | }// end sensei_complete_course_action |
| 607 | 607 | |
@@ -611,9 +611,9 @@ discard block |
||
| 611 | 611 | * |
| 612 | 612 | * @deprected since 1.9.0 |
| 613 | 613 | */ |
| 614 | - public static function deprecate_sensei_before_user_course_content_hook(){ |
|
| 614 | + public static function deprecate_sensei_before_user_course_content_hook() { |
|
| 615 | 615 | |
| 616 | - sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() ); |
|
| 616 | + sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user()); |
|
| 617 | 617 | |
| 618 | 618 | }// deprecate_sensei_before_user_course_content_hook |
| 619 | 619 | |
@@ -623,9 +623,9 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | * @deprected since 1.9.0 |
| 625 | 625 | */ |
| 626 | - public static function deprecate_sensei_after_user_course_content_hook(){ |
|
| 626 | + public static function deprecate_sensei_after_user_course_content_hook() { |
|
| 627 | 627 | |
| 628 | - sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() ); |
|
| 628 | + sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user()); |
|
| 629 | 629 | |
| 630 | 630 | }// deprecate_sensei_after_user_course_content_hook |
| 631 | 631 | |
@@ -635,10 +635,10 @@ discard block |
||
| 635 | 635 | * @deprecated since 1.9.0 |
| 636 | 636 | * @since 1.9.0 |
| 637 | 637 | */ |
| 638 | - public static function deprecated_archive_message_hooks (){ |
|
| 638 | + public static function deprecated_archive_message_hooks() { |
|
| 639 | 639 | |
| 640 | - sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' ); |
|
| 641 | - sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' ); |
|
| 640 | + sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop'); |
|
| 641 | + sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop'); |
|
| 642 | 642 | |
| 643 | 643 | } |
| 644 | 644 | |
@@ -648,9 +648,9 @@ discard block |
||
| 648 | 648 | * |
| 649 | 649 | * @deprecated since 1.9.0 |
| 650 | 650 | */ |
| 651 | - public static function deprecate_sensei_complete_quiz_action(){ |
|
| 651 | + public static function deprecate_sensei_complete_quiz_action() { |
|
| 652 | 652 | |
| 653 | - sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' ); |
|
| 653 | + sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before'); |
|
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | * |
| 661 | 661 | * @deprecated since 1.9.0 |
| 662 | 662 | */ |
| 663 | - public static function deprecate_sensei_quiz_question_type_action(){ |
|
| 663 | + public static function deprecate_sensei_quiz_question_type_action() { |
|
| 664 | 664 | |
| 665 | 665 | // Question Type |
| 666 | 666 | global $sensei_question_loop; |
@@ -670,14 +670,14 @@ discard block |
||
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | |
| 673 | - public static function the_register_button( $post_id = "" ){ |
|
| 673 | + public static function the_register_button($post_id = "") { |
|
| 674 | 674 | |
| 675 | 675 | global $current_user, $post; |
| 676 | 676 | |
| 677 | 677 | if ( ! get_option('users_can_register') |
| 678 | - || 'course' != get_post_type( $post_id ) |
|
| 679 | - || ! empty( $current_user->caps ) |
|
| 680 | - || ! Sensei()->settings->get('access_permission') ) { |
|
| 678 | + || 'course' != get_post_type($post_id) |
|
| 679 | + || ! empty($current_user->caps) |
|
| 680 | + || ! Sensei()->settings->get('access_permission')) { |
|
| 681 | 681 | |
| 682 | 682 | return; |
| 683 | 683 | |
@@ -687,15 +687,15 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | // show a link to the my_courses page or the WordPress register page if |
| 689 | 689 | // not my courses page was set in the settings |
| 690 | - if( !empty( $my_courses_page_id ) && $my_courses_page_id ){ |
|
| 690 | + if ( ! empty($my_courses_page_id) && $my_courses_page_id) { |
|
| 691 | 691 | |
| 692 | - $my_courses_url = get_permalink( $my_courses_page_id ); |
|
| 693 | - $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>'; |
|
| 694 | - echo '<div class="status register">' . $register_link . '</div>' ; |
|
| 692 | + $my_courses_url = get_permalink($my_courses_page_id); |
|
| 693 | + $register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>'; |
|
| 694 | + echo '<div class="status register">'.$register_link.'</div>'; |
|
| 695 | 695 | |
| 696 | - } else{ |
|
| 696 | + } else { |
|
| 697 | 697 | |
| 698 | - wp_register( '<div class="status register">', '</div>' ); |
|
| 698 | + wp_register('<div class="status register">', '</div>'); |
|
| 699 | 699 | |
| 700 | 700 | } |
| 701 | 701 | |
@@ -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. |
@@ -142,22 +142,22 @@ discard block |
||
| 142 | 142 | * @param string $file The base file of the plugin. |
| 143 | 143 | * @since 1.0.0 |
| 144 | 144 | */ |
| 145 | - public function __construct ( $file ) { |
|
| 145 | + public function __construct($file) { |
|
| 146 | 146 | |
| 147 | 147 | // Setup object data |
| 148 | 148 | $this->file = $file; |
| 149 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
| 150 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
| 151 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
| 149 | + $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file)); |
|
| 150 | + $this->plugin_path = trailingslashit(dirname($file)); |
|
| 151 | + $this->template_url = apply_filters('sensei_template_url', 'sensei/'); |
|
| 152 | 152 | |
| 153 | 153 | // Initialize the core Sensei functionality |
| 154 | 154 | $this->init(); |
| 155 | 155 | |
| 156 | 156 | // Installation |
| 157 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
| 157 | + if (is_admin() && ! defined('DOING_AJAX')) $this->install(); |
|
| 158 | 158 | |
| 159 | 159 | // Run this on activation. |
| 160 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
| 160 | + register_activation_hook($this->file, array($this, 'activation')); |
|
| 161 | 161 | |
| 162 | 162 | // Image Sizes |
| 163 | 163 | $this->init_image_sizes(); |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | * Load the foundations of Sensei. |
| 172 | 172 | * @since 1.9.0 |
| 173 | 173 | */ |
| 174 | - protected function init(){ |
|
| 174 | + protected function init() { |
|
| 175 | 175 | |
| 176 | 176 | // Localisation |
| 177 | 177 | $this->load_plugin_textdomain(); |
| 178 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
| 178 | + add_action('init', array($this, 'load_localisation'), 0); |
|
| 179 | 179 | |
| 180 | 180 | // Setup settings |
| 181 | 181 | $this->settings = new Sensei_Settings(); |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public static function instance() { |
| 200 | 200 | |
| 201 | - if ( is_null( self::$_instance ) ) { |
|
| 201 | + if (is_null(self::$_instance)) { |
|
| 202 | 202 | |
| 203 | 203 | //Sensei requires a reference to the main Sensei plugin file |
| 204 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
| 204 | + $sensei_main_plugin_file = dirname(dirname(__FILE__)).'/woothemes-sensei.php'; |
|
| 205 | 205 | |
| 206 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
| 206 | + self::$_instance = new self($sensei_main_plugin_file); |
|
| 207 | 207 | |
| 208 | 208 | // load the global class objects needed throughout Sensei |
| 209 | 209 | self::$_instance->initialize_global_objects(); |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @param $plugin |
| 224 | 224 | */ |
| 225 | - public static function activation_flush_rules( $plugin ){ |
|
| 225 | + public static function activation_flush_rules($plugin) { |
|
| 226 | 226 | |
| 227 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
| 227 | + if (strpos($plugin, '/woothemes-sensei.php') > 0) { |
|
| 228 | 228 | |
| 229 | 229 | flush_rewrite_rules(true); |
| 230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @since 1.8.0 |
| 238 | 238 | */ |
| 239 | 239 | public function __clone() { |
| 240 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
| 240 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @since 1.8.0 |
| 246 | 246 | */ |
| 247 | 247 | public function __wakeup() { |
| 248 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
| 248 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -253,13 +253,13 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @since 1.9.0 |
| 255 | 255 | */ |
| 256 | - public function initialize_global_objects(){ |
|
| 256 | + public function initialize_global_objects() { |
|
| 257 | 257 | |
| 258 | 258 | // Setup post types. |
| 259 | 259 | $this->post_types = new Sensei_PostTypes(); |
| 260 | 260 | |
| 261 | 261 | // Lad the updates class |
| 262 | - $this->updates = new Sensei_Updates( $this ); |
|
| 262 | + $this->updates = new Sensei_Updates($this); |
|
| 263 | 263 | |
| 264 | 264 | // Load Course Results Class |
| 265 | 265 | $this->course_results = new Sensei_Course_Results(); |
@@ -283,19 +283,19 @@ discard block |
||
| 283 | 283 | $this->load_modules_class(); |
| 284 | 284 | |
| 285 | 285 | // Load Learner Management Functionality |
| 286 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
| 286 | + $this->learners = new Sensei_Learner_Management($this->file); |
|
| 287 | 287 | |
| 288 | 288 | // Differentiate between administration and frontend logic. |
| 289 | - if ( is_admin() ) { |
|
| 289 | + if (is_admin()) { |
|
| 290 | 290 | |
| 291 | 291 | // Load Admin Welcome class |
| 292 | 292 | new Sensei_Welcome(); |
| 293 | 293 | |
| 294 | 294 | // Load Admin Class |
| 295 | - $this->admin = new Sensei_Admin( $this->file ); |
|
| 295 | + $this->admin = new Sensei_Admin($this->file); |
|
| 296 | 296 | |
| 297 | 297 | // Load Analysis Reports |
| 298 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
| 298 | + $this->analysis = new Sensei_Analysis($this->file); |
|
| 299 | 299 | |
| 300 | 300 | } else { |
| 301 | 301 | |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Load Grading Functionality |
| 315 | - $this->grading = new Sensei_Grading( $this->file ); |
|
| 315 | + $this->grading = new Sensei_Grading($this->file); |
|
| 316 | 316 | |
| 317 | 317 | // Load Email Class |
| 318 | - $this->emails = new Sensei_Emails( $this->file ); |
|
| 318 | + $this->emails = new Sensei_Emails($this->file); |
|
| 319 | 319 | |
| 320 | 320 | // Load Learner Profiles Class |
| 321 | 321 | $this->learner_profiles = new Sensei_Learner_Profiles(); |
@@ -327,21 +327,21 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @since 1.9.0 |
| 329 | 329 | */ |
| 330 | - public function load_hooks(){ |
|
| 330 | + public function load_hooks() { |
|
| 331 | 331 | |
| 332 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
| 333 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
| 332 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
| 333 | + add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support')); |
|
| 334 | 334 | |
| 335 | 335 | // Filter comment counts |
| 336 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
| 336 | + add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2); |
|
| 337 | 337 | |
| 338 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
| 338 | + add_action('body_class', array($this, 'body_class')); |
|
| 339 | 339 | |
| 340 | 340 | // Check for and activate JetPack LaTeX support |
| 341 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
| 341 | + add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules |
|
| 342 | 342 | |
| 343 | 343 | // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
| 344 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
| 344 | + add_action('init', array($this, 'flush_rewrite_rules'), 101); |
|
| 345 | 345 | |
| 346 | 346 | } |
| 347 | 347 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | public function run_updates() { |
| 355 | 355 | // Run updates if administrator |
| 356 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
| 356 | + if (current_user_can('manage_options') || current_user_can('manage_sensei')) { |
|
| 357 | 357 | |
| 358 | 358 | $this->updates->update(); |
| 359 | 359 | |
@@ -366,21 +366,21 @@ discard block |
||
| 366 | 366 | * @since 1.0.0 |
| 367 | 367 | * @return void |
| 368 | 368 | */ |
| 369 | - public function register_widgets () { |
|
| 369 | + public function register_widgets() { |
|
| 370 | 370 | // Widget List (key => value is filename => widget class). |
| 371 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
| 371 | + $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' => 'Course_Component', |
|
| 372 | 372 | 'lesson-component' => 'Lesson_Component', |
| 373 | 373 | 'course-categories' => 'Course_Categories', |
| 374 | - 'category-courses' => 'Category_Courses' ) |
|
| 374 | + 'category-courses' => 'Category_Courses') |
|
| 375 | 375 | ); |
| 376 | - foreach ( $widget_list as $key => $value ) { |
|
| 377 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
| 378 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
| 379 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
| 376 | + foreach ($widget_list as $key => $value) { |
|
| 377 | + if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php')) { |
|
| 378 | + require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php'); |
|
| 379 | + register_widget('WooThemes_Sensei_'.$value.'_Widget'); |
|
| 380 | 380 | } |
| 381 | 381 | } // End For Loop |
| 382 | 382 | |
| 383 | - do_action( 'sensei_register_widgets' ); |
|
| 383 | + do_action('sensei_register_widgets'); |
|
| 384 | 384 | |
| 385 | 385 | } // End register_widgets() |
| 386 | 386 | |
@@ -390,9 +390,9 @@ discard block |
||
| 390 | 390 | * @since 1.0.0 |
| 391 | 391 | * @return void |
| 392 | 392 | */ |
| 393 | - public function load_localisation () { |
|
| 393 | + public function load_localisation() { |
|
| 394 | 394 | |
| 395 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
| 395 | + load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/'); |
|
| 396 | 396 | |
| 397 | 397 | } // End load_localisation() |
| 398 | 398 | |
@@ -402,13 +402,13 @@ discard block |
||
| 402 | 402 | * @since 1.0.0 |
| 403 | 403 | * @return void |
| 404 | 404 | */ |
| 405 | - public function load_plugin_textdomain () { |
|
| 405 | + public function load_plugin_textdomain() { |
|
| 406 | 406 | |
| 407 | 407 | $domain = 'woothemes-sensei'; |
| 408 | 408 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
| 409 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
| 410 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
| 411 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
| 409 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
| 410 | + load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'); |
|
| 411 | + load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/'); |
|
| 412 | 412 | |
| 413 | 413 | } // End load_plugin_textdomain() |
| 414 | 414 | |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @since 1.0.0 |
| 419 | 419 | * @return void |
| 420 | 420 | */ |
| 421 | - public function activation () { |
|
| 421 | + public function activation() { |
|
| 422 | 422 | |
| 423 | 423 | $this->register_plugin_version(); |
| 424 | 424 | |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | * @since 1.0.0 |
| 432 | 432 | * @return void |
| 433 | 433 | */ |
| 434 | - public function install () { |
|
| 434 | + public function install() { |
|
| 435 | 435 | |
| 436 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
| 437 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
| 436 | + register_activation_hook($this->file, array($this, 'activate_sensei')); |
|
| 437 | + register_activation_hook($this->file, 'flush_rewrite_rules'); |
|
| 438 | 438 | |
| 439 | 439 | } // End install() |
| 440 | 440 | |
@@ -445,10 +445,10 @@ discard block |
||
| 445 | 445 | * @since 1.0.0 |
| 446 | 446 | * @return void |
| 447 | 447 | */ |
| 448 | - public function activate_sensei () { |
|
| 448 | + public function activate_sensei() { |
|
| 449 | 449 | |
| 450 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
| 451 | - update_option( 'sensei_installed', 1 ); |
|
| 450 | + update_option('skip_install_sensei_pages', 0); |
|
| 451 | + update_option('sensei_installed', 1); |
|
| 452 | 452 | |
| 453 | 453 | } // End activate_sensei() |
| 454 | 454 | |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | * @since 1.0.0 |
| 459 | 459 | * @return void |
| 460 | 460 | */ |
| 461 | - private function register_plugin_version () { |
|
| 462 | - if ( $this->version != '' ) { |
|
| 461 | + private function register_plugin_version() { |
|
| 462 | + if ($this->version != '') { |
|
| 463 | 463 | |
| 464 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
| 464 | + update_option('woothemes-sensei-version', $this->version); |
|
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | } // End register_plugin_version() |
@@ -472,9 +472,9 @@ discard block |
||
| 472 | 472 | * @since 1.0.1 |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function ensure_post_thumbnails_support () { |
|
| 475 | + public function ensure_post_thumbnails_support() { |
|
| 476 | 476 | |
| 477 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
| 477 | + if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); } |
|
| 478 | 478 | |
| 479 | 479 | } // End ensure_post_thumbnails_support() |
| 480 | 480 | |
@@ -486,10 +486,10 @@ discard block |
||
| 486 | 486 | * @return void |
| 487 | 487 | * @deprecated |
| 488 | 488 | */ |
| 489 | - public function template_loader ( $template = '' ) { |
|
| 489 | + public function template_loader($template = '') { |
|
| 490 | 490 | |
| 491 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
| 492 | - Sensei_Templates::template_loader( $template ); |
|
| 491 | + _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead'); |
|
| 492 | + Sensei_Templates::template_loader($template); |
|
| 493 | 493 | |
| 494 | 494 | } // End template_loader() |
| 495 | 495 | |
@@ -499,15 +499,15 @@ discard block |
||
| 499 | 499 | * @since 1.0.0 |
| 500 | 500 | * @return string $sensei_plugin_path |
| 501 | 501 | */ |
| 502 | - public function plugin_path () { |
|
| 502 | + public function plugin_path() { |
|
| 503 | 503 | |
| 504 | - if ( $this->plugin_path ) { |
|
| 504 | + if ($this->plugin_path) { |
|
| 505 | 505 | |
| 506 | - $sensei_plugin_path = $this->plugin_path; |
|
| 506 | + $sensei_plugin_path = $this->plugin_path; |
|
| 507 | 507 | |
| 508 | - }else{ |
|
| 508 | + } else { |
|
| 509 | 509 | |
| 510 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
| 510 | + $sensei_plugin_path = plugin_dir_path(__FILE__); |
|
| 511 | 511 | |
| 512 | 512 | } |
| 513 | 513 | |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | * @param string $page |
| 523 | 523 | * @return int |
| 524 | 524 | */ |
| 525 | - public function get_page_id ( $page ) { |
|
| 526 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
| 527 | - return ( $page ) ? $page : -1; |
|
| 525 | + public function get_page_id($page) { |
|
| 526 | + $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id')); |
|
| 527 | + return ($page) ? $page : -1; |
|
| 528 | 528 | } // End get_page_id() |
| 529 | 529 | |
| 530 | 530 | /** |
@@ -535,48 +535,48 @@ discard block |
||
| 535 | 535 | * |
| 536 | 536 | * @return bool |
| 537 | 537 | */ |
| 538 | - public function check_user_permissions ( $page = '' ) { |
|
| 538 | + public function check_user_permissions($page = '') { |
|
| 539 | 539 | |
| 540 | 540 | global $current_user, $post; |
| 541 | 541 | |
| 542 | 542 | $user_allowed = false; |
| 543 | 543 | |
| 544 | - switch ( $page ) { |
|
| 544 | + switch ($page) { |
|
| 545 | 545 | case 'course-single': |
| 546 | 546 | // check for prerequisite course or lesson, |
| 547 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
| 548 | - $update_course = Sensei_WC::course_update( $post->ID ); |
|
| 547 | + $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true); |
|
| 548 | + $update_course = Sensei_WC::course_update($post->ID); |
|
| 549 | 549 | |
| 550 | 550 | // Count completed lessons |
| 551 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
| 551 | + if (0 < absint($course_prerequisite_id)) { |
|
| 552 | 552 | |
| 553 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
| 553 | + $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID); |
|
| 554 | 554 | |
| 555 | 555 | } else { |
| 556 | 556 | $prerequisite_complete = true; |
| 557 | 557 | } // End If Statement |
| 558 | 558 | |
| 559 | 559 | // Handles restrictions on the course |
| 560 | - if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) { |
|
| 560 | + if (( ! $prerequisite_complete && 0 < absint($course_prerequisite_id))) { |
|
| 561 | 561 | |
| 562 | 562 | $user_allowed = false; |
| 563 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
| 564 | - $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' ); |
|
| 563 | + $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
| 564 | + $this->notices->add_notice(sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link), 'info'); |
|
| 565 | 565 | |
| 566 | - } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
| 566 | + } elseif (Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable($post->ID) && ! Sensei_Utils::user_started_course($post->ID, $current_user->ID)) { |
|
| 567 | 567 | |
| 568 | - $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' ); |
|
| 569 | - $this->notices->add_notice( $message, 'info' ); |
|
| 568 | + $message = sprintf(__('Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei'), '<a href="'.sensei_user_login_url().'">', '</a>'); |
|
| 569 | + $this->notices->add_notice($message, 'info'); |
|
| 570 | 570 | |
| 571 | 571 | |
| 572 | - } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
| 572 | + } elseif ( ! Sensei_Utils::user_started_course($post->ID, $current_user->ID)) { |
|
| 573 | 573 | |
| 574 | 574 | // users who haven't started the course are allowed to view it |
| 575 | - $user_allowed = true; |
|
| 575 | + $user_allowed = true; |
|
| 576 | 576 | |
| 577 | 577 | |
| 578 | 578 | |
| 579 | - } else { |
|
| 579 | + } else { |
|
| 580 | 580 | |
| 581 | 581 | $user_allowed = true; |
| 582 | 582 | |
@@ -584,60 +584,60 @@ discard block |
||
| 584 | 584 | break; |
| 585 | 585 | case 'lesson-single': |
| 586 | 586 | // Check for WC purchase |
| 587 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
| 587 | + $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
| 588 | 588 | |
| 589 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
| 590 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
| 589 | + $update_course = Sensei_WC::course_update($lesson_course_id); |
|
| 590 | + $is_preview = Sensei_Utils::is_preview_lesson($post->ID); |
|
| 591 | 591 | |
| 592 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
| 592 | + if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
| 593 | 593 | $user_allowed = true; |
| 594 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
| 594 | + } elseif ($this->access_settings() && false == $is_preview) { |
|
| 595 | 595 | |
| 596 | 596 | $user_allowed = true; |
| 597 | 597 | |
| 598 | 598 | } else { |
| 599 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 600 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
| 601 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
| 602 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 603 | - if ( $is_preview ) { |
|
| 604 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
| 599 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 600 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
| 601 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
| 602 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
| 603 | + if ($is_preview) { |
|
| 604 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
| 605 | 605 | } else { |
| 606 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 606 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link); |
|
| 607 | 607 | } |
| 608 | 608 | } else { |
| 609 | - if ( $is_preview ) { |
|
| 610 | - $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 ); |
|
| 609 | + if ($is_preview) { |
|
| 610 | + $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); |
|
| 611 | 611 | } else { |
| 612 | 612 | /** This filter is documented in class-woothemes-sensei-frontend.php */ |
| 613 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 613 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
| 614 | 614 | } |
| 615 | 615 | } // End If Statement |
| 616 | 616 | } // End If Statement |
| 617 | 617 | break; |
| 618 | 618 | case 'quiz-single': |
| 619 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
| 620 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
| 619 | + $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true); |
|
| 620 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 621 | 621 | |
| 622 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
| 623 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
| 622 | + $update_course = Sensei_WC::course_update($lesson_course_id); |
|
| 623 | + if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) { |
|
| 624 | 624 | |
| 625 | 625 | // Check for prerequisite lesson for this quiz |
| 626 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
| 627 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
| 626 | + $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
| 627 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID); |
|
| 628 | 628 | |
| 629 | 629 | // Handle restrictions |
| 630 | - if( sensei_all_access() ) { |
|
| 630 | + if (sensei_all_access()) { |
|
| 631 | 631 | |
| 632 | 632 | $user_allowed = true; |
| 633 | 633 | |
| 634 | 634 | } else { |
| 635 | 635 | |
| 636 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
| 636 | + if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) { |
|
| 637 | 637 | |
| 638 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 639 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
| 640 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
| 638 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 639 | + $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>'; |
|
| 640 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link); |
|
| 641 | 641 | |
| 642 | 642 | } else { |
| 643 | 643 | |
@@ -645,27 +645,27 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | } // End If Statement |
| 647 | 647 | } // End If Statement |
| 648 | - } elseif( $this->access_settings() ) { |
|
| 648 | + } elseif ($this->access_settings()) { |
|
| 649 | 649 | // Check if the user has started the course |
| 650 | 650 | |
| 651 | - 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'] ) ) ) { |
|
| 651 | + 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']))) { |
|
| 652 | 652 | |
| 653 | 653 | $user_allowed = false; |
| 654 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 655 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
| 656 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
| 657 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 658 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
| 654 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 655 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
| 656 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
| 657 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
| 658 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
| 659 | 659 | } else { |
| 660 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
| 660 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
| 661 | 661 | } // End If Statement |
| 662 | 662 | } else { |
| 663 | 663 | $user_allowed = true; |
| 664 | 664 | } // End If Statement |
| 665 | 665 | } else { |
| 666 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
| 667 | - $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>'; |
|
| 668 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
| 666 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
| 667 | + $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>'; |
|
| 668 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link); |
|
| 669 | 669 | } // End If Statement |
| 670 | 670 | break; |
| 671 | 671 | default: |
@@ -687,11 +687,11 @@ discard block |
||
| 687 | 687 | * } |
| 688 | 688 | * @param string $post_id |
| 689 | 689 | */ |
| 690 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
| 690 | + $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID); |
|
| 691 | 691 | |
| 692 | 692 | // add the permissions message to the stack |
| 693 | 693 | |
| 694 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
| 694 | + if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) { |
|
| 695 | 695 | $user_allowed = true; |
| 696 | 696 | } |
| 697 | 697 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | * @param integer $user_id |
| 706 | 706 | * |
| 707 | 707 | */ |
| 708 | - return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID ); |
|
| 708 | + return apply_filters('sensei_access_permissions', $user_allowed, $current_user->ID); |
|
| 709 | 709 | |
| 710 | 710 | } // End get_placeholder_image() |
| 711 | 711 | |
@@ -716,12 +716,12 @@ discard block |
||
| 716 | 716 | * @access public |
| 717 | 717 | * @return bool |
| 718 | 718 | */ |
| 719 | - public function access_settings () { |
|
| 719 | + public function access_settings() { |
|
| 720 | 720 | |
| 721 | - if( sensei_all_access() ) return true; |
|
| 721 | + if (sensei_all_access()) return true; |
|
| 722 | 722 | |
| 723 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
| 724 | - if ( is_user_logged_in() ) { |
|
| 723 | + if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) { |
|
| 724 | + if (is_user_logged_in()) { |
|
| 725 | 725 | return true; |
| 726 | 726 | } else { |
| 727 | 727 | return false; |
@@ -737,9 +737,9 @@ discard block |
||
| 737 | 737 | * @access public |
| 738 | 738 | * @return void |
| 739 | 739 | */ |
| 740 | - public function load_class ( $class_name = '' ) { |
|
| 741 | - if ( '' != $class_name && '' != $this->token ) { |
|
| 742 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
| 740 | + public function load_class($class_name = '') { |
|
| 741 | + if ('' != $class_name && '' != $this->token) { |
|
| 742 | + require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php'); |
|
| 743 | 743 | } // End If Statement |
| 744 | 744 | } // End load_class() |
| 745 | 745 | |
@@ -751,44 +751,44 @@ discard block |
||
| 751 | 751 | * @param integer $post_id |
| 752 | 752 | * @return array |
| 753 | 753 | */ |
| 754 | - public function sensei_count_comments( $comments, $post_id ) { |
|
| 754 | + public function sensei_count_comments($comments, $post_id) { |
|
| 755 | 755 | global $wpdb; |
| 756 | 756 | |
| 757 | 757 | $post_id = (int) $post_id; |
| 758 | 758 | |
| 759 | 759 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
| 760 | 760 | |
| 761 | - if ( false !== $count ) { |
|
| 761 | + if (false !== $count) { |
|
| 762 | 762 | return $count; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $statuses = array( '' ); // Default to the WP normal comments |
|
| 766 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
| 767 | - foreach ( (array) $stati AS $status ) { |
|
| 768 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
| 765 | + $statuses = array(''); // Default to the WP normal comments |
|
| 766 | + $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A); |
|
| 767 | + foreach ((array) $stati AS $status) { |
|
| 768 | + if ('sensei_' != substr($status['comment_type'], 0, 7)) { |
|
| 769 | 769 | $statuses[] = $status['comment_type']; |
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
| 772 | + $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')"; |
|
| 773 | 773 | |
| 774 | - if ( $post_id > 0 ) |
|
| 775 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
| 774 | + if ($post_id > 0) |
|
| 775 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
| 776 | 776 | |
| 777 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 777 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 778 | 778 | |
| 779 | 779 | $total = 0; |
| 780 | 780 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
| 781 | - foreach ( (array) $count as $row ) { |
|
| 781 | + foreach ((array) $count as $row) { |
|
| 782 | 782 | // Don't count post-trashed toward totals |
| 783 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
| 783 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
| 784 | 784 | $total += $row['num_comments']; |
| 785 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
| 785 | + if (isset($approved[$row['comment_approved']])) |
|
| 786 | 786 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | $stats['total_comments'] = $total; |
| 790 | - foreach ( $approved as $key ) { |
|
| 791 | - if ( empty($stats[$key]) ) |
|
| 790 | + foreach ($approved as $key) { |
|
| 791 | + if (empty($stats[$key])) |
|
| 792 | 792 | $stats[$key] = 0; |
| 793 | 793 | } |
| 794 | 794 | |
@@ -806,15 +806,15 @@ discard block |
||
| 806 | 806 | * @return void |
| 807 | 807 | */ |
| 808 | 808 | public function init_image_sizes() { |
| 809 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
| 810 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
| 811 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
| 812 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
| 813 | - |
|
| 814 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
| 815 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
| 816 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
| 817 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
| 809 | + $course_archive_thumbnail = $this->get_image_size('course_archive_image'); |
|
| 810 | + $course_single_thumbnail = $this->get_image_size('course_single_image'); |
|
| 811 | + $lesson_archive_thumbnail = $this->get_image_size('lesson_archive_image'); |
|
| 812 | + $lesson_single_thumbnail = $this->get_image_size('lesson_single_image'); |
|
| 813 | + |
|
| 814 | + add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']); |
|
| 815 | + add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']); |
|
| 816 | + add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']); |
|
| 817 | + add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
@@ -827,37 +827,37 @@ discard block |
||
| 827 | 827 | * @param mixed $image_size |
| 828 | 828 | * @return string |
| 829 | 829 | */ |
| 830 | - public function get_image_size( $image_size ) { |
|
| 830 | + public function get_image_size($image_size) { |
|
| 831 | 831 | |
| 832 | 832 | // Only return sizes we define in settings |
| 833 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
| 834 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
| 833 | + if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image'))) |
|
| 834 | + return apply_filters('sensei_get_image_size_'.$image_size, ''); |
|
| 835 | 835 | |
| 836 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
| 837 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
| 836 | + if ( ! isset($this->settings->settings[$image_size.'_width'])) { |
|
| 837 | + $this->settings->settings[$image_size.'_width'] = false; |
|
| 838 | 838 | } |
| 839 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
| 840 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
| 839 | + if ( ! isset($this->settings->settings[$image_size.'_height'])) { |
|
| 840 | + $this->settings->settings[$image_size.'_height'] = false; |
|
| 841 | 841 | } |
| 842 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
| 843 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
| 842 | + if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) { |
|
| 843 | + $this->settings->settings[$image_size.'_hard_crop'] = false; |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | - $size = array_filter( array( |
|
| 847 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
| 848 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
| 849 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
| 850 | - ) ); |
|
| 846 | + $size = array_filter(array( |
|
| 847 | + 'width' => $this->settings->settings[$image_size.'_width'], |
|
| 848 | + 'height' => $this->settings->settings[$image_size.'_height'], |
|
| 849 | + 'crop' => $this->settings->settings[$image_size.'_hard_crop'] |
|
| 850 | + )); |
|
| 851 | 851 | |
| 852 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
| 853 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
| 854 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
| 852 | + $size['width'] = isset($size['width']) ? $size['width'] : '100'; |
|
| 853 | + $size['height'] = isset($size['height']) ? $size['height'] : '100'; |
|
| 854 | + $size['crop'] = isset($size['crop']) ? $size['crop'] : 0; |
|
| 855 | 855 | |
| 856 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
| 856 | + return apply_filters('sensei_get_image_size_'.$image_size, $size); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - public function body_class( $classes ) { |
|
| 860 | - if( is_sensei() ) { |
|
| 859 | + public function body_class($classes) { |
|
| 860 | + if (is_sensei()) { |
|
| 861 | 861 | $classes[] = 'sensei'; |
| 862 | 862 | } |
| 863 | 863 | return $classes; |
@@ -870,9 +870,9 @@ discard block |
||
| 870 | 870 | * @since 1.7.0 |
| 871 | 871 | */ |
| 872 | 872 | public function jetpack_latex_support() { |
| 873 | - if ( function_exists( 'latex_markup') ) { |
|
| 874 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
| 875 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
| 873 | + if (function_exists('latex_markup')) { |
|
| 874 | + add_filter('sensei_question_title', 'latex_markup'); |
|
| 875 | + add_filter('sensei_answer_text', 'latex_markup'); |
|
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | 878 | |
@@ -884,21 +884,21 @@ discard block |
||
| 884 | 884 | * |
| 885 | 885 | * @since 1.8.0 |
| 886 | 886 | */ |
| 887 | - public function load_modules_class(){ |
|
| 887 | + public function load_modules_class() { |
|
| 888 | 888 | global $sensei_modules; |
| 889 | 889 | |
| 890 | - if( !class_exists( 'Sensei_Modules' ) |
|
| 891 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
| 890 | + if ( ! class_exists('Sensei_Modules') |
|
| 891 | + && 'Sensei_Modules' != get_class($sensei_modules)) { |
|
| 892 | 892 | |
| 893 | 893 | //Load the modules class |
| 894 | - require_once( 'class-sensei-modules.php'); |
|
| 895 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
| 894 | + require_once('class-sensei-modules.php'); |
|
| 895 | + Sensei()->modules = new Sensei_Core_Modules($this->file); |
|
| 896 | 896 | |
| 897 | - }else{ |
|
| 897 | + } else { |
|
| 898 | 898 | // fallback for people still using the modules extension. |
| 899 | 899 | global $sensei_modules; |
| 900 | 900 | Sensei()->modules = $sensei_modules; |
| 901 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
| 901 | + add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30); |
|
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
@@ -907,12 +907,12 @@ discard block |
||
| 907 | 907 | * |
| 908 | 908 | * @since 1.8.0 |
| 909 | 909 | */ |
| 910 | - public function disable_sensei_modules_extension(){ ?> |
|
| 910 | + public function disable_sensei_modules_extension() { ?> |
|
| 911 | 911 | <div class="notice updated fade"> |
| 912 | 912 | <p> |
| 913 | 913 | <?php |
| 914 | 914 | $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
| 915 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
| 915 | + $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> '; |
|
| 916 | 916 | ?> |
| 917 | 917 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
| 918 | 918 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
@@ -930,18 +930,18 @@ discard block |
||
| 930 | 930 | * |
| 931 | 931 | * @since 1.9.0 |
| 932 | 932 | */ |
| 933 | - public function flush_rewrite_rules(){ |
|
| 933 | + public function flush_rewrite_rules() { |
|
| 934 | 934 | |
| 935 | 935 | // ensures that the rewrite rules are flushed on the second |
| 936 | 936 | // attempt. This ensure that the settings for any other process |
| 937 | 937 | // have been completed and saved to the database before we refresh the |
| 938 | 938 | // rewrite rules. |
| 939 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
| 940 | - if( '1' == $option ) { |
|
| 939 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
| 940 | + if ('1' == $option) { |
|
| 941 | 941 | |
| 942 | 942 | update_option('sensei_flush_rewrite_rules', '2'); |
| 943 | 943 | |
| 944 | - }elseif( '2' == $option ) { |
|
| 944 | + }elseif ('2' == $option) { |
|
| 945 | 945 | |
| 946 | 946 | flush_rewrite_rules(); |
| 947 | 947 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | * |
| 957 | 957 | * @since 1.9.0 |
| 958 | 958 | */ |
| 959 | - public function initiate_rewrite_rules_flush(){ |
|
| 959 | + public function initiate_rewrite_rules_flush() { |
|
| 960 | 960 | |
| 961 | 961 | update_option('sensei_flush_rewrite_rules', '1'); |
| 962 | 962 | |
@@ -973,9 +973,9 @@ discard block |
||
| 973 | 973 | * |
| 974 | 974 | * @return void |
| 975 | 975 | */ |
| 976 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
| 976 | + public function sensei_woocommerce_email_course_details($order) { |
|
| 977 | 977 | |
| 978 | - Sensei_WC::email_course_details( $order ); |
|
| 978 | + Sensei_WC::email_course_details($order); |
|
| 979 | 979 | |
| 980 | 980 | } // end func email course details |
| 981 | 981 | |
@@ -984,9 +984,9 @@ discard block |
||
| 984 | 984 | * @param $user_id |
| 985 | 985 | * @param $subscription_key |
| 986 | 986 | */ |
| 987 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){ |
|
| 987 | + public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) { |
|
| 988 | 988 | |
| 989 | - Sensei_WC::reactivate_subscription( $user_id, $subscription_key ); |
|
| 989 | + Sensei_WC::reactivate_subscription($user_id, $subscription_key); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
@@ -994,9 +994,9 @@ discard block |
||
| 994 | 994 | * @param $user_id |
| 995 | 995 | * @param $subscription_key |
| 996 | 996 | */ |
| 997 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){ |
|
| 997 | + public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) { |
|
| 998 | 998 | |
| 999 | - Sensei_WC::end_subscription( $user_id, $subscription_key ); |
|
| 999 | + Sensei_WC::end_subscription($user_id, $subscription_key); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1009,9 +1009,9 @@ discard block |
||
| 1009 | 1009 | * |
| 1010 | 1010 | * @return void |
| 1011 | 1011 | */ |
| 1012 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
| 1012 | + public function sensei_woocommerce_complete_order($order_id = 0) { |
|
| 1013 | 1013 | |
| 1014 | - Sensei_WC::complete_order( $order_id ); |
|
| 1014 | + Sensei_WC::complete_order($order_id); |
|
| 1015 | 1015 | |
| 1016 | 1016 | } // End sensei_woocommerce_complete_order() |
| 1017 | 1017 | |
@@ -1024,9 +1024,9 @@ discard block |
||
| 1024 | 1024 | * @param integer $order_id order ID |
| 1025 | 1025 | * @return void |
| 1026 | 1026 | */ |
| 1027 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
| 1027 | + public function sensei_woocommerce_cancel_order($order_id) { |
|
| 1028 | 1028 | |
| 1029 | - Sensei_WC::cancel_order( $order_id ); |
|
| 1029 | + Sensei_WC::cancel_order($order_id); |
|
| 1030 | 1030 | |
| 1031 | 1031 | } // End sensei_woocommerce_cancel_order() |
| 1032 | 1032 | |
@@ -1038,9 +1038,9 @@ discard block |
||
| 1038 | 1038 | * @param integer $order_id order ID |
| 1039 | 1039 | * @return void |
| 1040 | 1040 | */ |
| 1041 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
| 1041 | + public function sensei_activate_subscription($order_id = 0) { |
|
| 1042 | 1042 | |
| 1043 | - Sensei_WC::activate_subscription( $order_id ); |
|
| 1043 | + Sensei_WC::activate_subscription($order_id); |
|
| 1044 | 1044 | |
| 1045 | 1045 | } // End sensei_activate_subscription() |
| 1046 | 1046 | |
@@ -1052,9 +1052,9 @@ discard block |
||
| 1052 | 1052 | * @param array/Object $order_user (default: array()) Specific user's data. |
| 1053 | 1053 | * @return bool|int |
| 1054 | 1054 | */ |
| 1055 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
| 1055 | + public function woocommerce_course_update($course_id = 0, $order_user = array()) { |
|
| 1056 | 1056 | |
| 1057 | - return Sensei_WC::course_update( $course_id, $order_user ); |
|
| 1057 | + return Sensei_WC::course_update($course_id, $order_user); |
|
| 1058 | 1058 | |
| 1059 | 1059 | } // End woocommerce_course_update() |
| 1060 | 1060 | |
@@ -1071,9 +1071,9 @@ discard block |
||
| 1071 | 1071 | * |
| 1072 | 1072 | * @return WC_Product $wc_product_object |
| 1073 | 1073 | */ |
| 1074 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
| 1074 | + public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') { |
|
| 1075 | 1075 | |
| 1076 | - return Sensei_WC::get_product_object( $wc_product_id, $product_type ); |
|
| 1076 | + return Sensei_WC::get_product_object($wc_product_id, $product_type); |
|
| 1077 | 1077 | |
| 1078 | 1078 | } // End sensei_get_woocommerce_product_object() |
| 1079 | 1079 | |
@@ -1095,9 +1095,9 @@ discard block |
||
| 1095 | 1095 | * @param boolean $guest_checkout Current guest checkout setting |
| 1096 | 1096 | * @return boolean Modified guest checkout setting |
| 1097 | 1097 | */ |
| 1098 | - public function disable_guest_checkout( $guest_checkout ) { |
|
| 1098 | + public function disable_guest_checkout($guest_checkout) { |
|
| 1099 | 1099 | |
| 1100 | - return Sensei_WC::disable_guest_checkout( $guest_checkout ); |
|
| 1100 | + return Sensei_WC::disable_guest_checkout($guest_checkout); |
|
| 1101 | 1101 | |
| 1102 | 1102 | }// end disable_guest_checkout |
| 1103 | 1103 | |
@@ -1111,9 +1111,9 @@ discard block |
||
| 1111 | 1111 | * @param int $order_id |
| 1112 | 1112 | * @return string |
| 1113 | 1113 | **/ |
| 1114 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
| 1114 | + public function virtual_order_payment_complete($order_status, $order_id) { |
|
| 1115 | 1115 | |
| 1116 | - return Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ); |
|
| 1116 | + return Sensei_WC::virtual_order_payment_complete($order_status, $order_id); |
|
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | } // End Class |
@@ -1123,4 +1123,4 @@ discard block |
||
| 1123 | 1123 | * @ignore only for backward compatibility |
| 1124 | 1124 | * @since 1.9.0 |
| 1125 | 1125 | */ |
| 1126 | -class Woothemes_Sensei extends Sensei_Main{ } |
|
| 1126 | +class Woothemes_Sensei extends Sensei_Main { } |
|
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | ***************************/ |
| 20 | 20 | //This hook allow us to change the template WordPress loads for a given page/post_type @since 1.9.0 |
| 21 | -add_filter( 'template_include', array ( 'Sensei_Templates', 'template_loader' ), 10, 1 ); |
|
| 21 | +add_filter('template_include', array('Sensei_Templates', 'template_loader'), 10, 1); |
|
| 22 | 22 | |
| 23 | 23 | //This hook adds the sensei pagination to the pagination hook |
| 24 | -add_action( 'sensei_pagination', array( 'Sensei_Frontend', 'load_content_pagination' ), 30 ); |
|
| 24 | +add_action('sensei_pagination', array('Sensei_Frontend', 'load_content_pagination'), 30); |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | /*************************** |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | ***************************/ |
| 34 | 34 | // deprecate the archive content hook @since 1.9.0 |
| 35 | -add_action( 'sensei_archive_before_course_loop', array ( 'Sensei_Templates', 'deprecated_archive_course_content_hook' ), 10, 1 ); |
|
| 35 | +add_action('sensei_archive_before_course_loop', array('Sensei_Templates', 'deprecated_archive_course_content_hook'), 10, 1); |
|
| 36 | 36 | |
| 37 | 37 | // Course archive title hook @since 1.9.0 |
| 38 | -add_action('sensei_archive_before_course_loop', array( 'Sensei_Course', 'archive_header' ), 10, 0 ); |
|
| 38 | +add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'archive_header'), 10, 0); |
|
| 39 | 39 | |
| 40 | 40 | // add the course image above the content |
| 41 | -add_action('sensei_course_content_inside_before', array( Sensei()->course, 'course_image' ) ,10, 1 ); |
|
| 41 | +add_action('sensei_course_content_inside_before', array(Sensei()->course, 'course_image'), 10, 1); |
|
| 42 | 42 | |
| 43 | 43 | // add course content title to the courses on the archive page |
| 44 | -add_action('sensei_course_content_inside_before', array( 'Sensei_Templates', 'the_title' ) ,5, 1 ); |
|
| 44 | +add_action('sensei_course_content_inside_before', array('Sensei_Templates', 'the_title'), 5, 1); |
|
| 45 | 45 | |
| 46 | 46 | /*************************** |
| 47 | 47 | * |
@@ -53,33 +53,33 @@ discard block |
||
| 53 | 53 | // @1.9.0 |
| 54 | 54 | // add deprecated action hooks for backwards compatibility sake |
| 55 | 55 | // hooks on single course page: sensei_course_image , sensei_course_single_title, sensei_course_single_meta |
| 56 | -add_action('sensei_single_course_content_inside_before', array( 'Sensei_Templates', 'deprecated_single_course_inside_before_hooks' ), 80); |
|
| 56 | +add_action('sensei_single_course_content_inside_before', array('Sensei_Templates', 'deprecated_single_course_inside_before_hooks'), 80); |
|
| 57 | 57 | |
| 58 | 58 | // @1.9.0 |
| 59 | 59 | // hook the single course title on the single course page |
| 60 | -add_action( 'sensei_single_course_content_inside_before',array( 'Sensei_Course', 'the_title'), 10 ); |
|
| 60 | +add_action('sensei_single_course_content_inside_before', array('Sensei_Course', 'the_title'), 10); |
|
| 61 | 61 | |
| 62 | 62 | // @1.9.0 |
| 63 | 63 | // hook the single course title on the single course page |
| 64 | -add_action( 'sensei_single_course_content_inside_before', array( Sensei()->course , 'course_image'), 20 ); |
|
| 64 | +add_action('sensei_single_course_content_inside_before', array(Sensei()->course, 'course_image'), 20); |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | // @1.9.0 |
| 68 | 68 | //Add legacy hooks deprecated in 1.9.0 |
| 69 | -add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Templates','deprecate_course_single_meta_hooks'), 10 ); |
|
| 69 | +add_action('sensei_single_course_content_inside_before', array('Sensei_Templates', 'deprecate_course_single_meta_hooks'), 10); |
|
| 70 | 70 | |
| 71 | 71 | // @1.9.0 |
| 72 | 72 | // Filter the content and replace it with the excerpt if the user doesn't have full access |
| 73 | -add_filter( 'the_content', array( 'Sensei_Course', 'single_course_content' ) ); |
|
| 73 | +add_filter('the_content', array('Sensei_Course', 'single_course_content')); |
|
| 74 | 74 | |
| 75 | 75 | // @1.9.0 |
| 76 | 76 | // Deprecate lessons specific single course hooks |
| 77 | -add_action( 'sensei_single_course_content_inside_after', array( 'Sensei_Templates','deprecate_sensei_course_single_lessons_hook' ) ); |
|
| 77 | +add_action('sensei_single_course_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_course_single_lessons_hook')); |
|
| 78 | 78 | |
| 79 | 79 | // @1.9.0 |
| 80 | 80 | // Deprecate single main content hooks |
| 81 | -add_action( 'sensei_single_course_content_inside_after', array( 'Sensei_Templates', 'deprecated_single_main_content_hook') ); |
|
| 82 | -add_action( 'sensei_single_message_content_inside_after', array( 'Sensei_Templates', 'deprecated_single_main_content_hook') ); |
|
| 81 | +add_action('sensei_single_course_content_inside_after', array('Sensei_Templates', 'deprecated_single_main_content_hook')); |
|
| 82 | +add_action('sensei_single_message_content_inside_after', array('Sensei_Templates', 'deprecated_single_main_content_hook')); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Deprecate all the post type single titile hooks in favor of before content and after content hooks |
@@ -87,75 +87,75 @@ discard block |
||
| 87 | 87 | * @deprecate 1.9.0 |
| 88 | 88 | * @1.9.0 |
| 89 | 89 | */ |
| 90 | -add_action('sensei_single_message_content_inside_before', array( 'Sensei_Templates', 'deprecate_all_post_type_single_title_hooks' ) ); |
|
| 90 | +add_action('sensei_single_message_content_inside_before', array('Sensei_Templates', 'deprecate_all_post_type_single_title_hooks')); |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Deprecate hooks into the single course modules |
| 94 | 94 | * @deprecated since 1.9.0 |
| 95 | 95 | */ |
| 96 | -add_action('sensei_single_course_modules_before', array('Sensei_Templates','deprecate_module_before_hook' ) ); |
|
| 97 | -add_action('sensei_single_course_modules_after', array('Sensei_Templates','deprecate_module_after_hook' ) ); |
|
| 96 | +add_action('sensei_single_course_modules_before', array('Sensei_Templates', 'deprecate_module_before_hook')); |
|
| 97 | +add_action('sensei_single_course_modules_after', array('Sensei_Templates', 'deprecate_module_after_hook')); |
|
| 98 | 98 | |
| 99 | 99 | // @since 1.9.0 |
| 100 | 100 | // add the single course lessons title |
| 101 | -add_action( 'sensei_single_course_content_inside_after' , array( 'Sensei_Course','the_course_lessons_title'), 9 ); |
|
| 101 | +add_action('sensei_single_course_content_inside_after', array('Sensei_Course', 'the_course_lessons_title'), 9); |
|
| 102 | 102 | |
| 103 | 103 | // @since 1.9.0 |
| 104 | 104 | // hooks in the course lessons query and remove it at the end |
| 105 | 105 | // also loading the course lessons template in the middle |
| 106 | -add_action( 'sensei_single_course_lessons_before', array('Sensei_Course','load_single_course_lessons_query' ) ); |
|
| 107 | -add_action( 'sensei_single_course_content_inside_after', 'course_single_lessons', 10 ); |
|
| 108 | -add_action( 'sensei_single_course_lessons_after', array( 'Sensei_Utils','restore_wp_query' )); |
|
| 106 | +add_action('sensei_single_course_lessons_before', array('Sensei_Course', 'load_single_course_lessons_query')); |
|
| 107 | +add_action('sensei_single_course_content_inside_after', 'course_single_lessons', 10); |
|
| 108 | +add_action('sensei_single_course_lessons_after', array('Sensei_Utils', 'restore_wp_query')); |
|
| 109 | 109 | |
| 110 | 110 | // @since 1.9.0 |
| 111 | 111 | // add post classes to the lessons on the single course page |
| 112 | -add_filter( 'post_class', array( 'Sensei_Lesson', 'single_course_lessons_classes' ) ); |
|
| 112 | +add_filter('post_class', array('Sensei_Lesson', 'single_course_lessons_classes')); |
|
| 113 | 113 | |
| 114 | 114 | // @since 1.9.0 |
| 115 | 115 | // lesson meta information on the single course page |
| 116 | -add_action( 'sensei_single_course_inside_before_lesson', array('Sensei_Lesson','the_lesson_meta') , 5); |
|
| 116 | +add_action('sensei_single_course_inside_before_lesson', array('Sensei_Lesson', 'the_lesson_meta'), 5); |
|
| 117 | 117 | |
| 118 | 118 | //@since 1.9.0 |
| 119 | 119 | // lesson image |
| 120 | -add_action( 'sensei_single_course_inside_before_lesson', array('Sensei_Lesson','the_lesson_thumbnail') , 8); |
|
| 120 | +add_action('sensei_single_course_inside_before_lesson', array('Sensei_Lesson', 'the_lesson_thumbnail'), 8); |
|
| 121 | 121 | |
| 122 | 122 | //@since 1.9.0 |
| 123 | 123 | // lesson custom excerpts |
| 124 | -add_filter( 'get_the_excerpt', array( 'Sensei_Lesson', 'alter_the_lesson_excerpt' ) ); |
|
| 124 | +add_filter('get_the_excerpt', array('Sensei_Lesson', 'alter_the_lesson_excerpt')); |
|
| 125 | 125 | |
| 126 | 126 | // @since 1.9.0 |
| 127 | 127 | // run a deprecated hook for backwards compatibility sake |
| 128 | -add_action( 'sensei_single_course_modules_before', array( 'Sensei_Core_Modules', 'deprecate_sensei_single_course_modules_content' ) ); |
|
| 128 | +add_action('sensei_single_course_modules_before', array('Sensei_Core_Modules', 'deprecate_sensei_single_course_modules_content')); |
|
| 129 | 129 | |
| 130 | 130 | // @since 1.9.0 |
| 131 | 131 | // hook in the module loop intialization functionality |
| 132 | -add_action( 'sensei_single_course_modules_before', array( 'Sensei_Core_Modules', 'setup_single_course_module_loop' ) ); |
|
| 132 | +add_action('sensei_single_course_modules_before', array('Sensei_Core_Modules', 'setup_single_course_module_loop')); |
|
| 133 | 133 | |
| 134 | 134 | // @since 1.9.0 |
| 135 | 135 | // hook in the module loop destructor functionality |
| 136 | -add_action( 'sensei_single_course_modules_after', array( 'Sensei_Core_Modules', 'teardown_single_course_module_loop' ) ); |
|
| 136 | +add_action('sensei_single_course_modules_after', array('Sensei_Core_Modules', 'teardown_single_course_module_loop')); |
|
| 137 | 137 | |
| 138 | 138 | // @since 1.9.0 |
| 139 | 139 | // hook in the possible full content override to show instead of excerpt |
| 140 | -add_filter('get_the_excerpt', array( 'Sensei_Course', 'full_content_excerpt_override' ) ); |
|
| 140 | +add_filter('get_the_excerpt', array('Sensei_Course', 'full_content_excerpt_override')); |
|
| 141 | 141 | |
| 142 | 142 | //@since 1.9.0 |
| 143 | 143 | //Course meta |
| 144 | -add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Course', 'the_course_enrolment_actions' ), 30 ); |
|
| 145 | -add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Course' , 'the_course_video' ), 40 ); |
|
| 144 | +add_action('sensei_single_course_content_inside_before', array('Sensei_Course', 'the_course_enrolment_actions'), 30); |
|
| 145 | +add_action('sensei_single_course_content_inside_before', array('Sensei_Course', 'the_course_video'), 40); |
|
| 146 | 146 | |
| 147 | 147 | // |
| 148 | 148 | //// no permissions template for the single course |
| 149 | 149 | // |
| 150 | -add_action( 'sensei_no_permissions_inside_before_content', array( 'Sensei_Course', 'the_title'), 20 ); |
|
| 151 | -add_action( 'sensei_no_permissions_inside_before_content', array( 'Sensei_Course', 'the_course_enrolment_actions' ), 23 ); |
|
| 152 | -add_action( 'sensei_no_permissions_inside_before_content', array( Sensei()->course , 'course_image'), 25 ); |
|
| 153 | -add_action( 'sensei_no_permissions_inside_before_content', array( 'Sensei_Course' , 'the_course_video' ), 40 ); |
|
| 154 | -add_action( 'sensei_no_permissions_inside_after_content', array( Sensei()->modules, 'load_course_module_content_template') , 43 ); |
|
| 155 | -add_action( 'sensei_no_permissions_inside_after_content' , array( 'Sensei_Course','the_course_lessons_title'), 45 ); |
|
| 156 | -add_action( 'sensei_no_permissions_inside_after_content', array('Sensei_Course','load_single_course_lessons_query' ),50 ); |
|
| 157 | -add_action( 'sensei_no_permissions_inside_after_content', 'course_single_lessons', 60 ); |
|
| 158 | -add_action( 'sensei_no_permissions_inside_after_content', array( 'Sensei_Utils','restore_wp_query' ), 70); |
|
| 150 | +add_action('sensei_no_permissions_inside_before_content', array('Sensei_Course', 'the_title'), 20); |
|
| 151 | +add_action('sensei_no_permissions_inside_before_content', array('Sensei_Course', 'the_course_enrolment_actions'), 23); |
|
| 152 | +add_action('sensei_no_permissions_inside_before_content', array(Sensei()->course, 'course_image'), 25); |
|
| 153 | +add_action('sensei_no_permissions_inside_before_content', array('Sensei_Course', 'the_course_video'), 40); |
|
| 154 | +add_action('sensei_no_permissions_inside_after_content', array(Sensei()->modules, 'load_course_module_content_template'), 43); |
|
| 155 | +add_action('sensei_no_permissions_inside_after_content', array('Sensei_Course', 'the_course_lessons_title'), 45); |
|
| 156 | +add_action('sensei_no_permissions_inside_after_content', array('Sensei_Course', 'load_single_course_lessons_query'), 50); |
|
| 157 | +add_action('sensei_no_permissions_inside_after_content', 'course_single_lessons', 60); |
|
| 158 | +add_action('sensei_no_permissions_inside_after_content', array('Sensei_Utils', 'restore_wp_query'), 70); |
|
| 159 | 159 | |
| 160 | 160 | /*************************** |
| 161 | 161 | * |
@@ -166,54 +166,54 @@ discard block |
||
| 166 | 166 | ***************************/ |
| 167 | 167 | //@since 1.9.0 |
| 168 | 168 | // deprecate hooks no longer needed |
| 169 | -add_action( 'sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_single_main_content_hook' ) ); |
|
| 170 | -add_action( 'sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_quiz_single_title_hook' ) ); |
|
| 169 | +add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_single_main_content_hook')); |
|
| 170 | +add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_quiz_single_title_hook')); |
|
| 171 | 171 | |
| 172 | 172 | //@since 1.9.0 |
| 173 | 173 | // Single quiz title |
| 174 | -add_filter( 'the_title', array( 'Sensei_Quiz' , 'single_quiz_title' ), 20 , 2 ); // append Quiz |
|
| 175 | -add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Quiz', 'the_title' ), 20 ); //output single quiz |
|
| 174 | +add_filter('the_title', array('Sensei_Quiz', 'single_quiz_title'), 20, 2); // append Quiz |
|
| 175 | +add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'the_title'), 20); //output single quiz |
|
| 176 | 176 | |
| 177 | 177 | // since 1.9.0 |
| 178 | 178 | // initialize the quiz questions loop |
| 179 | -add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Quiz', 'start_quiz_questions_loop') ); |
|
| 179 | +add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'start_quiz_questions_loop')); |
|
| 180 | 180 | |
| 181 | 181 | // since 1.9.0 |
| 182 | 182 | // hook in the quiz user message |
| 183 | -add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Quiz', 'the_user_status_message' ), 40 ); |
|
| 183 | +add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'the_user_status_message'), 40); |
|
| 184 | 184 | |
| 185 | 185 | //@since 1.9.0 |
| 186 | 186 | // hook in the question title, description and quesiton media |
| 187 | -add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_title' ), 10 ); |
|
| 188 | -add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_description' ), 20 ); |
|
| 189 | -add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_media' ), 30 ); |
|
| 190 | -add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_hidden_fields' ), 40 ); |
|
| 187 | +add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_title'), 10); |
|
| 188 | +add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_description'), 20); |
|
| 189 | +add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_media'), 30); |
|
| 190 | +add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_hidden_fields'), 40); |
|
| 191 | 191 | |
| 192 | 192 | //@since 1.9.0 |
| 193 | 193 | // hook in incorrect / correct message above questions if the quiz has been graded |
| 194 | -add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question', 'the_answer_result_indication' ), 50 ); |
|
| 194 | +add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_answer_result_indication'), 50); |
|
| 195 | 195 | |
| 196 | 196 | //@since 1.9.0 |
| 197 | 197 | // add answer grading feedback at the bottom of the question |
| 198 | -add_action( 'sensei_quiz_question_inside_after', array( 'Sensei_Question', 'answer_feedback_notes' ) ); |
|
| 198 | +add_action('sensei_quiz_question_inside_after', array('Sensei_Question', 'answer_feedback_notes')); |
|
| 199 | 199 | |
| 200 | 200 | //@since 1.9.0 |
| 201 | 201 | // add extra question data for different quesiton types when get_question_template_data_is_called. |
| 202 | -add_filter( 'sensei_get_question_template_data', array( 'Sensei_Question','multiple_choice_load_question_data'), 10, 3); |
|
| 203 | -add_filter( 'sensei_get_question_template_data', array( 'Sensei_Question','gap_fill_load_question_data'), 10, 3); |
|
| 204 | -add_filter( 'sensei_get_question_template_data', array( 'Sensei_Question','file_upload_load_question_data'), 10, 3); |
|
| 202 | +add_filter('sensei_get_question_template_data', array('Sensei_Question', 'multiple_choice_load_question_data'), 10, 3); |
|
| 203 | +add_filter('sensei_get_question_template_data', array('Sensei_Question', 'gap_fill_load_question_data'), 10, 3); |
|
| 204 | +add_filter('sensei_get_question_template_data', array('Sensei_Question', 'file_upload_load_question_data'), 10, 3); |
|
| 205 | 205 | |
| 206 | 206 | //@since 1.9.0 |
| 207 | 207 | // deprecate the quiz button action |
| 208 | -add_action( 'sensei_single_quiz_questions_after', array( 'Sensei_Quiz', 'action_buttons' ), 10, 0 ); |
|
| 208 | +add_action('sensei_single_quiz_questions_after', array('Sensei_Quiz', 'action_buttons'), 10, 0); |
|
| 209 | 209 | |
| 210 | 210 | //@since 1.9.0 |
| 211 | 211 | // deprecate the sensei_complete_quiz hook |
| 212 | -add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Templates', 'deprecate_sensei_complete_quiz_action' )); |
|
| 212 | +add_action('sensei_single_quiz_content_inside_before', array('Sensei_Templates', 'deprecate_sensei_complete_quiz_action')); |
|
| 213 | 213 | |
| 214 | 214 | //@since 1.9.0 |
| 215 | 215 | // deprecate the sensei_quiz_question_type hook |
| 216 | -add_action( 'sensei_quiz_question_inside_after', array( 'Sensei_Templates', 'deprecate_sensei_quiz_question_type_action' )); |
|
| 216 | +add_action('sensei_quiz_question_inside_after', array('Sensei_Templates', 'deprecate_sensei_quiz_question_type_action')); |
|
| 217 | 217 | |
| 218 | 218 | /*************************** |
| 219 | 219 | * |
@@ -224,63 +224,63 @@ discard block |
||
| 224 | 224 | ***************************/ |
| 225 | 225 | //@since 1.9.0 |
| 226 | 226 | // deprecate the main content hook on the single lesson page |
| 227 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Templates', 'deprecate_lesson_single_main_content_hook' ), 20); |
|
| 227 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Templates', 'deprecate_lesson_single_main_content_hook'), 20); |
|
| 228 | 228 | |
| 229 | 229 | //@since 1.9.0 |
| 230 | 230 | // hook in the lesson image on the single lesson |
| 231 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'the_lesson_image' ), 17 ); |
|
| 231 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'the_lesson_image'), 17); |
|
| 232 | 232 | |
| 233 | 233 | //@since 1.9.0 |
| 234 | 234 | // hook in the lesson image on the single lesson deprecated hook function |
| 235 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Templates','deprecate_lesson_image_hook' ), 10 ); |
|
| 235 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Templates', 'deprecate_lesson_image_hook'), 10); |
|
| 236 | 236 | |
| 237 | 237 | //@since 1.9.0 |
| 238 | 238 | // hook in the lesson single title deprecated function |
| 239 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Templates', 'deprecate_sensei_lesson_single_title' ), 15 ); |
|
| 239 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Templates', 'deprecate_sensei_lesson_single_title'), 15); |
|
| 240 | 240 | |
| 241 | 241 | // @since 1.9.0 |
| 242 | 242 | // hook in the sensei lesson user notices |
| 243 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'user_not_taking_course_message' ), 15 ); |
|
| 243 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'user_not_taking_course_message'), 15); |
|
| 244 | 244 | |
| 245 | 245 | // @since 1.9.0 |
| 246 | 246 | // attach the lesson title |
| 247 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'the_title' ), 15 ); |
|
| 247 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'the_title'), 15); |
|
| 248 | 248 | |
| 249 | 249 | //@since 1.9.0 |
| 250 | 250 | // hook in the lesson image on the single lesson |
| 251 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'user_lesson_quiz_status_message' ), 20 ); |
|
| 251 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'user_lesson_quiz_status_message'), 20); |
|
| 252 | 252 | |
| 253 | 253 | // @since 1.9.0 |
| 254 | 254 | // add the single lesson meta |
| 255 | -add_action( 'sensei_single_lesson_content_inside_after', 'sensei_the_single_lesson_meta', 10 ); |
|
| 255 | +add_action('sensei_single_lesson_content_inside_after', 'sensei_the_single_lesson_meta', 10); |
|
| 256 | 256 | |
| 257 | 257 | // @since 1.9.0 |
| 258 | 258 | // deprecate the sensei_lesson_single_meta hook |
| 259 | -add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Templates', 'deprecate_sensei_lesson_single_meta_hook' ), 15 ); |
|
| 259 | +add_action('sensei_single_lesson_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_lesson_single_meta_hook'), 15); |
|
| 260 | 260 | |
| 261 | 261 | // @since 1.9.0 |
| 262 | 262 | // deprecate the sensei_lesson_course_signup hook |
| 263 | -add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Templates','deprecate_sensei_lesson_course_signup_hook' ), 20 ); |
|
| 263 | +add_action('sensei_single_lesson_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_lesson_course_signup_hook'), 20); |
|
| 264 | 264 | |
| 265 | 265 | // @since 1.9.0 |
| 266 | 266 | // hook in the lesson prerequisite completion message |
| 267 | -add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Lesson', 'prerequisite_complete_message' ), 20 ); |
|
| 267 | +add_action('sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'prerequisite_complete_message'), 20); |
|
| 268 | 268 | |
| 269 | 269 | // @since 1.9.0 |
| 270 | 270 | // hook the single lesson course_signup_link |
| 271 | -add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'course_signup_link' ), 30 ); |
|
| 271 | +add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'course_signup_link'), 30); |
|
| 272 | 272 | |
| 273 | 273 | // @since 1.9.0 |
| 274 | 274 | // hook the deprecate breadcrumbs and comments hooks |
| 275 | -add_action( 'sensei_after_main_content', array( 'Sensei_Templates', 'deprecate_single_lesson_breadcrumbs_and_comments_hooks'), 5 ); |
|
| 275 | +add_action('sensei_after_main_content', array('Sensei_Templates', 'deprecate_single_lesson_breadcrumbs_and_comments_hooks'), 5); |
|
| 276 | 276 | |
| 277 | 277 | // @since 1.9.0 |
| 278 | 278 | // Add the quiz specific buttons and notices to the lesson |
| 279 | -add_action( 'sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'footer_quiz_call_to_action' )); |
|
| 279 | +add_action('sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'footer_quiz_call_to_action')); |
|
| 280 | 280 | |
| 281 | 281 | // @since 1.9.0 |
| 282 | 282 | // hook in the comments on the single lessons page |
| 283 | -add_action( 'sensei_pagination', array( 'Sensei_Lesson', 'output_comments' ), 90 ); |
|
| 283 | +add_action('sensei_pagination', array('Sensei_Lesson', 'output_comments'), 90); |
|
| 284 | 284 | |
| 285 | 285 | /********************** |
| 286 | 286 | * |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | ************************/ |
| 292 | 292 | |
| 293 | -add_action( 'sensei_single_message_content_inside_before', array( 'Sensei_Messages', 'the_title' ), 20 ); |
|
| 293 | +add_action('sensei_single_message_content_inside_before', array('Sensei_Messages', 'the_title'), 20); |
|
| 294 | 294 | |
| 295 | -add_action( 'sensei_single_message_content_inside_before', array( 'Sensei_Messages', 'the_message_sent_by_title' ), 40 ); |
|
| 295 | +add_action('sensei_single_message_content_inside_before', array('Sensei_Messages', 'the_message_sent_by_title'), 40); |
|
| 296 | 296 | |
| 297 | 297 | /************************* |
| 298 | 298 | * |
@@ -304,19 +304,19 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | // deprecate the sensei_lesson_archive_header hook |
| 306 | 306 | // @deprecated since 1.9.0 |
| 307 | -add_action( 'sensei_loop_lesson_inside_before', array( 'Sensei_Lesson', 'deprecate_sensei_lesson_archive_header_hook' ), 20 ); |
|
| 307 | +add_action('sensei_loop_lesson_inside_before', array('Sensei_Lesson', 'deprecate_sensei_lesson_archive_header_hook'), 20); |
|
| 308 | 308 | |
| 309 | 309 | // @1.9.0 |
| 310 | 310 | //The archive title header on the lesson archive loop |
| 311 | -add_action( 'sensei_loop_lesson_inside_before', array( Sensei()->lesson, 'the_archive_header' ), 20 ); |
|
| 311 | +add_action('sensei_loop_lesson_inside_before', array(Sensei()->lesson, 'the_archive_header'), 20); |
|
| 312 | 312 | |
| 313 | 313 | // @since 1.9.0 |
| 314 | 314 | //Output the lesson header on the content-lesson.php which runs inside the lessons loop |
| 315 | -add_action( 'sensei_content_lesson_inside_before', array( 'Sensei_Lesson', 'the_lesson_meta' ), 20 ); |
|
| 315 | +add_action('sensei_content_lesson_inside_before', array('Sensei_Lesson', 'the_lesson_meta'), 20); |
|
| 316 | 316 | |
| 317 | 317 | // @since 1.9.0 |
| 318 | 318 | // output only part of the lesson on the archive |
| 319 | -add_filter('the_content', array( 'Sensei_Lesson','limit_archive_content' ) ); |
|
| 319 | +add_filter('the_content', array('Sensei_Lesson', 'limit_archive_content')); |
|
| 320 | 320 | |
| 321 | 321 | /************************** |
| 322 | 322 | * |
@@ -327,15 +327,15 @@ discard block |
||
| 327 | 327 | **************************/ |
| 328 | 328 | // @since 1.9.0 |
| 329 | 329 | // deprecate the learner profile content hook as the markup code is added in the template directly. |
| 330 | -add_action('sensei_learner_profile_content_before', array( 'Sensei_Learner_Profiles', 'deprecate_sensei_learner_profile_content_hook' ) ); |
|
| 330 | +add_action('sensei_learner_profile_content_before', array('Sensei_Learner_Profiles', 'deprecate_sensei_learner_profile_content_hook')); |
|
| 331 | 331 | |
| 332 | 332 | // @since 1.9.0 |
| 333 | 333 | // do the sensei complete course action on the learner profiles page. |
| 334 | -add_action('sensei_learner_profile_content_before', array( 'Sensei_Templates', 'fire_sensei_complete_course_hook' ) ); |
|
| 334 | +add_action('sensei_learner_profile_content_before', array('Sensei_Templates', 'fire_sensei_complete_course_hook')); |
|
| 335 | 335 | |
| 336 | 336 | // @since 1.9.0 |
| 337 | 337 | // fire the frontend messages hook before the profile content |
| 338 | -add_action('sensei_learner_profile_inside_content_before', array( 'Sensei_Templates', 'fire_frontend_messages_hook' ) ); |
|
| 338 | +add_action('sensei_learner_profile_inside_content_before', array('Sensei_Templates', 'fire_frontend_messages_hook')); |
|
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | /********************************** |
@@ -348,22 +348,22 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | // @since 1.9.0 |
| 350 | 350 | // fire the deprecated hook function within the course-result.php file |
| 351 | -add_action( 'sensei_course_results_content_before', array('Sensei_Course_Results','deprecate_sensei_course_results_content_hook') ); |
|
| 351 | +add_action('sensei_course_results_content_before', array('Sensei_Course_Results', 'deprecate_sensei_course_results_content_hook')); |
|
| 352 | 352 | |
| 353 | 353 | // @since 1.9.0 |
| 354 | 354 | // load the course information on the course results page |
| 355 | -add_action( 'sensei_course_results_content_inside_before_lessons', array( Sensei()->course_results,'course_info') ); |
|
| 355 | +add_action('sensei_course_results_content_inside_before_lessons', array(Sensei()->course_results, 'course_info')); |
|
| 356 | 356 | |
| 357 | 357 | // @since 1.9.0 |
| 358 | -add_action( 'sensei_course_results_content_inside_before', array( Sensei()->course,'course_image') ); |
|
| 358 | +add_action('sensei_course_results_content_inside_before', array(Sensei()->course, 'course_image')); |
|
| 359 | 359 | |
| 360 | 360 | // @since 1.9.0 |
| 361 | 361 | // deprecate the course results top hook in favour of a new hook |
| 362 | -add_action( 'sensei_course_results_content_inside_before', array( 'Sensei_Course_Results', 'deprecate_course_results_top_hook') ); |
|
| 362 | +add_action('sensei_course_results_content_inside_before', array('Sensei_Course_Results', 'deprecate_course_results_top_hook')); |
|
| 363 | 363 | |
| 364 | 364 | // @since 1.9.0 |
| 365 | 365 | // Fire the course image hook within the course results page |
| 366 | -add_action( 'sensei_course_results_content_inside_before', array( 'Sensei_Course_Results', 'fire_course_image_hook') ); |
|
| 366 | +add_action('sensei_course_results_content_inside_before', array('Sensei_Course_Results', 'fire_course_image_hook')); |
|
| 367 | 367 | |
| 368 | 368 | |
| 369 | 369 | /********************************** |
@@ -375,19 +375,19 @@ discard block |
||
| 375 | 375 | ********************************/ |
| 376 | 376 | // @since 1.9.0 |
| 377 | 377 | // fire the sensei complete course action on the my courses template |
| 378 | -add_action( 'sensei_my_courses_before', array( 'Sensei_Templates', 'fire_sensei_complete_course_hook' ) ); |
|
| 378 | +add_action('sensei_my_courses_before', array('Sensei_Templates', 'fire_sensei_complete_course_hook')); |
|
| 379 | 379 | |
| 380 | 380 | // @since 1.9.0 |
| 381 | 381 | // fire the sensei frontend messages hook before the my-courses content |
| 382 | -add_action('sensei_my_courses_content_inside_before', array( 'Sensei_Templates', 'fire_frontend_messages_hook' ) ); |
|
| 382 | +add_action('sensei_my_courses_content_inside_before', array('Sensei_Templates', 'fire_frontend_messages_hook')); |
|
| 383 | 383 | |
| 384 | 384 | // @since 1.9.0 |
| 385 | 385 | // deprecate the sensei_before_user_course_content hook |
| 386 | -add_action('sensei_my_courses_content_inside_before', array( 'Sensei_Templates', 'deprecate_sensei_before_user_course_content_hook' ) ); |
|
| 386 | +add_action('sensei_my_courses_content_inside_before', array('Sensei_Templates', 'deprecate_sensei_before_user_course_content_hook')); |
|
| 387 | 387 | |
| 388 | 388 | // @since 1.9.0 |
| 389 | 389 | // deprecate the sensei_after_user_course_content hook |
| 390 | -add_action('sensei_my_courses_content_inside_after', array( 'Sensei_Templates', 'deprecate_sensei_after_user_course_content_hook' ) ); |
|
| 390 | +add_action('sensei_my_courses_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_after_user_course_content_hook')); |
|
| 391 | 391 | |
| 392 | 392 | /********************************** |
| 393 | 393 | * |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | // @since 1.9.0 |
| 400 | 400 | // deprecate the sensei_login_form hok which was use to load the login form. |
| 401 | 401 | // This now loads independent of the my-courses template which helps keep templates free from logic |
| 402 | -add_action( 'sensei_login_form_before', array( 'Sensei_Templates', 'deprecate_sensei_login_form_hook' ) ); |
|
| 402 | +add_action('sensei_login_form_before', array('Sensei_Templates', 'deprecate_sensei_login_form_hook')); |
|
| 403 | 403 | |
| 404 | 404 | /********************************** |
| 405 | 405 | * |
@@ -410,16 +410,16 @@ discard block |
||
| 410 | 410 | ********************************/ |
| 411 | 411 | // @since 1.9.0 |
| 412 | 412 | // Deprecate the archive messages hooks no longer supported |
| 413 | -add_action( 'sensei_archive_before_message_loop', array( 'Sensei_Templates', 'deprecated_archive_message_hooks' ) ); |
|
| 413 | +add_action('sensei_archive_before_message_loop', array('Sensei_Templates', 'deprecated_archive_message_hooks')); |
|
| 414 | 414 | |
| 415 | 415 | // @since 1.9.0 |
| 416 | 416 | // Deprecate the archive messages hooks no longer supported |
| 417 | -add_action( 'sensei_archive_before_message_loop', array( 'Sensei_Messages', 'the_archive_header' ) ); |
|
| 417 | +add_action('sensei_archive_before_message_loop', array('Sensei_Messages', 'the_archive_header')); |
|
| 418 | 418 | |
| 419 | 419 | // @since 1.9.0 |
| 420 | 420 | // output the message title and the message sensei |
| 421 | -add_action( 'sensei_content_message_before', array( 'Sensei_Messages', 'the_message_title' ), 10, 1 ); |
|
| 422 | -add_action( 'sensei_content_message_before', array( 'Sensei_Messages', 'the_message_sender' ), 20 , 1 ); |
|
| 421 | +add_action('sensei_content_message_before', array('Sensei_Messages', 'the_message_title'), 10, 1); |
|
| 422 | +add_action('sensei_content_message_before', array('Sensei_Messages', 'the_message_sender'), 20, 1); |
|
| 423 | 423 | |
| 424 | 424 | /********************************** |
| 425 | 425 | * |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * |
| 429 | 429 | * |
| 430 | 430 | **********************************/ |
| 431 | -add_action( 'sensei_loop_course_before', array( 'Sensei_Course', 'course_category_title' ), 70 , 1 ); |
|
| 431 | +add_action('sensei_loop_course_before', array('Sensei_Course', 'course_category_title'), 70, 1); |
|
| 432 | 432 | |
| 433 | 433 | /********************************** |
| 434 | 434 | * |
@@ -439,20 +439,20 @@ discard block |
||
| 439 | 439 | **********************************/ |
| 440 | 440 | //@since 1.9.0 |
| 441 | 441 | //add a title to the teacher archive page when view site-url/author/{teacher-username} |
| 442 | -add_action( 'sensei_teacher_archive_course_loop_before', array( 'Sensei_Teacher', 'archive_title' ) ); |
|
| 442 | +add_action('sensei_teacher_archive_course_loop_before', array('Sensei_Teacher', 'archive_title')); |
|
| 443 | 443 | |
| 444 | 444 | //@since 1.9.0 |
| 445 | 445 | // remove course meta from the teacher page until it can be refactored to allow only removing the |
| 446 | 446 | // teacher name and not all lessons |
| 447 | -add_action( 'sensei_teacher_archive_course_loop_before', array( 'Sensei_Teacher', 'remove_course_meta_on_teacher_archive' ) ); |
|
| 447 | +add_action('sensei_teacher_archive_course_loop_before', array('Sensei_Teacher', 'remove_course_meta_on_teacher_archive')); |
|
| 448 | 448 | |
| 449 | 449 | /********************************** |
| 450 | 450 | * |
| 451 | 451 | * Frontend notices display |
| 452 | 452 | * |
| 453 | 453 | **********************************/ |
| 454 | -add_action( 'sensei_course_results_content_inside_before', array( Sensei()->notices,'maybe_print_notices' ) ); |
|
| 455 | -add_action( 'sensei_no_permissions_inside_before_content', array( Sensei()->notices,'maybe_print_notices' ), 90 ); |
|
| 456 | -add_action( 'sensei_single_course_content_inside_before', array( Sensei()->notices,'maybe_print_notices' ), 40 ); |
|
| 457 | -add_action( 'sensei_single_lesson_content_inside_before', array( Sensei()->notices,'maybe_print_notices' ), 40 ); |
|
| 454 | +add_action('sensei_course_results_content_inside_before', array(Sensei()->notices, 'maybe_print_notices')); |
|
| 455 | +add_action('sensei_no_permissions_inside_before_content', array(Sensei()->notices, 'maybe_print_notices'), 90); |
|
| 456 | +add_action('sensei_single_course_content_inside_before', array(Sensei()->notices, 'maybe_print_notices'), 40); |
|
| 457 | +add_action('sensei_single_lesson_content_inside_before', array(Sensei()->notices, 'maybe_print_notices'), 40); |
|
| 458 | 458 | |
@@ -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 | * Output tags. |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | * @param string $type (default: 'newcourses') |
| 13 | 13 | * @return void |
| 14 | 14 | */ |
| 15 | - function sensei_course_archive_next_link( $type = 'newcourses' ) { |
|
| 15 | + function sensei_course_archive_next_link($type = 'newcourses') { |
|
| 16 | 16 | |
| 17 | - _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); |
|
| 17 | + _deprecated_function('sensei_course_archive_next_link', '1.9.0', 'This is no longer used or required in Sensei.'); |
|
| 18 | 18 | |
| 19 | 19 | } // End sensei_course_archive_next_link() |
| 20 | 20 | |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | function course_single_lessons() { |
| 28 | 28 | |
| 29 | 29 | // load backwards compatible template name if it exists in the users theme |
| 30 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); |
|
| 31 | - if( $located_template ){ |
|
| 30 | + $located_template = locate_template(Sensei()->template_url.'single-course/course-lessons.php'); |
|
| 31 | + if ($located_template) { |
|
| 32 | 32 | |
| 33 | - Sensei_Templates::get_template( 'single-course/course-lessons.php' ); |
|
| 33 | + Sensei_Templates::get_template('single-course/course-lessons.php'); |
|
| 34 | 34 | return; |
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - Sensei_Templates::get_template( 'single-course/lessons.php' ); |
|
| 38 | + Sensei_Templates::get_template('single-course/lessons.php'); |
|
| 39 | 39 | |
| 40 | 40 | } // End course_single_lessons() |
| 41 | 41 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | function lesson_single_meta() { |
| 50 | 50 | |
| 51 | - _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); |
|
| 51 | + _deprecated_function('lesson_single_meta', '1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta'); |
|
| 52 | 52 | sensei_the_single_lesson_meta(); |
| 53 | 53 | |
| 54 | 54 | } // End lesson_single_meta() |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @return void |
| 63 | 63 | * @deprecated since 1.9.0 |
| 64 | 64 | */ |
| 65 | - function quiz_questions( $return = false ) { |
|
| 65 | + function quiz_questions($return = false) { |
|
| 66 | 66 | |
| 67 | - Sensei_Templates::get_template( 'single-quiz/quiz-questions.php' ); |
|
| 67 | + Sensei_Templates::get_template('single-quiz/quiz-questions.php'); |
|
| 68 | 68 | |
| 69 | 69 | } // End quiz_questions() |
| 70 | 70 | |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * @return void |
| 77 | 77 | * @deprecated |
| 78 | 78 | */ |
| 79 | - function quiz_question_type( $question_type = 'multiple-choice' ) { |
|
| 79 | + function quiz_question_type($question_type = 'multiple-choice') { |
|
| 80 | 80 | |
| 81 | - Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
| 81 | + Sensei_Templates::get_template('single-quiz/question_type-'.$question_type.'.php'); |
|
| 82 | 82 | |
| 83 | 83 | } // End lesson_single_meta() |
| 84 | 84 | |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param mixed $course_id |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - function sensei_check_prerequisite_course( $course_id ) { |
|
| 97 | + function sensei_check_prerequisite_course($course_id) { |
|
| 98 | 98 | |
| 99 | - return Sensei_Course::is_prerequisite_complete( $course_id ); |
|
| 99 | + return Sensei_Course::is_prerequisite_complete($course_id); |
|
| 100 | 100 | |
| 101 | 101 | } // End sensei_check_prerequisite_course() |
| 102 | 102 | |
@@ -108,16 +108,16 @@ discard block |
||
| 108 | 108 | * @param mixed $course_id |
| 109 | 109 | * @return void |
| 110 | 110 | */ |
| 111 | - function sensei_start_course_form( $course_id ) { |
|
| 111 | + function sensei_start_course_form($course_id) { |
|
| 112 | 112 | |
| 113 | - $prerequisite_complete = sensei_check_prerequisite_course( $course_id ); |
|
| 113 | + $prerequisite_complete = sensei_check_prerequisite_course($course_id); |
|
| 114 | 114 | |
| 115 | - if ( $prerequisite_complete ) { |
|
| 116 | - ?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
| 115 | + if ($prerequisite_complete) { |
|
| 116 | + ?><form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
| 117 | 117 | |
| 118 | - <input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" /> |
|
| 118 | + <input type="hidden" name="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" id="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_start_course_noonce')); ?>" /> |
|
| 119 | 119 | |
| 120 | - <span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span> |
|
| 120 | + <span><input name="course_start" type="submit" class="course-start" value="<?php _e('Start taking this Course', 'woothemes-sensei'); ?>"/></span> |
|
| 121 | 121 | |
| 122 | 122 | </form><?php |
| 123 | 123 | } // End If Statement |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | * @param mixed $course_id |
| 133 | 133 | * @return void |
| 134 | 134 | */ |
| 135 | - function sensei_wc_add_to_cart( $course_id ) { |
|
| 135 | + function sensei_wc_add_to_cart($course_id) { |
|
| 136 | 136 | |
| 137 | - Sensei_WC::the_add_to_cart_button_html( $course_id ); |
|
| 137 | + Sensei_WC::the_add_to_cart_button_html($course_id); |
|
| 138 | 138 | |
| 139 | 139 | } // End sensei_wc_add_to_cart() |
| 140 | 140 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * @param int $wc_post_id (default: 0) |
| 147 | 147 | * @return bool |
| 148 | 148 | */ |
| 149 | - function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { |
|
| 150 | - return Sensei_WC::is_product_in_cart( $wc_product_id ); |
|
| 149 | + function sensei_check_if_product_is_in_cart($wc_product_id = 0) { |
|
| 150 | + return Sensei_WC::is_product_in_cart($wc_product_id); |
|
| 151 | 151 | } // End sensei_check_if_product_is_in_cart() |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | * @param mixed $post_id |
| 158 | 158 | * @return void |
| 159 | 159 | */ |
| 160 | - function sensei_simple_course_price( $post_id ) { |
|
| 160 | + function sensei_simple_course_price($post_id) { |
|
| 161 | 161 | |
| 162 | 162 | //WooCommerce Pricing |
| 163 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 164 | - $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); |
|
| 165 | - if ( 0 < $wc_post_id ) { |
|
| 163 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 164 | + $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true); |
|
| 165 | + if (0 < $wc_post_id) { |
|
| 166 | 166 | // Get the product |
| 167 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
| 167 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
|
| 168 | 168 | |
| 169 | - if ( isset( $product ) && !empty( $product ) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> |
|
| 169 | + if (isset($product) && ! empty($product) && $product->is_purchasable() && $product->is_in_stock() && ! sensei_check_if_product_is_in_cart($wc_post_id)) { ?> |
|
| 170 | 170 | <span class="course-price"><?php echo $product->get_price_html(); ?></span> |
| 171 | 171 | <?php } // End If Statement |
| 172 | 172 | } // End If Statement |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | * @param array $widget_args (default: array()) |
| 181 | 181 | * @return array |
| 182 | 182 | */ |
| 183 | - function sensei_recent_comments_widget_filter( $widget_args = array() ) { |
|
| 184 | - if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' ); |
|
| 183 | + function sensei_recent_comments_widget_filter($widget_args = array()) { |
|
| 184 | + if ( ! isset($widget_args['post_type'])) $widget_args['post_type'] = array('post', 'page'); |
|
| 185 | 185 | return $widget_args; |
| 186 | 186 | } // End sensei_recent_comments_widget_filter() |
| 187 | - add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 ); |
|
| 187 | + add_filter('widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1); |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * sensei_course_archive_filter function. |
@@ -193,26 +193,26 @@ discard block |
||
| 193 | 193 | * @param WP_Query $query ( default: array ( ) ) |
| 194 | 194 | * @return void |
| 195 | 195 | */ |
| 196 | - function sensei_course_archive_filter( $query ) { |
|
| 196 | + function sensei_course_archive_filter($query) { |
|
| 197 | 197 | |
| 198 | 198 | |
| 199 | - if ( ! $query->is_main_query() ) |
|
| 199 | + if ( ! $query->is_main_query()) |
|
| 200 | 200 | return; |
| 201 | 201 | |
| 202 | 202 | // Apply Filter only if on frontend and when course archive is running |
| 203 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
| 203 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
| 204 | 204 | |
| 205 | - if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) { |
|
| 205 | + if ( ! is_admin() && 0 < $course_page_id && 0 < intval($query->get('page_id')) && $query->get('page_id') == $course_page_id) { |
|
| 206 | 206 | // Check for pagination settings |
| 207 | - if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
|
| 208 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
| 207 | + if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { |
|
| 208 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
| 209 | 209 | } else { |
| 210 | - $amount = $query->get( 'posts_per_page' ); |
|
| 210 | + $amount = $query->get('posts_per_page'); |
|
| 211 | 211 | } // End If Statement |
| 212 | - $query->set( 'posts_per_page', $amount ); |
|
| 212 | + $query->set('posts_per_page', $amount); |
|
| 213 | 213 | } // End If Statement |
| 214 | 214 | } // End sensei_course_archive_filter() |
| 215 | - add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 ); |
|
| 215 | + add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1); |
|
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | 218 | * sensei_complete_lesson_button description |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @return html |
| 221 | 221 | */ |
| 222 | 222 | function sensei_complete_lesson_button() { |
| 223 | - do_action( 'sensei_complete_lesson_button' ); |
|
| 223 | + do_action('sensei_complete_lesson_button'); |
|
| 224 | 224 | } // End sensei_complete_lesson_button() |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @return html |
| 230 | 230 | */ |
| 231 | 231 | function sensei_reset_lesson_button() { |
| 232 | - do_action( 'sensei_reset_lesson_button' ); |
|
| 232 | + do_action('sensei_reset_lesson_button'); |
|
| 233 | 233 | } // End sensei_reset_lesson_button() |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -238,20 +238,20 @@ discard block |
||
| 238 | 238 | * @param integer $lesson_id |
| 239 | 239 | * @return array $return_values |
| 240 | 240 | */ |
| 241 | - function sensei_get_prev_next_lessons( $lesson_id = 0 ) { |
|
| 241 | + function sensei_get_prev_next_lessons($lesson_id = 0) { |
|
| 242 | 242 | |
| 243 | 243 | $return_values = array(); |
| 244 | 244 | $return_values['prev_lesson'] = 0; |
| 245 | 245 | $return_values['next_lesson'] = 0; |
| 246 | - if ( 0 < $lesson_id ) { |
|
| 246 | + if (0 < $lesson_id) { |
|
| 247 | 247 | // Get the List of Lessons in the Course |
| 248 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 248 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 249 | 249 | $all_lessons = array(); |
| 250 | 250 | |
| 251 | - $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); |
|
| 251 | + $modules = Sensei()->modules->get_course_modules(intval($lesson_course_id)); |
|
| 252 | 252 | |
| 253 | - if( !empty( $modules ) ){ |
|
| 254 | - foreach( (array) $modules as $module ) { |
|
| 253 | + if ( ! empty($modules)) { |
|
| 254 | + foreach ((array) $modules as $module) { |
|
| 255 | 255 | |
| 256 | 256 | $args = array( |
| 257 | 257 | 'post_type' => 'lesson', |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | 'meta_query' => array( |
| 261 | 261 | array( |
| 262 | 262 | 'key' => '_lesson_course', |
| 263 | - 'value' => intval( $lesson_course_id ), |
|
| 263 | + 'value' => intval($lesson_course_id), |
|
| 264 | 264 | 'compare' => '=' |
| 265 | 265 | ) |
| 266 | 266 | ), |
@@ -268,18 +268,18 @@ discard block |
||
| 268 | 268 | array( |
| 269 | 269 | 'taxonomy' => Sensei()->modules->taxonomy, |
| 270 | 270 | 'field' => 'id', |
| 271 | - 'terms' => intval( $module->term_id ) |
|
| 271 | + 'terms' => intval($module->term_id) |
|
| 272 | 272 | ) |
| 273 | 273 | ), |
| 274 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
| 274 | + 'meta_key' => '_order_module_'.$module->term_id, |
|
| 275 | 275 | 'orderby' => 'meta_value_num date', |
| 276 | 276 | 'order' => 'ASC', |
| 277 | 277 | 'suppress_filters' => 0 |
| 278 | 278 | ); |
| 279 | 279 | |
| 280 | - $lessons = get_posts( $args ); |
|
| 281 | - if ( 0 < count( $lessons ) ) { |
|
| 282 | - foreach ($lessons as $lesson_item){ |
|
| 280 | + $lessons = get_posts($args); |
|
| 281 | + if (0 < count($lessons)) { |
|
| 282 | + foreach ($lessons as $lesson_item) { |
|
| 283 | 283 | $all_lessons[] = $lesson_item->ID; |
| 284 | 284 | } // End For Loop |
| 285 | 285 | } // End If Statement |
@@ -292,36 +292,36 @@ discard block |
||
| 292 | 292 | 'post_type' => 'lesson', |
| 293 | 293 | 'posts_per_page' => -1, |
| 294 | 294 | 'suppress_filters' => 0, |
| 295 | - 'meta_key' => '_order_' . $lesson_course_id, |
|
| 295 | + 'meta_key' => '_order_'.$lesson_course_id, |
|
| 296 | 296 | 'orderby' => 'meta_value_num date', |
| 297 | 297 | 'order' => 'ASC', |
| 298 | 298 | 'meta_query' => array( |
| 299 | 299 | array( |
| 300 | 300 | 'key' => '_lesson_course', |
| 301 | - 'value' => intval( $lesson_course_id ), |
|
| 301 | + 'value' => intval($lesson_course_id), |
|
| 302 | 302 | ), |
| 303 | 303 | ), |
| 304 | 304 | 'post__not_in' => $all_lessons, |
| 305 | 305 | ); |
| 306 | 306 | |
| 307 | - $other_lessons = get_posts( $args ); |
|
| 308 | - if ( 0 < count( $other_lessons ) ) { |
|
| 309 | - foreach ($other_lessons as $lesson_item){ |
|
| 307 | + $other_lessons = get_posts($args); |
|
| 308 | + if (0 < count($other_lessons)) { |
|
| 309 | + foreach ($other_lessons as $lesson_item) { |
|
| 310 | 310 | $all_lessons[] = $lesson_item->ID; |
| 311 | 311 | } // End For Loop |
| 312 | 312 | } // End If Statement |
| 313 | 313 | |
| 314 | - if ( 0 < count( $all_lessons ) ) { |
|
| 314 | + if (0 < count($all_lessons)) { |
|
| 315 | 315 | $found_index = false; |
| 316 | - foreach ( $all_lessons as $lesson ){ |
|
| 317 | - if ( $found_index && $return_values['next_lesson'] == 0 ) { |
|
| 316 | + foreach ($all_lessons as $lesson) { |
|
| 317 | + if ($found_index && $return_values['next_lesson'] == 0) { |
|
| 318 | 318 | $return_values['next_lesson'] = $lesson; |
| 319 | 319 | } // End If Statement |
| 320 | - if ( $lesson == $lesson_id ) { |
|
| 320 | + if ($lesson == $lesson_id) { |
|
| 321 | 321 | // Is the current post |
| 322 | 322 | $found_index = true; |
| 323 | 323 | } // End If Statement |
| 324 | - if ( !$found_index ) { |
|
| 324 | + if ( ! $found_index) { |
|
| 325 | 325 | $return_values['prev_lesson'] = $lesson; |
| 326 | 326 | } // End If Statement |
| 327 | 327 | } // End For Loop |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | * @param int|WP_Post $post_id Optional. Defaults to current post |
| 341 | 341 | * @return string $excerpt |
| 342 | 342 | */ |
| 343 | - function sensei_get_excerpt( $post_id = '' ) { |
|
| 343 | + function sensei_get_excerpt($post_id = '') { |
|
| 344 | 344 | |
| 345 | 345 | global $post; |
| 346 | 346 | _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); |
@@ -348,14 +348,14 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - function sensei_has_user_started_course( $post_id = 0, $user_id = 0 ) { |
|
| 352 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()" ); |
|
| 353 | - return Sensei_Utils::user_started_course( $post_id, $user_id ); |
|
| 351 | + function sensei_has_user_started_course($post_id = 0, $user_id = 0) { |
|
| 352 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()"); |
|
| 353 | + return Sensei_Utils::user_started_course($post_id, $user_id); |
|
| 354 | 354 | } // End sensei_has_user_started_course() |
| 355 | 355 | |
| 356 | - function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { |
|
| 357 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); |
|
| 358 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); |
|
| 356 | + function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { |
|
| 357 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); |
|
| 358 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); |
|
| 359 | 359 | } // End sensei_has_user_completed_lesson() |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -367,9 +367,9 @@ discard block |
||
| 367 | 367 | * @param int $user_id |
| 368 | 368 | * @return bool |
| 369 | 369 | */ |
| 370 | -function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) { |
|
| 370 | +function sensei_has_user_completed_prerequisite_lesson($current_lesson_id, $user_id) { |
|
| 371 | 371 | |
| 372 | - return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); |
|
| 372 | + return WooThemes_Sensei_Lesson::is_pre_requisite_complete($current_lesson_id, $user_id); |
|
| 373 | 373 | |
| 374 | 374 | } // End sensei_has_user_completed_prerequisite_lesson() |
| 375 | 375 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * @return bool |
| 393 | 393 | * |
| 394 | 394 | */ |
| 395 | -function sensei_have_modules( $course_post_id = '' ){ |
|
| 395 | +function sensei_have_modules($course_post_id = '') { |
|
| 396 | 396 | |
| 397 | 397 | global $post, $wp_query, $sensei_modules_loop; |
| 398 | 398 | |
@@ -400,23 +400,23 @@ discard block |
||
| 400 | 400 | wp_reset_query(); |
| 401 | 401 | $post = $wp_query->post; |
| 402 | 402 | |
| 403 | - if( empty( $course_post_id ) ){ |
|
| 403 | + if (empty($course_post_id)) { |
|
| 404 | 404 | |
| 405 | 405 | $course_id = $post->ID; |
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | // doesn't apply to none course post types |
| 410 | - if( ! sensei_is_a_course( $course_id ) ){ |
|
| 410 | + if ( ! sensei_is_a_course($course_id)) { |
|
| 411 | 411 | return false; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // check the current item compared to the total number of modules |
| 415 | - if( $sensei_modules_loop[ 'current' ] + 1 > $sensei_modules_loop[ 'total' ] ){ |
|
| 415 | + if ($sensei_modules_loop['current'] + 1 > $sensei_modules_loop['total']) { |
|
| 416 | 416 | |
| 417 | 417 | return false; |
| 418 | 418 | |
| 419 | - }else{ |
|
| 419 | + } else { |
|
| 420 | 420 | |
| 421 | 421 | return true; |
| 422 | 422 | |
@@ -430,27 +430,27 @@ discard block |
||
| 430 | 430 | * |
| 431 | 431 | * @since 1.9.0 |
| 432 | 432 | */ |
| 433 | -function sensei_setup_module(){ |
|
| 433 | +function sensei_setup_module() { |
|
| 434 | 434 | |
| 435 | 435 | global $sensei_modules_loop, $wp_query; |
| 436 | 436 | |
| 437 | 437 | // increment the index |
| 438 | - $sensei_modules_loop[ 'current' ]++; |
|
| 439 | - $index = $sensei_modules_loop[ 'current' ]; |
|
| 440 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
| 438 | + $sensei_modules_loop['current']++; |
|
| 439 | + $index = $sensei_modules_loop['current']; |
|
| 440 | + if (isset($sensei_modules_loop['modules'][$index])) { |
|
| 441 | 441 | |
| 442 | 442 | $sensei_modules_loop['current_module'] = $sensei_modules_loop['modules'][$index]; |
| 443 | 443 | // setup the query for the module lessons |
| 444 | 444 | $course_id = $sensei_modules_loop['course_id']; |
| 445 | 445 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
| 446 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
| 446 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); |
|
| 447 | 447 | |
| 448 | 448 | // setup the global wp-query only if the lessons |
| 449 | - if( $modules_query->have_posts() ){ |
|
| 449 | + if ($modules_query->have_posts()) { |
|
| 450 | 450 | |
| 451 | 451 | $wp_query = $modules_query; |
| 452 | 452 | |
| 453 | - }else{ |
|
| 453 | + } else { |
|
| 454 | 454 | |
| 455 | 455 | wp_reset_query(); |
| 456 | 456 | |
@@ -474,30 +474,30 @@ discard block |
||
| 474 | 474 | * |
| 475 | 475 | * @return bool |
| 476 | 476 | */ |
| 477 | -function sensei_module_has_lessons(){ |
|
| 477 | +function sensei_module_has_lessons() { |
|
| 478 | 478 | |
| 479 | 479 | global $wp_query, $sensei_modules_loop; |
| 480 | 480 | |
| 481 | - if( 'lesson' == $wp_query->get('post_type') ){ |
|
| 481 | + if ('lesson' == $wp_query->get('post_type')) { |
|
| 482 | 482 | |
| 483 | 483 | return have_posts(); |
| 484 | 484 | |
| 485 | - }else{ |
|
| 485 | + } else { |
|
| 486 | 486 | |
| 487 | 487 | // if the loop has not been initiated check the first module has lessons |
| 488 | - if( -1 == $sensei_modules_loop[ 'current' ] ){ |
|
| 488 | + if ( -1 == $sensei_modules_loop['current'] ) { |
|
| 489 | 489 | |
| 490 | 490 | $index = 0; |
| 491 | 491 | |
| 492 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
| 492 | + if (isset($sensei_modules_loop['modules'][$index])) { |
|
| 493 | 493 | // setup the query for the module lessons |
| 494 | 494 | $course_id = $sensei_modules_loop['course_id']; |
| 495 | 495 | |
| 496 | - $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; |
|
| 497 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
| 496 | + $module_term_id = $sensei_modules_loop['modules'][$index] ->term_id; |
|
| 497 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); |
|
| 498 | 498 | |
| 499 | 499 | // setup the global wp-query only if the lessons |
| 500 | - if( $modules_query->have_posts() ){ |
|
| 500 | + if ($modules_query->have_posts()) { |
|
| 501 | 501 | |
| 502 | 502 | return true; |
| 503 | 503 | |
@@ -521,9 +521,9 @@ discard block |
||
| 521 | 521 | * @uses sensei_the_module_title |
| 522 | 522 | * @return string |
| 523 | 523 | */ |
| 524 | -function sensei_the_module_title_attribute(){ |
|
| 524 | +function sensei_the_module_title_attribute() { |
|
| 525 | 525 | |
| 526 | - esc_attr_e( sensei_get_the_module_title() ); |
|
| 526 | + esc_attr_e(sensei_get_the_module_title()); |
|
| 527 | 527 | |
| 528 | 528 | } |
| 529 | 529 | |
@@ -534,11 +534,11 @@ discard block |
||
| 534 | 534 | * |
| 535 | 535 | * @return string |
| 536 | 536 | */ |
| 537 | -function sensei_the_module_permalink(){ |
|
| 537 | +function sensei_the_module_permalink() { |
|
| 538 | 538 | |
| 539 | 539 | global $sensei_modules_loop; |
| 540 | 540 | $course_id = $sensei_modules_loop['course_id']; |
| 541 | - $module_url = add_query_arg('course_id', $course_id, get_term_link( $sensei_modules_loop['current_module'], 'module' ) ); |
|
| 541 | + $module_url = add_query_arg('course_id', $course_id, get_term_link($sensei_modules_loop['current_module'], 'module')); |
|
| 542 | 542 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param int $module_term_id |
| 551 | 551 | * @param string $course_id |
| 552 | 552 | */ |
| 553 | - echo esc_url_raw( apply_filters( 'sensei_the_module_permalink', $module_url, $module_term_id ,$course_id ) ); |
|
| 553 | + echo esc_url_raw(apply_filters('sensei_the_module_permalink', $module_url, $module_term_id, $course_id)); |
|
| 554 | 554 | |
| 555 | 555 | }// end sensei_the_module_permalink |
| 556 | 556 | |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | * |
| 563 | 563 | * @return string |
| 564 | 564 | */ |
| 565 | -function sensei_get_the_module_title(){ |
|
| 565 | +function sensei_get_the_module_title() { |
|
| 566 | 566 | |
| 567 | 567 | global $sensei_modules_loop; |
| 568 | 568 | |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @param $module_term_id |
| 582 | 582 | * @param $course_id |
| 583 | 583 | */ |
| 584 | - return apply_filters( 'sensei_the_module_title', $module_title , $module_term_id, $course_id ); |
|
| 584 | + return apply_filters('sensei_the_module_title', $module_title, $module_term_id, $course_id); |
|
| 585 | 585 | |
| 586 | 586 | } |
| 587 | 587 | |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @uses sensei_get_the_module_title |
| 594 | 594 | * @return string |
| 595 | 595 | */ |
| 596 | -function sensei_the_module_title(){ |
|
| 596 | +function sensei_the_module_title() { |
|
| 597 | 597 | |
| 598 | 598 | echo sensei_get_the_module_title(); |
| 599 | 599 | |
@@ -606,9 +606,9 @@ discard block |
||
| 606 | 606 | * @since 1.9.0 |
| 607 | 607 | * @return string |
| 608 | 608 | */ |
| 609 | -function sensei_get_the_module_status(){ |
|
| 609 | +function sensei_get_the_module_status() { |
|
| 610 | 610 | |
| 611 | - if( ! is_user_logged_in() ){ |
|
| 611 | + if ( ! is_user_logged_in()) { |
|
| 612 | 612 | return ''; |
| 613 | 613 | } |
| 614 | 614 | |
@@ -616,10 +616,10 @@ discard block |
||
| 616 | 616 | $module_title = $sensei_modules_loop['current_module']->name; |
| 617 | 617 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
| 618 | 618 | $course_id = $sensei_modules_loop['course_id']; |
| 619 | - $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() ); |
|
| 619 | + $module_progress = Sensei()->modules->get_user_module_progress($module_term_id, $course_id, get_current_user_id()); |
|
| 620 | 620 | |
| 621 | - $module_status = ''; |
|
| 622 | - if ( $module_progress && $module_progress > 0) { |
|
| 621 | + $module_status = ''; |
|
| 622 | + if ($module_progress && $module_progress > 0) { |
|
| 623 | 623 | |
| 624 | 624 | $module_status = __('Completed', 'woothemes-sensei'); |
| 625 | 625 | |
@@ -631,12 +631,12 @@ discard block |
||
| 631 | 631 | |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - if ( empty( $module_status ) ){ |
|
| 634 | + if (empty($module_status)) { |
|
| 635 | 635 | return ''; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $status_class = strtolower( str_replace( ' ', '-', $module_status ) ); |
|
| 639 | - $module_status_html = '<p class="status module-status ' . $status_class . '">' |
|
| 638 | + $status_class = strtolower(str_replace(' ', '-', $module_status)); |
|
| 639 | + $module_status_html = '<p class="status module-status '.$status_class.'">' |
|
| 640 | 640 | . $module_status |
| 641 | 641 | . '</p>'; |
| 642 | 642 | |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | * @param $module_term_id |
| 652 | 652 | * @param $course_id |
| 653 | 653 | */ |
| 654 | - return apply_filters( 'sensei_the_module_status_html', $module_status_html , $module_term_id, $course_id ); |
|
| 654 | + return apply_filters('sensei_the_module_status_html', $module_status_html, $module_term_id, $course_id); |
|
| 655 | 655 | |
| 656 | 656 | } |
| 657 | 657 | |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | * Print out the current module status |
| 660 | 660 | * @since 1.9.0 |
| 661 | 661 | */ |
| 662 | -function sensei_the_module_status(){ |
|
| 662 | +function sensei_the_module_status() { |
|
| 663 | 663 | |
| 664 | 664 | echo sensei_get_the_module_status(); |
| 665 | 665 | |
@@ -680,19 +680,19 @@ discard block |
||
| 680 | 680 | * |
| 681 | 681 | * @return bool |
| 682 | 682 | */ |
| 683 | -function sensei_quiz_has_questions(){ |
|
| 683 | +function sensei_quiz_has_questions() { |
|
| 684 | 684 | |
| 685 | 685 | global $sensei_question_loop; |
| 686 | 686 | |
| 687 | - if( !isset( $sensei_question_loop['total'] ) ){ |
|
| 687 | + if ( ! isset($sensei_question_loop['total'])) { |
|
| 688 | 688 | return false; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total'] ){ |
|
| 691 | + if ($sensei_question_loop['current'] + 1 < $sensei_question_loop['total']) { |
|
| 692 | 692 | |
| 693 | 693 | return true; |
| 694 | 694 | |
| 695 | - }else{ |
|
| 695 | + } else { |
|
| 696 | 696 | |
| 697 | 697 | return false; |
| 698 | 698 | |
@@ -709,13 +709,13 @@ discard block |
||
| 709 | 709 | * @since 1.9.0 |
| 710 | 710 | |
| 711 | 711 | */ |
| 712 | -function sensei_setup_the_question(){ |
|
| 712 | +function sensei_setup_the_question() { |
|
| 713 | 713 | |
| 714 | 714 | global $sensei_question_loop; |
| 715 | 715 | |
| 716 | 716 | $sensei_question_loop['current']++; |
| 717 | 717 | $index = $sensei_question_loop['current']; |
| 718 | - $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; |
|
| 718 | + $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][$index]; |
|
| 719 | 719 | |
| 720 | 720 | |
| 721 | 721 | }// end sensei_setup_the_question |
@@ -726,14 +726,14 @@ discard block |
||
| 726 | 726 | * This function gets the type and loads the template that will handle it. |
| 727 | 727 | * |
| 728 | 728 | */ |
| 729 | -function sensei_the_question_content(){ |
|
| 729 | +function sensei_the_question_content() { |
|
| 730 | 730 | |
| 731 | 731 | global $sensei_question_loop; |
| 732 | 732 | |
| 733 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
| 733 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
| 734 | 734 | |
| 735 | 735 | // load the template that displays the question information. |
| 736 | - WooThemes_Sensei_Question::load_question_template( $question_type ); |
|
| 736 | + WooThemes_Sensei_Question::load_question_template($question_type); |
|
| 737 | 737 | |
| 738 | 738 | }// end sensei_the_question_content |
| 739 | 739 | |
@@ -742,11 +742,11 @@ discard block |
||
| 742 | 742 | * |
| 743 | 743 | * @since 1.9.0 |
| 744 | 744 | */ |
| 745 | -function sensei_the_question_class(){ |
|
| 745 | +function sensei_the_question_class() { |
|
| 746 | 746 | |
| 747 | 747 | global $sensei_question_loop; |
| 748 | 748 | |
| 749 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
| 749 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | 752 | * filter the sensei question class within |
@@ -754,16 +754,16 @@ discard block |
||
| 754 | 754 | * |
| 755 | 755 | * @since 1.9.0 |
| 756 | 756 | */ |
| 757 | - $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); |
|
| 757 | + $classes = apply_filters('sensei_question_classes', array($question_type)); |
|
| 758 | 758 | |
| 759 | 759 | $html_classes = ''; |
| 760 | - foreach( $classes as $class ){ |
|
| 760 | + foreach ($classes as $class) { |
|
| 761 | 761 | |
| 762 | - $html_classes .= $class . ' '; |
|
| 762 | + $html_classes .= $class.' '; |
|
| 763 | 763 | |
| 764 | 764 | }// end foreach |
| 765 | 765 | |
| 766 | - esc_attr_e( trim( $html_classes ) ); |
|
| 766 | + esc_attr_e(trim($html_classes)); |
|
| 767 | 767 | |
| 768 | 768 | } |
| 769 | 769 | |
@@ -772,10 +772,10 @@ discard block |
||
| 772 | 772 | * |
| 773 | 773 | * @since 1.9.0 |
| 774 | 774 | */ |
| 775 | -function sensei_get_the_question_id( ){ |
|
| 775 | +function sensei_get_the_question_id( ) { |
|
| 776 | 776 | |
| 777 | 777 | global $sensei_question_loop; |
| 778 | - if( isset( $sensei_question_loop['current_question']->ID ) ){ |
|
| 778 | + if (isset($sensei_question_loop['current_question']->ID)) { |
|
| 779 | 779 | |
| 780 | 780 | return $sensei_question_loop['current_question']->ID; |
| 781 | 781 | |
@@ -804,33 +804,33 @@ discard block |
||
| 804 | 804 | * @param string $lesson_id |
| 805 | 805 | * @return bool |
| 806 | 806 | */ |
| 807 | -function sensei_can_user_view_lesson( $lesson_id = '', $user_id = '' ){ |
|
| 807 | +function sensei_can_user_view_lesson($lesson_id = '', $user_id = '') { |
|
| 808 | 808 | |
| 809 | - if( empty( $lesson_id ) ){ |
|
| 809 | + if (empty($lesson_id)) { |
|
| 810 | 810 | |
| 811 | 811 | $lesson_id = get_the_ID(); |
| 812 | 812 | |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - if ( 'quiz'== get_post_type( get_the_ID() ) ){ |
|
| 815 | + if ('quiz' == get_post_type(get_the_ID())) { |
|
| 816 | 816 | |
| 817 | - $lesson_id = Sensei()->quiz->get_lesson_id( get_the_ID() ); |
|
| 817 | + $lesson_id = Sensei()->quiz->get_lesson_id(get_the_ID()); |
|
| 818 | 818 | |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - if( empty( $user_id ) ){ |
|
| 821 | + if (empty($user_id)) { |
|
| 822 | 822 | |
| 823 | 823 | $user_id = get_current_user_id(); |
| 824 | 824 | |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | // Check for prerequisite lesson completions |
| 828 | - $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); |
|
| 829 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 830 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); |
|
| 828 | + $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id); |
|
| 829 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 830 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, $user_id); |
|
| 831 | 831 | |
| 832 | 832 | $is_preview = false; |
| 833 | - if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { |
|
| 833 | + if (Sensei_Utils::is_preview_lesson($lesson_id)) { |
|
| 834 | 834 | |
| 835 | 835 | $is_preview = true; |
| 836 | 836 | $pre_requisite_complete = true; |
@@ -838,24 +838,24 @@ discard block |
||
| 838 | 838 | }; |
| 839 | 839 | |
| 840 | 840 | |
| 841 | - $user_can_access_lesson = false; |
|
| 841 | + $user_can_access_lesson = false; |
|
| 842 | 842 | |
| 843 | - if( is_user_logged_in() && $user_taking_course ){ |
|
| 843 | + if (is_user_logged_in() && $user_taking_course) { |
|
| 844 | 844 | |
| 845 | - $user_can_access_lesson = true; |
|
| 845 | + $user_can_access_lesson = true; |
|
| 846 | 846 | |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | |
| 850 | 850 | $access_permission = false; |
| 851 | 851 | |
| 852 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
| 852 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) { |
|
| 853 | 853 | |
| 854 | 854 | $access_permission = true; |
| 855 | 855 | |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | - $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; |
|
| 858 | + $can_user_view_lesson = $access_permission || ($user_can_access_lesson && $pre_requisite_complete) || $is_preview; |
|
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | 861 | * Filter the can user view lesson function |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | * @param string $lesson_id |
| 869 | 869 | * @param string $user_id |
| 870 | 870 | */ |
| 871 | - return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); |
|
| 871 | + return apply_filters('sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id); |
|
| 872 | 872 | |
| 873 | 873 | } // end sensei_can_current_user_view_lesson |
| 874 | 874 | |
@@ -878,51 +878,51 @@ discard block |
||
| 878 | 878 | * The function should only be called on the single lesson |
| 879 | 879 | * |
| 880 | 880 | */ |
| 881 | -function sensei_the_single_lesson_meta(){ |
|
| 881 | +function sensei_the_single_lesson_meta() { |
|
| 882 | 882 | |
| 883 | 883 | // if the lesson meta is included within theme load that instead of the function content |
| 884 | - $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); |
|
| 885 | - if( ! empty( $template ) ){ |
|
| 884 | + $template = Sensei_Templates::locate_template('single-lesson/lesson-meta.php'); |
|
| 885 | + if ( ! empty($template)) { |
|
| 886 | 886 | |
| 887 | - Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); |
|
| 887 | + Sensei_Templates::get_template('single-lesson/lesson-meta.php'); |
|
| 888 | 888 | return; |
| 889 | 889 | |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // Get the meta info |
| 893 | - $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); |
|
| 894 | - $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); |
|
| 893 | + $lesson_course_id = absint(get_post_meta(get_the_ID(), '_lesson_course', true)); |
|
| 894 | + $is_preview = Sensei_Utils::is_preview_lesson(get_the_ID()); |
|
| 895 | 895 | |
| 896 | 896 | // Complete Lesson Logic |
| 897 | - do_action( 'sensei_complete_lesson' ); |
|
| 897 | + do_action('sensei_complete_lesson'); |
|
| 898 | 898 | // Check that the course has been started |
| 899 | - if ( Sensei()->access_settings() |
|
| 900 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) |
|
| 901 | - || $is_preview ) { |
|
| 899 | + if (Sensei()->access_settings() |
|
| 900 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()) |
|
| 901 | + || $is_preview) { |
|
| 902 | 902 | ?> |
| 903 | 903 | <section class="lesson-meta"> |
| 904 | 904 | <?php |
| 905 | - if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { |
|
| 905 | + if (apply_filters('sensei_video_position', 'top', get_the_ID()) == 'bottom') { |
|
| 906 | 906 | |
| 907 | - do_action( 'sensei_lesson_video', get_the_ID() ); |
|
| 907 | + do_action('sensei_lesson_video', get_the_ID()); |
|
| 908 | 908 | |
| 909 | 909 | } |
| 910 | 910 | ?> |
| 911 | - <?php do_action( 'sensei_frontend_messages' ); ?> |
|
| 911 | + <?php do_action('sensei_frontend_messages'); ?> |
|
| 912 | 912 | |
| 913 | 913 | <?php if ( ! $is_preview |
| 914 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { |
|
| 914 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())) { |
|
| 915 | 915 | |
| 916 | - sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); |
|
| 916 | + sensei_do_deprecated_action('sensei_lesson_quiz_meta', '1.9.0', 'sensei_single_lesson_content_inside_before', array(get_the_ID(), get_current_user_id())); |
|
| 917 | 917 | |
| 918 | 918 | } ?> |
| 919 | 919 | </section> |
| 920 | 920 | |
| 921 | - <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?> |
|
| 921 | + <?php do_action('sensei_lesson_back_link', $lesson_course_id); ?> |
|
| 922 | 922 | |
| 923 | 923 | <?php } |
| 924 | 924 | |
| 925 | - do_action( 'sensei_lesson_meta_extra', get_the_ID() ); |
|
| 925 | + do_action('sensei_lesson_meta_extra', get_the_ID()); |
|
| 926 | 926 | |
| 927 | 927 | } // end the_single_lesson_meta |
| 928 | 928 | |
@@ -936,9 +936,9 @@ discard block |
||
| 936 | 936 | * |
| 937 | 937 | * @since 1.9.0 |
| 938 | 938 | */ |
| 939 | -function get_sensei_header(){ |
|
| 939 | +function get_sensei_header() { |
|
| 940 | 940 | |
| 941 | - if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 941 | + if ( ! defined('ABSPATH')) exit; |
|
| 942 | 942 | |
| 943 | 943 | get_header(); |
| 944 | 944 | |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | * |
| 948 | 948 | * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) |
| 949 | 949 | */ |
| 950 | - do_action( 'sensei_before_main_content' ); |
|
| 950 | + do_action('sensei_before_main_content'); |
|
| 951 | 951 | |
| 952 | 952 | }// end get_sensei_header |
| 953 | 953 | |
@@ -961,28 +961,28 @@ discard block |
||
| 961 | 961 | * |
| 962 | 962 | * @since 1.9.0 |
| 963 | 963 | */ |
| 964 | -function get_sensei_footer(){ |
|
| 964 | +function get_sensei_footer() { |
|
| 965 | 965 | |
| 966 | 966 | /** |
| 967 | 967 | * sensei_pagination hook |
| 968 | 968 | * |
| 969 | 969 | * @hooked sensei_pagination - 10 (outputs pagination) |
| 970 | 970 | */ |
| 971 | - do_action( 'sensei_pagination' ); |
|
| 971 | + do_action('sensei_pagination'); |
|
| 972 | 972 | |
| 973 | 973 | /** |
| 974 | 974 | * sensei_after_main_content hook |
| 975 | 975 | * |
| 976 | 976 | * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) |
| 977 | 977 | */ |
| 978 | - do_action( 'sensei_after_main_content' ); |
|
| 978 | + do_action('sensei_after_main_content'); |
|
| 979 | 979 | |
| 980 | 980 | /** |
| 981 | 981 | * sensei_sidebar hook |
| 982 | 982 | * |
| 983 | 983 | * @hooked sensei_get_sidebar - 10 |
| 984 | 984 | */ |
| 985 | - do_action( 'sensei_sidebar' ); |
|
| 985 | + do_action('sensei_sidebar'); |
|
| 986 | 986 | |
| 987 | 987 | get_footer(); |
| 988 | 988 | |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | * |
| 995 | 995 | * @since 1.9.0 |
| 996 | 996 | */ |
| 997 | -function the_no_permissions_title(){ |
|
| 997 | +function the_no_permissions_title() { |
|
| 998 | 998 | |
| 999 | 999 | /** |
| 1000 | 1000 | * Filter the no permissions title just before it is echo'd on the |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | * @since 1.9.0 |
| 1004 | 1004 | * @param $no_permissions_title |
| 1005 | 1005 | */ |
| 1006 | - echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); |
|
| 1006 | + echo apply_filters('sensei_the_no_permissions_title', Sensei()->permissions_message['title']); |
|
| 1007 | 1007 | |
| 1008 | 1008 | } |
| 1009 | 1009 | |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | * |
| 1013 | 1013 | * @since 1.9.0 |
| 1014 | 1014 | */ |
| 1015 | -function the_no_permissions_message( $post_id ){ |
|
| 1015 | +function the_no_permissions_message($post_id) { |
|
| 1016 | 1016 | |
| 1017 | 1017 | /** |
| 1018 | 1018 | * Filter the no permissions message just before it is echo'd on the |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | * @since 1.9.0 |
| 1022 | 1022 | * @param $no_permissions_message |
| 1023 | 1023 | */ |
| 1024 | - echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); |
|
| 1024 | + echo apply_filters('sensei_the_no_permissions_message', Sensei()->permissions_message['message'], $post_id); |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | /** |
@@ -1029,10 +1029,10 @@ discard block |
||
| 1029 | 1029 | * |
| 1030 | 1030 | * @since 1.9.0 |
| 1031 | 1031 | */ |
| 1032 | -function sensei_the_excerpt( $post_id ){ |
|
| 1032 | +function sensei_the_excerpt($post_id) { |
|
| 1033 | 1033 | |
| 1034 | 1034 | global $post; |
| 1035 | - the_excerpt( $post ); |
|
| 1035 | + the_excerpt($post); |
|
| 1036 | 1036 | |
| 1037 | 1037 | } |
| 1038 | 1038 | |
@@ -1044,10 +1044,10 @@ discard block |
||
| 1044 | 1044 | * @global WP $wp |
| 1045 | 1045 | * @return string $current_page_url |
| 1046 | 1046 | */ |
| 1047 | - function sensei_get_current_page_url(){ |
|
| 1047 | + function sensei_get_current_page_url() { |
|
| 1048 | 1048 | |
| 1049 | 1049 | global $wp; |
| 1050 | - $current_page_url = home_url( $wp->request ); |
|
| 1050 | + $current_page_url = home_url($wp->request); |
|
| 1051 | 1051 | return $current_page_url; |
| 1052 | 1052 | |
| 1053 | 1053 | } |
@@ -1058,9 +1058,9 @@ discard block |
||
| 1058 | 1058 | * |
| 1059 | 1059 | * @since 1.9.0 |
| 1060 | 1060 | */ |
| 1061 | -function sensei_the_my_courses_content(){ |
|
| 1061 | +function sensei_the_my_courses_content() { |
|
| 1062 | 1062 | |
| 1063 | - echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); |
|
| 1063 | + echo Sensei()->course->load_user_courses_content(wp_get_current_user()); |
|
| 1064 | 1064 | |
| 1065 | 1065 | } // sensei_the_my_courses_content |
| 1066 | 1066 | |
@@ -1073,9 +1073,9 @@ discard block |
||
| 1073 | 1073 | * |
| 1074 | 1074 | * @since 1.9.0 |
| 1075 | 1075 | */ |
| 1076 | -function sensei_load_template( $template_name ){ |
|
| 1076 | +function sensei_load_template($template_name) { |
|
| 1077 | 1077 | |
| 1078 | - Sensei_Templates::get_template( $template_name ); |
|
| 1078 | + Sensei_Templates::get_template($template_name); |
|
| 1079 | 1079 | |
| 1080 | 1080 | } |
| 1081 | 1081 | |
@@ -1087,9 +1087,9 @@ discard block |
||
| 1087 | 1087 | * @param string $name the name of the template. |
| 1088 | 1088 | * @since 1.9.0 |
| 1089 | 1089 | */ |
| 1090 | -function sensei_load_template_part( $slug, $name ){ |
|
| 1090 | +function sensei_load_template_part($slug, $name) { |
|
| 1091 | 1091 | |
| 1092 | - Sensei_Templates::get_part( $slug, $name ); |
|
| 1092 | + Sensei_Templates::get_part($slug, $name); |
|
| 1093 | 1093 | |
| 1094 | 1094 | } |
| 1095 | 1095 | |
@@ -1106,19 +1106,19 @@ discard block |
||
| 1106 | 1106 | * @access public |
| 1107 | 1107 | * @param string $lesson_id |
| 1108 | 1108 | */ |
| 1109 | -function sensei_the_lesson_excerpt( $lesson_id = '' ) { |
|
| 1109 | +function sensei_the_lesson_excerpt($lesson_id = '') { |
|
| 1110 | 1110 | |
| 1111 | - if( empty( $lesson_id )){ |
|
| 1111 | + if (empty($lesson_id)) { |
|
| 1112 | 1112 | |
| 1113 | 1113 | $lesson_id = get_the_ID(); |
| 1114 | 1114 | |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 1117 | + if ('lesson' != get_post_type($lesson_id)) { |
|
| 1118 | 1118 | return; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | - echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); |
|
| 1121 | + echo Sensei_Lesson::lesson_excerpt(get_post($lesson_id), false); |
|
| 1122 | 1122 | |
| 1123 | 1123 | }// End lesson_excerpt() |
| 1124 | 1124 | |
@@ -1127,17 +1127,17 @@ discard block |
||
| 1127 | 1127 | * |
| 1128 | 1128 | * @since 1.9.0 |
| 1129 | 1129 | */ |
| 1130 | -function sensei_the_course_results_lessons(){ |
|
| 1130 | +function sensei_the_course_results_lessons() { |
|
| 1131 | 1131 | // load backwards compatible template name if it exists in the users theme |
| 1132 | - $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); |
|
| 1133 | - if( $located_template ){ |
|
| 1132 | + $located_template = locate_template(Sensei()->template_url.'course-results/course-lessons.php'); |
|
| 1133 | + if ($located_template) { |
|
| 1134 | 1134 | |
| 1135 | - Sensei_Templates::get_template( 'course-results/course-lessons.php' ); |
|
| 1135 | + Sensei_Templates::get_template('course-results/course-lessons.php'); |
|
| 1136 | 1136 | return; |
| 1137 | 1137 | |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - Sensei_Templates::get_template( 'course-results/lessons.php' ); |
|
| 1140 | + Sensei_Templates::get_template('course-results/lessons.php'); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | * @uses Sensei_Course::get_loop_number_of_columns |
| 1148 | 1148 | * @since 1.9.0 |
| 1149 | 1149 | */ |
| 1150 | -function sensei_courses_per_row(){ |
|
| 1150 | +function sensei_courses_per_row() { |
|
| 1151 | 1151 | |
| 1152 | 1152 | echo Sensei_Course::get_loop_number_of_columns(); |
| 1153 | 1153 | |
@@ -1161,9 +1161,9 @@ discard block |
||
| 1161 | 1161 | * @param $args |
| 1162 | 1162 | * @param $path |
| 1163 | 1163 | */ |
| 1164 | -function sensei_get_template( $template_name, $args, $path ){ |
|
| 1164 | +function sensei_get_template($template_name, $args, $path) { |
|
| 1165 | 1165 | |
| 1166 | - Sensei_Templates::get_template( $template_name, $args, $path ); |
|
| 1166 | + Sensei_Templates::get_template($template_name, $args, $path); |
|
| 1167 | 1167 | |
| 1168 | 1168 | } |
| 1169 | 1169 | |
@@ -1175,12 +1175,12 @@ discard block |
||
| 1175 | 1175 | * |
| 1176 | 1176 | * @return string $status_class |
| 1177 | 1177 | */ |
| 1178 | -function get_the_lesson_status_class(){ |
|
| 1178 | +function get_the_lesson_status_class() { |
|
| 1179 | 1179 | |
| 1180 | 1180 | $status_class = ''; |
| 1181 | - $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); |
|
| 1181 | + $lesson_completed = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id()); |
|
| 1182 | 1182 | |
| 1183 | - if ( $lesson_completed ) { |
|
| 1183 | + if ($lesson_completed) { |
|
| 1184 | 1184 | $status_class = 'completed'; |
| 1185 | 1185 | } |
| 1186 | 1186 | |
@@ -1194,7 +1194,7 @@ discard block |
||
| 1194 | 1194 | * |
| 1195 | 1195 | * @since 1.9.0 |
| 1196 | 1196 | */ |
| 1197 | -function sensei_the_lesson_status_class(){ |
|
| 1197 | +function sensei_the_lesson_status_class() { |
|
| 1198 | 1198 | |
| 1199 | 1199 | echo get_the_lesson_status_class(); |
| 1200 | 1200 | } |