@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Analysis Class |
@@ -23,23 +23,23 @@ discard block |
||
| 23 | 23 | * @since 1.0.0 |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | - public function __construct ( $file ) { |
|
| 26 | + public function __construct($file) { |
|
| 27 | 27 | $this->name = __('Analysis', 'woothemes-sensei'); |
| 28 | 28 | $this->file = $file; |
| 29 | 29 | $this->page_slug = 'sensei_analysis'; |
| 30 | 30 | |
| 31 | 31 | // Admin functions |
| 32 | - if ( is_admin() ) { |
|
| 33 | - add_action( 'admin_menu', array( $this, 'analysis_admin_menu' ), 10); |
|
| 34 | - add_action( 'analysis_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, 'analysis_admin_menu'), 10); |
|
| 34 | + add_action('analysis_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, 'report_download_page' ) ); |
|
| 40 | + add_action('admin_init', array($this, 'report_download_page')); |
|
| 41 | 41 | |
| 42 | - add_filter( 'user_search_columns', array( $this, 'user_search_columns_filter' ), 10, 3 ); |
|
| 42 | + add_filter('user_search_columns', array($this, 'user_search_columns_filter'), 10, 3); |
|
| 43 | 43 | } // End If Statement |
| 44 | 44 | } // End __construct() |
| 45 | 45 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | public function analysis_admin_menu() { |
| 54 | 54 | global $menu, $woocommerce; |
| 55 | 55 | |
| 56 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 56 | + if (current_user_can('manage_sensei_grades')) { |
|
| 57 | 57 | |
| 58 | - add_submenu_page( 'sensei', __('Analysis', 'woothemes-sensei'), __('Analysis', 'woothemes-sensei') , 'manage_sensei_grades', 'sensei_analysis', array( $this, 'analysis_page' ) ); |
|
| 58 | + add_submenu_page('sensei', __('Analysis', 'woothemes-sensei'), __('Analysis', 'woothemes-sensei'), 'manage_sensei_grades', 'sensei_analysis', array($this, 'analysis_page')); |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @since 1.0.0 |
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | - public function enqueue_scripts () { |
|
| 72 | + public function enqueue_scripts() { |
|
| 73 | 73 | // None for now |
| 74 | 74 | |
| 75 | 75 | } // End enqueue_scripts() |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | * @since 1.0.0 |
| 83 | 83 | * @return void |
| 84 | 84 | */ |
| 85 | - public function enqueue_styles () { |
|
| 85 | + public function enqueue_styles() { |
|
| 86 | 86 | |
| 87 | - wp_enqueue_style( 'woothemes-sensei-admin' ); |
|
| 87 | + wp_enqueue_style('woothemes-sensei-admin'); |
|
| 88 | 88 | |
| 89 | - wp_enqueue_style( 'woothemes-sensei-settings-api', Sensei()->plugin_url . 'assets/css/settings.css', '', Sensei()->version ); |
|
| 89 | + wp_enqueue_style('woothemes-sensei-settings-api', Sensei()->plugin_url.'assets/css/settings.css', '', Sensei()->version); |
|
| 90 | 90 | |
| 91 | 91 | } // End enqueue_styles() |
| 92 | 92 | |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | public function load_data_table_files() { |
| 99 | 99 | |
| 100 | 100 | // Load Analysis Classes |
| 101 | - $classes_to_load = array( 'list-table', |
|
| 101 | + $classes_to_load = array('list-table', |
|
| 102 | 102 | 'analysis-overview', |
| 103 | 103 | 'analysis-user-profile', |
| 104 | 104 | 'analysis-course', |
| 105 | 105 | 'analysis-lesson' |
| 106 | 106 | ); |
| 107 | - foreach ( $classes_to_load as $class_file ) { |
|
| 108 | - Sensei()->load_class( $class_file ); |
|
| 107 | + foreach ($classes_to_load as $class_file) { |
|
| 108 | + Sensei()->load_class($class_file); |
|
| 109 | 109 | } // End For Loop |
| 110 | 110 | } // End load_data_table_files() |
| 111 | 111 | |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * @param undefined $optional_data optional constructor arguments |
| 117 | 117 | * @return object class instance object |
| 118 | 118 | */ |
| 119 | - public function load_data_object( $name = '', $data = 0, $optional_data = null ) { |
|
| 119 | + public function load_data_object($name = '', $data = 0, $optional_data = null) { |
|
| 120 | 120 | // Load Analysis data |
| 121 | - $object_name = 'WooThemes_Sensei_Analysis_' . $name . '_List_Table'; |
|
| 122 | - if ( is_null($optional_data) ) { |
|
| 123 | - $sensei_analysis_object = new $object_name( $data ); |
|
| 121 | + $object_name = 'WooThemes_Sensei_Analysis_'.$name.'_List_Table'; |
|
| 122 | + if (is_null($optional_data)) { |
|
| 123 | + $sensei_analysis_object = new $object_name($data); |
|
| 124 | 124 | } else { |
| 125 | - $sensei_analysis_object = new $object_name( $data, $optional_data ); |
|
| 125 | + $sensei_analysis_object = new $object_name($data, $optional_data); |
|
| 126 | 126 | } |
| 127 | 127 | $sensei_analysis_object->prepare_items(); |
| 128 | 128 | return $sensei_analysis_object; |
@@ -139,40 +139,40 @@ discard block |
||
| 139 | 139 | $course_id = 0; |
| 140 | 140 | $lesson_id = 0; |
| 141 | 141 | $user_id = 0; |
| 142 | - if( isset( $_GET['course_id'] ) ) { |
|
| 143 | - $course_id = intval( $_GET['course_id'] ); |
|
| 142 | + if (isset($_GET['course_id'])) { |
|
| 143 | + $course_id = intval($_GET['course_id']); |
|
| 144 | 144 | } |
| 145 | - if( isset( $_GET['lesson_id'] ) ) { |
|
| 146 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 145 | + if (isset($_GET['lesson_id'])) { |
|
| 146 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 147 | 147 | } |
| 148 | - if( isset( $_GET['user_id'] ) ) { |
|
| 149 | - $user_id = intval( $_GET['user_id'] ); |
|
| 148 | + if (isset($_GET['user_id'])) { |
|
| 149 | + $user_id = intval($_GET['user_id']); |
|
| 150 | 150 | } |
| 151 | - $type = isset( $_GET['view'] ) ? esc_html( $_GET['view'] ) : false; |
|
| 151 | + $type = isset($_GET['view']) ? esc_html($_GET['view']) : false; |
|
| 152 | 152 | |
| 153 | - if ( 0 < $lesson_id ) { |
|
| 153 | + if (0 < $lesson_id) { |
|
| 154 | 154 | // Viewing a specific Lesson and all its Learners |
| 155 | - $this->analysis_lesson_users_view( $lesson_id ); |
|
| 155 | + $this->analysis_lesson_users_view($lesson_id); |
|
| 156 | 156 | } |
| 157 | - elseif ( 0 < $course_id && !$user_id && 'user' == $type ) { |
|
| 157 | + elseif (0 < $course_id && ! $user_id && 'user' == $type) { |
|
| 158 | 158 | // Viewing a specific Course and all its Learners |
| 159 | - $this->analysis_course_users_view( $course_id ); |
|
| 159 | + $this->analysis_course_users_view($course_id); |
|
| 160 | 160 | } |
| 161 | - elseif ( 0 < $course_id && 0 < $user_id ) { |
|
| 161 | + elseif (0 < $course_id && 0 < $user_id) { |
|
| 162 | 162 | // Viewing a specific Learner on a specific Course, showing their Lessons |
| 163 | - $this->analysis_user_course_view( $course_id, $user_id ); |
|
| 163 | + $this->analysis_user_course_view($course_id, $user_id); |
|
| 164 | 164 | } |
| 165 | - elseif( 0 < $course_id ) { |
|
| 165 | + elseif (0 < $course_id) { |
|
| 166 | 166 | // Viewing a specific Course and all it's Lessons |
| 167 | - $this->analysis_course_view( $course_id ); |
|
| 167 | + $this->analysis_course_view($course_id); |
|
| 168 | 168 | } |
| 169 | - elseif ( 0 < $user_id ) { |
|
| 169 | + elseif (0 < $user_id) { |
|
| 170 | 170 | // Viewing a specific Learner, and their Courses |
| 171 | - $this->analysis_user_profile_view( $user_id ); |
|
| 171 | + $this->analysis_user_profile_view($user_id); |
|
| 172 | 172 | } |
| 173 | 173 | else { |
| 174 | 174 | // Overview of all Learners, all Courses, or all Lessons |
| 175 | - $this->analysis_default_view( $type ); |
|
| 175 | + $this->analysis_default_view($type); |
|
| 176 | 176 | } // End If Statement |
| 177 | 177 | } // End analysis_page() |
| 178 | 178 | |
@@ -181,35 +181,35 @@ discard block |
||
| 181 | 181 | * @since 1.2.0 |
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | - public function analysis_default_view( $type ) { |
|
| 184 | + public function analysis_default_view($type) { |
|
| 185 | 185 | |
| 186 | 186 | // Load Analysis data |
| 187 | - $sensei_analysis_overview = $this->load_data_object( 'Overview', $type ); |
|
| 187 | + $sensei_analysis_overview = $this->load_data_object('Overview', $type); |
|
| 188 | 188 | // Wrappers |
| 189 | - do_action( 'analysis_before_container' ); |
|
| 190 | - do_action( 'analysis_wrapper_container', 'top' ); |
|
| 189 | + do_action('analysis_before_container'); |
|
| 190 | + do_action('analysis_wrapper_container', 'top'); |
|
| 191 | 191 | $this->analysis_headers(); |
| 192 | 192 | ?> |
| 193 | 193 | <div id="poststuff" class="sensei-analysis-wrap"> |
| 194 | 194 | <div class="sensei-analysis-sidebar"> |
| 195 | 195 | <?php |
| 196 | - do_action( 'sensei_analysis_before_stats_boxes' ); |
|
| 197 | - foreach ( $sensei_analysis_overview->stats_boxes() as $key => $value ) { |
|
| 198 | - $this->render_stats_box( esc_html( $key ), esc_html( $value ) ); |
|
| 196 | + do_action('sensei_analysis_before_stats_boxes'); |
|
| 197 | + foreach ($sensei_analysis_overview->stats_boxes() as $key => $value) { |
|
| 198 | + $this->render_stats_box(esc_html($key), esc_html($value)); |
|
| 199 | 199 | } // End For Loop |
| 200 | - do_action( 'sensei_analysis_after_stats_boxes' ); |
|
| 200 | + do_action('sensei_analysis_after_stats_boxes'); |
|
| 201 | 201 | ?> |
| 202 | 202 | </div> |
| 203 | 203 | <div class="sensei-analysis-main"> |
| 204 | 204 | <?php $sensei_analysis_overview->display(); ?> |
| 205 | 205 | </div> |
| 206 | 206 | <div class="sensei-analysis-extra"> |
| 207 | - <?php do_action( 'sensei_analysis_extra' ); ?> |
|
| 207 | + <?php do_action('sensei_analysis_extra'); ?> |
|
| 208 | 208 | </div> |
| 209 | 209 | </div> |
| 210 | 210 | <?php |
| 211 | - do_action( 'analysis_wrapper_container', 'bottom' ); |
|
| 212 | - do_action( 'analysis_after_container' ); |
|
| 211 | + do_action('analysis_wrapper_container', 'bottom'); |
|
| 212 | + do_action('analysis_after_container'); |
|
| 213 | 213 | } // End analysis_default_view() |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -217,26 +217,26 @@ discard block |
||
| 217 | 217 | * @since 1.2.0 |
| 218 | 218 | * @return void |
| 219 | 219 | */ |
| 220 | - public function analysis_user_profile_view( $user_id ) { |
|
| 220 | + public function analysis_user_profile_view($user_id) { |
|
| 221 | 221 | |
| 222 | 222 | // Load Analysis data |
| 223 | - $sensei_analysis_user_profile = $this->load_data_object( 'User_Profile', $user_id ); |
|
| 223 | + $sensei_analysis_user_profile = $this->load_data_object('User_Profile', $user_id); |
|
| 224 | 224 | // Wrappers |
| 225 | - do_action( 'analysis_before_container' ); |
|
| 226 | - do_action( 'analysis_wrapper_container', 'top' ); |
|
| 227 | - $this->analysis_headers( array( 'nav' => 'user_profile' ) ); |
|
| 225 | + do_action('analysis_before_container'); |
|
| 226 | + do_action('analysis_wrapper_container', 'top'); |
|
| 227 | + $this->analysis_headers(array('nav' => 'user_profile')); |
|
| 228 | 228 | ?> |
| 229 | 229 | <div id="poststuff" class="sensei-analysis-wrap user-profile"> |
| 230 | 230 | <div class="sensei-analysis-main"> |
| 231 | 231 | <?php $sensei_analysis_user_profile->display(); ?> |
| 232 | 232 | </div> |
| 233 | 233 | <div class="sensei-analysis-extra"> |
| 234 | - <?php do_action( 'sensei_analysis_extra' ); ?> |
|
| 234 | + <?php do_action('sensei_analysis_extra'); ?> |
|
| 235 | 235 | </div> |
| 236 | 236 | </div> |
| 237 | 237 | <?php |
| 238 | - do_action( 'analysis_wrapper_container', 'bottom' ); |
|
| 239 | - do_action( 'analysis_after_container' ); |
|
| 238 | + do_action('analysis_wrapper_container', 'bottom'); |
|
| 239 | + do_action('analysis_after_container'); |
|
| 240 | 240 | } // End analysis_user_profile_view() |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -244,26 +244,26 @@ discard block |
||
| 244 | 244 | * @since 1.2.0 |
| 245 | 245 | * @return void |
| 246 | 246 | */ |
| 247 | - public function analysis_course_view( $course_id ) { |
|
| 247 | + public function analysis_course_view($course_id) { |
|
| 248 | 248 | |
| 249 | 249 | // Load Analysis data |
| 250 | - $sensei_analysis_course = $this->load_data_object( 'Course', $course_id ); |
|
| 250 | + $sensei_analysis_course = $this->load_data_object('Course', $course_id); |
|
| 251 | 251 | // Wrappers |
| 252 | - do_action( 'analysis_before_container' ); |
|
| 253 | - do_action( 'analysis_wrapper_container', 'top' ); |
|
| 254 | - $this->analysis_headers( array( 'nav' => 'course' ) ); |
|
| 252 | + do_action('analysis_before_container'); |
|
| 253 | + do_action('analysis_wrapper_container', 'top'); |
|
| 254 | + $this->analysis_headers(array('nav' => 'course')); |
|
| 255 | 255 | ?> |
| 256 | 256 | <div id="poststuff" class="sensei-analysis-wrap course-profile"> |
| 257 | 257 | <div class="sensei-analysis-main"> |
| 258 | 258 | <?php $sensei_analysis_course->display(); ?> |
| 259 | 259 | </div> |
| 260 | 260 | <div class="sensei-analysis-extra"> |
| 261 | - <?php do_action( 'sensei_analysis_extra' ); ?> |
|
| 261 | + <?php do_action('sensei_analysis_extra'); ?> |
|
| 262 | 262 | </div> |
| 263 | 263 | </div> |
| 264 | 264 | <?php |
| 265 | - do_action( 'analysis_wrapper_container', 'bottom' ); |
|
| 266 | - do_action( 'analysis_after_container' ); |
|
| 265 | + do_action('analysis_wrapper_container', 'bottom'); |
|
| 266 | + do_action('analysis_after_container'); |
|
| 267 | 267 | } // End analysis_course_view() |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -271,26 +271,26 @@ discard block |
||
| 271 | 271 | * @since 1.2.0 |
| 272 | 272 | * @return void |
| 273 | 273 | */ |
| 274 | - public function analysis_user_course_view( $course_id, $user_id ) { |
|
| 274 | + public function analysis_user_course_view($course_id, $user_id) { |
|
| 275 | 275 | |
| 276 | 276 | // Load Analysis data |
| 277 | - $sensei_analysis_user_course = $this->load_data_object( 'Course', $course_id, $user_id ); |
|
| 277 | + $sensei_analysis_user_course = $this->load_data_object('Course', $course_id, $user_id); |
|
| 278 | 278 | // Wrappers |
| 279 | - do_action( 'analysis_before_container' ); |
|
| 280 | - do_action( 'analysis_wrapper_container', 'top' ); |
|
| 281 | - $this->analysis_headers( array( 'nav' => 'user_course' ) ); |
|
| 279 | + do_action('analysis_before_container'); |
|
| 280 | + do_action('analysis_wrapper_container', 'top'); |
|
| 281 | + $this->analysis_headers(array('nav' => 'user_course')); |
|
| 282 | 282 | ?> |
| 283 | 283 | <div id="poststuff" class="sensei-analysis-wrap course-profile"> |
| 284 | 284 | <div class="sensei-analysis-main"> |
| 285 | 285 | <?php $sensei_analysis_user_course->display(); ?> |
| 286 | 286 | </div> |
| 287 | 287 | <div class="sensei-analysis-extra"> |
| 288 | - <?php do_action( 'sensei_analysis_extra' ); ?> |
|
| 288 | + <?php do_action('sensei_analysis_extra'); ?> |
|
| 289 | 289 | </div> |
| 290 | 290 | </div> |
| 291 | 291 | <?php |
| 292 | - do_action( 'analysis_wrapper_container', 'bottom' ); |
|
| 293 | - do_action( 'analysis_after_container' ); |
|
| 292 | + do_action('analysis_wrapper_container', 'bottom'); |
|
| 293 | + do_action('analysis_after_container'); |
|
| 294 | 294 | } // End analysis_user_course_view() |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -298,26 +298,26 @@ discard block |
||
| 298 | 298 | * @since 1.2.0 |
| 299 | 299 | * @return void |
| 300 | 300 | */ |
| 301 | - public function analysis_course_users_view( $course_id ) { |
|
| 301 | + public function analysis_course_users_view($course_id) { |
|
| 302 | 302 | |
| 303 | 303 | // Load Analysis data |
| 304 | - $sensei_analysis_course_users = $this->load_data_object( 'Course', $course_id ); |
|
| 304 | + $sensei_analysis_course_users = $this->load_data_object('Course', $course_id); |
|
| 305 | 305 | // Wrappers |
| 306 | - do_action( 'analysis_before_container' ); |
|
| 307 | - do_action( 'analysis_wrapper_container', 'top' ); |
|
| 308 | - $this->analysis_headers( array( 'nav' => 'course_users' ) ); |
|
| 306 | + do_action('analysis_before_container'); |
|
| 307 | + do_action('analysis_wrapper_container', 'top'); |
|
| 308 | + $this->analysis_headers(array('nav' => 'course_users')); |
|
| 309 | 309 | ?> |
| 310 | 310 | <div id="poststuff" class="sensei-analysis-wrap course-profile"> |
| 311 | 311 | <div class="sensei-analysis-main"> |
| 312 | 312 | <?php $sensei_analysis_course_users->display(); ?> |
| 313 | 313 | </div> |
| 314 | 314 | <div class="sensei-analysis-extra"> |
| 315 | - <?php do_action( 'sensei_analysis_extra' ); ?> |
|
| 315 | + <?php do_action('sensei_analysis_extra'); ?> |
|
| 316 | 316 | </div> |
| 317 | 317 | </div> |
| 318 | 318 | <?php |
| 319 | - do_action( 'analysis_wrapper_container', 'bottom' ); |
|
| 320 | - do_action( 'analysis_after_container' ); |
|
| 319 | + do_action('analysis_wrapper_container', 'bottom'); |
|
| 320 | + do_action('analysis_after_container'); |
|
| 321 | 321 | } // End analysis_course_users_view() |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -325,26 +325,26 @@ discard block |
||
| 325 | 325 | * @since 1.2.0 |
| 326 | 326 | * @return void |
| 327 | 327 | */ |
| 328 | - public function analysis_lesson_users_view( $lesson_id ) { |
|
| 328 | + public function analysis_lesson_users_view($lesson_id) { |
|
| 329 | 329 | |
| 330 | 330 | // Load Analysis data |
| 331 | - $sensei_analysis_lesson_users = $this->load_data_object( 'Lesson', $lesson_id ); |
|
| 331 | + $sensei_analysis_lesson_users = $this->load_data_object('Lesson', $lesson_id); |
|
| 332 | 332 | // Wrappers |
| 333 | - do_action( 'analysis_before_container' ); |
|
| 334 | - do_action( 'analysis_wrapper_container', 'top' ); |
|
| 335 | - $this->analysis_headers( array( 'nav' => 'lesson_users' ) ); |
|
| 333 | + do_action('analysis_before_container'); |
|
| 334 | + do_action('analysis_wrapper_container', 'top'); |
|
| 335 | + $this->analysis_headers(array('nav' => 'lesson_users')); |
|
| 336 | 336 | ?> |
| 337 | 337 | <div id="poststuff" class="sensei-analysis-wrap course-profile"> |
| 338 | 338 | <div class="sensei-analysis-main"> |
| 339 | 339 | <?php $sensei_analysis_lesson_users->display(); ?> |
| 340 | 340 | </div> |
| 341 | 341 | <div class="sensei-analysis-extra"> |
| 342 | - <?php do_action( 'sensei_analysis_extra' ); ?> |
|
| 342 | + <?php do_action('sensei_analysis_extra'); ?> |
|
| 343 | 343 | </div> |
| 344 | 344 | </div> |
| 345 | 345 | <?php |
| 346 | - do_action( 'analysis_wrapper_container', 'bottom' ); |
|
| 347 | - do_action( 'analysis_after_container' ); |
|
| 346 | + do_action('analysis_wrapper_container', 'bottom'); |
|
| 347 | + do_action('analysis_after_container'); |
|
| 348 | 348 | } // End analysis_lesson_users_view() |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param $data string stats data |
| 355 | 355 | * @return void |
| 356 | 356 | */ |
| 357 | - public function render_stats_box( $title, $data ) { |
|
| 357 | + public function render_stats_box($title, $data) { |
|
| 358 | 358 | ?><div class="postbox"> |
| 359 | 359 | <h3><span><?php echo $title; ?></span></h3> |
| 360 | 360 | <div class="inside"> |
@@ -368,14 +368,14 @@ discard block |
||
| 368 | 368 | * @since 1.2.0 |
| 369 | 369 | * @return void |
| 370 | 370 | */ |
| 371 | - public function analysis_headers( $args = array( 'nav' => 'default' ) ) { |
|
| 371 | + public function analysis_headers($args = array('nav' => 'default')) { |
|
| 372 | 372 | |
| 373 | - $function = 'analysis_' . $args['nav'] . '_nav'; |
|
| 373 | + $function = 'analysis_'.$args['nav'].'_nav'; |
|
| 374 | 374 | $this->$function(); |
| 375 | 375 | ?> |
| 376 | 376 | <p class="powered-by-woo"> |
| 377 | 377 | |
| 378 | - <?php _e( 'Powered by', 'woothemes-sensei' ); ?> |
|
| 378 | + <?php _e('Powered by', 'woothemes-sensei'); ?> |
|
| 379 | 379 | |
| 380 | 380 | <a href="http://www.woothemes.com/" title="WooThemes"> |
| 381 | 381 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | </p> |
| 387 | 387 | |
| 388 | 388 | <?php |
| 389 | - do_action( 'sensei_analysis_after_headers' ); |
|
| 389 | + do_action('sensei_analysis_after_headers'); |
|
| 390 | 390 | } // End analysis_headers() |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -395,10 +395,10 @@ discard block |
||
| 395 | 395 | * @param $which string |
| 396 | 396 | * @return void |
| 397 | 397 | */ |
| 398 | - public function wrapper_container( $which ) { |
|
| 399 | - if ( 'top' == $which ) { |
|
| 398 | + public function wrapper_container($which) { |
|
| 399 | + if ('top' == $which) { |
|
| 400 | 400 | ?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php |
| 401 | - } elseif ( 'bottom' == $which ) { |
|
| 401 | + } elseif ('bottom' == $which) { |
|
| 402 | 402 | ?></div><!--/#woothemes-sensei--><?php |
| 403 | 403 | } // End If Statement |
| 404 | 404 | } // End wrapper_container() |
@@ -410,24 +410,24 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | public function analysis_default_nav() { |
| 412 | 412 | |
| 413 | - $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 ) ); |
|
| 414 | - $view = isset($_GET['view']) ? esc_html( $_GET['view'] ) : ''; |
|
| 415 | - switch ( $view ) { |
|
| 413 | + $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)); |
|
| 414 | + $view = isset($_GET['view']) ? esc_html($_GET['view']) : ''; |
|
| 415 | + switch ($view) { |
|
| 416 | 416 | case 'courses' : |
| 417 | - $title .= sprintf( ' <span class="course-title">> %s</span>', __( 'Courses', 'woothemes-sensei' ) ); |
|
| 417 | + $title .= sprintf(' <span class="course-title">> %s</span>', __('Courses', 'woothemes-sensei')); |
|
| 418 | 418 | break; |
| 419 | 419 | |
| 420 | 420 | case 'lessons' : |
| 421 | - $title .= sprintf( ' <span class="lesson-title">> %s</span>', __( 'Lessons', 'woothemes-sensei' ) ); |
|
| 421 | + $title .= sprintf(' <span class="lesson-title">> %s</span>', __('Lessons', 'woothemes-sensei')); |
|
| 422 | 422 | break; |
| 423 | 423 | |
| 424 | 424 | case 'users' : |
| 425 | 425 | default : |
| 426 | - $title .= sprintf( ' <span class="user-title">> %s</span>', __( 'Learners', 'woothemes-sensei' ) ); |
|
| 426 | + $title .= sprintf(' <span class="user-title">> %s</span>', __('Learners', 'woothemes-sensei')); |
|
| 427 | 427 | break; |
| 428 | 428 | } |
| 429 | 429 | ?> |
| 430 | - <h2><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h2> |
|
| 430 | + <h2><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h2> |
|
| 431 | 431 | <?php |
| 432 | 432 | } // End analysis_default_nav() |
| 433 | 433 | |
@@ -438,17 +438,17 @@ discard block |
||
| 438 | 438 | */ |
| 439 | 439 | public function analysis_user_profile_nav() { |
| 440 | 440 | |
| 441 | - $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 ) ); |
|
| 442 | - if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) { |
|
| 441 | + $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)); |
|
| 442 | + if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) { |
|
| 443 | 443 | |
| 444 | - $user_id = intval( $_GET['user_id'] ); |
|
| 445 | - $url = esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user' => $user_id ), admin_url( 'admin.php' ) ) ); |
|
| 446 | - $user_name = Sensei_Student::get_full_name( $user_id ); |
|
| 447 | - $title .= sprintf( ' <span class="user-title">> <a href="%s">%s</a></span>', $url, $user_name ); |
|
| 444 | + $user_id = intval($_GET['user_id']); |
|
| 445 | + $url = esc_url(add_query_arg(array('page' => $this->page_slug, 'user' => $user_id), admin_url('admin.php'))); |
|
| 446 | + $user_name = Sensei_Student::get_full_name($user_id); |
|
| 447 | + $title .= sprintf(' <span class="user-title">> <a href="%s">%s</a></span>', $url, $user_name); |
|
| 448 | 448 | |
| 449 | 449 | } // End If Statement |
| 450 | 450 | ?> |
| 451 | - <h2><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h2> |
|
| 451 | + <h2><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h2> |
|
| 452 | 452 | <?php |
| 453 | 453 | } // End analysis_user_profile_nav() |
| 454 | 454 | |
@@ -459,22 +459,22 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public function analysis_user_course_nav() { |
| 461 | 461 | |
| 462 | - $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 ) ); |
|
| 463 | - if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) { |
|
| 464 | - $user_id = intval( $_GET['user_id'] ); |
|
| 465 | - $user_data = get_userdata( $user_id ); |
|
| 466 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $user_id ), admin_url( 'admin.php' ) ); |
|
| 467 | - $user_name = Sensei_Student::get_full_name( $user_id ); |
|
| 468 | - $title .= sprintf( ' <span class="user-title">> <a href="%s">%s</a></span>', $url, $user_name ); |
|
| 469 | - $title .= sprintf( ' <span class="user-title">> <a href="%s">%s</a></span>', esc_url( $url ), $user_data->display_name ); |
|
| 462 | + $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)); |
|
| 463 | + if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) { |
|
| 464 | + $user_id = intval($_GET['user_id']); |
|
| 465 | + $user_data = get_userdata($user_id); |
|
| 466 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $user_id), admin_url('admin.php')); |
|
| 467 | + $user_name = Sensei_Student::get_full_name($user_id); |
|
| 468 | + $title .= sprintf(' <span class="user-title">> <a href="%s">%s</a></span>', $url, $user_name); |
|
| 469 | + $title .= sprintf(' <span class="user-title">> <a href="%s">%s</a></span>', esc_url($url), $user_data->display_name); |
|
| 470 | 470 | } // End If Statement |
| 471 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 472 | - $course_id = intval( $_GET['course_id'] ); |
|
| 473 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 474 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 471 | + if (isset($_GET['course_id'])) { |
|
| 472 | + $course_id = intval($_GET['course_id']); |
|
| 473 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 474 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 475 | 475 | } |
| 476 | 476 | ?> |
| 477 | - <h2><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h2> |
|
| 477 | + <h2><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h2> |
|
| 478 | 478 | <?php |
| 479 | 479 | } // End analysis_user_course_nav() |
| 480 | 480 | |
@@ -485,14 +485,14 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | public function analysis_course_nav() { |
| 487 | 487 | |
| 488 | - $title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) ); |
|
| 489 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 490 | - $course_id = intval( $_GET['course_id'] ); |
|
| 491 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 492 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>',esc_url( $url ), get_the_title( $course_id ) ); |
|
| 488 | + $title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name)); |
|
| 489 | + if (isset($_GET['course_id'])) { |
|
| 490 | + $course_id = intval($_GET['course_id']); |
|
| 491 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 492 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 493 | 493 | } |
| 494 | 494 | ?> |
| 495 | - <h2><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h2> |
|
| 495 | + <h2><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h2> |
|
| 496 | 496 | <?php |
| 497 | 497 | } // End analysis_course_nav() |
| 498 | 498 | |
@@ -503,14 +503,14 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | public function analysis_course_users_nav() { |
| 505 | 505 | |
| 506 | - $title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) ); |
|
| 507 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 508 | - $course_id = intval( $_GET['course_id'] ); |
|
| 509 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 510 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 506 | + $title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name)); |
|
| 507 | + if (isset($_GET['course_id'])) { |
|
| 508 | + $course_id = intval($_GET['course_id']); |
|
| 509 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 510 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 511 | 511 | } |
| 512 | 512 | ?> |
| 513 | - <h2><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h2> |
|
| 513 | + <h2><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h2> |
|
| 514 | 514 | <?php |
| 515 | 515 | } // End analysis_course_users_nav() |
| 516 | 516 | |
@@ -521,17 +521,17 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | public function analysis_lesson_users_nav() { |
| 523 | 523 | |
| 524 | - $title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) ); |
|
| 525 | - if ( isset( $_GET['lesson_id'] ) ) { |
|
| 526 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 527 | - $course_id = intval( get_post_meta( $lesson_id, '_lesson_course', true ) ); |
|
| 528 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 529 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 530 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id ), admin_url( 'admin.php' ) ); |
|
| 531 | - $title .= sprintf( ' <span class="lesson-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $lesson_id ) ); |
|
| 524 | + $title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name)); |
|
| 525 | + if (isset($_GET['lesson_id'])) { |
|
| 526 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 527 | + $course_id = intval(get_post_meta($lesson_id, '_lesson_course', true)); |
|
| 528 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 529 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 530 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id), admin_url('admin.php')); |
|
| 531 | + $title .= sprintf(' <span class="lesson-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($lesson_id)); |
|
| 532 | 532 | } |
| 533 | 533 | ?> |
| 534 | - <h2><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h2> |
|
| 534 | + <h2><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h2> |
|
| 535 | 535 | <?php |
| 536 | 536 | } // End analysis_lesson_users_nav() |
| 537 | 537 | |
@@ -542,59 +542,59 @@ discard block |
||
| 542 | 542 | */ |
| 543 | 543 | public function report_download_page() { |
| 544 | 544 | // Check if is a report |
| 545 | - if ( !empty( $_GET['sensei_report_download'] ) ) { |
|
| 546 | - $report = sanitize_text_field( $_GET['sensei_report_download'] ); |
|
| 545 | + if ( ! empty($_GET['sensei_report_download'])) { |
|
| 546 | + $report = sanitize_text_field($_GET['sensei_report_download']); |
|
| 547 | 547 | |
| 548 | 548 | // Simple verification to ensure intent, Note that a Nonce is per user, so the URL can't be shared |
| 549 | - if ( !wp_verify_nonce( $_REQUEST['_sdl_nonce'], 'sensei_csv_download-' . $report ) ) { |
|
| 550 | - wp_die( __('Invalid request', 'woothemes-sensei') ); |
|
| 549 | + if ( ! wp_verify_nonce($_REQUEST['_sdl_nonce'], 'sensei_csv_download-'.$report)) { |
|
| 550 | + wp_die(__('Invalid request', 'woothemes-sensei')); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | // Setup the variables we might need |
| 554 | - $filename = apply_filters( 'sensei_csv_export_filename', $report ); |
|
| 554 | + $filename = apply_filters('sensei_csv_export_filename', $report); |
|
| 555 | 555 | $course_id = 0; |
| 556 | 556 | $lesson_id = 0; |
| 557 | 557 | $user_id = 0; |
| 558 | - if( isset( $_GET['course_id'] ) ) { |
|
| 559 | - $course_id = intval( $_GET['course_id'] ); |
|
| 558 | + if (isset($_GET['course_id'])) { |
|
| 559 | + $course_id = intval($_GET['course_id']); |
|
| 560 | 560 | } |
| 561 | - if( isset( $_GET['lesson_id'] ) ) { |
|
| 562 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 561 | + if (isset($_GET['lesson_id'])) { |
|
| 562 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 563 | 563 | } |
| 564 | - if( isset( $_GET['user_id'] ) ) { |
|
| 565 | - $user_id = intval( $_GET['user_id'] ); |
|
| 564 | + if (isset($_GET['user_id'])) { |
|
| 565 | + $user_id = intval($_GET['user_id']); |
|
| 566 | 566 | } |
| 567 | - $type = isset( $_GET['view'] ) ? esc_html( $_GET['view'] ) : false; |
|
| 567 | + $type = isset($_GET['view']) ? esc_html($_GET['view']) : false; |
|
| 568 | 568 | |
| 569 | - if ( 0 < $lesson_id ) { |
|
| 569 | + if (0 < $lesson_id) { |
|
| 570 | 570 | // Viewing a specific Lesson and all its Learners |
| 571 | - $sensei_analysis_report_object = $this->load_report_object( 'Lesson', $lesson_id ); |
|
| 571 | + $sensei_analysis_report_object = $this->load_report_object('Lesson', $lesson_id); |
|
| 572 | 572 | } |
| 573 | - elseif ( 0 < $course_id && 0 < $user_id ) { |
|
| 573 | + elseif (0 < $course_id && 0 < $user_id) { |
|
| 574 | 574 | // Viewing a specific User on a specific Course |
| 575 | - $sensei_analysis_report_object = $this->load_report_object( 'Course', $course_id, $user_id ); |
|
| 575 | + $sensei_analysis_report_object = $this->load_report_object('Course', $course_id, $user_id); |
|
| 576 | 576 | } |
| 577 | - elseif( 0 < $course_id ) { |
|
| 577 | + elseif (0 < $course_id) { |
|
| 578 | 578 | // Viewing a specific Course and all it's Lessons, or it's Learners |
| 579 | - $sensei_analysis_report_object = $this->load_report_object( 'Course', $course_id ); |
|
| 579 | + $sensei_analysis_report_object = $this->load_report_object('Course', $course_id); |
|
| 580 | 580 | } |
| 581 | - elseif ( 0 < $user_id ) { |
|
| 581 | + elseif (0 < $user_id) { |
|
| 582 | 582 | // Viewing a specific Learner, and their Courses |
| 583 | - $sensei_analysis_report_object = $this->load_report_object( 'User_Profile', $user_id ); |
|
| 583 | + $sensei_analysis_report_object = $this->load_report_object('User_Profile', $user_id); |
|
| 584 | 584 | } |
| 585 | 585 | else { |
| 586 | 586 | // Overview of all Learners, all Courses, or all Lessons |
| 587 | - $sensei_analysis_report_object = $this->load_report_object( 'Overview', $type ); |
|
| 587 | + $sensei_analysis_report_object = $this->load_report_object('Overview', $type); |
|
| 588 | 588 | } // End If Statement |
| 589 | 589 | |
| 590 | 590 | // Handle the headers |
| 591 | - $this->report_set_headers( $filename ); |
|
| 591 | + $this->report_set_headers($filename); |
|
| 592 | 592 | |
| 593 | 593 | // Collate the data, there could be many different reports for a single object |
| 594 | - $report_data_array = $sensei_analysis_report_object->generate_report( $report ); |
|
| 594 | + $report_data_array = $sensei_analysis_report_object->generate_report($report); |
|
| 595 | 595 | |
| 596 | 596 | // Output the data |
| 597 | - $this->report_write_download( $report_data_array ); |
|
| 597 | + $this->report_write_download($report_data_array); |
|
| 598 | 598 | |
| 599 | 599 | // Cleanly exit |
| 600 | 600 | exit; |
@@ -607,9 +607,9 @@ discard block |
||
| 607 | 607 | * @param string $filename name of report file |
| 608 | 608 | * @return void |
| 609 | 609 | */ |
| 610 | - public function report_set_headers( $filename = '' ) { |
|
| 611 | - header( 'Content-Type: text/csv' ); |
|
| 612 | - header( 'Content-Disposition: attachment;filename=' . $filename . '.csv'); |
|
| 610 | + public function report_set_headers($filename = '') { |
|
| 611 | + header('Content-Type: text/csv'); |
|
| 612 | + header('Content-Disposition: attachment;filename='.$filename.'.csv'); |
|
| 613 | 613 | } // End report_set_headers() |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -620,12 +620,12 @@ discard block |
||
| 620 | 620 | * @param undefined $optional_data optional constructor arguments |
| 621 | 621 | * @return object class instance object |
| 622 | 622 | */ |
| 623 | - public function load_report_object( $name = '', $data = 0, $optional_data = null ) { |
|
| 624 | - $object_name = 'WooThemes_Sensei_Analysis_' . $name . '_List_Table'; |
|
| 625 | - if ( is_null($optional_data) ) { |
|
| 626 | - $sensei_analysis_report_object = new $object_name( $data ); |
|
| 623 | + public function load_report_object($name = '', $data = 0, $optional_data = null) { |
|
| 624 | + $object_name = 'WooThemes_Sensei_Analysis_'.$name.'_List_Table'; |
|
| 625 | + if (is_null($optional_data)) { |
|
| 626 | + $sensei_analysis_report_object = new $object_name($data); |
|
| 627 | 627 | } else { |
| 628 | - $sensei_analysis_report_object = new $object_name( $data, $optional_data ); |
|
| 628 | + $sensei_analysis_report_object = new $object_name($data, $optional_data); |
|
| 629 | 629 | } |
| 630 | 630 | return $sensei_analysis_report_object; |
| 631 | 631 | } // End load_report_object() |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * @param array $report_array data array |
| 637 | 637 | * @return void |
| 638 | 638 | */ |
| 639 | - public function report_write_download( $report_data = array() ) { |
|
| 639 | + public function report_write_download($report_data = array()) { |
|
| 640 | 640 | $fp = fopen('php://output', 'w'); |
| 641 | 641 | foreach ($report_data as $row) { |
| 642 | 642 | fputcsv($fp, $row); |
@@ -652,9 +652,9 @@ discard block |
||
| 652 | 652 | * @param object $user_query_object WP_User_Query Object |
| 653 | 653 | * @return array $search_columns array of user columns to search |
| 654 | 654 | */ |
| 655 | - public function user_search_columns_filter( $search_columns, $search, $user_query_object ) { |
|
| 655 | + public function user_search_columns_filter($search_columns, $search, $user_query_object) { |
|
| 656 | 656 | // Alter $search_columns to include the fields you want to search on |
| 657 | - array_push( $search_columns, 'display_name' ); |
|
| 657 | + array_push($search_columns, 'display_name'); |
|
| 658 | 658 | return $search_columns; |
| 659 | 659 | } |
| 660 | 660 | |
@@ -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 Learners Class |
@@ -23,30 +23,30 @@ discard block |
||
| 23 | 23 | * @since 1.6.0 |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | - public function __construct ( $file ) { |
|
| 27 | - $this->name = __( 'Learner Management', 'woothemes-sensei' );; |
|
| 26 | + public function __construct($file) { |
|
| 27 | + $this->name = __('Learner Management', 'woothemes-sensei'); ; |
|
| 28 | 28 | $this->file = $file; |
| 29 | 29 | $this->page_slug = 'sensei_learners'; |
| 30 | 30 | |
| 31 | 31 | // Admin functions |
| 32 | - if ( is_admin() ) { |
|
| 33 | - add_action( 'admin_menu', array( $this, 'learners_admin_menu' ), 30); |
|
| 34 | - add_action( 'learners_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, 'learners_admin_menu'), 30); |
|
| 34 | + add_action('learners_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, 'add_new_learners' ) ); |
|
| 40 | + add_action('admin_init', array($this, 'add_new_learners')); |
|
| 41 | 41 | |
| 42 | - add_action( 'admin_notices', array( $this, 'add_learner_notices' ) ); |
|
| 42 | + add_action('admin_notices', array($this, 'add_learner_notices')); |
|
| 43 | 43 | } // End If Statement |
| 44 | 44 | |
| 45 | 45 | // Ajax functions |
| 46 | - if ( is_admin() ) { |
|
| 47 | - add_action( 'wp_ajax_get_redirect_url_learners', array( $this, 'get_redirect_url' ) ); |
|
| 48 | - add_action( 'wp_ajax_remove_user_from_post', array( $this, 'remove_user_from_post' ) ); |
|
| 49 | - add_action( 'wp_ajax_sensei_json_search_users', array( $this, 'json_search_users' ) ); |
|
| 46 | + if (is_admin()) { |
|
| 47 | + add_action('wp_ajax_get_redirect_url_learners', array($this, 'get_redirect_url')); |
|
| 48 | + add_action('wp_ajax_remove_user_from_post', array($this, 'remove_user_from_post')); |
|
| 49 | + add_action('wp_ajax_sensei_json_search_users', array($this, 'json_search_users')); |
|
| 50 | 50 | } |
| 51 | 51 | } // End __construct() |
| 52 | 52 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | public function learners_admin_menu() { |
| 60 | 60 | global $menu; |
| 61 | 61 | |
| 62 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 63 | - $learners_page = add_submenu_page( 'sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array( $this, 'learners_page' ) ); |
|
| 62 | + if (current_user_can('manage_sensei_grades')) { |
|
| 63 | + $learners_page = add_submenu_page('sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array($this, 'learners_page')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | } // End learners_admin_menu() |
@@ -73,26 +73,26 @@ discard block |
||
| 73 | 73 | * @since 1.6.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 Learners JS |
| 81 | - wp_enqueue_script( 'sensei-learners-general', |
|
| 82 | - Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js', |
|
| 83 | - array('jquery','select2','sensei-chosen-ajax' ), Sensei()->version, true ); |
|
| 81 | + wp_enqueue_script('sensei-learners-general', |
|
| 82 | + Sensei()->plugin_url.'assets/js/learners-general'.$suffix.'.js', |
|
| 83 | + array('jquery', 'select2', 'sensei-chosen-ajax'), Sensei()->version, true); |
|
| 84 | 84 | |
| 85 | 85 | $data = array( |
| 86 | - 'remove_generic_confirm' => __( 'Are you sure you want to remove this user?', 'woothemes-sensei' ), |
|
| 87 | - 'remove_from_lesson_confirm' => __( 'Are you sure you want to remove the user from this lesson?', 'woothemes-sensei' ), |
|
| 88 | - 'remove_from_course_confirm' => __( 'Are you sure you want to remove the user from this course?', 'woothemes-sensei' ), |
|
| 89 | - 'remove_from_purchased_course_confirm' => __( 'Are you sure you want to remove the user from this course? This order associate with this will also be set to canceled.', 'woothemes-sensei' ), |
|
| 90 | - 'remove_user_from_post_nonce' => wp_create_nonce( 'remove_user_from_post_nonce' ), |
|
| 91 | - 'search_users_nonce' => wp_create_nonce( 'search-users' ), |
|
| 92 | - 'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' ) |
|
| 86 | + 'remove_generic_confirm' => __('Are you sure you want to remove this user?', 'woothemes-sensei'), |
|
| 87 | + 'remove_from_lesson_confirm' => __('Are you sure you want to remove the user from this lesson?', 'woothemes-sensei'), |
|
| 88 | + 'remove_from_course_confirm' => __('Are you sure you want to remove the user from this course?', 'woothemes-sensei'), |
|
| 89 | + 'remove_from_purchased_course_confirm' => __('Are you sure you want to remove the user from this course? This order associate with this will also be set to canceled.', 'woothemes-sensei'), |
|
| 90 | + 'remove_user_from_post_nonce' => wp_create_nonce('remove_user_from_post_nonce'), |
|
| 91 | + 'search_users_nonce' => wp_create_nonce('search-users'), |
|
| 92 | + 'selectplaceholder'=> __('Select Learner', 'woothemes-sensei') |
|
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | - wp_localize_script( 'sensei-learners-general', 'woo_learners_general_data', $data ); |
|
| 95 | + wp_localize_script('sensei-learners-general', 'woo_learners_general_data', $data); |
|
| 96 | 96 | |
| 97 | 97 | } // End enqueue_scripts() |
| 98 | 98 | |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * @since 1.6.0 |
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | - public function enqueue_styles () { |
|
| 107 | + public function enqueue_styles() { |
|
| 108 | 108 | |
| 109 | - wp_enqueue_style( 'woothemes-sensei-admin' ); |
|
| 109 | + wp_enqueue_style('woothemes-sensei-admin'); |
|
| 110 | 110 | |
| 111 | 111 | } // End enqueue_styles() |
| 112 | 112 | |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | public function load_data_table_files() { |
| 119 | 119 | |
| 120 | 120 | // Load Learners Classes |
| 121 | - $classes_to_load = array( 'list-table', |
|
| 121 | + $classes_to_load = array('list-table', |
|
| 122 | 122 | 'learners-main', |
| 123 | 123 | ); |
| 124 | - foreach ( $classes_to_load as $class_file ) { |
|
| 125 | - Sensei()->load_class( $class_file ); |
|
| 124 | + foreach ($classes_to_load as $class_file) { |
|
| 125 | + Sensei()->load_class($class_file); |
|
| 126 | 126 | } // End For Loop |
| 127 | 127 | } // End load_data_table_files() |
| 128 | 128 | |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | * @param undefined $optional_data optional constructor arguments |
| 135 | 135 | * @return object class instance object |
| 136 | 136 | */ |
| 137 | - public function load_data_object( $name = '', $data = 0, $optional_data = null ) { |
|
| 137 | + public function load_data_object($name = '', $data = 0, $optional_data = null) { |
|
| 138 | 138 | // Load Analysis data |
| 139 | - $object_name = 'WooThemes_Sensei_Learners_' . $name; |
|
| 140 | - if ( is_null($optional_data) ) { |
|
| 141 | - $sensei_learners_object = new $object_name( $data ); |
|
| 139 | + $object_name = 'WooThemes_Sensei_Learners_'.$name; |
|
| 140 | + if (is_null($optional_data)) { |
|
| 141 | + $sensei_learners_object = new $object_name($data); |
|
| 142 | 142 | } else { |
| 143 | - $sensei_learners_object = new $object_name( $data, $optional_data ); |
|
| 143 | + $sensei_learners_object = new $object_name($data, $optional_data); |
|
| 144 | 144 | } // End If Statement |
| 145 | - if ( 'Main' == $name ) { |
|
| 145 | + if ('Main' == $name) { |
|
| 146 | 146 | $sensei_learners_object->prepare_items(); |
| 147 | 147 | } // End If Statement |
| 148 | 148 | return $sensei_learners_object; |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | // Load Learners data |
| 160 | 160 | $course_id = 0; |
| 161 | 161 | $lesson_id = 0; |
| 162 | - if( isset( $_GET['course_id'] ) ) { |
|
| 163 | - $course_id = intval( $_GET['course_id'] ); |
|
| 162 | + if (isset($_GET['course_id'])) { |
|
| 163 | + $course_id = intval($_GET['course_id']); |
|
| 164 | 164 | } |
| 165 | - if( isset( $_GET['lesson_id'] ) ) { |
|
| 166 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 165 | + if (isset($_GET['lesson_id'])) { |
|
| 166 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 167 | 167 | } |
| 168 | - $sensei_learners_main = $this->load_data_object( 'Main', $course_id, $lesson_id ); |
|
| 168 | + $sensei_learners_main = $this->load_data_object('Main', $course_id, $lesson_id); |
|
| 169 | 169 | // Wrappers |
| 170 | - do_action( 'learners_before_container' ); |
|
| 171 | - do_action( 'learners_wrapper_container', 'top' ); |
|
| 170 | + do_action('learners_before_container'); |
|
| 171 | + do_action('learners_wrapper_container', 'top'); |
|
| 172 | 172 | $this->learners_headers(); |
| 173 | 173 | ?> |
| 174 | 174 | <div id="poststuff" class="sensei-learners-wrap"> |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | <?php $sensei_learners_main->display(); ?> |
| 177 | 177 | </div> |
| 178 | 178 | <div class="sensei-learners-extra"> |
| 179 | - <?php do_action( 'sensei_learners_extra' ); ?> |
|
| 179 | + <?php do_action('sensei_learners_extra'); ?> |
|
| 180 | 180 | </div> |
| 181 | 181 | </div> |
| 182 | 182 | <?php |
| 183 | - do_action( 'learners_wrapper_container', 'bottom' ); |
|
| 184 | - do_action( 'learners_after_container' ); |
|
| 183 | + do_action('learners_wrapper_container', 'bottom'); |
|
| 184 | + do_action('learners_after_container'); |
|
| 185 | 185 | } // End learners_default_view() |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -189,15 +189,15 @@ discard block |
||
| 189 | 189 | * @since 1.6.0 |
| 190 | 190 | * @return void |
| 191 | 191 | */ |
| 192 | - public function learners_headers( $args = array( 'nav' => 'default' ) ) { |
|
| 192 | + public function learners_headers($args = array('nav' => 'default')) { |
|
| 193 | 193 | |
| 194 | 194 | |
| 195 | - $function = 'learners_' . $args['nav'] . '_nav'; |
|
| 195 | + $function = 'learners_'.$args['nav'].'_nav'; |
|
| 196 | 196 | $this->$function(); |
| 197 | 197 | ?> |
| 198 | - <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> |
|
| 198 | + <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> |
|
| 199 | 199 | <?php |
| 200 | - do_action( 'sensei_learners_after_headers' ); |
|
| 200 | + do_action('sensei_learners_after_headers'); |
|
| 201 | 201 | } // End learners_headers() |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -206,10 +206,10 @@ discard block |
||
| 206 | 206 | * @param $which string |
| 207 | 207 | * @return void |
| 208 | 208 | */ |
| 209 | - public function wrapper_container( $which ) { |
|
| 210 | - if ( 'top' == $which ) { |
|
| 209 | + public function wrapper_container($which) { |
|
| 210 | + if ('top' == $which) { |
|
| 211 | 211 | ?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php |
| 212 | - } elseif ( 'bottom' == $which ) { |
|
| 212 | + } elseif ('bottom' == $which) { |
|
| 213 | 213 | ?></div><!--/#woothemes-sensei--><?php |
| 214 | 214 | } // End If Statement |
| 215 | 215 | } // End wrapper_container() |
@@ -220,18 +220,18 @@ discard block |
||
| 220 | 220 | * @return void |
| 221 | 221 | */ |
| 222 | 222 | public function learners_default_nav() { |
| 223 | - $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 ) ); |
|
| 224 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 225 | - $course_id = intval( $_GET['course_id'] ); |
|
| 226 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) ); |
|
| 227 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 223 | + $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)); |
|
| 224 | + if (isset($_GET['course_id'])) { |
|
| 225 | + $course_id = intval($_GET['course_id']); |
|
| 226 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id, 'view' => 'learners'), admin_url('admin.php')); |
|
| 227 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 228 | 228 | } |
| 229 | - if ( isset( $_GET['lesson_id'] ) ) { |
|
| 230 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 231 | - $title .= ' <span class="lesson-title">> ' . get_the_title( intval( $lesson_id ) ) . '</span>'; |
|
| 229 | + if (isset($_GET['lesson_id'])) { |
|
| 230 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 231 | + $title .= ' <span class="lesson-title">> '.get_the_title(intval($lesson_id)).'</span>'; |
|
| 232 | 232 | } |
| 233 | 233 | ?> |
| 234 | - <h2><?php echo apply_filters( 'sensei_learners_nav_title', $title ); ?></h2> |
|
| 234 | + <h2><?php echo apply_filters('sensei_learners_nav_title', $title); ?></h2> |
|
| 235 | 235 | <?php |
| 236 | 236 | } // End learners_default_nav() |
| 237 | 237 | |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | // Parse POST data |
| 241 | 241 | $data = $_POST['data']; |
| 242 | 242 | $course_data = array(); |
| 243 | - parse_str( $data, $course_data ); |
|
| 243 | + parse_str($data, $course_data); |
|
| 244 | 244 | |
| 245 | - $course_cat = intval( $course_data['course_cat'] ); |
|
| 245 | + $course_cat = intval($course_data['course_cat']); |
|
| 246 | 246 | |
| 247 | - $redirect_url = apply_filters( 'sensei_ajax_redirect_url', add_query_arg( array( 'page' => $this->page_slug, 'course_cat' => $course_cat ), admin_url( 'admin.php' ) ) ); |
|
| 247 | + $redirect_url = apply_filters('sensei_ajax_redirect_url', add_query_arg(array('page' => $this->page_slug, 'course_cat' => $course_cat), admin_url('admin.php'))); |
|
| 248 | 248 | |
| 249 | - echo esc_url_raw( $redirect_url ); |
|
| 249 | + echo esc_url_raw($redirect_url); |
|
| 250 | 250 | die(); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -257,38 +257,38 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | // Security check |
| 259 | 259 | $nonce = ''; |
| 260 | - if ( isset($_POST['remove_user_from_post_nonce']) ) { |
|
| 261 | - $nonce = esc_html( $_POST['remove_user_from_post_nonce'] ); |
|
| 260 | + if (isset($_POST['remove_user_from_post_nonce'])) { |
|
| 261 | + $nonce = esc_html($_POST['remove_user_from_post_nonce']); |
|
| 262 | 262 | } |
| 263 | - if ( ! wp_verify_nonce( $nonce, 'remove_user_from_post_nonce' ) ) { |
|
| 264 | - die( $return ); |
|
| 263 | + if ( ! wp_verify_nonce($nonce, 'remove_user_from_post_nonce')) { |
|
| 264 | + die($return); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Parse POST data |
| 268 | 268 | $data = $_POST['data']; |
| 269 | 269 | $action_data = array(); |
| 270 | - parse_str( $data, $action_data ); |
|
| 270 | + parse_str($data, $action_data); |
|
| 271 | 271 | |
| 272 | - if( $action_data['user_id'] && $action_data['post_id'] && $action_data['post_type'] ) { |
|
| 272 | + if ($action_data['user_id'] && $action_data['post_id'] && $action_data['post_type']) { |
|
| 273 | 273 | |
| 274 | - $user_id = intval( $action_data['user_id'] ); |
|
| 275 | - $post_id = intval( $action_data['post_id'] ); |
|
| 276 | - $post_type = sanitize_text_field( $action_data['post_type'] ); |
|
| 277 | - $order_id = sanitize_text_field( $action_data['order_id'] ); |
|
| 274 | + $user_id = intval($action_data['user_id']); |
|
| 275 | + $post_id = intval($action_data['post_id']); |
|
| 276 | + $post_type = sanitize_text_field($action_data['post_type']); |
|
| 277 | + $order_id = sanitize_text_field($action_data['order_id']); |
|
| 278 | 278 | |
| 279 | - $user = get_userdata( $user_id ); |
|
| 279 | + $user = get_userdata($user_id); |
|
| 280 | 280 | |
| 281 | - switch( $post_type ) { |
|
| 281 | + switch ($post_type) { |
|
| 282 | 282 | |
| 283 | 283 | case 'course': |
| 284 | - $removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id ); |
|
| 284 | + $removed = Sensei_Utils::sensei_remove_user_from_course($post_id, $user_id); |
|
| 285 | 285 | |
| 286 | - if( ! empty( $order_id ) && Sensei_WC::is_woocommerce_active() ){ |
|
| 286 | + if ( ! empty($order_id) && Sensei_WC::is_woocommerce_active()) { |
|
| 287 | 287 | |
| 288 | 288 | $order = new WC_Order($order_id); |
| 289 | 289 | |
| 290 | - if (!empty($order)) { |
|
| 291 | - $order->update_status( 'cancelled' ); |
|
| 290 | + if ( ! empty($order)) { |
|
| 291 | + $order->update_status('cancelled'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | } |
@@ -296,126 +296,126 @@ discard block |
||
| 296 | 296 | break; |
| 297 | 297 | |
| 298 | 298 | case 'lesson': |
| 299 | - $removed = Sensei_Utils::sensei_remove_user_from_lesson( $post_id, $user_id ); |
|
| 299 | + $removed = Sensei_Utils::sensei_remove_user_from_lesson($post_id, $user_id); |
|
| 300 | 300 | break; |
| 301 | 301 | |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if( $removed ) { |
|
| 304 | + if ($removed) { |
|
| 305 | 305 | $return = 'removed'; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - die( $return ); |
|
| 310 | + die($return); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | public function json_search_users() { |
| 314 | 314 | |
| 315 | 315 | |
| 316 | - check_ajax_referer( 'search-users', 'security' ); |
|
| 316 | + check_ajax_referer('search-users', 'security'); |
|
| 317 | 317 | |
| 318 | - $term = sanitize_text_field( stripslashes( $_GET['term'] ) ); |
|
| 318 | + $term = sanitize_text_field(stripslashes($_GET['term'])); |
|
| 319 | 319 | |
| 320 | - if ( empty( $term ) ) { |
|
| 320 | + if (empty($term)) { |
|
| 321 | 321 | die(); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $default = isset( $_GET['default'] ) ? $_GET['default'] : __( 'None', 'woocommerce' ); |
|
| 324 | + $default = isset($_GET['default']) ? $_GET['default'] : __('None', 'woocommerce'); |
|
| 325 | 325 | |
| 326 | - $found_users = array( '' => $default ); |
|
| 326 | + $found_users = array('' => $default); |
|
| 327 | 327 | |
| 328 | - $users_query = new WP_User_Query( apply_filters( 'sensei_json_search_users_query', array( |
|
| 328 | + $users_query = new WP_User_Query(apply_filters('sensei_json_search_users_query', array( |
|
| 329 | 329 | 'fields' => 'all', |
| 330 | 330 | 'orderby' => 'display_name', |
| 331 | - 'search' => '*' . $term . '*', |
|
| 332 | - 'search_columns' => array( 'ID', 'user_login', 'user_email', 'user_nicename','user_firstname','user_lastname' ) |
|
| 333 | - ), $term ) ); |
|
| 331 | + 'search' => '*'.$term.'*', |
|
| 332 | + 'search_columns' => array('ID', 'user_login', 'user_email', 'user_nicename', 'user_firstname', 'user_lastname') |
|
| 333 | + ), $term)); |
|
| 334 | 334 | |
| 335 | 335 | $users = $users_query->get_results(); |
| 336 | 336 | |
| 337 | - if ( $users ) { |
|
| 338 | - foreach ( $users as $user ) { |
|
| 339 | - $full_name = Sensei_Student::get_full_name( $user->ID ); |
|
| 337 | + if ($users) { |
|
| 338 | + foreach ($users as $user) { |
|
| 339 | + $full_name = Sensei_Student::get_full_name($user->ID); |
|
| 340 | 340 | |
| 341 | - if( trim($user->display_name ) == trim( $full_name ) ){ |
|
| 341 | + if (trim($user->display_name) == trim($full_name)) { |
|
| 342 | 342 | |
| 343 | 343 | $name = $full_name; |
| 344 | 344 | |
| 345 | - }else{ |
|
| 345 | + } else { |
|
| 346 | 346 | |
| 347 | - $name = $full_name . ' ['. $user->display_name .']'; |
|
| 347 | + $name = $full_name.' ['.$user->display_name.']'; |
|
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - $found_users[ $user->ID ] = $name . ' (#' . $user->ID . ' – ' . sanitize_email( $user->user_email ) . ')'; |
|
| 351 | + $found_users[$user->ID] = $name.' (#'.$user->ID.' – '.sanitize_email($user->user_email).')'; |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - wp_send_json( $found_users ); |
|
| 355 | + wp_send_json($found_users); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | public function add_new_learners() { |
| 359 | 359 | |
| 360 | 360 | $result = false; |
| 361 | 361 | |
| 362 | - if( ! isset( $_POST['add_learner_submit'] ) ) return $result; |
|
| 362 | + if ( ! isset($_POST['add_learner_submit'])) return $result; |
|
| 363 | 363 | |
| 364 | - if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) return $result; |
|
| 364 | + if ( ! isset($_POST['add_learner_nonce']) || ! wp_verify_nonce($_POST['add_learner_nonce'], 'add_learner_to_sensei')) return $result; |
|
| 365 | 365 | |
| 366 | - if( ( ! isset( $_POST['add_user_id'] ) || '' == $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) return $result; |
|
| 366 | + if (( ! isset($_POST['add_user_id']) || '' == $_POST['add_user_id']) || ! isset($_POST['add_post_type']) || ! isset($_POST['add_course_id']) || ! isset($_POST['add_lesson_id'])) return $result; |
|
| 367 | 367 | |
| 368 | 368 | $post_type = $_POST['add_post_type']; |
| 369 | - $user_id = absint( $_POST['add_user_id'] ); |
|
| 370 | - $course_id = absint( $_POST['add_course_id'] ); |
|
| 369 | + $user_id = absint($_POST['add_user_id']); |
|
| 370 | + $course_id = absint($_POST['add_course_id']); |
|
| 371 | 371 | |
| 372 | - switch( $post_type ) { |
|
| 372 | + switch ($post_type) { |
|
| 373 | 373 | case 'course': |
| 374 | 374 | |
| 375 | - $result = Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
| 375 | + $result = Sensei_Utils::user_start_course($user_id, $course_id); |
|
| 376 | 376 | |
| 377 | 377 | // Complete each lesson if course is set to be completed |
| 378 | - if( isset( $_POST['add_complete_course'] ) && 'yes' == $_POST['add_complete_course'] ) { |
|
| 378 | + if (isset($_POST['add_complete_course']) && 'yes' == $_POST['add_complete_course']) { |
|
| 379 | 379 | |
| 380 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); |
|
| 380 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); |
|
| 381 | 381 | |
| 382 | - foreach( $lesson_ids as $id ) { |
|
| 383 | - Sensei_Utils::sensei_start_lesson( $id, $user_id, true ); |
|
| 382 | + foreach ($lesson_ids as $id) { |
|
| 383 | + Sensei_Utils::sensei_start_lesson($id, $user_id, true); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // Updates the Course status and it's meta data |
| 387 | - Sensei_Utils::user_complete_course( $course_id, $user_id ); |
|
| 387 | + Sensei_Utils::user_complete_course($course_id, $user_id); |
|
| 388 | 388 | |
| 389 | - do_action( 'sensei_user_course_end', $user_id, $course_id ); |
|
| 389 | + do_action('sensei_user_course_end', $user_id, $course_id); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | break; |
| 393 | 393 | |
| 394 | 394 | case 'lesson': |
| 395 | - $lesson_id = absint( $_POST['add_lesson_id'] ); |
|
| 395 | + $lesson_id = absint($_POST['add_lesson_id']); |
|
| 396 | 396 | $complete = false; |
| 397 | - if( isset( $_POST['add_complete_lesson'] ) && 'yes' == $_POST['add_complete_lesson'] ) { |
|
| 397 | + if (isset($_POST['add_complete_lesson']) && 'yes' == $_POST['add_complete_lesson']) { |
|
| 398 | 398 | $complete = true; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $result = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id, $complete ); |
|
| 401 | + $result = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id, $complete); |
|
| 402 | 402 | |
| 403 | 403 | // Updates the Course status and it's meta data |
| 404 | - Sensei_Utils::user_complete_course( $course_id, $user_id ); |
|
| 404 | + Sensei_Utils::user_complete_course($course_id, $user_id); |
|
| 405 | 405 | |
| 406 | 406 | break; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | // Set redirect URL after adding user to course/lesson |
| 410 | - $query_args = array( 'page' => $this->page_slug, 'view' => 'learners' ); |
|
| 410 | + $query_args = array('page' => $this->page_slug, 'view' => 'learners'); |
|
| 411 | 411 | |
| 412 | - if( $result ) { |
|
| 412 | + if ($result) { |
|
| 413 | 413 | |
| 414 | - if( $course_id ) { |
|
| 414 | + if ($course_id) { |
|
| 415 | 415 | $query_args['course_id'] = $course_id; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if( $lesson_id ) { |
|
| 418 | + if ($lesson_id) { |
|
| 419 | 419 | $query_args['lesson_id'] = $lesson_id; |
| 420 | 420 | } |
| 421 | 421 | |
@@ -425,23 +425,23 @@ discard block |
||
| 425 | 425 | $query_args['message'] = 'error'; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - $redirect_url = apply_filters( 'sensei_learners_add_learner_redirect_url', add_query_arg( $query_args, admin_url( 'admin.php' ) ) ); |
|
| 428 | + $redirect_url = apply_filters('sensei_learners_add_learner_redirect_url', add_query_arg($query_args, admin_url('admin.php'))); |
|
| 429 | 429 | |
| 430 | - wp_safe_redirect( esc_url_raw( $redirect_url ) ); |
|
| 430 | + wp_safe_redirect(esc_url_raw($redirect_url)); |
|
| 431 | 431 | exit; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | public function add_learner_notices() { |
| 435 | - if( isset( $_GET['page'] ) && $this->page_slug == $_GET['page'] && isset( $_GET['message'] ) && $_GET['message'] ) { |
|
| 436 | - if( 'success' == $_GET['message'] ) { |
|
| 435 | + if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) { |
|
| 436 | + if ('success' == $_GET['message']) { |
|
| 437 | 437 | $msg = array( |
| 438 | 438 | 'updated', |
| 439 | - __( 'Learner added successfully!', 'woothemes-sensei' ), |
|
| 439 | + __('Learner added successfully!', 'woothemes-sensei'), |
|
| 440 | 440 | ); |
| 441 | 441 | } else { |
| 442 | 442 | $msg = array( |
| 443 | 443 | 'error', |
| 444 | - __( 'Error adding learner.', 'woothemes-sensei' ), |
|
| 444 | + __('Error adding learner.', 'woothemes-sensei'), |
|
| 445 | 445 | ); |
| 446 | 446 | } |
| 447 | 447 | ?> |
@@ -464,9 +464,9 @@ discard block |
||
| 464 | 464 | * |
| 465 | 465 | * @return string $full_name |
| 466 | 466 | */ |
| 467 | - public function get_learner_full_name( $user_id ){ |
|
| 467 | + public function get_learner_full_name($user_id) { |
|
| 468 | 468 | |
| 469 | - return Sensei_Student::get_full_name( $user_id ); |
|
| 469 | + return Sensei_Student::get_full_name($user_id); |
|
| 470 | 470 | |
| 471 | 471 | } // end get_learner_full_name |
| 472 | 472 | |
@@ -477,4 +477,4 @@ discard block |
||
| 477 | 477 | * for backward compatibility |
| 478 | 478 | * @since 1.9.0 |
| 479 | 479 | */ |
| 480 | -class WooThemes_Sensei_Learners extends Sensei_Learner_Management{} |
|
| 480 | +class WooThemes_Sensei_Learners extends Sensei_Learner_Management {} |
|
@@ -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 Learner Profiles Class |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | * Constructor. |
| 23 | 23 | * @since 1.4.0 |
| 24 | 24 | */ |
| 25 | - public function __construct () { |
|
| 25 | + public function __construct() { |
|
| 26 | 26 | |
| 27 | 27 | // Setup learner profile URL base |
| 28 | - $this->profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
|
| 28 | + $this->profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei')); |
|
| 29 | 29 | |
| 30 | 30 | // Setup permalink structure for learner profiles |
| 31 | - add_action( 'init', array( $this, 'setup_permastruct' ) ); |
|
| 32 | - add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 ); |
|
| 31 | + add_action('init', array($this, 'setup_permastruct')); |
|
| 32 | + add_filter('wp_title', array($this, 'page_title'), 10, 2); |
|
| 33 | 33 | |
| 34 | 34 | // Set heading for courses section of learner profiles |
| 35 | - add_action( 'sensei_learner_profile_info', array( $this, 'learner_profile_courses_heading' ), 30, 1 ); |
|
| 35 | + add_action('sensei_learner_profile_info', array($this, 'learner_profile_courses_heading'), 30, 1); |
|
| 36 | 36 | |
| 37 | 37 | // Add class to body tag |
| 38 | - add_filter( 'body_class', array( $this, 'learner_profile_body_class' ), 10, 1 ); |
|
| 38 | + add_filter('body_class', array($this, 'learner_profile_body_class'), 10, 1); |
|
| 39 | 39 | } // End __construct() |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | public function setup_permastruct() { |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) { |
|
| 50 | - add_rewrite_rule( '^' . $this->profile_url_base . '/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top' ); |
|
| 51 | - add_rewrite_tag( '%learner_profile%', '([^&]+)' ); |
|
| 49 | + if (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable']) { |
|
| 50 | + add_rewrite_rule('^'.$this->profile_url_base.'/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top'); |
|
| 51 | + add_rewrite_tag('%learner_profile%', '([^&]+)'); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | * @param string $sep Seeparator string |
| 59 | 59 | * @return string Modified title |
| 60 | 60 | */ |
| 61 | - public function page_title( $title, $sep = null ) { |
|
| 61 | + public function page_title($title, $sep = null) { |
|
| 62 | 62 | global $wp_query; |
| 63 | - if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 64 | - $learner_user = get_user_by( 'login', $wp_query->query_vars['learner_profile'] ); |
|
| 63 | + if (isset($wp_query->query_vars['learner_profile'])) { |
|
| 64 | + $learner_user = get_user_by('login', $wp_query->query_vars['learner_profile']); |
|
| 65 | 65 | |
| 66 | - $name = Sensei_Student::get_full_name( $learner_user->ID ); |
|
| 66 | + $name = Sensei_Student::get_full_name($learner_user->ID); |
|
| 67 | 67 | |
| 68 | - $title = apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . ' ' . $sep . ' '; |
|
| 68 | + $title = apply_filters('sensei_learner_profile_courses_heading', sprintf(__('Courses %s is taking', 'woothemes-sensei'), $name)).' '.$sep.' '; |
|
| 69 | 69 | } |
| 70 | 70 | return $title; |
| 71 | 71 | } |
@@ -76,23 +76,23 @@ discard block |
||
| 76 | 76 | * @param integer $user_id ID of user |
| 77 | 77 | * @return string The learner profile permalink |
| 78 | 78 | */ |
| 79 | - public function get_permalink( $user_id = 0 ) { |
|
| 79 | + public function get_permalink($user_id = 0) { |
|
| 80 | 80 | $user = false; |
| 81 | - if( $user_id == 0 ) { |
|
| 81 | + if ($user_id == 0) { |
|
| 82 | 82 | global $current_user; |
| 83 | 83 | wp_get_current_user(); |
| 84 | 84 | $user = $current_user; |
| 85 | 85 | } else { |
| 86 | - $user = get_userdata( $user_id ); |
|
| 86 | + $user = get_userdata($user_id); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $permalink = ''; |
| 90 | 90 | |
| 91 | - if( $user ) { |
|
| 92 | - if ( get_option('permalink_structure') ) { |
|
| 93 | - $permalink = trailingslashit( get_site_url() ) . $this->profile_url_base . '/' . $user->user_nicename; |
|
| 91 | + if ($user) { |
|
| 92 | + if (get_option('permalink_structure')) { |
|
| 93 | + $permalink = trailingslashit(get_site_url()).$this->profile_url_base.'/'.$user->user_nicename; |
|
| 94 | 94 | } else { |
| 95 | - $permalink = trailingslashit( get_site_url() ) . '?learner_profile=' . $user->user_nicename; |
|
| 95 | + $permalink = trailingslashit(get_site_url()).'?learner_profile='.$user->user_nicename; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | 107 | public function content() { |
| 108 | - global $wp_query, $learner_user, $current_user; |
|
| 108 | + global $wp_query, $learner_user, $current_user; |
|
| 109 | 109 | |
| 110 | - if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) { |
|
| 110 | + if (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable']) { |
|
| 111 | 111 | |
| 112 | - if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 112 | + if (isset($wp_query->query_vars['learner_profile'])) { |
|
| 113 | 113 | |
| 114 | - Sensei_Templates::get_template( 'learner-profile/learner-info.php' ); |
|
| 114 | + Sensei_Templates::get_template('learner-profile/learner-info.php'); |
|
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | * @param object $user Queried user object |
| 124 | 124 | * @return void |
| 125 | 125 | */ |
| 126 | - public function learner_profile_courses_heading( $user ) { |
|
| 127 | - if( strlen( $user->first_name ) > 0 ) { |
|
| 126 | + public function learner_profile_courses_heading($user) { |
|
| 127 | + if (strlen($user->first_name) > 0) { |
|
| 128 | 128 | $name = $user->first_name; |
| 129 | 129 | } else { |
| 130 | 130 | $name = $user->display_name; |
| 131 | 131 | } |
| 132 | - $name = apply_filters( 'sensei_learner_profile_courses_heading_name', $name ); |
|
| 133 | - echo '<h2>' . apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . '</h2>'; |
|
| 132 | + $name = apply_filters('sensei_learner_profile_courses_heading_name', $name); |
|
| 133 | + echo '<h2>'.apply_filters('sensei_learner_profile_courses_heading', sprintf(__('Courses %s is taking', 'woothemes-sensei'), $name)).'</h2>'; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | * @param object $user Queried user object |
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | - public static function user_info( $user ) { |
|
| 142 | + public static function user_info($user) { |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * This hooke fires inside the Sensei_Learner_Profiles::user_info function. |
| 146 | 146 | * just before the htmls is generated. |
| 147 | 147 | * @since 1.0.0 |
| 148 | 148 | */ |
| 149 | - do_action( 'sensei_learner_profile_info', $user ); |
|
| 149 | + do_action('sensei_learner_profile_info', $user); |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @param false|string `<img>` $user_avatar |
| 158 | 158 | */ |
| 159 | - $learner_avatar = apply_filters( 'sensei_learner_profile_info_avatar', get_avatar( $user->ID, 120 ), $user->ID ); |
|
| 159 | + $learner_avatar = apply_filters('sensei_learner_profile_info_avatar', get_avatar($user->ID, 120), $user->ID); |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param string $user_display_name |
| 167 | 167 | * @param string $user_id |
| 168 | 168 | */ |
| 169 | - $learner_name = apply_filters( 'sensei_learner_profile_info_name', $user->display_name, $user->ID ); |
|
| 169 | + $learner_name = apply_filters('sensei_learner_profile_info_name', $user->display_name, $user->ID); |
|
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param string $user_description |
| 179 | 179 | * @param string $user_id |
| 180 | 180 | */ |
| 181 | - $learner_bio = apply_filters( 'sensei_learner_profile_info_bio', $user->description, $user->ID ); |
|
| 181 | + $learner_bio = apply_filters('sensei_learner_profile_info_bio', $user->description, $user->ID); |
|
| 182 | 182 | ?> |
| 183 | 183 | |
| 184 | 184 | <div id="learner-info"> |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | <h2><?php echo $learner_name; ?></h2> |
| 191 | 191 | |
| 192 | - <div class="description"><?php echo wpautop( $learner_bio ); ?></div> |
|
| 192 | + <div class="description"><?php echo wpautop($learner_bio); ?></div> |
|
| 193 | 193 | |
| 194 | 194 | </div> |
| 195 | 195 | |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | * @param array $classes Existing classes |
| 204 | 204 | * @return array Modified classes |
| 205 | 205 | */ |
| 206 | - public function learner_profile_body_class( $classes ) { |
|
| 206 | + public function learner_profile_body_class($classes) { |
|
| 207 | 207 | global $wp_query; |
| 208 | - if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 208 | + if (isset($wp_query->query_vars['learner_profile'])) { |
|
| 209 | 209 | $classes[] = 'learner-profile'; |
| 210 | 210 | } |
| 211 | 211 | return $classes; |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @since 1.9.0 |
| 218 | 218 | */ |
| 219 | - public static function deprecate_sensei_learner_profile_content_hook(){ |
|
| 219 | + public static function deprecate_sensei_learner_profile_content_hook() { |
|
| 220 | 220 | |
| 221 | - sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' ); |
|
| 221 | + sensei_do_deprecated_action('sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before'); |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Analysis Lesson List Table Class |
@@ -22,18 +22,18 @@ discard block |
||
| 22 | 22 | * @since 1.2.0 |
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | - public function __construct ( $lesson_id = 0 ) { |
|
| 26 | - $this->lesson_id = intval( $lesson_id ); |
|
| 27 | - $this->course_id = intval( get_post_meta( $this->lesson_id, '_lesson_course', true ) ); |
|
| 25 | + public function __construct($lesson_id = 0) { |
|
| 26 | + $this->lesson_id = intval($lesson_id); |
|
| 27 | + $this->course_id = intval(get_post_meta($this->lesson_id, '_lesson_course', true)); |
|
| 28 | 28 | |
| 29 | 29 | // Load Parent token into constructor |
| 30 | - parent::__construct( 'analysis_lesson' ); |
|
| 30 | + parent::__construct('analysis_lesson'); |
|
| 31 | 31 | |
| 32 | 32 | // Actions |
| 33 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 34 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 33 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 34 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 35 | 35 | |
| 36 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 36 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 37 | 37 | } // End __construct() |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | function get_columns() { |
| 45 | 45 | $columns = array( |
| 46 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 47 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 48 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
| 49 | - 'status' => __( 'Status', 'woothemes-sensei' ), |
|
| 50 | - 'grade' => __( 'Grade', 'woothemes-sensei' ), |
|
| 46 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 47 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
| 48 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
| 49 | + 'status' => __('Status', 'woothemes-sensei'), |
|
| 50 | + 'grade' => __('Grade', 'woothemes-sensei'), |
|
| 51 | 51 | ); |
| 52 | - $columns = apply_filters( 'sensei_analysis_lesson_columns', $columns, $this ); |
|
| 52 | + $columns = apply_filters('sensei_analysis_lesson_columns', $columns, $this); |
|
| 53 | 53 | return $columns; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function get_sortable_columns() { |
| 62 | 62 | $columns = array( |
| 63 | - 'title' => array( 'title', false ), |
|
| 64 | - 'started' => array( 'started', false ), |
|
| 65 | - 'completed' => array( 'completed', false ), |
|
| 66 | - 'status' => array( 'status', false ), |
|
| 67 | - 'grade' => array( 'grade', false ), |
|
| 63 | + 'title' => array('title', false), |
|
| 64 | + 'started' => array('started', false), |
|
| 65 | + 'completed' => array('completed', false), |
|
| 66 | + 'status' => array('status', false), |
|
| 67 | + 'grade' => array('grade', false), |
|
| 68 | 68 | ); |
| 69 | - $columns = apply_filters( 'sensei_analysis_lesson_columns_sortable', $columns, $this ); |
|
| 69 | + $columns = apply_filters('sensei_analysis_lesson_columns_sortable', $columns, $this); |
|
| 70 | 70 | return $columns; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -80,32 +80,32 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | // Handle orderby (needs work) |
| 82 | 82 | $orderby = ''; |
| 83 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 84 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 85 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 83 | + if ( ! empty($_GET['orderby'])) { |
|
| 84 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 85 | + $orderby = esc_html($_GET['orderby']); |
|
| 86 | 86 | } // End If Statement |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Handle order |
| 90 | 90 | $order = 'ASC'; |
| 91 | - if ( !empty( $_GET['order'] ) ) { |
|
| 92 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 91 | + if ( ! empty($_GET['order'])) { |
|
| 92 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
| 96 | 96 | $search = false; |
| 97 | - if ( !empty( $_GET['s'] ) ) { |
|
| 98 | - $search = esc_html( $_GET['s'] ); |
|
| 97 | + if ( ! empty($_GET['s'])) { |
|
| 98 | + $search = esc_html($_GET['s']); |
|
| 99 | 99 | } // End If Statement |
| 100 | 100 | $this->search = $search; |
| 101 | 101 | |
| 102 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 103 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 102 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 103 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 104 | 104 | |
| 105 | 105 | $paged = $this->get_pagenum(); |
| 106 | 106 | $offset = 0; |
| 107 | - if ( !empty($paged) ) { |
|
| 108 | - $offset = $per_page * ( $paged - 1 ); |
|
| 107 | + if ( ! empty($paged)) { |
|
| 108 | + $offset = $per_page * ($paged - 1); |
|
| 109 | 109 | } // End If Statement |
| 110 | 110 | |
| 111 | 111 | $args = array( |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | 'orderby' => $orderby, |
| 115 | 115 | 'order' => $order, |
| 116 | 116 | ); |
| 117 | - if ( $this->search ) { |
|
| 117 | + if ($this->search) { |
|
| 118 | 118 | $args['search'] = $this->search; |
| 119 | 119 | } // End If Statement |
| 120 | 120 | |
| 121 | - $this->items = $this->get_lesson_statuses( $args ); |
|
| 121 | + $this->items = $this->get_lesson_statuses($args); |
|
| 122 | 122 | |
| 123 | 123 | $total_items = $this->total_items; |
| 124 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 125 | - $this->set_pagination_args( array( |
|
| 124 | + $total_pages = ceil($total_items / $per_page); |
|
| 125 | + $this->set_pagination_args(array( |
|
| 126 | 126 | 'total_items' => $total_items, |
| 127 | 127 | 'total_pages' => $total_pages, |
| 128 | 128 | 'per_page' => $per_page |
| 129 | - ) ); |
|
| 129 | + )); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @since 1.7.0 |
| 135 | 135 | * @return data |
| 136 | 136 | */ |
| 137 | - public function generate_report( $report ) { |
|
| 137 | + public function generate_report($report) { |
|
| 138 | 138 | |
| 139 | 139 | $data = array(); |
| 140 | 140 | |
@@ -142,22 +142,22 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | // Handle orderby |
| 144 | 144 | $orderby = ''; |
| 145 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 146 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 147 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 145 | + if ( ! empty($_GET['orderby'])) { |
|
| 146 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 147 | + $orderby = esc_html($_GET['orderby']); |
|
| 148 | 148 | } // End If Statement |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Handle order |
| 152 | 152 | $order = 'ASC'; |
| 153 | - if ( !empty( $_GET['order'] ) ) { |
|
| 154 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 153 | + if ( ! empty($_GET['order'])) { |
|
| 154 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Handle search |
| 158 | 158 | $search = false; |
| 159 | - if ( !empty( $_GET['s'] ) ) { |
|
| 160 | - $search = esc_html( $_GET['s'] ); |
|
| 159 | + if ( ! empty($_GET['s'])) { |
|
| 160 | + $search = esc_html($_GET['s']); |
|
| 161 | 161 | } // End If Statement |
| 162 | 162 | $this->search = $search; |
| 163 | 163 | |
@@ -165,23 +165,23 @@ discard block |
||
| 165 | 165 | 'orderby' => $orderby, |
| 166 | 166 | 'order' => $order, |
| 167 | 167 | ); |
| 168 | - if ( $this->search ) { |
|
| 168 | + if ($this->search) { |
|
| 169 | 169 | $args['search'] = $this->search; |
| 170 | 170 | } // End If Statement |
| 171 | 171 | |
| 172 | 172 | // Start the csv with the column headings |
| 173 | 173 | $column_headers = array(); |
| 174 | 174 | $columns = $this->get_columns(); |
| 175 | - foreach( $columns AS $key => $title ) { |
|
| 175 | + foreach ($columns AS $key => $title) { |
|
| 176 | 176 | $column_headers[] = $title; |
| 177 | 177 | } |
| 178 | 178 | $data[] = $column_headers; |
| 179 | 179 | |
| 180 | - $this->items = $this->get_lesson_statuses( $args ); |
|
| 180 | + $this->items = $this->get_lesson_statuses($args); |
|
| 181 | 181 | |
| 182 | 182 | // Process each row |
| 183 | - foreach( $this->items AS $item) { |
|
| 184 | - $data[] = $this->get_row_data( $item ); |
|
| 183 | + foreach ($this->items AS $item) { |
|
| 184 | + $data[] = $this->get_row_data($item); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | return $data; |
@@ -193,64 +193,64 @@ discard block |
||
| 193 | 193 | * @since 1.7.0 |
| 194 | 194 | * @param object $item The current item |
| 195 | 195 | */ |
| 196 | - protected function get_row_data( $item ) { |
|
| 196 | + protected function get_row_data($item) { |
|
| 197 | 197 | |
| 198 | - $user_start_date = get_comment_meta( $item->comment_ID, 'start', true ); |
|
| 198 | + $user_start_date = get_comment_meta($item->comment_ID, 'start', true); |
|
| 199 | 199 | $user_end_date = $item->comment_date; |
| 200 | 200 | $status_class = $grade = ''; |
| 201 | 201 | |
| 202 | - if( 'complete' == $item->comment_approved ) { |
|
| 203 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
| 202 | + if ('complete' == $item->comment_approved) { |
|
| 203 | + $status = __('Completed', 'woothemes-sensei'); |
|
| 204 | 204 | $status_class = 'graded'; |
| 205 | 205 | |
| 206 | - $grade = __( 'No Grade', 'woothemes-sensei' ); |
|
| 206 | + $grade = __('No Grade', 'woothemes-sensei'); |
|
| 207 | 207 | } |
| 208 | - elseif( 'graded' == $item->comment_approved ) { |
|
| 209 | - $status = __( 'Graded', 'woothemes-sensei' ) ; |
|
| 208 | + elseif ('graded' == $item->comment_approved) { |
|
| 209 | + $status = __('Graded', 'woothemes-sensei'); |
|
| 210 | 210 | $status_class = 'graded'; |
| 211 | 211 | |
| 212 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
| 212 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
| 213 | 213 | } |
| 214 | - elseif( 'passed' == $item->comment_approved ) { |
|
| 215 | - $status = __( 'Passed', 'woothemes-sensei' ); |
|
| 214 | + elseif ('passed' == $item->comment_approved) { |
|
| 215 | + $status = __('Passed', 'woothemes-sensei'); |
|
| 216 | 216 | $status_class = 'graded'; |
| 217 | 217 | |
| 218 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
| 218 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
| 219 | 219 | } |
| 220 | - elseif( 'failed' == $item->comment_approved ) { |
|
| 221 | - $status = __( 'Failed', 'woothemes-sensei' ); |
|
| 220 | + elseif ('failed' == $item->comment_approved) { |
|
| 221 | + $status = __('Failed', 'woothemes-sensei'); |
|
| 222 | 222 | $status_class = 'failed'; |
| 223 | 223 | |
| 224 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
| 224 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
| 225 | 225 | } |
| 226 | - elseif( 'ungraded' == $item->comment_approved ) { |
|
| 227 | - $status = __( 'Ungraded', 'woothemes-sensei' ); |
|
| 226 | + elseif ('ungraded' == $item->comment_approved) { |
|
| 227 | + $status = __('Ungraded', 'woothemes-sensei'); |
|
| 228 | 228 | $status_class = 'ungraded'; |
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | else { |
| 232 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
| 232 | + $status = __('In Progress', 'woothemes-sensei'); |
|
| 233 | 233 | $user_end_date = ''; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Output users data |
| 237 | - $user_name = Sensei_Student::get_full_name( $item->user_id ); |
|
| 237 | + $user_name = Sensei_Student::get_full_name($item->user_id); |
|
| 238 | 238 | |
| 239 | - if ( !$this->csv_output ) { |
|
| 240 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ); |
|
| 239 | + if ( ! $this->csv_output) { |
|
| 240 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php')); |
|
| 241 | 241 | |
| 242 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>'; |
|
| 243 | - $status = sprintf( '<span class="%s">%s</span>', $item->comment_approved, $status ); |
|
| 244 | - if ( is_numeric($grade) ) { |
|
| 242 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>'; |
|
| 243 | + $status = sprintf('<span class="%s">%s</span>', $item->comment_approved, $status); |
|
| 244 | + if (is_numeric($grade)) { |
|
| 245 | 245 | $grade .= '%'; |
| 246 | 246 | } |
| 247 | 247 | } // End If Statement |
| 248 | - $column_data = apply_filters( 'sensei_analysis_lesson_column_data', array( 'title' => $user_name, |
|
| 248 | + $column_data = apply_filters('sensei_analysis_lesson_column_data', array('title' => $user_name, |
|
| 249 | 249 | 'started' => $user_start_date, |
| 250 | 250 | 'completed' => $user_end_date, |
| 251 | 251 | 'status' => $status, |
| 252 | 252 | 'grade' => $grade, |
| 253 | - ), $item, $this ); |
|
| 253 | + ), $item, $this); |
|
| 254 | 254 | |
| 255 | 255 | return $column_data; |
| 256 | 256 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @since 1.7.0 |
| 261 | 261 | * @return array statuses |
| 262 | 262 | */ |
| 263 | - private function get_lesson_statuses( $args ) { |
|
| 263 | + private function get_lesson_statuses($args) { |
|
| 264 | 264 | |
| 265 | 265 | $activity_args = array( |
| 266 | 266 | 'post_id' => $this->lesson_id, |
@@ -273,34 +273,34 @@ discard block |
||
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | 275 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
| 276 | - if ( $this->search ) { |
|
| 276 | + if ($this->search) { |
|
| 277 | 277 | $user_args = array( |
| 278 | - 'search' => '*' . $this->search . '*', |
|
| 278 | + 'search' => '*'.$this->search.'*', |
|
| 279 | 279 | 'fields' => 'ID', |
| 280 | 280 | ); |
| 281 | 281 | // Filter for extending |
| 282 | - $user_args = apply_filters( 'sensei_analysis_lesson_search_users', $user_args ); |
|
| 283 | - if ( !empty( $user_args ) ) { |
|
| 284 | - $learners_search = new WP_User_Query( $user_args ); |
|
| 282 | + $user_args = apply_filters('sensei_analysis_lesson_search_users', $user_args); |
|
| 283 | + if ( ! empty($user_args)) { |
|
| 284 | + $learners_search = new WP_User_Query($user_args); |
|
| 285 | 285 | // Store for reuse on counts |
| 286 | 286 | $activity_args['user_id'] = (array) $learners_search->get_results(); |
| 287 | 287 | } |
| 288 | 288 | } // End If Statement |
| 289 | 289 | |
| 290 | - $activity_args = apply_filters( 'sensei_analysis_lesson_filter_statuses', $activity_args ); |
|
| 290 | + $activity_args = apply_filters('sensei_analysis_lesson_filter_statuses', $activity_args); |
|
| 291 | 291 | |
| 292 | 292 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
| 293 | - $this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
| 293 | + $this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
| 294 | 294 | |
| 295 | 295 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
| 296 | - if ( $this->total_items < $activity_args['offset'] ) { |
|
| 297 | - $new_paged = floor( $total_statuses / $activity_args['number'] ); |
|
| 296 | + if ($this->total_items < $activity_args['offset']) { |
|
| 297 | + $new_paged = floor($total_statuses / $activity_args['number']); |
|
| 298 | 298 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
| 299 | 299 | } |
| 300 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
| 300 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
| 301 | 301 | // Need to always return an array, even with only 1 item |
| 302 | - if ( !is_array($statuses) ) { |
|
| 303 | - $statuses = array( $statuses ); |
|
| 302 | + if ( ! is_array($statuses)) { |
|
| 303 | + $statuses = array($statuses); |
|
| 304 | 304 | } |
| 305 | 305 | return $statuses; |
| 306 | 306 | } // End get_lesson_statuses() |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | 314 | public function no_items() { |
| 315 | - _e( 'No learners found.', 'woothemes-sensei' ); |
|
| 315 | + _e('No learners found.', 'woothemes-sensei'); |
|
| 316 | 316 | } // End no_items() |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return void |
| 322 | 322 | */ |
| 323 | 323 | public function data_table_header() { |
| 324 | - echo '<strong>' . __( 'Learners taking this Lesson', 'woothemes-sensei' ) . '</strong>'; |
|
| 324 | + echo '<strong>'.__('Learners taking this Lesson', 'woothemes-sensei').'</strong>'; |
|
| 325 | 325 | } // End data_table_header() |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | * @return void |
| 331 | 331 | */ |
| 332 | 332 | public function data_table_footer() { |
| 333 | - $lesson = get_post( $this->lesson_id ); |
|
| 334 | - $report = sanitize_title( $lesson->post_title ) . '-learners-overview'; |
|
| 335 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
| 336 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
| 333 | + $lesson = get_post($this->lesson_id); |
|
| 334 | + $report = sanitize_title($lesson->post_title).'-learners-overview'; |
|
| 335 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
| 336 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
| 337 | 337 | } // End data_table_footer() |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | * @since 1.7.0 |
| 342 | 342 | * @return void |
| 343 | 343 | */ |
| 344 | - public function search_button( $text = '' ) { |
|
| 345 | - return __( 'Search Learners', 'woothemes-sensei' );; |
|
| 344 | + public function search_button($text = '') { |
|
| 345 | + return __('Search Learners', 'woothemes-sensei'); ; |
|
| 346 | 346 | } |
| 347 | 347 | } // End Class |
| 348 | 348 | |
@@ -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 Course Class |
@@ -33,72 +33,72 @@ discard block |
||
| 33 | 33 | * Constructor. |
| 34 | 34 | * @since 1.0.0 |
| 35 | 35 | */ |
| 36 | - public function __construct () { |
|
| 36 | + public function __construct() { |
|
| 37 | 37 | |
| 38 | 38 | $this->token = 'course'; |
| 39 | 39 | |
| 40 | 40 | // Setup meta fields for this post type |
| 41 | - $this->meta_fields = array( 'course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product' ); |
|
| 41 | + $this->meta_fields = array('course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product'); |
|
| 42 | 42 | // Admin actions |
| 43 | - if ( is_admin() ) { |
|
| 43 | + if (is_admin()) { |
|
| 44 | 44 | // Metabox functions |
| 45 | - add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 ); |
|
| 46 | - add_action( 'save_post', array( $this, 'meta_box_save' ) ); |
|
| 45 | + add_action('add_meta_boxes', array($this, 'meta_box_setup'), 20); |
|
| 46 | + add_action('save_post', array($this, 'meta_box_save')); |
|
| 47 | 47 | // Custom Write Panel Columns |
| 48 | - add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 ); |
|
| 49 | - add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 ); |
|
| 48 | + add_filter('manage_edit-course_columns', array($this, 'add_column_headings'), 10, 1); |
|
| 49 | + add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2); |
|
| 50 | 50 | } else { |
| 51 | 51 | $this->my_courses_page = false; |
| 52 | 52 | } // End If Statement |
| 53 | 53 | |
| 54 | 54 | // Update course completion upon completion of a lesson |
| 55 | - add_action( 'sensei_user_lesson_end', array( $this, 'update_status_after_lesson_change' ), 10, 2 ); |
|
| 55 | + add_action('sensei_user_lesson_end', array($this, 'update_status_after_lesson_change'), 10, 2); |
|
| 56 | 56 | // Update course completion upon reset of a lesson |
| 57 | - add_action( 'sensei_user_lesson_reset', array( $this, 'update_status_after_lesson_change' ), 10, 2 ); |
|
| 57 | + add_action('sensei_user_lesson_reset', array($this, 'update_status_after_lesson_change'), 10, 2); |
|
| 58 | 58 | // Update course completion upon grading of a quiz |
| 59 | - add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 ); |
|
| 59 | + add_action('sensei_user_quiz_grade', array($this, 'update_status_after_quiz_submission'), 10, 2); |
|
| 60 | 60 | |
| 61 | 61 | // show the progress bar ont he single course page |
| 62 | - add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 ); |
|
| 63 | - add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 ); |
|
| 62 | + add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_statement'), 15); |
|
| 63 | + add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_meter'), 16); |
|
| 64 | 64 | |
| 65 | 65 | // provide an option to block all emails related to a selected course |
| 66 | - add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) ); |
|
| 67 | - add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) ); |
|
| 66 | + add_filter('sensei_send_emails', array($this, 'block_notification_emails')); |
|
| 67 | + add_action('save_post', array($this, 'save_course_notification_meta_box')); |
|
| 68 | 68 | |
| 69 | 69 | // preview lessons on the course content |
| 70 | - add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) ); |
|
| 70 | + add_action('sensei_course_content_inside_after', array($this, 'the_course_free_lesson_preview')); |
|
| 71 | 71 | |
| 72 | 72 | // the course meta |
| 73 | - add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) ); |
|
| 73 | + add_action('sensei_course_content_inside_before', array($this, 'the_course_meta')); |
|
| 74 | 74 | |
| 75 | 75 | // backwards compatible template hooks |
| 76 | - add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' )); |
|
| 77 | - add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) ); |
|
| 76 | + add_action('sensei_course_content_inside_before', array($this, 'content_before_backwards_compatibility_hooks')); |
|
| 77 | + add_action('sensei_loop_course_before', array($this, 'loop_before_backwards_compatibility_hooks')); |
|
| 78 | 78 | |
| 79 | 79 | // add the user status on the course to the markup as a class |
| 80 | - add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 ); |
|
| 80 | + add_filter('post_class', array(__CLASS__, 'add_course_user_status_class'), 20, 3); |
|
| 81 | 81 | |
| 82 | 82 | //filter the course query in Sensei specific instances |
| 83 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) ); |
|
| 83 | + add_filter('pre_get_posts', array(__CLASS__, 'course_query_filter')); |
|
| 84 | 84 | |
| 85 | 85 | //attache the sorting to the course archive |
| 86 | - add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) ); |
|
| 86 | + add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_sorting')); |
|
| 87 | 87 | |
| 88 | 88 | //attach the filter links to the course archive |
| 89 | - add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) ); |
|
| 89 | + add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_filters')); |
|
| 90 | 90 | |
| 91 | 91 | //filter the course query when featured filter is applied |
| 92 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_featured_filter')); |
|
| 92 | + add_filter('pre_get_posts', array(__CLASS__, 'course_archive_featured_filter')); |
|
| 93 | 93 | |
| 94 | 94 | // handle the order by title post submission |
| 95 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_order_by_title')); |
|
| 95 | + add_filter('pre_get_posts', array(__CLASS__, 'course_archive_order_by_title')); |
|
| 96 | 96 | |
| 97 | 97 | // ensure the course category page respects the manual order set for courses |
| 98 | - add_filter( 'pre_get_posts', array( __CLASS__, 'alter_course_category_order')); |
|
| 98 | + add_filter('pre_get_posts', array(__CLASS__, 'alter_course_category_order')); |
|
| 99 | 99 | |
| 100 | 100 | // flush rewrite rules when saving a course |
| 101 | - add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) ); |
|
| 101 | + add_action('save_post', array('Sensei_Course', 'flush_rewrite_rules')); |
|
| 102 | 102 | |
| 103 | 103 | } // End __construct() |
| 104 | 104 | |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | * @param type $user_id |
| 109 | 109 | * @param type $quiz_id |
| 110 | 110 | */ |
| 111 | - public function update_status_after_quiz_submission( $user_id, $quiz_id ) { |
|
| 112 | - if ( intval( $user_id ) > 0 && intval( $quiz_id ) > 0 ) { |
|
| 113 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 114 | - $this->update_status_after_lesson_change( $user_id, $lesson_id ); |
|
| 111 | + public function update_status_after_quiz_submission($user_id, $quiz_id) { |
|
| 112 | + if (intval($user_id) > 0 && intval($quiz_id) > 0) { |
|
| 113 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 114 | + $this->update_status_after_lesson_change($user_id, $lesson_id); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | * @param int $user_id |
| 122 | 122 | * @param int $lesson_id |
| 123 | 123 | */ |
| 124 | - public function update_status_after_lesson_change( $user_id, $lesson_id ) { |
|
| 125 | - if ( intval( $user_id ) > 0 && intval( $lesson_id ) > 0 ) { |
|
| 126 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 127 | - if ( intval( $course_id ) > 0 ) { |
|
| 124 | + public function update_status_after_lesson_change($user_id, $lesson_id) { |
|
| 125 | + if (intval($user_id) > 0 && intval($lesson_id) > 0) { |
|
| 126 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 127 | + if (intval($course_id) > 0) { |
|
| 128 | 128 | // Updates the Course status and it's meta data |
| 129 | - Sensei_Utils::user_complete_course( $course_id, $user_id ); |
|
| 129 | + Sensei_Utils::user_complete_course($course_id, $user_id); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -137,27 +137,27 @@ discard block |
||
| 137 | 137 | * @access public |
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | - public function meta_box_setup () { |
|
| 140 | + public function meta_box_setup() { |
|
| 141 | 141 | |
| 142 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 142 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 143 | 143 | // Add Meta Box for WooCommerce Course |
| 144 | - add_meta_box( 'course-wc-product', __( 'WooCommerce Product', 'woothemes-sensei' ), array( $this, 'course_woocommerce_product_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 144 | + add_meta_box('course-wc-product', __('WooCommerce Product', 'woothemes-sensei'), array($this, 'course_woocommerce_product_meta_box_content'), $this->token, 'side', 'default'); |
|
| 145 | 145 | } // End If Statement |
| 146 | 146 | // Add Meta Box for Prerequisite Course |
| 147 | - add_meta_box( 'course-prerequisite', __( 'Course Prerequisite', 'woothemes-sensei' ), array( $this, 'course_prerequisite_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 147 | + add_meta_box('course-prerequisite', __('Course Prerequisite', 'woothemes-sensei'), array($this, 'course_prerequisite_meta_box_content'), $this->token, 'side', 'default'); |
|
| 148 | 148 | // Add Meta Box for Featured Course |
| 149 | - add_meta_box( 'course-featured', __( 'Featured Course', 'woothemes-sensei' ), array( $this, 'course_featured_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 149 | + add_meta_box('course-featured', __('Featured Course', 'woothemes-sensei'), array($this, 'course_featured_meta_box_content'), $this->token, 'side', 'default'); |
|
| 150 | 150 | // Add Meta Box for Course Meta |
| 151 | - add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 151 | + add_meta_box('course-video', __('Course Video', 'woothemes-sensei'), array($this, 'course_video_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 152 | 152 | // Add Meta Box for Course Lessons |
| 153 | - add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 153 | + add_meta_box('course-lessons', __('Course Lessons', 'woothemes-sensei'), array($this, 'course_lessons_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 154 | 154 | // Add Meta Box to link to Manage Learners |
| 155 | - add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 155 | + add_meta_box('course-manage', __('Course Management', 'woothemes-sensei'), array($this, 'course_manage_meta_box_content'), $this->token, 'side', 'default'); |
|
| 156 | 156 | // Remove "Custom Settings" meta box. |
| 157 | - remove_meta_box( 'woothemes-settings', $this->token, 'normal' ); |
|
| 157 | + remove_meta_box('woothemes-settings', $this->token, 'normal'); |
|
| 158 | 158 | |
| 159 | 159 | // add Disable email notification box |
| 160 | - add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' ); |
|
| 160 | + add_meta_box('course-notifications', __('Course Notifications', 'woothemes-sensei'), array($this, 'course_notification_meta_box_content'), 'course', 'normal', 'default'); |
|
| 161 | 161 | |
| 162 | 162 | } // End meta_box_setup() |
| 163 | 163 | |
@@ -167,58 +167,58 @@ discard block |
||
| 167 | 167 | * @access public |
| 168 | 168 | * @return void |
| 169 | 169 | */ |
| 170 | - public function course_woocommerce_product_meta_box_content () { |
|
| 170 | + public function course_woocommerce_product_meta_box_content() { |
|
| 171 | 171 | global $post; |
| 172 | 172 | |
| 173 | - $select_course_woocommerce_product = get_post_meta( $post->ID, '_course_woocommerce_product', true ); |
|
| 173 | + $select_course_woocommerce_product = get_post_meta($post->ID, '_course_woocommerce_product', true); |
|
| 174 | 174 | |
| 175 | - $post_args = array( 'post_type' => array( 'product', 'product_variation' ), |
|
| 175 | + $post_args = array('post_type' => array('product', 'product_variation'), |
|
| 176 | 176 | 'posts_per_page' => -1, |
| 177 | 177 | 'orderby' => 'title', |
| 178 | 178 | 'order' => 'DESC', |
| 179 | 179 | 'exclude' => $post->ID, |
| 180 | - 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 180 | + 'post_status' => array('publish', 'private', 'draft'), |
|
| 181 | 181 | 'tax_query' => array( |
| 182 | 182 | array( |
| 183 | 183 | 'taxonomy' => 'product_type', |
| 184 | 184 | 'field' => 'slug', |
| 185 | - 'terms' => array( 'variable', 'grouped' ), |
|
| 185 | + 'terms' => array('variable', 'grouped'), |
|
| 186 | 186 | 'operator' => 'NOT IN' |
| 187 | 187 | ) |
| 188 | 188 | ), |
| 189 | 189 | 'suppress_filters' => 0 |
| 190 | 190 | ); |
| 191 | - $posts_array = get_posts( $post_args ); |
|
| 191 | + $posts_array = get_posts($post_args); |
|
| 192 | 192 | |
| 193 | 193 | $html = ''; |
| 194 | 194 | |
| 195 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 195 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 196 | 196 | |
| 197 | - if ( count( $posts_array ) > 0 ) { |
|
| 197 | + if (count($posts_array) > 0) { |
|
| 198 | 198 | |
| 199 | - $html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n"; |
|
| 200 | - $html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 199 | + $html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n"; |
|
| 200 | + $html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 201 | 201 | $prev_parent_id = 0; |
| 202 | - foreach ( $posts_array as $post_item ) { |
|
| 202 | + foreach ($posts_array as $post_item) { |
|
| 203 | 203 | |
| 204 | - if ( 'product_variation' == $post_item->post_type ) { |
|
| 204 | + if ('product_variation' == $post_item->post_type) { |
|
| 205 | 205 | |
| 206 | - $product_object = get_product( $post_item->ID ); |
|
| 207 | - $parent_id = wp_get_post_parent_id( $post_item->ID ); |
|
| 206 | + $product_object = get_product($post_item->ID); |
|
| 207 | + $parent_id = wp_get_post_parent_id($post_item->ID); |
|
| 208 | 208 | |
| 209 | - if( sensei_check_woocommerce_version( '2.1' ) ) { |
|
| 210 | - $formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true ); |
|
| 209 | + if (sensei_check_woocommerce_version('2.1')) { |
|
| 210 | + $formatted_variation = wc_get_formatted_variation($product_object->variation_data, true); |
|
| 211 | 211 | |
| 212 | 212 | } else { |
| 213 | 213 | // fall back to pre wc 2.1 |
| 214 | - $formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true ); |
|
| 214 | + $formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true); |
|
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $product_name = ucwords( $formatted_variation ); |
|
| 219 | - if( empty( $product_name ) ){ |
|
| 218 | + $product_name = ucwords($formatted_variation); |
|
| 219 | + if (empty($product_name)) { |
|
| 220 | 220 | |
| 221 | - $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id; |
|
| 221 | + $product_name = __('Variation #', 'woothemes-sensei').$product_object->variation_id; |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -231,47 +231,47 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Show variations in groups |
| 234 | - if( $parent_id && $parent_id != $prev_parent_id ) { |
|
| 234 | + if ($parent_id && $parent_id != $prev_parent_id) { |
|
| 235 | 235 | |
| 236 | - if( 0 != $prev_parent_id ) { |
|
| 236 | + if (0 != $prev_parent_id) { |
|
| 237 | 237 | |
| 238 | 238 | $html .= '</optgroup>'; |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | - $html .= '<optgroup label="' . get_the_title( $parent_id ) . '">'; |
|
| 241 | + $html .= '<optgroup label="'.get_the_title($parent_id).'">'; |
|
| 242 | 242 | $prev_parent_id = $parent_id; |
| 243 | 243 | |
| 244 | - } elseif( ! $parent_id && 0 == $prev_parent_id ) { |
|
| 244 | + } elseif ( ! $parent_id && 0 == $prev_parent_id) { |
|
| 245 | 245 | |
| 246 | 246 | $html .= '</optgroup>'; |
| 247 | 247 | |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_woocommerce_product, false ) . '>' . esc_html( $product_name ) . '</option>' . "\n"; |
|
| 250 | + $html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_woocommerce_product, false).'>'.esc_html($product_name).'</option>'."\n"; |
|
| 251 | 251 | |
| 252 | 252 | } // End For Loop |
| 253 | 253 | |
| 254 | - $html .= '</select>' . "\n"; |
|
| 255 | - if ( current_user_can( 'publish_product' )) { |
|
| 254 | + $html .= '</select>'."\n"; |
|
| 255 | + if (current_user_can('publish_product')) { |
|
| 256 | 256 | |
| 257 | - $html .= '<p>' . "\n"; |
|
| 258 | - $html .= '<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Add a Product', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 257 | + $html .= '<p>'."\n"; |
|
| 258 | + $html .= '<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Add a Product', 'woothemes-sensei').'</a>'."\n"; |
|
| 259 | 259 | $html .= '</p>'."\n"; |
| 260 | 260 | |
| 261 | 261 | } // End If Statement |
| 262 | 262 | |
| 263 | 263 | } else { |
| 264 | 264 | |
| 265 | - if ( current_user_can( 'publish_product' )) { |
|
| 265 | + if (current_user_can('publish_product')) { |
|
| 266 | 266 | |
| 267 | - $html .= '<p>' . "\n"; |
|
| 268 | - $html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . ' <a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Please add some first', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 267 | + $html .= '<p>'."\n"; |
|
| 268 | + $html .= esc_html(__('No products exist yet.', 'woothemes-sensei')).' <a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Please add some first', 'woothemes-sensei').'</a>'."\n"; |
|
| 269 | 269 | $html .= '</p>'."\n"; |
| 270 | 270 | |
| 271 | 271 | } else { |
| 272 | 272 | |
| 273 | - $html .= '<p>' . "\n"; |
|
| 274 | - $html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n"; |
|
| 273 | + $html .= '<p>'."\n"; |
|
| 274 | + $html .= esc_html(__('No products exist yet.', 'woothemes-sensei'))."\n"; |
|
| 275 | 275 | $html .= '</p>'."\n"; |
| 276 | 276 | |
| 277 | 277 | } // End If Statement |
@@ -288,33 +288,33 @@ discard block |
||
| 288 | 288 | * @access public |
| 289 | 289 | * @return void |
| 290 | 290 | */ |
| 291 | - public function course_prerequisite_meta_box_content () { |
|
| 291 | + public function course_prerequisite_meta_box_content() { |
|
| 292 | 292 | global $post; |
| 293 | 293 | |
| 294 | - $select_course_prerequisite = get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
| 294 | + $select_course_prerequisite = get_post_meta($post->ID, '_course_prerequisite', true); |
|
| 295 | 295 | |
| 296 | - $post_args = array( 'post_type' => 'course', |
|
| 296 | + $post_args = array('post_type' => 'course', |
|
| 297 | 297 | 'posts_per_page' => -1, |
| 298 | 298 | 'orderby' => 'title', |
| 299 | 299 | 'order' => 'DESC', |
| 300 | 300 | 'exclude' => $post->ID, |
| 301 | 301 | 'suppress_filters' => 0 |
| 302 | 302 | ); |
| 303 | - $posts_array = get_posts( $post_args ); |
|
| 303 | + $posts_array = get_posts($post_args); |
|
| 304 | 304 | |
| 305 | 305 | $html = ''; |
| 306 | 306 | |
| 307 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 307 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 308 | 308 | |
| 309 | - if ( count( $posts_array ) > 0 ) { |
|
| 310 | - $html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n"; |
|
| 311 | - $html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 312 | - foreach ($posts_array as $post_item){ |
|
| 313 | - $html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n"; |
|
| 309 | + if (count($posts_array) > 0) { |
|
| 310 | + $html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n"; |
|
| 311 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 312 | + foreach ($posts_array as $post_item) { |
|
| 313 | + $html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n"; |
|
| 314 | 314 | } // End For Loop |
| 315 | - $html .= '</select>' . "\n"; |
|
| 315 | + $html .= '</select>'."\n"; |
|
| 316 | 316 | } else { |
| 317 | - $html .= '<p>' . esc_html( __( 'No courses exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>'; |
|
| 317 | + $html .= '<p>'.esc_html(__('No courses exist yet. Please add some first.', 'woothemes-sensei')).'</p>'; |
|
| 318 | 318 | } // End If Statement |
| 319 | 319 | |
| 320 | 320 | echo $html; |
@@ -327,21 +327,21 @@ discard block |
||
| 327 | 327 | * @access public |
| 328 | 328 | * @return void |
| 329 | 329 | */ |
| 330 | - public function course_featured_meta_box_content () { |
|
| 330 | + public function course_featured_meta_box_content() { |
|
| 331 | 331 | global $post; |
| 332 | 332 | |
| 333 | - $course_featured = get_post_meta( $post->ID, '_course_featured', true ); |
|
| 333 | + $course_featured = get_post_meta($post->ID, '_course_featured', true); |
|
| 334 | 334 | |
| 335 | 335 | $html = ''; |
| 336 | 336 | |
| 337 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 337 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 338 | 338 | |
| 339 | 339 | $checked = ''; |
| 340 | - if ( isset( $course_featured ) && ( '' != $course_featured ) ) { |
|
| 341 | - $checked = checked( 'featured', $course_featured, false ); |
|
| 340 | + if (isset($course_featured) && ('' != $course_featured)) { |
|
| 341 | + $checked = checked('featured', $course_featured, false); |
|
| 342 | 342 | } // End If Statement |
| 343 | 343 | |
| 344 | - $html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '> ' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>'; |
|
| 344 | + $html .= '<input type="checkbox" name="course_featured" value="featured" '.$checked.'> '.__('Feature this course', 'woothemes-sensei').'<br>'; |
|
| 345 | 345 | |
| 346 | 346 | echo $html; |
| 347 | 347 | |
@@ -353,16 +353,16 @@ discard block |
||
| 353 | 353 | * @access public |
| 354 | 354 | * @return void |
| 355 | 355 | */ |
| 356 | - public function course_video_meta_box_content () { |
|
| 356 | + public function course_video_meta_box_content() { |
|
| 357 | 357 | global $post; |
| 358 | 358 | |
| 359 | - $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true ); |
|
| 359 | + $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true); |
|
| 360 | 360 | |
| 361 | 361 | $html = ''; |
| 362 | 362 | |
| 363 | - $html .= '<label class="screen-reader-text" for="course_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . '</label>'; |
|
| 364 | - $html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">' . $course_video_embed . '</textarea>'; |
|
| 365 | - $html .= '<p>' . __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>'; |
|
| 363 | + $html .= '<label class="screen-reader-text" for="course_video_embed">'.__('Video Embed Code', 'woothemes-sensei').'</label>'; |
|
| 364 | + $html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">'.$course_video_embed.'</textarea>'; |
|
| 365 | + $html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>'; |
|
| 366 | 366 | |
| 367 | 367 | echo $html; |
| 368 | 368 | |
@@ -377,36 +377,36 @@ discard block |
||
| 377 | 377 | * @param int $post_id |
| 378 | 378 | * @return int |
| 379 | 379 | */ |
| 380 | - public function meta_box_save ( $post_id ) { |
|
| 380 | + public function meta_box_save($post_id) { |
|
| 381 | 381 | global $post; |
| 382 | 382 | |
| 383 | 383 | /* Verify the nonce before proceeding. */ |
| 384 | - if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename(__FILE__) ) ) { |
|
| 384 | + if ((get_post_type() != $this->token) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_noonce'], plugin_basename(__FILE__))) { |
|
| 385 | 385 | return $post_id; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /* Get the post type object. */ |
| 389 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 389 | + $post_type = get_post_type_object($post->post_type); |
|
| 390 | 390 | |
| 391 | 391 | /* Check if the current user has permission to edit the post. */ |
| 392 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
| 392 | + if ( ! current_user_can($post_type->cap->edit_post, $post_id)) { |
|
| 393 | 393 | return $post_id; |
| 394 | 394 | } // End If Statement |
| 395 | 395 | |
| 396 | - if ( 'page' == $_POST['post_type'] ) { |
|
| 397 | - if ( ! current_user_can( 'edit_page', $post_id ) ) { |
|
| 396 | + if ('page' == $_POST['post_type']) { |
|
| 397 | + if ( ! current_user_can('edit_page', $post_id)) { |
|
| 398 | 398 | return $post_id; |
| 399 | 399 | } // End If Statement |
| 400 | 400 | } else { |
| 401 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 401 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 402 | 402 | return $post_id; |
| 403 | 403 | } // End If Statement |
| 404 | 404 | } // End If Statement |
| 405 | 405 | |
| 406 | 406 | // Save the post meta data fields |
| 407 | - if ( isset($this->meta_fields) && is_array($this->meta_fields) ) { |
|
| 408 | - foreach ( $this->meta_fields as $meta_key ) { |
|
| 409 | - $this->save_post_meta( $meta_key, $post_id ); |
|
| 407 | + if (isset($this->meta_fields) && is_array($this->meta_fields)) { |
|
| 408 | + foreach ($this->meta_fields as $meta_key) { |
|
| 409 | + $this->save_post_meta($meta_key, $post_id); |
|
| 410 | 410 | } // End For Loop |
| 411 | 411 | } // End If Statement |
| 412 | 412 | |
@@ -423,18 +423,18 @@ discard block |
||
| 423 | 423 | * @param int $post_id (default: 0) |
| 424 | 424 | * @return int new meta id | bool meta value saved status |
| 425 | 425 | */ |
| 426 | - private function save_post_meta( $post_key = '', $post_id = 0 ) { |
|
| 426 | + private function save_post_meta($post_key = '', $post_id = 0) { |
|
| 427 | 427 | // Get the meta key. |
| 428 | - $meta_key = '_' . $post_key; |
|
| 428 | + $meta_key = '_'.$post_key; |
|
| 429 | 429 | // Get the posted data and sanitize it for use as an HTML class. |
| 430 | - if ( 'course_video_embed' == $post_key) { |
|
| 431 | - $new_meta_value = esc_html( $_POST[$post_key] ); |
|
| 430 | + if ('course_video_embed' == $post_key) { |
|
| 431 | + $new_meta_value = esc_html($_POST[$post_key]); |
|
| 432 | 432 | } else { |
| 433 | - $new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' ); |
|
| 433 | + $new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : ''); |
|
| 434 | 434 | } // End If Statement |
| 435 | 435 | |
| 436 | 436 | // update field with the new value |
| 437 | - return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 437 | + return update_post_meta($post_id, $meta_key, $new_meta_value); |
|
| 438 | 438 | |
| 439 | 439 | } // End save_post_meta() |
| 440 | 440 | |
@@ -444,31 +444,31 @@ discard block |
||
| 444 | 444 | * @access public |
| 445 | 445 | * @return void |
| 446 | 446 | */ |
| 447 | - public function course_lessons_meta_box_content () { |
|
| 447 | + public function course_lessons_meta_box_content() { |
|
| 448 | 448 | |
| 449 | 449 | global $post; |
| 450 | 450 | |
| 451 | 451 | // Setup Lesson Query |
| 452 | 452 | $posts_array = array(); |
| 453 | - if ( 0 < $post->ID ) { |
|
| 453 | + if (0 < $post->ID) { |
|
| 454 | 454 | |
| 455 | - $posts_array = $this->course_lessons( $post->ID, 'any' ); |
|
| 455 | + $posts_array = $this->course_lessons($post->ID, 'any'); |
|
| 456 | 456 | |
| 457 | 457 | } // End If Statement |
| 458 | 458 | |
| 459 | 459 | $html = ''; |
| 460 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' |
|
| 461 | - . esc_attr( 'woo_' . $this->token . '_noonce' ) |
|
| 462 | - . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 460 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="' |
|
| 461 | + . esc_attr('woo_'.$this->token.'_noonce') |
|
| 462 | + . '" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 463 | 463 | |
| 464 | - if ( count( $posts_array ) > 0 ) { |
|
| 464 | + if (count($posts_array) > 0) { |
|
| 465 | 465 | |
| 466 | - foreach ($posts_array as $post_item){ |
|
| 466 | + foreach ($posts_array as $post_item) { |
|
| 467 | 467 | |
| 468 | 468 | $html .= '<p>'."\n"; |
| 469 | 469 | |
| 470 | 470 | $html .= $post_item->post_title."\n"; |
| 471 | - $html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>'; |
|
| 471 | + $html .= '<a href="'.esc_url(get_edit_post_link($post_item->ID)).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $post_item->post_title)).'" class="edit-lesson-action">'.__('Edit this lesson', 'woothemes-sensei').'</a>'; |
|
| 472 | 472 | |
| 473 | 473 | $html .= '</p>'."\n"; |
| 474 | 474 | |
@@ -476,12 +476,12 @@ discard block |
||
| 476 | 476 | |
| 477 | 477 | } else { |
| 478 | 478 | $course_id = ''; |
| 479 | - if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; } |
|
| 480 | - $html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n"; |
|
| 479 | + if (0 < $post->ID) { $course_id = '&course_id='.$post->ID; } |
|
| 480 | + $html .= '<p>'.esc_html(__('No lessons exist yet for this course.', 'woothemes-sensei'))."\n"; |
|
| 481 | 481 | |
| 482 | - $html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id ) |
|
| 483 | - . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">' |
|
| 484 | - . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 482 | + $html .= '<a href="'.admin_url('post-new.php?post_type=lesson'.$course_id) |
|
| 483 | + . '" title="'.esc_attr(__('Add a Lesson', 'woothemes-sensei')).'">' |
|
| 484 | + . __('Please add some.', 'woothemes-sensei').'</a>'."\n"; |
|
| 485 | 485 | |
| 486 | 486 | $html .= '</p>'."\n"; |
| 487 | 487 | } // End If Statement |
@@ -498,12 +498,12 @@ discard block |
||
| 498 | 498 | * @return void |
| 499 | 499 | */ |
| 500 | 500 | |
| 501 | - public function course_manage_meta_box_content () { |
|
| 501 | + public function course_manage_meta_box_content() { |
|
| 502 | 502 | global $post; |
| 503 | 503 | |
| 504 | - $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 504 | + $manage_url = esc_url(add_query_arg(array('page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php'))); |
|
| 505 | 505 | |
| 506 | - $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 506 | + $grading_url = esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php'))); |
|
| 507 | 507 | |
| 508 | 508 | |
| 509 | 509 | echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>"; |
@@ -521,16 +521,16 @@ discard block |
||
| 521 | 521 | * @param array $defaults |
| 522 | 522 | * @return array $new_columns |
| 523 | 523 | */ |
| 524 | - public function add_column_headings ( $defaults ) { |
|
| 524 | + public function add_column_headings($defaults) { |
|
| 525 | 525 | $new_columns['cb'] = '<input type="checkbox" />'; |
| 526 | 526 | // $new_columns['id'] = __( 'ID' ); |
| 527 | - $new_columns['title'] = _x( 'Course Title', 'column name', 'woothemes-sensei' ); |
|
| 528 | - $new_columns['course-prerequisite'] = _x( 'Pre-requisite Course', 'column name', 'woothemes-sensei' ); |
|
| 529 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 530 | - $new_columns['course-woocommerce-product'] = _x( 'WooCommerce Product', 'column name', 'woothemes-sensei' ); |
|
| 527 | + $new_columns['title'] = _x('Course Title', 'column name', 'woothemes-sensei'); |
|
| 528 | + $new_columns['course-prerequisite'] = _x('Pre-requisite Course', 'column name', 'woothemes-sensei'); |
|
| 529 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 530 | + $new_columns['course-woocommerce-product'] = _x('WooCommerce Product', 'column name', 'woothemes-sensei'); |
|
| 531 | 531 | } // End If Statement |
| 532 | - $new_columns['course-category'] = _x( 'Category', 'column name', 'woothemes-sensei' ); |
|
| 533 | - if ( isset( $defaults['date'] ) ) { |
|
| 532 | + $new_columns['course-category'] = _x('Category', 'column name', 'woothemes-sensei'); |
|
| 533 | + if (isset($defaults['date'])) { |
|
| 534 | 534 | $new_columns['date'] = $defaults['date']; |
| 535 | 535 | } |
| 536 | 536 | |
@@ -545,45 +545,45 @@ discard block |
||
| 545 | 545 | * @param int $id |
| 546 | 546 | * @return void |
| 547 | 547 | */ |
| 548 | - public function add_column_data ( $column_name, $id ) { |
|
| 548 | + public function add_column_data($column_name, $id) { |
|
| 549 | 549 | global $wpdb, $post; |
| 550 | 550 | |
| 551 | - switch ( $column_name ) { |
|
| 551 | + switch ($column_name) { |
|
| 552 | 552 | case 'id': |
| 553 | 553 | echo $id; |
| 554 | 554 | break; |
| 555 | 555 | |
| 556 | 556 | case 'course-prerequisite': |
| 557 | - $course_prerequisite_id = get_post_meta( $id, '_course_prerequisite', true); |
|
| 558 | - if ( 0 < absint( $course_prerequisite_id ) ) { echo '<a href="' . esc_url( get_edit_post_link( absint( $course_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $course_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $course_prerequisite_id ) ) . '</a>'; } |
|
| 557 | + $course_prerequisite_id = get_post_meta($id, '_course_prerequisite', true); |
|
| 558 | + if (0 < absint($course_prerequisite_id)) { echo '<a href="'.esc_url(get_edit_post_link(absint($course_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($course_prerequisite_id)))).'">'.get_the_title(absint($course_prerequisite_id)).'</a>'; } |
|
| 559 | 559 | |
| 560 | 560 | break; |
| 561 | 561 | |
| 562 | 562 | case 'course-woocommerce-product': |
| 563 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 564 | - $course_woocommerce_product_id = get_post_meta( $id, '_course_woocommerce_product', true); |
|
| 565 | - if ( 0 < absint( $course_woocommerce_product_id ) ) { |
|
| 566 | - if ( 'product_variation' == get_post_type( $course_woocommerce_product_id ) ) { |
|
| 567 | - $product_object = get_product( $course_woocommerce_product_id ); |
|
| 568 | - if( sensei_check_woocommerce_version( '2.1' ) ) { |
|
| 569 | - $formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true ); |
|
| 563 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 564 | + $course_woocommerce_product_id = get_post_meta($id, '_course_woocommerce_product', true); |
|
| 565 | + if (0 < absint($course_woocommerce_product_id)) { |
|
| 566 | + if ('product_variation' == get_post_type($course_woocommerce_product_id)) { |
|
| 567 | + $product_object = get_product($course_woocommerce_product_id); |
|
| 568 | + if (sensei_check_woocommerce_version('2.1')) { |
|
| 569 | + $formatted_variation = wc_get_formatted_variation($product_object->variation_data, true); |
|
| 570 | 570 | } else { |
| 571 | - $formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true ); |
|
| 571 | + $formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true); |
|
| 572 | 572 | } |
| 573 | 573 | $course_woocommerce_product_id = $product_object->parent->post->ID; |
| 574 | - $product_name = $product_object->parent->post->post_title . '<br/> ' . ucwords( $formatted_variation ); |
|
| 574 | + $product_name = $product_object->parent->post->post_title.'<br/> '.ucwords($formatted_variation); |
|
| 575 | 575 | } else { |
| 576 | - $product_name = get_the_title( absint( $course_woocommerce_product_id ) ); |
|
| 576 | + $product_name = get_the_title(absint($course_woocommerce_product_id)); |
|
| 577 | 577 | } // End If Statement |
| 578 | - echo '<a href="' . esc_url( get_edit_post_link( absint( $course_woocommerce_product_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $product_name ) ) . '">' . $product_name . '</a>'; |
|
| 578 | + echo '<a href="'.esc_url(get_edit_post_link(absint($course_woocommerce_product_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $product_name)).'">'.$product_name.'</a>'; |
|
| 579 | 579 | } // End If Statement |
| 580 | 580 | } // End If Statement |
| 581 | 581 | break; |
| 582 | 582 | |
| 583 | 583 | case 'course-category': |
| 584 | - $output = get_the_term_list( $id, 'course-category', '', ', ', '' ); |
|
| 585 | - if ( '' == $output ) { |
|
| 586 | - $output = __( 'None', 'woothemes-sensei' ); |
|
| 584 | + $output = get_the_term_list($id, 'course-category', '', ', ', ''); |
|
| 585 | + if ('' == $output) { |
|
| 586 | + $output = __('None', 'woothemes-sensei'); |
|
| 587 | 587 | } // End If Statement |
| 588 | 588 | echo $output; |
| 589 | 589 | break; |
@@ -603,29 +603,29 @@ discard block |
||
| 603 | 603 | * @param array $includes (default: array()) |
| 604 | 604 | * @return array |
| 605 | 605 | */ |
| 606 | - public function course_query( $amount = 0, $type = 'default', $includes = array(), $excludes = array() ) { |
|
| 607 | - global $my_courses_page ; |
|
| 606 | + public function course_query($amount = 0, $type = 'default', $includes = array(), $excludes = array()) { |
|
| 607 | + global $my_courses_page; |
|
| 608 | 608 | |
| 609 | 609 | $results_array = array(); |
| 610 | 610 | |
| 611 | - if( $my_courses_page ) { add_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); } |
|
| 611 | + if ($my_courses_page) { add_action('pre_get_posts', array($this, 'filter_my_courses')); } |
|
| 612 | 612 | |
| 613 | - $post_args = $this->get_archive_query_args( $type, $amount, $includes, $excludes ); |
|
| 613 | + $post_args = $this->get_archive_query_args($type, $amount, $includes, $excludes); |
|
| 614 | 614 | |
| 615 | 615 | // get the posts |
| 616 | - if( empty( $post_args ) ) { |
|
| 616 | + if (empty($post_args)) { |
|
| 617 | 617 | |
| 618 | 618 | return $results_array; |
| 619 | 619 | |
| 620 | - }else{ |
|
| 620 | + } else { |
|
| 621 | 621 | |
| 622 | 622 | //reset the pagination as this widgets do not need it |
| 623 | 623 | $post_args['paged'] = 1; |
| 624 | - $results_array = get_posts( $post_args ); |
|
| 624 | + $results_array = get_posts($post_args); |
|
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - if( $my_courses_page ) { remove_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); } |
|
| 628 | + if ($my_courses_page) { remove_action('pre_get_posts', array($this, 'filter_my_courses')); } |
|
| 629 | 629 | |
| 630 | 630 | return $results_array; |
| 631 | 631 | |
@@ -641,22 +641,22 @@ discard block |
||
| 641 | 641 | * @param array $includes (default: array()) |
| 642 | 642 | * @return array |
| 643 | 643 | */ |
| 644 | - public function get_archive_query_args( $type = '', $amount = 0 , $includes = array(), $excludes = array() ) { |
|
| 644 | + public function get_archive_query_args($type = '', $amount = 0, $includes = array(), $excludes = array()) { |
|
| 645 | 645 | |
| 646 | 646 | global $wp_query; |
| 647 | 647 | |
| 648 | - if ( 0 == $amount && ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && 'usercourses' != $type && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) ) { |
|
| 649 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
| 648 | + if (0 == $amount && (isset(Sensei()->settings->settings['course_archive_amount']) && 'usercourses' != $type && (0 < absint(Sensei()->settings->settings['course_archive_amount'])))) { |
|
| 649 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
| 650 | 650 | } else { |
| 651 | - if ( 0 == $amount) { |
|
| 652 | - $amount = $wp_query->get( 'posts_per_page' ); |
|
| 651 | + if (0 == $amount) { |
|
| 652 | + $amount = $wp_query->get('posts_per_page'); |
|
| 653 | 653 | } // End If Statement |
| 654 | 654 | } // End If Statement |
| 655 | 655 | |
| 656 | - $stored_order = get_option( 'sensei_course_order', '' ); |
|
| 656 | + $stored_order = get_option('sensei_course_order', ''); |
|
| 657 | 657 | $order = 'ASC'; |
| 658 | 658 | $orderby = 'menu_order'; |
| 659 | - if( empty( $stored_order ) ){ |
|
| 659 | + if (empty($stored_order)) { |
|
| 660 | 660 | |
| 661 | 661 | $order = 'DESC'; |
| 662 | 662 | $orderby = 'date'; |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | switch ($type) { |
| 667 | 667 | |
| 668 | 668 | case 'usercourses': |
| 669 | - $post_args = array( 'post_type' => 'course', |
|
| 669 | + $post_args = array('post_type' => 'course', |
|
| 670 | 670 | 'orderby' => $orderby, |
| 671 | 671 | 'order' => $order, |
| 672 | 672 | 'post_status' => 'publish', |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | break; |
| 708 | 708 | |
| 709 | 709 | case 'featuredcourses': |
| 710 | - $post_args = array( 'post_type' => 'course', |
|
| 710 | + $post_args = array('post_type' => 'course', |
|
| 711 | 711 | 'orderby' => $orderby, |
| 712 | 712 | 'order' => $order, |
| 713 | 713 | 'post_status' => 'publish', |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | ); |
| 720 | 720 | break; |
| 721 | 721 | default: |
| 722 | - $post_args = array( 'post_type' => 'course', |
|
| 722 | + $post_args = array('post_type' => 'course', |
|
| 723 | 723 | 'orderby' => $orderby, |
| 724 | 724 | 'order' => $order, |
| 725 | 725 | 'post_status' => 'publish', |
@@ -731,13 +731,13 @@ discard block |
||
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | $post_args['posts_per_page'] = $amount; |
| 734 | - $paged = $wp_query->get( 'paged' ); |
|
| 735 | - $post_args['paged'] = empty( $paged) ? 1 : $paged; |
|
| 734 | + $paged = $wp_query->get('paged'); |
|
| 735 | + $post_args['paged'] = empty($paged) ? 1 : $paged; |
|
| 736 | 736 | |
| 737 | - if( 'newcourses' == $type ){ |
|
| 737 | + if ('newcourses' == $type) { |
|
| 738 | 738 | |
| 739 | - $post_args[ 'orderby' ] = 'date'; |
|
| 740 | - $post_args[ 'order' ] = 'DESC'; |
|
| 739 | + $post_args['orderby'] = 'date'; |
|
| 740 | + $post_args['order'] = 'DESC'; |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | return $post_args; |
@@ -759,35 +759,35 @@ discard block |
||
| 759 | 759 | * |
| 760 | 760 | * @return string | void |
| 761 | 761 | */ |
| 762 | - public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) { |
|
| 762 | + public function course_image($course_id = 0, $width = '100', $height = '100', $return = false) { |
|
| 763 | 763 | |
| 764 | - if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 764 | + if (is_a($course_id, 'WP_Post')) { |
|
| 765 | 765 | $course_id = $course_id->ID; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | $html = ''; |
| 769 | 769 | |
| 770 | 770 | // Get Width and Height settings |
| 771 | - if ( ( $width == '100' ) && ( $height == '100' ) ) { |
|
| 771 | + if (($width == '100') && ($height == '100')) { |
|
| 772 | 772 | |
| 773 | - if ( is_singular( 'course' ) ) { |
|
| 773 | + if (is_singular('course')) { |
|
| 774 | 774 | |
| 775 | - if ( !Sensei()->settings->settings[ 'course_single_image_enable' ] ) { |
|
| 775 | + if ( ! Sensei()->settings->settings['course_single_image_enable']) { |
|
| 776 | 776 | return ''; |
| 777 | 777 | } // End If Statement |
| 778 | 778 | $image_thumb_size = 'course_single_image'; |
| 779 | - $dimensions = Sensei()->get_image_size( $image_thumb_size ); |
|
| 779 | + $dimensions = Sensei()->get_image_size($image_thumb_size); |
|
| 780 | 780 | $width = $dimensions['width']; |
| 781 | 781 | $height = $dimensions['height']; |
| 782 | 782 | |
| 783 | 783 | } else { |
| 784 | 784 | |
| 785 | - if ( !Sensei()->settings->settings[ 'course_archive_image_enable' ] ) { |
|
| 785 | + if ( ! Sensei()->settings->settings['course_archive_image_enable']) { |
|
| 786 | 786 | return ''; |
| 787 | 787 | } // End If Statement |
| 788 | 788 | |
| 789 | 789 | $image_thumb_size = 'course_archive_image'; |
| 790 | - $dimensions = Sensei()->get_image_size( $image_thumb_size ); |
|
| 790 | + $dimensions = Sensei()->get_image_size($image_thumb_size); |
|
| 791 | 791 | $width = $dimensions['width']; |
| 792 | 792 | $height = $dimensions['height']; |
| 793 | 793 | |
@@ -796,31 +796,31 @@ discard block |
||
| 796 | 796 | } // End If Statement |
| 797 | 797 | |
| 798 | 798 | $img_url = ''; |
| 799 | - if ( has_post_thumbnail( $course_id ) ) { |
|
| 799 | + if (has_post_thumbnail($course_id)) { |
|
| 800 | 800 | // Get Featured Image |
| 801 | - $img_url = get_the_post_thumbnail( $course_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') ); |
|
| 801 | + $img_url = get_the_post_thumbnail($course_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft')); |
|
| 802 | 802 | } else { |
| 803 | 803 | |
| 804 | 804 | // Check for a Lesson Image |
| 805 | - $course_lessons = $this->course_lessons( $course_id ); |
|
| 805 | + $course_lessons = $this->course_lessons($course_id); |
|
| 806 | 806 | |
| 807 | - foreach ($course_lessons as $lesson_item){ |
|
| 808 | - if ( has_post_thumbnail( $lesson_item->ID ) ) { |
|
| 807 | + foreach ($course_lessons as $lesson_item) { |
|
| 808 | + if (has_post_thumbnail($lesson_item->ID)) { |
|
| 809 | 809 | // Get Featured Image |
| 810 | - $img_url = get_the_post_thumbnail( $lesson_item->ID, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') ); |
|
| 811 | - if ( '' != $img_url ) { |
|
| 810 | + $img_url = get_the_post_thumbnail($lesson_item->ID, array($width, $height), array('class' => 'woo-image thumbnail alignleft')); |
|
| 811 | + if ('' != $img_url) { |
|
| 812 | 812 | break; |
| 813 | 813 | } // End If Statement |
| 814 | 814 | |
| 815 | 815 | } // End If Statement |
| 816 | 816 | } // End For Loop |
| 817 | 817 | |
| 818 | - if ( '' == $img_url ) { |
|
| 818 | + if ('' == $img_url) { |
|
| 819 | 819 | |
| 820 | 820 | // Display Image Placeholder if none |
| 821 | - if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) { |
|
| 821 | + if (Sensei()->settings->get('placeholder_images_enable')) { |
|
| 822 | 822 | |
| 823 | - $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 823 | + $img_url = apply_filters('sensei_course_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />'); |
|
| 824 | 824 | |
| 825 | 825 | } // End If Statement |
| 826 | 826 | |
@@ -828,17 +828,17 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | } // End If Statement |
| 830 | 830 | |
| 831 | - if ( '' != $img_url ) { |
|
| 831 | + if ('' != $img_url) { |
|
| 832 | 832 | |
| 833 | - $html .= '<a href="' . get_permalink( $course_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $course_id ) ) . '">' . $img_url .'</a>'; |
|
| 833 | + $html .= '<a href="'.get_permalink($course_id).'" title="'.esc_attr(get_post_field('post_title', $course_id)).'">'.$img_url.'</a>'; |
|
| 834 | 834 | |
| 835 | 835 | } // End If Statement |
| 836 | 836 | |
| 837 | - if( $return ){ |
|
| 837 | + if ($return) { |
|
| 838 | 838 | |
| 839 | 839 | return $html; |
| 840 | 840 | |
| 841 | - }else{ |
|
| 841 | + } else { |
|
| 842 | 842 | |
| 843 | 843 | echo $html; |
| 844 | 844 | |
@@ -855,9 +855,9 @@ discard block |
||
| 855 | 855 | * @param string $post_status (default: 'publish') |
| 856 | 856 | * @return int |
| 857 | 857 | */ |
| 858 | - public function course_count( $post_status = 'publish' ) { |
|
| 858 | + public function course_count($post_status = 'publish') { |
|
| 859 | 859 | |
| 860 | - $post_args = array( 'post_type' => 'course', |
|
| 860 | + $post_args = array('post_type' => 'course', |
|
| 861 | 861 | 'posts_per_page' => -1, |
| 862 | 862 | // 'orderby' => 'menu_order date', |
| 863 | 863 | // 'order' => 'ASC', |
@@ -868,10 +868,10 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | // Allow WP to generate the complex final query, just shortcut to only do an overall count |
| 870 | 870 | // add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) ); |
| 871 | - $courses_query = new WP_Query( apply_filters( 'sensei_course_count', $post_args ) ); |
|
| 871 | + $courses_query = new WP_Query(apply_filters('sensei_course_count', $post_args)); |
|
| 872 | 872 | // remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) ); |
| 873 | 873 | |
| 874 | - return count( $courses_query->posts ); |
|
| 874 | + return count($courses_query->posts); |
|
| 875 | 875 | } // End course_count() |
| 876 | 876 | |
| 877 | 877 | |
@@ -884,42 +884,42 @@ discard block |
||
| 884 | 884 | * @param string $fields (default: 'all'). WP only allows 3 types, but we will limit it to only 'ids' or 'all' |
| 885 | 885 | * @return array{ type WP_Post } $posts_array |
| 886 | 886 | */ |
| 887 | - public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) { |
|
| 887 | + public function course_lessons($course_id = 0, $post_status = 'publish', $fields = 'all') { |
|
| 888 | 888 | |
| 889 | - if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 889 | + if (is_a($course_id, 'WP_Post')) { |
|
| 890 | 890 | $course_id = $course_id->ID; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - $post_args = array( 'post_type' => 'lesson', |
|
| 893 | + $post_args = array('post_type' => 'lesson', |
|
| 894 | 894 | 'posts_per_page' => -1, |
| 895 | 895 | 'orderby' => 'date', |
| 896 | 896 | 'order' => 'ASC', |
| 897 | 897 | 'meta_query' => array( |
| 898 | 898 | array( |
| 899 | 899 | 'key' => '_lesson_course', |
| 900 | - 'value' => intval( $course_id ), |
|
| 900 | + 'value' => intval($course_id), |
|
| 901 | 901 | ), |
| 902 | 902 | ), |
| 903 | 903 | 'post_status' => $post_status, |
| 904 | 904 | 'suppress_filters' => 0, |
| 905 | 905 | ); |
| 906 | - $query_results = new WP_Query( $post_args ); |
|
| 906 | + $query_results = new WP_Query($post_args); |
|
| 907 | 907 | $lessons = $query_results->posts; |
| 908 | 908 | |
| 909 | 909 | // re order the lessons. This could not be done via the OR meta query as there may be lessons |
| 910 | 910 | // with the course order for a different course and this should not be included. It could also not |
| 911 | 911 | // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but |
| 912 | 912 | // that have been added to the course. |
| 913 | - if( count( $lessons) > 1 ){ |
|
| 913 | + if (count($lessons) > 1) { |
|
| 914 | 914 | |
| 915 | - foreach( $lessons as $lesson ){ |
|
| 915 | + foreach ($lessons as $lesson) { |
|
| 916 | 916 | |
| 917 | - $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) ); |
|
| 917 | + $order = intval(get_post_meta($lesson->ID, '_order_'.$course_id, true)); |
|
| 918 | 918 | // for lessons with no order set it to be 10000 so that it show up at the end |
| 919 | 919 | $lesson->course_order = $order ? $order : 100000; |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - uasort( $lessons, array( $this, '_short_course_lessons_callback' ) ); |
|
| 922 | + uasort($lessons, array($this, '_short_course_lessons_callback')); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
@@ -930,12 +930,12 @@ discard block |
||
| 930 | 930 | * @param array $lessons |
| 931 | 931 | * @param int $course_id |
| 932 | 932 | */ |
| 933 | - $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id ); |
|
| 933 | + $lessons = apply_filters('sensei_course_get_lessons', $lessons, $course_id); |
|
| 934 | 934 | |
| 935 | 935 | //return the requested fields |
| 936 | 936 | // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson |
| 937 | 937 | // objects |
| 938 | - if( 'ids' == $fields ) { |
|
| 938 | + if ('ids' == $fields) { |
|
| 939 | 939 | $lesson_objects = $lessons; |
| 940 | 940 | $lessons = array(); |
| 941 | 941 | |
@@ -957,9 +957,9 @@ discard block |
||
| 957 | 957 | * @param array $lesson_2 |
| 958 | 958 | * @return int |
| 959 | 959 | */ |
| 960 | - protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){ |
|
| 960 | + protected function _short_course_lessons_callback($lesson_1, $lesson_2) { |
|
| 961 | 961 | |
| 962 | - if ( $lesson_1->course_order == $lesson_2->course_order ) { |
|
| 962 | + if ($lesson_1->course_order == $lesson_2->course_order) { |
|
| 963 | 963 | return 0; |
| 964 | 964 | } |
| 965 | 965 | |
@@ -973,21 +973,21 @@ discard block |
||
| 973 | 973 | * @param boolean $boolean_check True if a simple yes/no is required |
| 974 | 974 | * @return array Array of quiz post objects |
| 975 | 975 | */ |
| 976 | - public function course_quizzes( $course_id = 0, $boolean_check = false ) { |
|
| 976 | + public function course_quizzes($course_id = 0, $boolean_check = false) { |
|
| 977 | 977 | |
| 978 | 978 | |
| 979 | 979 | $course_quizzes = array(); |
| 980 | 980 | |
| 981 | - if( $course_id ) { |
|
| 982 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); |
|
| 981 | + if ($course_id) { |
|
| 982 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); |
|
| 983 | 983 | |
| 984 | - foreach( $lesson_ids as $lesson_id ) { |
|
| 985 | - $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 986 | - if ( $has_questions && $boolean_check ) { |
|
| 984 | + foreach ($lesson_ids as $lesson_id) { |
|
| 985 | + $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
| 986 | + if ($has_questions && $boolean_check) { |
|
| 987 | 987 | return true; |
| 988 | 988 | } |
| 989 | - elseif ( $has_questions ) { |
|
| 990 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 989 | + elseif ($has_questions) { |
|
| 990 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 991 | 991 | // $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 992 | 992 | // if( count( $questions ) > 0 ) { |
| 993 | 993 | $course_quizzes[] = $quiz_id; |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | } |
| 998 | - if ( $boolean_check && empty($course_quizzes) ) { |
|
| 998 | + if ($boolean_check && empty($course_quizzes)) { |
|
| 999 | 999 | $course_quizzes = false; |
| 1000 | 1000 | } |
| 1001 | 1001 | return $course_quizzes; |
@@ -1010,9 +1010,9 @@ discard block |
||
| 1010 | 1010 | * @param string $post_status (default: 'publish') |
| 1011 | 1011 | * @return array |
| 1012 | 1012 | */ |
| 1013 | - public function course_lessons_completed( $course_id = 0, $post_status = 'publish' ) { |
|
| 1013 | + public function course_lessons_completed($course_id = 0, $post_status = 'publish') { |
|
| 1014 | 1014 | |
| 1015 | - return $this->course_lessons( $course_id, $post_status ); |
|
| 1015 | + return $this->course_lessons($course_id, $post_status); |
|
| 1016 | 1016 | |
| 1017 | 1017 | } // End course_lessons_completed() |
| 1018 | 1018 | |
@@ -1025,9 +1025,9 @@ discard block |
||
| 1025 | 1025 | * @param int $course_id (default: 0) |
| 1026 | 1026 | * @return int |
| 1027 | 1027 | */ |
| 1028 | - public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) { |
|
| 1028 | + public function course_author_lesson_count($author_id = 0, $course_id = 0) { |
|
| 1029 | 1029 | |
| 1030 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1030 | + $lesson_args = array('post_type' => 'lesson', |
|
| 1031 | 1031 | 'posts_per_page' => -1, |
| 1032 | 1032 | 'author' => $author_id, |
| 1033 | 1033 | 'meta_key' => '_lesson_course', |
@@ -1036,8 +1036,8 @@ discard block |
||
| 1036 | 1036 | 'suppress_filters' => 0, |
| 1037 | 1037 | 'fields' => 'ids', // less data to retrieve |
| 1038 | 1038 | ); |
| 1039 | - $lessons_array = get_posts( $lesson_args ); |
|
| 1040 | - $count = count( $lessons_array ); |
|
| 1039 | + $lessons_array = get_posts($lesson_args); |
|
| 1040 | + $count = count($lessons_array); |
|
| 1041 | 1041 | return $count; |
| 1042 | 1042 | |
| 1043 | 1043 | } // End course_author_lesson_count() |
@@ -1049,9 +1049,9 @@ discard block |
||
| 1049 | 1049 | * @param int $course_id (default: 0) |
| 1050 | 1050 | * @return int |
| 1051 | 1051 | */ |
| 1052 | - public function course_lesson_count( $course_id = 0 ) { |
|
| 1052 | + public function course_lesson_count($course_id = 0) { |
|
| 1053 | 1053 | |
| 1054 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1054 | + $lesson_args = array('post_type' => 'lesson', |
|
| 1055 | 1055 | 'posts_per_page' => -1, |
| 1056 | 1056 | 'meta_key' => '_lesson_course', |
| 1057 | 1057 | 'meta_value' => $course_id, |
@@ -1059,9 +1059,9 @@ discard block |
||
| 1059 | 1059 | 'suppress_filters' => 0, |
| 1060 | 1060 | 'fields' => 'ids', // less data to retrieve |
| 1061 | 1061 | ); |
| 1062 | - $lessons_array = get_posts( $lesson_args ); |
|
| 1062 | + $lessons_array = get_posts($lesson_args); |
|
| 1063 | 1063 | |
| 1064 | - $count = count( $lessons_array ); |
|
| 1064 | + $count = count($lessons_array); |
|
| 1065 | 1065 | |
| 1066 | 1066 | return $count; |
| 1067 | 1067 | |
@@ -1074,9 +1074,9 @@ discard block |
||
| 1074 | 1074 | * @param int $course_id (default: 0) |
| 1075 | 1075 | * @return int |
| 1076 | 1076 | */ |
| 1077 | - public function course_lesson_preview_count( $course_id = 0 ) { |
|
| 1077 | + public function course_lesson_preview_count($course_id = 0) { |
|
| 1078 | 1078 | |
| 1079 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1079 | + $lesson_args = array('post_type' => 'lesson', |
|
| 1080 | 1080 | 'posts_per_page' => -1, |
| 1081 | 1081 | 'post_status' => 'publish', |
| 1082 | 1082 | 'suppress_filters' => 0, |
@@ -1092,9 +1092,9 @@ discard block |
||
| 1092 | 1092 | ), |
| 1093 | 1093 | 'fields' => 'ids', // less data to retrieve |
| 1094 | 1094 | ); |
| 1095 | - $lessons_array = get_posts( $lesson_args ); |
|
| 1095 | + $lessons_array = get_posts($lesson_args); |
|
| 1096 | 1096 | |
| 1097 | - $count = count( $lessons_array ); |
|
| 1097 | + $count = count($lessons_array); |
|
| 1098 | 1098 | |
| 1099 | 1099 | return $count; |
| 1100 | 1100 | |
@@ -1107,12 +1107,12 @@ discard block |
||
| 1107 | 1107 | * @param int $product_id (default: 0) |
| 1108 | 1108 | * @return array |
| 1109 | 1109 | */ |
| 1110 | - public function get_product_courses( $product_id = 0 ) { |
|
| 1110 | + public function get_product_courses($product_id = 0) { |
|
| 1111 | 1111 | |
| 1112 | 1112 | $posts_array = array(); |
| 1113 | 1113 | // Check for WooCommerce |
| 1114 | - if ( Sensei_WC::is_woocommerce_active() && 0 < $product_id ) { |
|
| 1115 | - $post_args = array( 'post_type' => 'course', |
|
| 1114 | + if (Sensei_WC::is_woocommerce_active() && 0 < $product_id) { |
|
| 1115 | + $post_args = array('post_type' => 'course', |
|
| 1116 | 1116 | 'posts_per_page' => -1, |
| 1117 | 1117 | 'meta_key' => '_course_woocommerce_product', |
| 1118 | 1118 | 'meta_value' => $product_id, |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | 'orderby' => 'menu_order date', |
| 1122 | 1122 | 'order' => 'ASC', |
| 1123 | 1123 | ); |
| 1124 | - $posts_array = get_posts( $post_args ); |
|
| 1124 | + $posts_array = get_posts($post_args); |
|
| 1125 | 1125 | } // End If Statement |
| 1126 | 1126 | return $posts_array; |
| 1127 | 1127 | |
@@ -1141,17 +1141,17 @@ discard block |
||
| 1141 | 1141 | * @param WP_Query $query |
| 1142 | 1142 | * @return void |
| 1143 | 1143 | */ |
| 1144 | - public function filter_my_courses( $query ) { |
|
| 1144 | + public function filter_my_courses($query) { |
|
| 1145 | 1145 | global $my_courses_section; |
| 1146 | 1146 | |
| 1147 | - if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) { |
|
| 1148 | - $amount = absint( Sensei()->settings->settings[ 'my_course_amount' ] ); |
|
| 1149 | - $query->set( 'posts_per_page', $amount ); |
|
| 1147 | + if (isset(Sensei()->settings->settings['my_course_amount']) && (0 < absint(Sensei()->settings->settings['my_course_amount']))) { |
|
| 1148 | + $amount = absint(Sensei()->settings->settings['my_course_amount']); |
|
| 1149 | + $query->set('posts_per_page', $amount); |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - if( isset( $_GET[ $my_courses_section . '_page' ] ) && 0 < intval( $_GET[ $my_courses_section . '_page' ] ) ) { |
|
| 1153 | - $page = intval( $_GET[ $my_courses_section . '_page' ] ); |
|
| 1154 | - $query->set( 'paged', $page ); |
|
| 1152 | + if (isset($_GET[$my_courses_section.'_page']) && 0 < intval($_GET[$my_courses_section.'_page'])) { |
|
| 1153 | + $page = intval($_GET[$my_courses_section.'_page']); |
|
| 1154 | + $query->set('paged', $page); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | } |
| 1157 | 1157 | |
@@ -1165,48 +1165,48 @@ discard block |
||
| 1165 | 1165 | * @param boolean $manage Whether the user has permission to manage the courses |
| 1166 | 1166 | * @return string HTML displayng course data |
| 1167 | 1167 | */ |
| 1168 | - public function load_user_courses_content( $user = false ) { |
|
| 1168 | + public function load_user_courses_content($user = false) { |
|
| 1169 | 1169 | global $course, $my_courses_page, $my_courses_section; |
| 1170 | 1170 | |
| 1171 | - if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) |
|
| 1172 | - || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) { |
|
| 1171 | + if ( ! isset(Sensei()->settings->settings['learner_profile_show_courses']) |
|
| 1172 | + || ! Sensei()->settings->settings['learner_profile_show_courses']) { |
|
| 1173 | 1173 | |
| 1174 | 1174 | // do not show the content if the settings doesn't allow for it |
| 1175 | 1175 | return; |
| 1176 | 1176 | |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | - $manage = ( $user->ID == get_current_user_id() ) ? true : false; |
|
| 1179 | + $manage = ($user->ID == get_current_user_id()) ? true : false; |
|
| 1180 | 1180 | |
| 1181 | - do_action( 'sensei_before_learner_course_content', $user ); |
|
| 1181 | + do_action('sensei_before_learner_course_content', $user); |
|
| 1182 | 1182 | |
| 1183 | 1183 | // Build Output HTML |
| 1184 | 1184 | $complete_html = $active_html = ''; |
| 1185 | 1185 | |
| 1186 | - if( is_a( $user, 'WP_User' ) ) { |
|
| 1186 | + if (is_a($user, 'WP_User')) { |
|
| 1187 | 1187 | |
| 1188 | 1188 | $my_courses_page = true; |
| 1189 | 1189 | |
| 1190 | 1190 | // Allow action to be run before My Courses content has loaded |
| 1191 | - do_action( 'sensei_before_my_courses', $user->ID ); |
|
| 1191 | + do_action('sensei_before_my_courses', $user->ID); |
|
| 1192 | 1192 | |
| 1193 | 1193 | // Logic for Active and Completed Courses |
| 1194 | 1194 | $per_page = 20; |
| 1195 | - if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) |
|
| 1196 | - && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) { |
|
| 1195 | + if (isset(Sensei()->settings->settings['my_course_amount']) |
|
| 1196 | + && (0 < absint(Sensei()->settings->settings['my_course_amount']))) { |
|
| 1197 | 1197 | |
| 1198 | - $per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] ); |
|
| 1198 | + $per_page = absint(Sensei()->settings->settings['my_course_amount']); |
|
| 1199 | 1199 | |
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | - $course_statuses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user->ID, 'type' => 'sensei_course_status' ), true ); |
|
| 1202 | + $course_statuses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user->ID, 'type' => 'sensei_course_status'), true); |
|
| 1203 | 1203 | // User may only be on 1 Course |
| 1204 | - if ( !is_array($course_statuses) ) { |
|
| 1205 | - $course_statuses = array( $course_statuses ); |
|
| 1204 | + if ( ! is_array($course_statuses)) { |
|
| 1205 | + $course_statuses = array($course_statuses); |
|
| 1206 | 1206 | } |
| 1207 | 1207 | $completed_ids = $active_ids = array(); |
| 1208 | - foreach( $course_statuses as $course_status ) { |
|
| 1209 | - if ( Sensei_Utils::user_completed_course( $course_status, $user->ID ) ) { |
|
| 1208 | + foreach ($course_statuses as $course_status) { |
|
| 1209 | + if (Sensei_Utils::user_completed_course($course_status, $user->ID)) { |
|
| 1210 | 1210 | $completed_ids[] = $course_status->comment_post_ID; |
| 1211 | 1211 | } else { |
| 1212 | 1212 | $active_ids[] = $course_status->comment_post_ID; |
@@ -1216,41 +1216,41 @@ discard block |
||
| 1216 | 1216 | $active_count = $completed_count = 0; |
| 1217 | 1217 | |
| 1218 | 1218 | $active_courses = array(); |
| 1219 | - if ( 0 < intval( count( $active_ids ) ) ) { |
|
| 1219 | + if (0 < intval(count($active_ids))) { |
|
| 1220 | 1220 | $my_courses_section = 'active'; |
| 1221 | - $active_courses = Sensei()->course->course_query( $per_page, 'usercourses', $active_ids ); |
|
| 1222 | - $active_count = count( $active_ids ); |
|
| 1221 | + $active_courses = Sensei()->course->course_query($per_page, 'usercourses', $active_ids); |
|
| 1222 | + $active_count = count($active_ids); |
|
| 1223 | 1223 | } // End If Statement |
| 1224 | 1224 | |
| 1225 | 1225 | $completed_courses = array(); |
| 1226 | - if ( 0 < intval( count( $completed_ids ) ) ) { |
|
| 1226 | + if (0 < intval(count($completed_ids))) { |
|
| 1227 | 1227 | $my_courses_section = 'completed'; |
| 1228 | - $completed_courses = Sensei()->course->course_query( $per_page, 'usercourses', $completed_ids ); |
|
| 1229 | - $completed_count = count( $completed_ids ); |
|
| 1228 | + $completed_courses = Sensei()->course->course_query($per_page, 'usercourses', $completed_ids); |
|
| 1229 | + $completed_count = count($completed_ids); |
|
| 1230 | 1230 | } // End If Statement |
| 1231 | 1231 | |
| 1232 | - foreach ( $active_courses as $course_item ) { |
|
| 1232 | + foreach ($active_courses as $course_item) { |
|
| 1233 | 1233 | |
| 1234 | - $course_lessons = Sensei()->course->course_lessons( $course_item->ID ); |
|
| 1234 | + $course_lessons = Sensei()->course->course_lessons($course_item->ID); |
|
| 1235 | 1235 | $lessons_completed = 0; |
| 1236 | - foreach ( $course_lessons as $lesson ) { |
|
| 1237 | - if ( Sensei_Utils::user_completed_lesson( $lesson->ID, $user->ID ) ) { |
|
| 1236 | + foreach ($course_lessons as $lesson) { |
|
| 1237 | + if (Sensei_Utils::user_completed_lesson($lesson->ID, $user->ID)) { |
|
| 1238 | 1238 | ++$lessons_completed; |
| 1239 | 1239 | } |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | // Get Course Categories |
| 1243 | - $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1243 | + $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', ''); |
|
| 1244 | 1244 | |
| 1245 | - $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">'; |
|
| 1245 | + $active_html .= '<article class="'.esc_attr(join(' ', get_post_class(array('course', 'post'), $course_item->ID))).'">'; |
|
| 1246 | 1246 | |
| 1247 | 1247 | // Image |
| 1248 | - $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true ); |
|
| 1248 | + $active_html .= Sensei()->course->course_image(absint($course_item->ID), '100', '100', true); |
|
| 1249 | 1249 | |
| 1250 | 1250 | // Title |
| 1251 | 1251 | $active_html .= '<header>'; |
| 1252 | 1252 | |
| 1253 | - $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1253 | + $active_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>'; |
|
| 1254 | 1254 | |
| 1255 | 1255 | $active_html .= '</header>'; |
| 1256 | 1256 | |
@@ -1259,82 +1259,82 @@ discard block |
||
| 1259 | 1259 | $active_html .= '<p class="sensei-course-meta">'; |
| 1260 | 1260 | |
| 1261 | 1261 | // Author |
| 1262 | - $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1263 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) |
|
| 1264 | - && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1262 | + $user_info = get_userdata(absint($course_item->post_author)); |
|
| 1263 | + if (isset(Sensei()->settings->settings['course_author']) |
|
| 1264 | + && (Sensei()->settings->settings['course_author'])) { |
|
| 1265 | 1265 | |
| 1266 | 1266 | $active_html .= '<span class="course-author">' |
| 1267 | - . __( 'by ', 'woothemes-sensei' ) |
|
| 1268 | - . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) |
|
| 1269 | - . '" title="' . esc_attr( $user_info->display_name ) . '">' |
|
| 1270 | - . esc_html( $user_info->display_name ) |
|
| 1267 | + . __('by ', 'woothemes-sensei') |
|
| 1268 | + . '<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))) |
|
| 1269 | + . '" title="'.esc_attr($user_info->display_name).'">' |
|
| 1270 | + . esc_html($user_info->display_name) |
|
| 1271 | 1271 | . '</a></span>'; |
| 1272 | 1272 | |
| 1273 | 1273 | } // End If Statement |
| 1274 | 1274 | |
| 1275 | 1275 | // Lesson count for this author |
| 1276 | - $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) ); |
|
| 1276 | + $lesson_count = Sensei()->course->course_lesson_count(absint($course_item->ID)); |
|
| 1277 | 1277 | // Handle Division by Zero |
| 1278 | - if ( 0 == $lesson_count ) { |
|
| 1278 | + if (0 == $lesson_count) { |
|
| 1279 | 1279 | |
| 1280 | 1280 | $lesson_count = 1; |
| 1281 | 1281 | |
| 1282 | 1282 | } // End If Statement |
| 1283 | - $active_html .= '<span class="course-lesson-count">' . $lesson_count . ' ' . __( 'Lessons', 'woothemes-sensei' ) . '</span>'; |
|
| 1283 | + $active_html .= '<span class="course-lesson-count">'.$lesson_count.' '.__('Lessons', 'woothemes-sensei').'</span>'; |
|
| 1284 | 1284 | // Course Categories |
| 1285 | - if ( '' != $category_output ) { |
|
| 1285 | + if ('' != $category_output) { |
|
| 1286 | 1286 | |
| 1287 | - $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1287 | + $active_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>'; |
|
| 1288 | 1288 | |
| 1289 | 1289 | } // End If Statement |
| 1290 | - $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count ) . '</span>'; |
|
| 1290 | + $active_html .= '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count).'</span>'; |
|
| 1291 | 1291 | |
| 1292 | 1292 | $active_html .= '</p>'; |
| 1293 | 1293 | |
| 1294 | - $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
|
| 1294 | + $active_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>'; |
|
| 1295 | 1295 | |
| 1296 | 1296 | |
| 1297 | 1297 | |
| 1298 | - $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) ); |
|
| 1298 | + $progress_percentage = abs(round((doubleval($lessons_completed) * 100) / ($lesson_count), 0)); |
|
| 1299 | 1299 | |
| 1300 | - $active_html .= $this->get_progress_meter( $progress_percentage ); |
|
| 1300 | + $active_html .= $this->get_progress_meter($progress_percentage); |
|
| 1301 | 1301 | |
| 1302 | 1302 | $active_html .= '</section>'; |
| 1303 | 1303 | |
| 1304 | - if( is_user_logged_in() ) { |
|
| 1304 | + if (is_user_logged_in()) { |
|
| 1305 | 1305 | |
| 1306 | 1306 | $active_html .= '<section class="entry-actions">'; |
| 1307 | 1307 | |
| 1308 | - $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">'; |
|
| 1308 | + $active_html .= '<form method="POST" action="'.esc_url(remove_query_arg(array('active_page', 'completed_page'))).'">'; |
|
| 1309 | 1309 | |
| 1310 | - $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />'; |
|
| 1310 | + $active_html .= '<input type="hidden" name="'.esc_attr('woothemes_sensei_complete_course_noonce').'" id="'.esc_attr('woothemes_sensei_complete_course_noonce').'" value="'.esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')).'" />'; |
|
| 1311 | 1311 | |
| 1312 | - $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />'; |
|
| 1312 | + $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="'.esc_attr(absint($course_item->ID)).'" />'; |
|
| 1313 | 1313 | |
| 1314 | - if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { |
|
| 1314 | + if (0 < absint(count($course_lessons)) && Sensei()->settings->settings['course_completion'] == 'complete') { |
|
| 1315 | 1315 | |
| 1316 | 1316 | $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="' |
| 1317 | - . __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>'; |
|
| 1317 | + . __('Mark as Complete', 'woothemes-sensei').'"/> </span>'; |
|
| 1318 | 1318 | |
| 1319 | 1319 | } // End If Statement |
| 1320 | 1320 | |
| 1321 | 1321 | $course_purchased = false; |
| 1322 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 1322 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 1323 | 1323 | |
| 1324 | 1324 | // Get the product ID |
| 1325 | - $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true ); |
|
| 1326 | - if ( 0 < $wc_post_id ) { |
|
| 1325 | + $wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true); |
|
| 1326 | + if (0 < $wc_post_id) { |
|
| 1327 | 1327 | |
| 1328 | - $course_purchased = Sensei_WC::has_customer_bought_product( $user->ID, $wc_post_id ); |
|
| 1328 | + $course_purchased = Sensei_WC::has_customer_bought_product($user->ID, $wc_post_id); |
|
| 1329 | 1329 | |
| 1330 | 1330 | } // End If Statement |
| 1331 | 1331 | |
| 1332 | 1332 | } // End If Statement |
| 1333 | 1333 | |
| 1334 | - if ( false == $course_purchased ) { |
|
| 1334 | + if (false == $course_purchased) { |
|
| 1335 | 1335 | |
| 1336 | 1336 | $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="' |
| 1337 | - . __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>'; |
|
| 1337 | + . __('Delete Course', 'woothemes-sensei').'"/></span>'; |
|
| 1338 | 1338 | |
| 1339 | 1339 | } // End If Statement |
| 1340 | 1340 | |
@@ -1347,54 +1347,54 @@ discard block |
||
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | // Active pagination |
| 1350 | - if( $active_count > $per_page ) { |
|
| 1350 | + if ($active_count > $per_page) { |
|
| 1351 | 1351 | |
| 1352 | 1352 | $current_page = 1; |
| 1353 | - if( isset( $_GET['active_page'] ) && 0 < intval( $_GET['active_page'] ) ) { |
|
| 1353 | + if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) { |
|
| 1354 | 1354 | $current_page = $_GET['active_page']; |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | $active_html .= '<nav class="pagination woo-pagination">'; |
| 1358 | - $total_pages = ceil( $active_count / $per_page ); |
|
| 1358 | + $total_pages = ceil($active_count / $per_page); |
|
| 1359 | 1359 | |
| 1360 | - if( $current_page > 1 ) { |
|
| 1361 | - $prev_link = add_query_arg( 'active_page', $current_page - 1 ); |
|
| 1362 | - $active_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> '; |
|
| 1360 | + if ($current_page > 1) { |
|
| 1361 | + $prev_link = add_query_arg('active_page', $current_page - 1); |
|
| 1362 | + $active_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> '; |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
| 1366 | - $link = add_query_arg( 'active_page', $i ); |
|
| 1365 | + for ($i = 1; $i <= $total_pages; $i++) { |
|
| 1366 | + $link = add_query_arg('active_page', $i); |
|
| 1367 | 1367 | |
| 1368 | - if( $i == $current_page ) { |
|
| 1369 | - $active_html .= '<span class="page-numbers current">' . $i . '</span> '; |
|
| 1368 | + if ($i == $current_page) { |
|
| 1369 | + $active_html .= '<span class="page-numbers current">'.$i.'</span> '; |
|
| 1370 | 1370 | } else { |
| 1371 | - $active_html .= '<a class="page-numbers" href="' . esc_url( $link ). '">' . $i . '</a> '; |
|
| 1371 | + $active_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> '; |
|
| 1372 | 1372 | } |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | - if( $current_page < $total_pages ) { |
|
| 1376 | - $next_link = add_query_arg( 'active_page', $current_page + 1 ); |
|
| 1377 | - $active_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> '; |
|
| 1375 | + if ($current_page < $total_pages) { |
|
| 1376 | + $next_link = add_query_arg('active_page', $current_page + 1); |
|
| 1377 | + $active_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> '; |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | $active_html .= '</nav>'; |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | - foreach ( $completed_courses as $course_item ) { |
|
| 1383 | + foreach ($completed_courses as $course_item) { |
|
| 1384 | 1384 | $course = $course_item; |
| 1385 | 1385 | |
| 1386 | 1386 | // Get Course Categories |
| 1387 | - $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1387 | + $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', ''); |
|
| 1388 | 1388 | |
| 1389 | - $complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">'; |
|
| 1389 | + $complete_html .= '<article class="'.join(' ', get_post_class(array('course', 'post'), $course_item->ID)).'">'; |
|
| 1390 | 1390 | |
| 1391 | 1391 | // Image |
| 1392 | - $complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true ); |
|
| 1392 | + $complete_html .= Sensei()->course->course_image(absint($course_item->ID), 100, 100, true); |
|
| 1393 | 1393 | |
| 1394 | 1394 | // Title |
| 1395 | 1395 | $complete_html .= '<header>'; |
| 1396 | 1396 | |
| 1397 | - $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1397 | + $complete_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>'; |
|
| 1398 | 1398 | |
| 1399 | 1399 | $complete_html .= '</header>'; |
| 1400 | 1400 | |
@@ -1403,46 +1403,46 @@ discard block |
||
| 1403 | 1403 | $complete_html .= '<p class="sensei-course-meta">'; |
| 1404 | 1404 | |
| 1405 | 1405 | // Author |
| 1406 | - $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1407 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1408 | - $complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 1406 | + $user_info = get_userdata(absint($course_item->post_author)); |
|
| 1407 | + if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { |
|
| 1408 | + $complete_html .= '<span class="course-author">'.__('by ', 'woothemes-sensei').'<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>'; |
|
| 1409 | 1409 | } // End If Statement |
| 1410 | 1410 | |
| 1411 | 1411 | // Lesson count for this author |
| 1412 | 1412 | $complete_html .= '<span class="course-lesson-count">' |
| 1413 | - . Sensei()->course->course_lesson_count( absint( $course_item->ID ) ) |
|
| 1414 | - . ' ' . __( 'Lessons', 'woothemes-sensei' ) |
|
| 1413 | + . Sensei()->course->course_lesson_count(absint($course_item->ID)) |
|
| 1414 | + . ' '.__('Lessons', 'woothemes-sensei') |
|
| 1415 | 1415 | . '</span>'; |
| 1416 | 1416 | |
| 1417 | 1417 | // Course Categories |
| 1418 | - if ( '' != $category_output ) { |
|
| 1418 | + if ('' != $category_output) { |
|
| 1419 | 1419 | |
| 1420 | - $complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1420 | + $complete_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>'; |
|
| 1421 | 1421 | |
| 1422 | 1422 | } // End If Statement |
| 1423 | 1423 | |
| 1424 | 1424 | $complete_html .= '</p>'; |
| 1425 | 1425 | |
| 1426 | - $complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
|
| 1426 | + $complete_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>'; |
|
| 1427 | 1427 | |
| 1428 | - $complete_html .= $this->get_progress_meter( 100 ); |
|
| 1428 | + $complete_html .= $this->get_progress_meter(100); |
|
| 1429 | 1429 | |
| 1430 | - if( $manage ) { |
|
| 1431 | - $has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true ); |
|
| 1430 | + if ($manage) { |
|
| 1431 | + $has_quizzes = Sensei()->course->course_quizzes($course_item->ID, true); |
|
| 1432 | 1432 | // Output only if there is content to display |
| 1433 | - if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { |
|
| 1433 | + if (has_filter('sensei_results_links') || $has_quizzes) { |
|
| 1434 | 1434 | |
| 1435 | 1435 | |
| 1436 | 1436 | $complete_html .= '<p class="sensei-results-links">'; |
| 1437 | 1437 | $results_link = ''; |
| 1438 | - if( $has_quizzes ) { |
|
| 1438 | + if ($has_quizzes) { |
|
| 1439 | 1439 | |
| 1440 | 1440 | $results_link = '<a class="button view-results" href="' |
| 1441 | - . Sensei()->course_results->get_permalink( $course_item->ID ) |
|
| 1442 | - . '">' . __( 'View results', 'woothemes-sensei' ) |
|
| 1441 | + . Sensei()->course_results->get_permalink($course_item->ID) |
|
| 1442 | + . '">'.__('View results', 'woothemes-sensei') |
|
| 1443 | 1443 | . '</a>'; |
| 1444 | 1444 | } |
| 1445 | - $complete_html .= apply_filters( 'sensei_results_links', $results_link ); |
|
| 1445 | + $complete_html .= apply_filters('sensei_results_links', $results_link); |
|
| 1446 | 1446 | $complete_html .= '</p>'; |
| 1447 | 1447 | |
| 1448 | 1448 | } |
@@ -1454,35 +1454,35 @@ discard block |
||
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | 1456 | // Active pagination |
| 1457 | - if( $completed_count > $per_page ) { |
|
| 1457 | + if ($completed_count > $per_page) { |
|
| 1458 | 1458 | |
| 1459 | 1459 | $current_page = 1; |
| 1460 | - if( isset( $_GET['completed_page'] ) && 0 < intval( $_GET['completed_page'] ) ) { |
|
| 1460 | + if (isset($_GET['completed_page']) && 0 < intval($_GET['completed_page'])) { |
|
| 1461 | 1461 | $current_page = $_GET['completed_page']; |
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | 1464 | $complete_html .= '<nav class="pagination woo-pagination">'; |
| 1465 | - $total_pages = ceil( $completed_count / $per_page ); |
|
| 1465 | + $total_pages = ceil($completed_count / $per_page); |
|
| 1466 | 1466 | |
| 1467 | 1467 | |
| 1468 | - if( $current_page > 1 ) { |
|
| 1469 | - $prev_link = add_query_arg( 'completed_page', $current_page - 1 ); |
|
| 1470 | - $complete_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> '; |
|
| 1468 | + if ($current_page > 1) { |
|
| 1469 | + $prev_link = add_query_arg('completed_page', $current_page - 1); |
|
| 1470 | + $complete_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> '; |
|
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | - for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
| 1474 | - $link = add_query_arg( 'completed_page', $i ); |
|
| 1473 | + for ($i = 1; $i <= $total_pages; $i++) { |
|
| 1474 | + $link = add_query_arg('completed_page', $i); |
|
| 1475 | 1475 | |
| 1476 | - if( $i == $current_page ) { |
|
| 1477 | - $complete_html .= '<span class="page-numbers current">' . $i . '</span> '; |
|
| 1476 | + if ($i == $current_page) { |
|
| 1477 | + $complete_html .= '<span class="page-numbers current">'.$i.'</span> '; |
|
| 1478 | 1478 | } else { |
| 1479 | - $complete_html .= '<a class="page-numbers" href="' . esc_url( $link ) . '">' . $i . '</a> '; |
|
| 1479 | + $complete_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> '; |
|
| 1480 | 1480 | } |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - if( $current_page < $total_pages ) { |
|
| 1484 | - $next_link = add_query_arg( 'completed_page', $current_page + 1 ); |
|
| 1485 | - $complete_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> '; |
|
| 1483 | + if ($current_page < $total_pages) { |
|
| 1484 | + $next_link = add_query_arg('completed_page', $current_page + 1); |
|
| 1485 | + $complete_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> '; |
|
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | $complete_html .= '</nav>'; |
@@ -1490,26 +1490,26 @@ discard block |
||
| 1490 | 1490 | |
| 1491 | 1491 | } // End If Statement |
| 1492 | 1492 | |
| 1493 | - if( $manage ) { |
|
| 1494 | - $no_active_message = __( 'You have no active courses.', 'woothemes-sensei' ); |
|
| 1495 | - $no_complete_message = __( 'You have not completed any courses yet.', 'woothemes-sensei' ); |
|
| 1493 | + if ($manage) { |
|
| 1494 | + $no_active_message = __('You have no active courses.', 'woothemes-sensei'); |
|
| 1495 | + $no_complete_message = __('You have not completed any courses yet.', 'woothemes-sensei'); |
|
| 1496 | 1496 | } else { |
| 1497 | - $no_active_message = __( 'This learner has no active courses.', 'woothemes-sensei' ); |
|
| 1498 | - $no_complete_message = __( 'This learner has not completed any courses yet.', 'woothemes-sensei' ); |
|
| 1497 | + $no_active_message = __('This learner has no active courses.', 'woothemes-sensei'); |
|
| 1498 | + $no_complete_message = __('This learner has not completed any courses yet.', 'woothemes-sensei'); |
|
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | ob_start(); |
| 1502 | 1502 | ?> |
| 1503 | 1503 | |
| 1504 | - <?php do_action( 'sensei_before_user_courses' ); ?> |
|
| 1504 | + <?php do_action('sensei_before_user_courses'); ?> |
|
| 1505 | 1505 | |
| 1506 | 1506 | <?php |
| 1507 | - if( $manage && ( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) ) { |
|
| 1507 | + if ($manage && ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable'])) { |
|
| 1508 | 1508 | ?> |
| 1509 | 1509 | <p class="my-messages-link-container"> |
| 1510 | - <a class="my-messages-link" href="<?php echo get_post_type_archive_link( 'sensei_message' ); ?>" |
|
| 1511 | - title="<?php _e( 'View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei' ); ?>"> |
|
| 1512 | - <?php _e( 'My Messages', 'woothemes-sensei' ); ?> |
|
| 1510 | + <a class="my-messages-link" href="<?php echo get_post_type_archive_link('sensei_message'); ?>" |
|
| 1511 | + title="<?php _e('View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei'); ?>"> |
|
| 1512 | + <?php _e('My Messages', 'woothemes-sensei'); ?> |
|
| 1513 | 1513 | </a> |
| 1514 | 1514 | </p> |
| 1515 | 1515 | <?php |
@@ -1518,11 +1518,11 @@ discard block |
||
| 1518 | 1518 | <div id="my-courses"> |
| 1519 | 1519 | |
| 1520 | 1520 | <ul> |
| 1521 | - <li><a href="#active-courses"><?php _e( 'Active Courses', 'woothemes-sensei' ); ?></a></li> |
|
| 1522 | - <li><a href="#completed-courses"><?php _e( 'Completed Courses', 'woothemes-sensei' ); ?></a></li> |
|
| 1521 | + <li><a href="#active-courses"><?php _e('Active Courses', 'woothemes-sensei'); ?></a></li> |
|
| 1522 | + <li><a href="#completed-courses"><?php _e('Completed Courses', 'woothemes-sensei'); ?></a></li> |
|
| 1523 | 1523 | </ul> |
| 1524 | 1524 | |
| 1525 | - <?php do_action( 'sensei_before_active_user_courses' ); ?> |
|
| 1525 | + <?php do_action('sensei_before_active_user_courses'); ?> |
|
| 1526 | 1526 | |
| 1527 | 1527 | <?php |
| 1528 | 1528 | $course_page_url = Sensei_Course::get_courses_page_url(); |
@@ -1530,7 +1530,7 @@ discard block |
||
| 1530 | 1530 | |
| 1531 | 1531 | <div id="active-courses"> |
| 1532 | 1532 | |
| 1533 | - <?php if ( '' != $active_html ) { |
|
| 1533 | + <?php if ('' != $active_html) { |
|
| 1534 | 1534 | |
| 1535 | 1535 | echo $active_html; |
| 1536 | 1536 | |
@@ -1542,7 +1542,7 @@ discard block |
||
| 1542 | 1542 | |
| 1543 | 1543 | <a href="<?php echo $course_page_url; ?>"> |
| 1544 | 1544 | |
| 1545 | - <?php _e( 'Start a Course!', 'woothemes-sensei' ); ?> |
|
| 1545 | + <?php _e('Start a Course!', 'woothemes-sensei'); ?> |
|
| 1546 | 1546 | |
| 1547 | 1547 | </a> |
| 1548 | 1548 | |
@@ -1552,13 +1552,13 @@ discard block |
||
| 1552 | 1552 | |
| 1553 | 1553 | </div> |
| 1554 | 1554 | |
| 1555 | - <?php do_action( 'sensei_after_active_user_courses' ); ?> |
|
| 1555 | + <?php do_action('sensei_after_active_user_courses'); ?> |
|
| 1556 | 1556 | |
| 1557 | - <?php do_action( 'sensei_before_completed_user_courses' ); ?> |
|
| 1557 | + <?php do_action('sensei_before_completed_user_courses'); ?> |
|
| 1558 | 1558 | |
| 1559 | 1559 | <div id="completed-courses"> |
| 1560 | 1560 | |
| 1561 | - <?php if ( '' != $complete_html ) { |
|
| 1561 | + <?php if ('' != $complete_html) { |
|
| 1562 | 1562 | |
| 1563 | 1563 | echo $complete_html; |
| 1564 | 1564 | |
@@ -1574,16 +1574,16 @@ discard block |
||
| 1574 | 1574 | |
| 1575 | 1575 | </div> |
| 1576 | 1576 | |
| 1577 | - <?php do_action( 'sensei_after_completed_user_courses' ); ?> |
|
| 1577 | + <?php do_action('sensei_after_completed_user_courses'); ?> |
|
| 1578 | 1578 | |
| 1579 | 1579 | </div> |
| 1580 | 1580 | |
| 1581 | - <?php do_action( 'sensei_after_user_courses' ); ?> |
|
| 1581 | + <?php do_action('sensei_after_user_courses'); ?> |
|
| 1582 | 1582 | |
| 1583 | 1583 | <?php |
| 1584 | 1584 | echo ob_get_clean(); |
| 1585 | 1585 | |
| 1586 | - do_action( 'sensei_after_learner_course_content', $user ); |
|
| 1586 | + do_action('sensei_after_learner_course_content', $user); |
|
| 1587 | 1587 | |
| 1588 | 1588 | } // end load_user_courses_content |
| 1589 | 1589 | |
@@ -1595,7 +1595,7 @@ discard block |
||
| 1595 | 1595 | * @type $course WP_Post |
| 1596 | 1596 | * } |
| 1597 | 1597 | */ |
| 1598 | - public static function get_all_courses(){ |
|
| 1598 | + public static function get_all_courses() { |
|
| 1599 | 1599 | |
| 1600 | 1600 | $args = array( |
| 1601 | 1601 | 'post_type' => 'course', |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | 'suppress_filters' => 0, |
| 1607 | 1607 | ); |
| 1608 | 1608 | |
| 1609 | - $wp_query_obj = new WP_Query( $args ); |
|
| 1609 | + $wp_query_obj = new WP_Query($args); |
|
| 1610 | 1610 | |
| 1611 | 1611 | /** |
| 1612 | 1612 | * sensei_get_all_courses filter |
@@ -1618,7 +1618,7 @@ discard block |
||
| 1618 | 1618 | * } |
| 1619 | 1619 | * @param array $attributes |
| 1620 | 1620 | */ |
| 1621 | - return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts ); |
|
| 1621 | + return apply_filters('sensei_get_all_courses', $wp_query_obj->posts); |
|
| 1622 | 1622 | |
| 1623 | 1623 | }// end get_all_courses |
| 1624 | 1624 | |
@@ -1629,16 +1629,16 @@ discard block |
||
| 1629 | 1629 | * @param int $progress_percentage 0 - 100 |
| 1630 | 1630 | * @return string $progress_bar_html |
| 1631 | 1631 | */ |
| 1632 | - public function get_progress_meter( $progress_percentage ){ |
|
| 1632 | + public function get_progress_meter($progress_percentage) { |
|
| 1633 | 1633 | |
| 1634 | - if ( 50 < $progress_percentage ) { |
|
| 1634 | + if (50 < $progress_percentage) { |
|
| 1635 | 1635 | $class = ' green'; |
| 1636 | - } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) { |
|
| 1636 | + } elseif (25 <= $progress_percentage && 50 >= $progress_percentage) { |
|
| 1637 | 1637 | $class = ' orange'; |
| 1638 | 1638 | } else { |
| 1639 | 1639 | $class = ' red'; |
| 1640 | 1640 | } |
| 1641 | - $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>'; |
|
| 1641 | + $progress_bar_html = '<div class="meter'.esc_attr($class).'"><span style="width: '.$progress_percentage.'%">'.round($progress_percentage).'%</span></div>'; |
|
| 1642 | 1642 | |
| 1643 | 1643 | return $progress_bar_html; |
| 1644 | 1644 | |
@@ -1653,17 +1653,17 @@ discard block |
||
| 1653 | 1653 | * |
| 1654 | 1654 | * @return string $statement_html |
| 1655 | 1655 | */ |
| 1656 | - public function get_progress_statement( $course_id, $user_id ){ |
|
| 1656 | + public function get_progress_statement($course_id, $user_id) { |
|
| 1657 | 1657 | |
| 1658 | - if( empty( $course_id ) || empty( $user_id ) |
|
| 1659 | - || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){ |
|
| 1658 | + if (empty($course_id) || empty($user_id) |
|
| 1659 | + || ! Sensei_Utils::user_started_course($course_id, $user_id)) { |
|
| 1660 | 1660 | return ''; |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | - $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1664 | - $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1663 | + $completed = count($this->get_completed_lesson_ids($course_id, $user_id)); |
|
| 1664 | + $total_lessons = count($this->course_lessons($course_id)); |
|
| 1665 | 1665 | |
| 1666 | - $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons ); |
|
| 1666 | + $statement = sprintf(_n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons); |
|
| 1667 | 1667 | |
| 1668 | 1668 | /** |
| 1669 | 1669 | * Filter the course completion statement. |
@@ -1671,7 +1671,7 @@ discard block |
||
| 1671 | 1671 | * |
| 1672 | 1672 | * @param string $statement |
| 1673 | 1673 | */ |
| 1674 | - return apply_filters( 'sensei_course_completion_statement', $statement ); |
|
| 1674 | + return apply_filters('sensei_course_completion_statement', $statement); |
|
| 1675 | 1675 | |
| 1676 | 1676 | }// end generate_progress_statement |
| 1677 | 1677 | |
@@ -1681,17 +1681,17 @@ discard block |
||
| 1681 | 1681 | * @param $course_id |
| 1682 | 1682 | * @return void |
| 1683 | 1683 | */ |
| 1684 | - public function the_progress_statement( $course_id = 0, $user_id = 0 ){ |
|
| 1685 | - if( empty( $course_id ) ){ |
|
| 1684 | + public function the_progress_statement($course_id = 0, $user_id = 0) { |
|
| 1685 | + if (empty($course_id)) { |
|
| 1686 | 1686 | global $post; |
| 1687 | 1687 | $course_id = $post->ID; |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - if( empty( $user_id ) ){ |
|
| 1690 | + if (empty($user_id)) { |
|
| 1691 | 1691 | $user_id = get_current_user_id(); |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | - echo '<span class="progress statement course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id ) . '</span>'; |
|
| 1694 | + echo '<span class="progress statement course-completion-rate">'.$this->get_progress_statement($course_id, $user_id).'</span>'; |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | 1697 | /** |
@@ -1700,24 +1700,24 @@ discard block |
||
| 1700 | 1700 | * @param $course_id |
| 1701 | 1701 | * @return void |
| 1702 | 1702 | */ |
| 1703 | - public function the_progress_meter( $course_id = 0, $user_id = 0 ){ |
|
| 1703 | + public function the_progress_meter($course_id = 0, $user_id = 0) { |
|
| 1704 | 1704 | |
| 1705 | - if( empty( $course_id ) ){ |
|
| 1705 | + if (empty($course_id)) { |
|
| 1706 | 1706 | global $post; |
| 1707 | 1707 | $course_id = $post->ID; |
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | - if( empty( $user_id ) ){ |
|
| 1710 | + if (empty($user_id)) { |
|
| 1711 | 1711 | $user_id = get_current_user_id(); |
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | - if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id ) |
|
| 1715 | - || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){ |
|
| 1714 | + if ('course' != get_post_type($course_id) || ! get_userdata($user_id) |
|
| 1715 | + || ! Sensei_Utils::user_started_course($course_id, $user_id)) { |
|
| 1716 | 1716 | return; |
| 1717 | 1717 | } |
| 1718 | - $percentage_completed = $this->get_completion_percentage( $course_id, $user_id ); |
|
| 1718 | + $percentage_completed = $this->get_completion_percentage($course_id, $user_id); |
|
| 1719 | 1719 | |
| 1720 | - echo $this->get_progress_meter( $percentage_completed ); |
|
| 1720 | + echo $this->get_progress_meter($percentage_completed); |
|
| 1721 | 1721 | |
| 1722 | 1722 | }// end the_progress_meter |
| 1723 | 1723 | |
@@ -1730,20 +1730,20 @@ discard block |
||
| 1730 | 1730 | * @param int $user_id |
| 1731 | 1731 | * @return array $completed_lesson_ids |
| 1732 | 1732 | */ |
| 1733 | - public function get_completed_lesson_ids( $course_id, $user_id = 0 ){ |
|
| 1733 | + public function get_completed_lesson_ids($course_id, $user_id = 0) { |
|
| 1734 | 1734 | |
| 1735 | - if( !( intval( $user_id ) ) > 0 ){ |
|
| 1735 | + if ( ! (intval($user_id)) > 0) { |
|
| 1736 | 1736 | $user_id = get_current_user_id(); |
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | 1739 | $completed_lesson_ids = array(); |
| 1740 | 1740 | |
| 1741 | - $course_lessons = $this->course_lessons( $course_id ); |
|
| 1741 | + $course_lessons = $this->course_lessons($course_id); |
|
| 1742 | 1742 | |
| 1743 | - foreach( $course_lessons as $lesson ){ |
|
| 1743 | + foreach ($course_lessons as $lesson) { |
|
| 1744 | 1744 | |
| 1745 | - $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id ); |
|
| 1746 | - if( $is_lesson_completed ){ |
|
| 1745 | + $is_lesson_completed = Sensei_Utils::user_completed_lesson($lesson->ID, $user_id); |
|
| 1746 | + if ($is_lesson_completed) { |
|
| 1747 | 1747 | $completed_lesson_ids[] = $lesson->ID; |
| 1748 | 1748 | } |
| 1749 | 1749 | |
@@ -1762,19 +1762,19 @@ discard block |
||
| 1762 | 1762 | * @param int $user_id |
| 1763 | 1763 | * @return int $percentage |
| 1764 | 1764 | */ |
| 1765 | - public function get_completion_percentage( $course_id, $user_id = 0 ){ |
|
| 1765 | + public function get_completion_percentage($course_id, $user_id = 0) { |
|
| 1766 | 1766 | |
| 1767 | - if( !( intval( $user_id ) ) > 0 ){ |
|
| 1767 | + if ( ! (intval($user_id)) > 0) { |
|
| 1768 | 1768 | $user_id = get_current_user_id(); |
| 1769 | 1769 | } |
| 1770 | 1770 | |
| 1771 | - $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1771 | + $completed = count($this->get_completed_lesson_ids($course_id, $user_id)); |
|
| 1772 | 1772 | |
| 1773 | - if( ! ( $completed > 0 ) ){ |
|
| 1773 | + if ( ! ($completed > 0)) { |
|
| 1774 | 1774 | return 0; |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | - $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1777 | + $total_lessons = count($this->course_lessons($course_id)); |
|
| 1778 | 1778 | $percentage = $completed / $total_lessons * 100; |
| 1779 | 1779 | |
| 1780 | 1780 | /** |
@@ -1786,7 +1786,7 @@ discard block |
||
| 1786 | 1786 | * @param $user_id |
| 1787 | 1787 | * @since 1.8.0 |
| 1788 | 1788 | */ |
| 1789 | - return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id ); |
|
| 1789 | + return apply_filters('sensei_course_completion_percentage', $percentage, $course_id, $user_id); |
|
| 1790 | 1790 | |
| 1791 | 1791 | }// end get_completed_lesson_ids |
| 1792 | 1792 | |
@@ -1798,28 +1798,28 @@ discard block |
||
| 1798 | 1798 | * @param $should_send |
| 1799 | 1799 | * @return bool |
| 1800 | 1800 | */ |
| 1801 | - public function block_notification_emails( $should_send ){ |
|
| 1801 | + public function block_notification_emails($should_send) { |
|
| 1802 | 1802 | global $sensei_email_data; |
| 1803 | 1803 | $email = $sensei_email_data; |
| 1804 | 1804 | |
| 1805 | 1805 | $course_id = ''; |
| 1806 | 1806 | |
| 1807 | - if( isset( $email['course_id'] ) ){ |
|
| 1807 | + if (isset($email['course_id'])) { |
|
| 1808 | 1808 | |
| 1809 | 1809 | $course_id = $email['course_id']; |
| 1810 | 1810 | |
| 1811 | - }elseif( isset( $email['lesson_id'] ) ){ |
|
| 1811 | + }elseif (isset($email['lesson_id'])) { |
|
| 1812 | 1812 | |
| 1813 | - $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] ); |
|
| 1813 | + $course_id = Sensei()->lesson->get_course_id($email['lesson_id']); |
|
| 1814 | 1814 | |
| 1815 | - }elseif( isset( $email['quiz_id'] ) ){ |
|
| 1815 | + }elseif (isset($email['quiz_id'])) { |
|
| 1816 | 1816 | |
| 1817 | - $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] ); |
|
| 1818 | - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 1817 | + $lesson_id = Sensei()->quiz->get_lesson_id($email['quiz_id']); |
|
| 1818 | + $course_id = Sensei()->lesson->get_course_id($lesson_id); |
|
| 1819 | 1819 | |
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | - if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) { |
|
| 1822 | + if ( ! empty($course_id) && 'course' == get_post_type($course_id)) { |
|
| 1823 | 1823 | |
| 1824 | 1824 | $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true); |
| 1825 | 1825 | |
@@ -1840,19 +1840,19 @@ discard block |
||
| 1840 | 1840 | * @since 1.8.0 |
| 1841 | 1841 | * @param $course |
| 1842 | 1842 | */ |
| 1843 | - public function course_notification_meta_box_content( $course ){ |
|
| 1843 | + public function course_notification_meta_box_content($course) { |
|
| 1844 | 1844 | |
| 1845 | - $checked = get_post_meta( $course->ID , 'disable_notification', true ); |
|
| 1845 | + $checked = get_post_meta($course->ID, 'disable_notification', true); |
|
| 1846 | 1846 | |
| 1847 | 1847 | // generate checked html |
| 1848 | 1848 | $checked_html = ''; |
| 1849 | - if( $checked ){ |
|
| 1849 | + if ($checked) { |
|
| 1850 | 1850 | $checked_html = 'checked="checked"'; |
| 1851 | 1851 | } |
| 1852 | - wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' ); |
|
| 1852 | + wp_nonce_field('update-course-notification-setting', '_sensei_course_notification'); |
|
| 1853 | 1853 | |
| 1854 | - echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >'; |
|
| 1855 | - echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>'; |
|
| 1854 | + echo '<input id="disable_sensei_course_notification" '.$checked_html.' type="checkbox" name="disable_sensei_course_notification" >'; |
|
| 1855 | + echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei').'</label>'; |
|
| 1856 | 1856 | |
| 1857 | 1857 | }// end course_notification_meta_box_content |
| 1858 | 1858 | |
@@ -1864,20 +1864,20 @@ discard block |
||
| 1864 | 1864 | * |
| 1865 | 1865 | * @param $course_id |
| 1866 | 1866 | */ |
| 1867 | - public function save_course_notification_meta_box( $course_id ){ |
|
| 1867 | + public function save_course_notification_meta_box($course_id) { |
|
| 1868 | 1868 | |
| 1869 | - if( !isset( $_POST['_sensei_course_notification'] ) |
|
| 1870 | - || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){ |
|
| 1869 | + if ( ! isset($_POST['_sensei_course_notification']) |
|
| 1870 | + || ! wp_verify_nonce($_POST['_sensei_course_notification'], 'update-course-notification-setting')) { |
|
| 1871 | 1871 | return; |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | - if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification'] ) { |
|
| 1874 | + if (isset($_POST['disable_sensei_course_notification']) && 'on' == $_POST['disable_sensei_course_notification']) { |
|
| 1875 | 1875 | $new_val = true; |
| 1876 | - }else{ |
|
| 1876 | + } else { |
|
| 1877 | 1877 | $new_val = false; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - update_post_meta( $course_id , 'disable_notification', $new_val ); |
|
| 1880 | + update_post_meta($course_id, 'disable_notification', $new_val); |
|
| 1881 | 1881 | |
| 1882 | 1882 | }// end save notification meta box |
| 1883 | 1883 | |
@@ -1891,10 +1891,10 @@ discard block |
||
| 1891 | 1891 | * |
| 1892 | 1892 | * @param WP_Post $post |
| 1893 | 1893 | */ |
| 1894 | - public function content_before_backwards_compatibility_hooks( $post ){ |
|
| 1894 | + public function content_before_backwards_compatibility_hooks($post) { |
|
| 1895 | 1895 | |
| 1896 | - sensei_do_deprecated_action( 'sensei_course_image','1.9.0','sensei_course_content_inside_before' ); |
|
| 1897 | - sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before' ); |
|
| 1896 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_course_content_inside_before'); |
|
| 1897 | + sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before'); |
|
| 1898 | 1898 | |
| 1899 | 1899 | } |
| 1900 | 1900 | |
@@ -1907,10 +1907,10 @@ discard block |
||
| 1907 | 1907 | * |
| 1908 | 1908 | * @global WP_Post $post |
| 1909 | 1909 | */ |
| 1910 | - public function loop_before_backwards_compatibility_hooks( ){ |
|
| 1910 | + public function loop_before_backwards_compatibility_hooks( ) { |
|
| 1911 | 1911 | |
| 1912 | 1912 | global $post; |
| 1913 | - sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type ); |
|
| 1913 | + sensei_do_deprecated_action('sensei_course_archive_header', '1.9.0', 'sensei_course_content_inside_before', $post->post_type); |
|
| 1914 | 1914 | |
| 1915 | 1915 | } |
| 1916 | 1916 | |
@@ -1923,18 +1923,18 @@ discard block |
||
| 1923 | 1923 | * |
| 1924 | 1924 | * @param WP_Post $course |
| 1925 | 1925 | */ |
| 1926 | - public function the_course_free_lesson_preview( $course ){ |
|
| 1926 | + public function the_course_free_lesson_preview($course) { |
|
| 1927 | 1927 | // Meta data |
| 1928 | - $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) ); |
|
| 1929 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 1928 | + $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course->ID)); |
|
| 1929 | + $is_user_taking_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id()); |
|
| 1930 | 1930 | |
| 1931 | - if ( 0 < $preview_lesson_count && !$is_user_taking_course ) { |
|
| 1931 | + if (0 < $preview_lesson_count && ! $is_user_taking_course) { |
|
| 1932 | 1932 | ?> |
| 1933 | 1933 | <p class="sensei-free-lessons"> |
| 1934 | 1934 | <a href="<?php echo get_permalink(); ?>"> |
| 1935 | - <?php _e( 'Preview this course', 'woothemes-sensei' ) ?> |
|
| 1935 | + <?php _e('Preview this course', 'woothemes-sensei') ?> |
|
| 1936 | 1936 | </a> |
| 1937 | - - <?php echo sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ) ; ?> |
|
| 1937 | + - <?php echo sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?> |
|
| 1938 | 1938 | </p> |
| 1939 | 1939 | |
| 1940 | 1940 | <?php |
@@ -1947,38 +1947,38 @@ discard block |
||
| 1947 | 1947 | * @since 1.9.0 |
| 1948 | 1948 | * @param WP_Post $course |
| 1949 | 1949 | */ |
| 1950 | - public function the_course_meta( $course ){ |
|
| 1950 | + public function the_course_meta($course) { |
|
| 1951 | 1951 | echo '<p class="sensei-course-meta">'; |
| 1952 | 1952 | |
| 1953 | - $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' ); |
|
| 1954 | - $author_display_name = get_the_author_meta( 'display_name', $course->post_author ); |
|
| 1953 | + $category_output = get_the_term_list($course->ID, 'course-category', '', ', ', ''); |
|
| 1954 | + $author_display_name = get_the_author_meta('display_name', $course->post_author); |
|
| 1955 | 1955 | |
| 1956 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?> |
|
| 1956 | + if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {?> |
|
| 1957 | 1957 | |
| 1958 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?> |
|
| 1958 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?> |
|
| 1959 | 1959 | |
| 1960 | - <a href="<?php esc_attr_e( get_author_posts_url( $course->post_author ) ); ?>" title="<?php esc_attr_e( $author_display_name ); ?>"><?php esc_attr_e( $author_display_name ); ?></a> |
|
| 1960 | + <a href="<?php esc_attr_e(get_author_posts_url($course->post_author)); ?>" title="<?php esc_attr_e($author_display_name); ?>"><?php esc_attr_e($author_display_name); ?></a> |
|
| 1961 | 1961 | |
| 1962 | 1962 | </span> |
| 1963 | 1963 | |
| 1964 | 1964 | <?php } // End If Statement ?> |
| 1965 | 1965 | |
| 1966 | - <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $course->ID ) . ' ' . __( 'Lessons', 'woothemes-sensei' ); ?></span> |
|
| 1966 | + <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($course->ID).' '.__('Lessons', 'woothemes-sensei'); ?></span> |
|
| 1967 | 1967 | |
| 1968 | - <?php if ( '' != $category_output ) { ?> |
|
| 1968 | + <?php if ('' != $category_output) { ?> |
|
| 1969 | 1969 | |
| 1970 | - <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span> |
|
| 1970 | + <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span> |
|
| 1971 | 1971 | |
| 1972 | 1972 | <?php } // End If Statement |
| 1973 | 1973 | |
| 1974 | 1974 | // number of completed lessons |
| 1975 | - if( is_user_logged_in() ){ |
|
| 1976 | - $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) ); |
|
| 1977 | - $lesson_count = count( $this->course_lessons( $course->ID ) ); |
|
| 1978 | - echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count ) . '</span>'; |
|
| 1975 | + if (is_user_logged_in()) { |
|
| 1976 | + $completed = count($this->get_completed_lesson_ids($course->ID, get_current_user_id())); |
|
| 1977 | + $lesson_count = count($this->course_lessons($course->ID)); |
|
| 1978 | + echo '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $completed, $lesson_count).'</span>'; |
|
| 1979 | 1979 | } |
| 1980 | 1980 | |
| 1981 | - sensei_simple_course_price( $course->ID ); |
|
| 1981 | + sensei_simple_course_price($course->ID); |
|
| 1982 | 1982 | |
| 1983 | 1983 | echo '</p>'; |
| 1984 | 1984 | } // end the course meta |
@@ -1993,15 +1993,15 @@ discard block |
||
| 1993 | 1993 | * |
| 1994 | 1994 | * @return array $classes |
| 1995 | 1995 | */ |
| 1996 | - public static function add_course_user_status_class( $classes, $class, $course_id ){ |
|
| 1996 | + public static function add_course_user_status_class($classes, $class, $course_id) { |
|
| 1997 | 1997 | |
| 1998 | - if( 'course' == get_post_type( $course_id ) && is_user_logged_in() ){ |
|
| 1998 | + if ('course' == get_post_type($course_id) && is_user_logged_in()) { |
|
| 1999 | 1999 | |
| 2000 | - if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){ |
|
| 2000 | + if (Sensei_Utils::user_completed_course($course_id, get_current_user_id())) { |
|
| 2001 | 2001 | |
| 2002 | 2002 | $classes[] = 'user-status-completed'; |
| 2003 | 2003 | |
| 2004 | - }else{ |
|
| 2004 | + } else { |
|
| 2005 | 2005 | |
| 2006 | 2006 | $classes[] = 'user-status-active'; |
| 2007 | 2007 | |
@@ -2021,56 +2021,56 @@ discard block |
||
| 2021 | 2021 | * |
| 2022 | 2022 | * @param WP_Post $course |
| 2023 | 2023 | */ |
| 2024 | - public static function the_course_action_buttons( $course ){ |
|
| 2024 | + public static function the_course_action_buttons($course) { |
|
| 2025 | 2025 | |
| 2026 | - if( is_user_logged_in() ) { ?> |
|
| 2026 | + if (is_user_logged_in()) { ?> |
|
| 2027 | 2027 | |
| 2028 | 2028 | <section class="entry-actions"> |
| 2029 | - <form method="POST" action="<?php echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>"> |
|
| 2029 | + <form method="POST" action="<?php echo esc_url(remove_query_arg(array('active_page', 'completed_page'))); ?>"> |
|
| 2030 | 2030 | |
| 2031 | 2031 | <input type="hidden" |
| 2032 | - name="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ) ?>" |
|
| 2033 | - id="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ); ?>" |
|
| 2034 | - value="<?php esc_attr_e( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ); ?>" |
|
| 2032 | + name="<?php esc_attr_e('woothemes_sensei_complete_course_noonce') ?>" |
|
| 2033 | + id="<?php esc_attr_e('woothemes_sensei_complete_course_noonce'); ?>" |
|
| 2034 | + value="<?php esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce')); ?>" |
|
| 2035 | 2035 | /> |
| 2036 | 2036 | |
| 2037 | - <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e( intval( $course->ID ) ); ?>" /> |
|
| 2037 | + <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e(intval($course->ID)); ?>" /> |
|
| 2038 | 2038 | |
| 2039 | - <?php if ( 0 < absint( count( Sensei()->course->course_lessons( $course->ID ) ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { ?> |
|
| 2039 | + <?php if (0 < absint(count(Sensei()->course->course_lessons($course->ID))) && Sensei()->settings->settings['course_completion'] == 'complete') { ?> |
|
| 2040 | 2040 | |
| 2041 | - <span><input name="course_complete" type="submit" class="course-complete" value="<?php _e( 'Mark as Complete', 'woothemes-sensei' ); ?>" /></span> |
|
| 2041 | + <span><input name="course_complete" type="submit" class="course-complete" value="<?php _e('Mark as Complete', 'woothemes-sensei'); ?>" /></span> |
|
| 2042 | 2042 | |
| 2043 | 2043 | <?php } // End If Statement |
| 2044 | 2044 | |
| 2045 | 2045 | $course_purchased = false; |
| 2046 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 2046 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 2047 | 2047 | // Get the product ID |
| 2048 | - $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true ); |
|
| 2049 | - if ( 0 < $wc_post_id ) { |
|
| 2048 | + $wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true); |
|
| 2049 | + if (0 < $wc_post_id) { |
|
| 2050 | 2050 | |
| 2051 | 2051 | $user = wp_get_current_user(); |
| 2052 | - $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id ); |
|
| 2052 | + $course_purchased = Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id); |
|
| 2053 | 2053 | |
| 2054 | 2054 | } // End If Statement |
| 2055 | 2055 | } // End If Statement |
| 2056 | 2056 | |
| 2057 | - if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?> |
|
| 2057 | + if ( ! $course_purchased && ! Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {?> |
|
| 2058 | 2058 | |
| 2059 | - <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span> |
|
| 2059 | + <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __('Delete Course', 'woothemes-sensei'); ?>"/></span> |
|
| 2060 | 2060 | |
| 2061 | 2061 | <?php } // End If Statement |
| 2062 | 2062 | |
| 2063 | - $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true ); |
|
| 2063 | + $has_quizzes = Sensei()->course->course_quizzes($course->ID, true); |
|
| 2064 | 2064 | $results_link = ''; |
| 2065 | - if( $has_quizzes ){ |
|
| 2066 | - $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2065 | + if ($has_quizzes) { |
|
| 2066 | + $results_link = '<a class="button view-results" href="'.Sensei()->course_results->get_permalink($course->ID).'">'.__('View results', 'woothemes-sensei').'</a>'; |
|
| 2067 | 2067 | } |
| 2068 | 2068 | |
| 2069 | 2069 | // Output only if there is content to display |
| 2070 | - if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2070 | + if (has_filter('sensei_results_links') || $has_quizzes) { ?> |
|
| 2071 | 2071 | |
| 2072 | 2072 | <p class="sensei-results-links"> |
| 2073 | - <?php echo apply_filters( 'sensei_results_links', $results_link ); ?> |
|
| 2073 | + <?php echo apply_filters('sensei_results_links', $results_link); ?> |
|
| 2074 | 2074 | </p> |
| 2075 | 2075 | |
| 2076 | 2076 | <?php } // end if has filter ?> |
@@ -2095,27 +2095,27 @@ discard block |
||
| 2095 | 2095 | * @param WP_Query $query |
| 2096 | 2096 | * @return WP_Query $query |
| 2097 | 2097 | */ |
| 2098 | - public static function course_query_filter( $query ){ |
|
| 2098 | + public static function course_query_filter($query) { |
|
| 2099 | 2099 | |
| 2100 | 2100 | // exit early for no course queries and admin queries |
| 2101 | - if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){ |
|
| 2101 | + if (is_admin( ) || 'course' != $query->get('post_type')) { |
|
| 2102 | 2102 | return $query; |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | 2105 | global $post; // used to get the current page id for my courses |
| 2106 | 2106 | |
| 2107 | 2107 | // for the course archive page |
| 2108 | - if( $query->is_main_query() && is_post_type_archive('course') ) |
|
| 2108 | + if ($query->is_main_query() && is_post_type_archive('course')) |
|
| 2109 | 2109 | { |
| 2110 | 2110 | |
| 2111 | - $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2111 | + $query->set('posts_per_page', apply_filters('sensei_archive_courses_per_page', get_option('posts_per_page'))); |
|
| 2112 | 2112 | |
| 2113 | 2113 | } |
| 2114 | 2114 | // for the my courses page |
| 2115 | - elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID ) |
|
| 2115 | + elseif (is_page() && Sensei()->settings->get('my_course_page') == $post->ID) |
|
| 2116 | 2116 | { |
| 2117 | 2117 | |
| 2118 | - $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2118 | + $query->set('posts_per_page', apply_filters('sensei_my_courses_per_page', get_option('posts_per_page'))); |
|
| 2119 | 2119 | |
| 2120 | 2120 | } |
| 2121 | 2121 | |
@@ -2131,21 +2131,21 @@ discard block |
||
| 2131 | 2131 | * @return array $extra_classes |
| 2132 | 2132 | * @since 1.9.0 |
| 2133 | 2133 | */ |
| 2134 | - public static function get_course_loop_content_class () |
|
| 2134 | + public static function get_course_loop_content_class() |
|
| 2135 | 2135 | { |
| 2136 | 2136 | |
| 2137 | 2137 | global $sensei_course_loop; |
| 2138 | 2138 | |
| 2139 | 2139 | |
| 2140 | - if( !isset( $sensei_course_loop ) ){ |
|
| 2140 | + if ( ! isset($sensei_course_loop)) { |
|
| 2141 | 2141 | $sensei_course_loop = array(); |
| 2142 | 2142 | } |
| 2143 | 2143 | |
| 2144 | - if (!isset($sensei_course_loop['counter'])) { |
|
| 2144 | + if ( ! isset($sensei_course_loop['counter'])) { |
|
| 2145 | 2145 | $sensei_course_loop['counter'] = 0; |
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | - if (!isset($sensei_course_loop['columns'])) { |
|
| 2148 | + if ( ! isset($sensei_course_loop['columns'])) { |
|
| 2149 | 2149 | $sensei_course_loop['columns'] = self::get_loop_number_of_columns(); |
| 2150 | 2150 | } |
| 2151 | 2151 | |
@@ -2153,16 +2153,16 @@ discard block |
||
| 2153 | 2153 | $sensei_course_loop['counter']++; |
| 2154 | 2154 | |
| 2155 | 2155 | $extra_classes = array(); |
| 2156 | - if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns'] ){ |
|
| 2156 | + if (0 == ($sensei_course_loop['counter'] - 1) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']) { |
|
| 2157 | 2157 | $extra_classes[] = 'first'; |
| 2158 | 2158 | } |
| 2159 | 2159 | |
| 2160 | - if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns'] ){ |
|
| 2160 | + if (0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']) { |
|
| 2161 | 2161 | $extra_classes[] = 'last'; |
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | // add the item number to the classes as well. |
| 2165 | - $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter']; |
|
| 2165 | + $extra_classes[] = 'loop-item-number-'.$sensei_course_loop['counter']; |
|
| 2166 | 2166 | |
| 2167 | 2167 | /** |
| 2168 | 2168 | * Filter the course loop class the fires in the in get_course_loop_content_class function |
@@ -2173,7 +2173,7 @@ discard block |
||
| 2173 | 2173 | * @param array $extra_classes |
| 2174 | 2174 | * @param WP_Post $loop_current_course |
| 2175 | 2175 | */ |
| 2176 | - return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() ); |
|
| 2176 | + return apply_filters('sensei_course_loop_content_class', $extra_classes, get_post()); |
|
| 2177 | 2177 | |
| 2178 | 2178 | }// end get_course_loop_class |
| 2179 | 2179 | |
@@ -2183,7 +2183,7 @@ discard block |
||
| 2183 | 2183 | * @since 1.9.0 |
| 2184 | 2184 | * @return mixed|void |
| 2185 | 2185 | */ |
| 2186 | - public static function get_loop_number_of_columns(){ |
|
| 2186 | + public static function get_loop_number_of_columns() { |
|
| 2187 | 2187 | |
| 2188 | 2188 | /** |
| 2189 | 2189 | * Filter the number of columns on the course archive page. |
@@ -2203,10 +2203,10 @@ discard block |
||
| 2203 | 2203 | * @since 1.9.0 |
| 2204 | 2204 | * @param |
| 2205 | 2205 | */ |
| 2206 | - public static function course_archive_sorting( $query ){ |
|
| 2206 | + public static function course_archive_sorting($query) { |
|
| 2207 | 2207 | |
| 2208 | 2208 | // don't show on category pages and other pages |
| 2209 | - if( ! is_archive( 'course ') || is_tax('course-category') ){ |
|
| 2209 | + if ( ! is_archive('course ') || is_tax('course-category')) { |
|
| 2210 | 2210 | return; |
| 2211 | 2211 | } |
| 2212 | 2212 | |
@@ -2219,27 +2219,27 @@ discard block |
||
| 2219 | 2219 | * @type string $option_string |
| 2220 | 2220 | * } |
| 2221 | 2221 | */ |
| 2222 | - $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array( |
|
| 2223 | - "newness" => __( "Sort by newest first", "woothemes-sensei"), |
|
| 2224 | - "title" => __( "Sort by title A-Z", "woothemes-sensei" ), |
|
| 2222 | + $course_order_by_options = apply_filters('sensei_archive_course_order_by_options', array( |
|
| 2223 | + "newness" => __("Sort by newest first", "woothemes-sensei"), |
|
| 2224 | + "title" => __("Sort by title A-Z", "woothemes-sensei"), |
|
| 2225 | 2225 | )); |
| 2226 | 2226 | |
| 2227 | 2227 | // setup the currently selected item |
| 2228 | 2228 | $selected = 'newness'; |
| 2229 | - if( isset( $_GET['orderby'] ) ){ |
|
| 2229 | + if (isset($_GET['orderby'])) { |
|
| 2230 | 2230 | |
| 2231 | - $selected = $_GET[ 'orderby' ]; |
|
| 2231 | + $selected = $_GET['orderby']; |
|
| 2232 | 2232 | |
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | 2235 | ?> |
| 2236 | 2236 | |
| 2237 | - <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr( Sensei_Utils::get_current_url() ) ; ?>" method="POST"> |
|
| 2237 | + <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr(Sensei_Utils::get_current_url()); ?>" method="POST"> |
|
| 2238 | 2238 | <select name="course-orderby" class="orderby"> |
| 2239 | 2239 | <?php |
| 2240 | - foreach( $course_order_by_options as $value => $text ){ |
|
| 2240 | + foreach ($course_order_by_options as $value => $text) { |
|
| 2241 | 2241 | |
| 2242 | - echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>'; |
|
| 2242 | + echo '<option value="'.$value.' "'.selected($selected, $value, false).'>'.$text.'</option>'; |
|
| 2243 | 2243 | |
| 2244 | 2244 | } |
| 2245 | 2245 | ?> |
@@ -2257,10 +2257,10 @@ discard block |
||
| 2257 | 2257 | * @since 1.9.0 |
| 2258 | 2258 | * @param |
| 2259 | 2259 | */ |
| 2260 | - public static function course_archive_filters( $query ){ |
|
| 2260 | + public static function course_archive_filters($query) { |
|
| 2261 | 2261 | |
| 2262 | 2262 | // don't show on category pages |
| 2263 | - if( is_tax('course-category') ){ |
|
| 2263 | + if (is_tax('course-category')) { |
|
| 2264 | 2264 | return; |
| 2265 | 2265 | } |
| 2266 | 2266 | |
@@ -2273,9 +2273,9 @@ discard block |
||
| 2273 | 2273 | * } |
| 2274 | 2274 | * |
| 2275 | 2275 | */ |
| 2276 | - $filters = apply_filters( 'sensei_archive_course_filter_by_options', array( |
|
| 2277 | - array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ), |
|
| 2278 | - array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url() ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ), |
|
| 2276 | + $filters = apply_filters('sensei_archive_course_filter_by_options', array( |
|
| 2277 | + array('id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __('All', 'woothemes-sensei')), |
|
| 2278 | + array('id' => 'featured', 'url' => add_query_arg(array('course_filter'=>'featured'), self::get_courses_page_url()), 'title'=> __('Featured', 'woothemes-sensei')), |
|
| 2279 | 2279 | )); |
| 2280 | 2280 | |
| 2281 | 2281 | |
@@ -2286,11 +2286,11 @@ discard block |
||
| 2286 | 2286 | //determine the current active url |
| 2287 | 2287 | $current_url = Sensei_Utils::get_current_url(); |
| 2288 | 2288 | |
| 2289 | - foreach( $filters as $filter ) { |
|
| 2289 | + foreach ($filters as $filter) { |
|
| 2290 | 2290 | |
| 2291 | - $active_class = $current_url == $filter['url'] ? ' class="active" ' : ''; |
|
| 2291 | + $active_class = $current_url == $filter['url'] ? ' class="active" ' : ''; |
|
| 2292 | 2292 | |
| 2293 | - echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title'] .'</a></li>'; |
|
| 2293 | + echo '<li><a '.$active_class.' id="'.$filter['id'].'" href="'.esc_url($filter['url']).'" >'.$filter['title'].'</a></li>'; |
|
| 2294 | 2294 | |
| 2295 | 2295 | } |
| 2296 | 2296 | ?> |
@@ -2311,13 +2311,13 @@ discard block |
||
| 2311 | 2311 | * @param WP_Query $query |
| 2312 | 2312 | * @return WP_Query $query |
| 2313 | 2313 | */ |
| 2314 | - public static function course_archive_featured_filter( $query ){ |
|
| 2314 | + public static function course_archive_featured_filter($query) { |
|
| 2315 | 2315 | |
| 2316 | - if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query() ){ |
|
| 2316 | + if (isset ($_GET['course_filter']) && 'featured' == $_GET['course_filter'] && $query->is_main_query()) { |
|
| 2317 | 2317 | //setup meta query for featured courses |
| 2318 | - $query->set( 'meta_value', 'featured' ); |
|
| 2319 | - $query->set( 'meta_key', '_course_featured' ); |
|
| 2320 | - $query->set( 'meta_compare', '=' ); |
|
| 2318 | + $query->set('meta_value', 'featured'); |
|
| 2319 | + $query->set('meta_key', '_course_featured'); |
|
| 2320 | + $query->set('meta_compare', '='); |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | return $query; |
@@ -2332,13 +2332,13 @@ discard block |
||
| 2332 | 2332 | * @param WP_Query $query |
| 2333 | 2333 | * @return WP_Query $query |
| 2334 | 2334 | */ |
| 2335 | - public static function course_archive_order_by_title( $query ){ |
|
| 2335 | + public static function course_archive_order_by_title($query) { |
|
| 2336 | 2336 | |
| 2337 | - if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby'] |
|
| 2338 | - && 'course'== $query->get('post_type') && $query->is_main_query() ){ |
|
| 2337 | + if (isset ($_POST['course-orderby']) && 'title ' == $_POST['course-orderby'] |
|
| 2338 | + && 'course' == $query->get('post_type') && $query->is_main_query()) { |
|
| 2339 | 2339 | // setup the order by title for this query |
| 2340 | - $query->set( 'orderby', 'title' ); |
|
| 2341 | - $query->set( 'order', 'ASC' ); |
|
| 2340 | + $query->set('orderby', 'title'); |
|
| 2341 | + $query->set('order', 'ASC'); |
|
| 2342 | 2342 | } |
| 2343 | 2343 | |
| 2344 | 2344 | return $query; |
@@ -2352,10 +2352,10 @@ discard block |
||
| 2352 | 2352 | * @since 1.9.0 |
| 2353 | 2353 | * @return string $course_page_url |
| 2354 | 2354 | */ |
| 2355 | - public static function get_courses_page_url(){ |
|
| 2355 | + public static function get_courses_page_url() { |
|
| 2356 | 2356 | |
| 2357 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
| 2358 | - $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id ); |
|
| 2357 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
| 2358 | + $course_page_url = empty($course_page_id) ? get_post_type_archive_link('course') : get_permalink($course_page_id); |
|
| 2359 | 2359 | |
| 2360 | 2360 | return $course_page_url; |
| 2361 | 2361 | |
@@ -2372,61 +2372,61 @@ discard block |
||
| 2372 | 2372 | * @param string $after_html |
| 2373 | 2373 | * @return void |
| 2374 | 2374 | */ |
| 2375 | - public static function archive_header( $query_type ='' , $before_html='', $after_html ='' ){ |
|
| 2375 | + public static function archive_header($query_type = '', $before_html = '', $after_html = '') { |
|
| 2376 | 2376 | |
| 2377 | - if( ! is_post_type_archive('course') ){ |
|
| 2377 | + if ( ! is_post_type_archive('course')) { |
|
| 2378 | 2378 | return; |
| 2379 | 2379 | } |
| 2380 | 2380 | |
| 2381 | 2381 | // deprecated since 1.9.0 |
| 2382 | - sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop'); |
|
| 2382 | + sensei_do_deprecated_action('sensei_archive_title', '1.9.0', 'sensei_archive_before_course_loop'); |
|
| 2383 | 2383 | |
| 2384 | 2384 | $html = ''; |
| 2385 | 2385 | |
| 2386 | - if( empty( $before_html ) ){ |
|
| 2386 | + if (empty($before_html)) { |
|
| 2387 | 2387 | |
| 2388 | 2388 | $before_html = '<header class="archive-header"><h1>'; |
| 2389 | 2389 | |
| 2390 | 2390 | } |
| 2391 | 2391 | |
| 2392 | - if( empty( $after_html ) ){ |
|
| 2392 | + if (empty($after_html)) { |
|
| 2393 | 2393 | |
| 2394 | 2394 | $after_html = '</h1></header>'; |
| 2395 | 2395 | |
| 2396 | 2396 | } |
| 2397 | 2397 | |
| 2398 | - if ( is_tax( 'course-category' ) ) { |
|
| 2398 | + if (is_tax('course-category')) { |
|
| 2399 | 2399 | |
| 2400 | 2400 | global $wp_query; |
| 2401 | 2401 | |
| 2402 | 2402 | $taxonomy_obj = $wp_query->get_queried_object(); |
| 2403 | 2403 | $taxonomy_short_name = $taxonomy_obj->taxonomy; |
| 2404 | - $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name ); |
|
| 2405 | - $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name ); |
|
| 2406 | - echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html ); |
|
| 2404 | + $taxonomy_raw_obj = get_taxonomy($taxonomy_short_name); |
|
| 2405 | + $title = sprintf(__('%1$s Archives: %2$s', 'woothemes-sensei'), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name); |
|
| 2406 | + echo apply_filters('course_category_archive_title', $before_html.$title.$after_html); |
|
| 2407 | 2407 | return; |
| 2408 | 2408 | |
| 2409 | 2409 | } // End If Statement |
| 2410 | 2410 | |
| 2411 | - switch ( $query_type ) { |
|
| 2411 | + switch ($query_type) { |
|
| 2412 | 2412 | case 'newcourses': |
| 2413 | - $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2413 | + $html .= $before_html.__('New Courses', 'woothemes-sensei').$after_html; |
|
| 2414 | 2414 | break; |
| 2415 | 2415 | case 'featuredcourses': |
| 2416 | - $html .= $before_html . __( 'Featured Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2416 | + $html .= $before_html.__('Featured Courses', 'woothemes-sensei').$after_html; |
|
| 2417 | 2417 | break; |
| 2418 | 2418 | case 'freecourses': |
| 2419 | - $html .= $before_html . __( 'Free Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2419 | + $html .= $before_html.__('Free Courses', 'woothemes-sensei').$after_html; |
|
| 2420 | 2420 | break; |
| 2421 | 2421 | case 'paidcourses': |
| 2422 | - $html .= $before_html . __( 'Paid Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2422 | + $html .= $before_html.__('Paid Courses', 'woothemes-sensei').$after_html; |
|
| 2423 | 2423 | break; |
| 2424 | 2424 | default: |
| 2425 | - $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2425 | + $html .= $before_html.__('Courses', 'woothemes-sensei').$after_html; |
|
| 2426 | 2426 | break; |
| 2427 | 2427 | } // End Switch Statement |
| 2428 | 2428 | |
| 2429 | - echo apply_filters( 'course_archive_title', $html ); |
|
| 2429 | + echo apply_filters('course_archive_title', $html); |
|
| 2430 | 2430 | |
| 2431 | 2431 | }//course_archive_header |
| 2432 | 2432 | |
@@ -2440,9 +2440,9 @@ discard block |
||
| 2440 | 2440 | * @param string $content |
| 2441 | 2441 | * @return string $content or $excerpt |
| 2442 | 2442 | */ |
| 2443 | - public static function single_course_content( $content ){ |
|
| 2443 | + public static function single_course_content($content) { |
|
| 2444 | 2444 | |
| 2445 | - if( ! is_singular('course') ){ |
|
| 2445 | + if ( ! is_singular('course')) { |
|
| 2446 | 2446 | |
| 2447 | 2447 | return $content; |
| 2448 | 2448 | |
@@ -2451,21 +2451,21 @@ discard block |
||
| 2451 | 2451 | // Content Access Permissions |
| 2452 | 2452 | $access_permission = false; |
| 2453 | 2453 | |
| 2454 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
| 2454 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) { |
|
| 2455 | 2455 | |
| 2456 | 2456 | $access_permission = true; |
| 2457 | 2457 | |
| 2458 | 2458 | } // End If Statement |
| 2459 | 2459 | |
| 2460 | 2460 | // Check if the user is taking the course |
| 2461 | - $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() ); |
|
| 2461 | + $is_user_taking_course = Sensei_Utils::user_started_course(get_the_ID(), get_current_user_id()); |
|
| 2462 | 2462 | |
| 2463 | - if(Sensei_WC::is_woocommerce_active()) { |
|
| 2463 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 2464 | 2464 | |
| 2465 | - $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true ); |
|
| 2466 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
| 2465 | + $wc_post_id = get_post_meta(get_the_ID(), '_course_woocommerce_product', true); |
|
| 2466 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
|
| 2467 | 2467 | |
| 2468 | - $has_product_attached = isset ( $product ) && is_object ( $product ); |
|
| 2468 | + $has_product_attached = isset ($product) && is_object($product); |
|
| 2469 | 2469 | |
| 2470 | 2470 | } else { |
| 2471 | 2471 | |
@@ -2473,15 +2473,15 @@ discard block |
||
| 2473 | 2473 | |
| 2474 | 2474 | } |
| 2475 | 2475 | |
| 2476 | - if ( ( is_user_logged_in() && $is_user_taking_course ) |
|
| 2477 | - || ( $access_permission && !$has_product_attached) |
|
| 2478 | - || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) { |
|
| 2476 | + if ((is_user_logged_in() && $is_user_taking_course) |
|
| 2477 | + || ($access_permission && ! $has_product_attached) |
|
| 2478 | + || 'full' == Sensei()->settings->get('course_single_content_display')) { |
|
| 2479 | 2479 | |
| 2480 | 2480 | return $content; |
| 2481 | 2481 | |
| 2482 | 2482 | } else { |
| 2483 | 2483 | |
| 2484 | - return '<p class="course-excerpt">' . get_post( get_the_ID() )->post_excerpt . '</p>'; |
|
| 2484 | + return '<p class="course-excerpt">'.get_post(get_the_ID())->post_excerpt.'</p>'; |
|
| 2485 | 2485 | |
| 2486 | 2486 | } |
| 2487 | 2487 | |
@@ -2492,14 +2492,14 @@ discard block |
||
| 2492 | 2492 | * |
| 2493 | 2493 | * @since 1.9.0 |
| 2494 | 2494 | */ |
| 2495 | - public static function the_course_lessons_title(){ |
|
| 2495 | + public static function the_course_lessons_title() { |
|
| 2496 | 2496 | global $post; |
| 2497 | - $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID ); |
|
| 2498 | - $course_lessons = Sensei()->course->course_lessons( $post->ID ); |
|
| 2497 | + $none_module_lessons = Sensei()->modules->get_none_module_lessons($post->ID); |
|
| 2498 | + $course_lessons = Sensei()->course->course_lessons($post->ID); |
|
| 2499 | 2499 | |
| 2500 | 2500 | // title should be Other Lessons if there are lessons belonging to models. |
| 2501 | 2501 | $title = __('Other Lessons', 'woothemes-sensei'); |
| 2502 | - if( count( $course_lessons ) == count( $none_module_lessons ) ){ |
|
| 2502 | + if (count($course_lessons) == count($none_module_lessons)) { |
|
| 2503 | 2503 | |
| 2504 | 2504 | $title = __('Lessons', 'woothemes-sensei'); |
| 2505 | 2505 | |
@@ -2508,7 +2508,7 @@ discard block |
||
| 2508 | 2508 | /** |
| 2509 | 2509 | * hook document in class-woothemes-sensei-message.php |
| 2510 | 2510 | */ |
| 2511 | - $title = apply_filters( 'sensei_single_title', $title, $post->post_type ); |
|
| 2511 | + $title = apply_filters('sensei_single_title', $title, $post->post_type); |
|
| 2512 | 2512 | |
| 2513 | 2513 | ob_start(); // start capturing the following output. |
| 2514 | 2514 | |
@@ -2527,7 +2527,7 @@ discard block |
||
| 2527 | 2527 | * @since 1.9.0 |
| 2528 | 2528 | * @param string $lessons_title_html |
| 2529 | 2529 | */ |
| 2530 | - echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing. |
|
| 2530 | + echo apply_filters('the_course_lessons_title', ob_get_clean()); // output and filter the captured output and stop capturing. |
|
| 2531 | 2531 | |
| 2532 | 2532 | }// end the_course_lessons_title |
| 2533 | 2533 | |
@@ -2542,13 +2542,13 @@ discard block |
||
| 2542 | 2542 | * @since 1.9.0 |
| 2543 | 2543 | * @global $wp_query |
| 2544 | 2544 | */ |
| 2545 | - public static function load_single_course_lessons_query(){ |
|
| 2545 | + public static function load_single_course_lessons_query() { |
|
| 2546 | 2546 | |
| 2547 | 2547 | global $post, $wp_query; |
| 2548 | 2548 | |
| 2549 | 2549 | $course_id = $post->ID; |
| 2550 | 2550 | |
| 2551 | - if( 'course' != get_post_type( $course_id ) ){ |
|
| 2551 | + if ('course' != get_post_type($course_id)) { |
|
| 2552 | 2552 | return; |
| 2553 | 2553 | } |
| 2554 | 2554 | |
@@ -2560,7 +2560,7 @@ discard block |
||
| 2560 | 2560 | 'meta_query' => array( |
| 2561 | 2561 | array( |
| 2562 | 2562 | 'key' => '_lesson_course', |
| 2563 | - 'value' => intval( $course_id ), |
|
| 2563 | + 'value' => intval($course_id), |
|
| 2564 | 2564 | ), |
| 2565 | 2565 | ), |
| 2566 | 2566 | 'post_status' => 'public', |
@@ -2568,17 +2568,17 @@ discard block |
||
| 2568 | 2568 | ); |
| 2569 | 2569 | |
| 2570 | 2570 | // Exclude lessons belonging to modules as they are queried along with the modules. |
| 2571 | - $modules = Sensei()->modules->get_course_modules( $course_id ); |
|
| 2572 | - if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){ |
|
| 2571 | + $modules = Sensei()->modules->get_course_modules($course_id); |
|
| 2572 | + if ( ! is_wp_error($modules) && ! empty($modules) && is_array($modules)) { |
|
| 2573 | 2573 | |
| 2574 | 2574 | $terms_ids = array(); |
| 2575 | - foreach( $modules as $term ){ |
|
| 2575 | + foreach ($modules as $term) { |
|
| 2576 | 2576 | |
| 2577 | 2577 | $terms_ids[] = $term->term_id; |
| 2578 | 2578 | |
| 2579 | 2579 | } |
| 2580 | 2580 | |
| 2581 | - $course_lesson_query_args[ 'tax_query'] = array( |
|
| 2581 | + $course_lesson_query_args['tax_query'] = array( |
|
| 2582 | 2582 | array( |
| 2583 | 2583 | 'taxonomy' => 'module', |
| 2584 | 2584 | 'field' => 'id', |
@@ -2588,7 +2588,7 @@ discard block |
||
| 2588 | 2588 | ); |
| 2589 | 2589 | } |
| 2590 | 2590 | |
| 2591 | - $wp_query = new WP_Query( $course_lesson_query_args ); |
|
| 2591 | + $wp_query = new WP_Query($course_lesson_query_args); |
|
| 2592 | 2592 | |
| 2593 | 2593 | }// load_single_course_lessons |
| 2594 | 2594 | |
@@ -2599,16 +2599,16 @@ discard block |
||
| 2599 | 2599 | * |
| 2600 | 2600 | * @param $post_id |
| 2601 | 2601 | */ |
| 2602 | - public static function flush_rewrite_rules( $post_id ){ |
|
| 2602 | + public static function flush_rewrite_rules($post_id) { |
|
| 2603 | 2603 | |
| 2604 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 2604 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 2605 | 2605 | |
| 2606 | 2606 | return; |
| 2607 | 2607 | |
| 2608 | 2608 | } |
| 2609 | 2609 | |
| 2610 | 2610 | |
| 2611 | - if( 'course' == get_post_type( $post_id ) ){ |
|
| 2611 | + if ('course' == get_post_type($post_id)) { |
|
| 2612 | 2612 | |
| 2613 | 2613 | Sensei()->initiate_rewrite_rules_flush(); |
| 2614 | 2614 | |
@@ -2624,10 +2624,10 @@ discard block |
||
| 2624 | 2624 | * @param $excerpt |
| 2625 | 2625 | * @return string |
| 2626 | 2626 | */ |
| 2627 | - public static function full_content_excerpt_override( $excerpt ){ |
|
| 2627 | + public static function full_content_excerpt_override($excerpt) { |
|
| 2628 | 2628 | |
| 2629 | - if ( is_singular('course') && |
|
| 2630 | - 'full' == Sensei()->settings->get( 'course_single_content_display' ) ){ |
|
| 2629 | + if (is_singular('course') && |
|
| 2630 | + 'full' == Sensei()->settings->get('course_single_content_display')) { |
|
| 2631 | 2631 | |
| 2632 | 2632 | return get_the_content(); |
| 2633 | 2633 | |
@@ -2644,60 +2644,60 @@ discard block |
||
| 2644 | 2644 | * |
| 2645 | 2645 | * @since 1.9.0 |
| 2646 | 2646 | */ |
| 2647 | - public static function the_course_enrolment_actions(){ |
|
| 2647 | + public static function the_course_enrolment_actions() { |
|
| 2648 | 2648 | ?> |
| 2649 | 2649 | <section class="course-meta course-enrolment"> |
| 2650 | 2650 | <?php |
| 2651 | 2651 | global $post, $current_user; |
| 2652 | - $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
| 2653 | - if ( is_user_logged_in() && ! $is_user_taking_course ) { |
|
| 2652 | + $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID); |
|
| 2653 | + if (is_user_logged_in() && ! $is_user_taking_course) { |
|
| 2654 | 2654 | |
| 2655 | 2655 | // Get the product ID |
| 2656 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2656 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
| 2657 | 2657 | |
| 2658 | 2658 | // Check for woocommerce |
| 2659 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2659 | + if (Sensei_WC::is_woocommerce_active() && (0 < intval($wc_post_id))) { |
|
| 2660 | 2660 | sensei_wc_add_to_cart($post->ID); |
| 2661 | 2661 | } else { |
| 2662 | 2662 | sensei_start_course_form($post->ID); |
| 2663 | 2663 | } // End If Statement |
| 2664 | 2664 | |
| 2665 | - } elseif ( is_user_logged_in() ) { |
|
| 2665 | + } elseif (is_user_logged_in()) { |
|
| 2666 | 2666 | |
| 2667 | 2667 | // Check if course is completed |
| 2668 | - $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID ); |
|
| 2669 | - $completed_course = Sensei_Utils::user_completed_course( $user_course_status ); |
|
| 2668 | + $user_course_status = Sensei_Utils::user_course_status($post->ID, $current_user->ID); |
|
| 2669 | + $completed_course = Sensei_Utils::user_completed_course($user_course_status); |
|
| 2670 | 2670 | // Success message |
| 2671 | - if ( $completed_course ) { ?> |
|
| 2672 | - <div class="status completed"><?php _e( 'Completed', 'woothemes-sensei' ); ?></div> |
|
| 2671 | + if ($completed_course) { ?> |
|
| 2672 | + <div class="status completed"><?php _e('Completed', 'woothemes-sensei'); ?></div> |
|
| 2673 | 2673 | <?php |
| 2674 | - $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true ); |
|
| 2675 | - if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2674 | + $has_quizzes = Sensei()->course->course_quizzes($post->ID, true); |
|
| 2675 | + if (has_filter('sensei_results_links') || $has_quizzes) { ?> |
|
| 2676 | 2676 | <p class="sensei-results-links"> |
| 2677 | 2677 | <?php |
| 2678 | 2678 | $results_link = ''; |
| 2679 | - if( $has_quizzes ) { |
|
| 2680 | - $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2679 | + if ($has_quizzes) { |
|
| 2680 | + $results_link = '<a class="view-results" href="'.Sensei()->course_results->get_permalink($post->ID).'">'.__('View results', 'woothemes-sensei').'</a>'; |
|
| 2681 | 2681 | } |
| 2682 | - $results_link = apply_filters( 'sensei_results_links', $results_link ); |
|
| 2682 | + $results_link = apply_filters('sensei_results_links', $results_link); |
|
| 2683 | 2683 | echo $results_link; |
| 2684 | 2684 | ?></p> |
| 2685 | 2685 | <?php } ?> |
| 2686 | 2686 | <?php } else { ?> |
| 2687 | - <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div> |
|
| 2687 | + <div class="status in-progress"><?php echo __('In Progress', 'woothemes-sensei'); ?></div> |
|
| 2688 | 2688 | <?php } |
| 2689 | 2689 | |
| 2690 | 2690 | } else { |
| 2691 | 2691 | // Get the product ID |
| 2692 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2692 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
| 2693 | 2693 | // Check for woocommerce |
| 2694 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2694 | + if (Sensei_WC::is_woocommerce_active() && (0 < intval($wc_post_id))) { |
|
| 2695 | 2695 | |
| 2696 | 2696 | sensei_wc_add_to_cart($post->ID); |
| 2697 | 2697 | |
| 2698 | 2698 | } else { |
| 2699 | 2699 | |
| 2700 | - if( get_option( 'users_can_register') ) { |
|
| 2700 | + if (get_option('users_can_register')) { |
|
| 2701 | 2701 | |
| 2702 | 2702 | |
| 2703 | 2703 | $my_courses_page_id = ''; |
@@ -2713,24 +2713,24 @@ discard block |
||
| 2713 | 2713 | $wp_register_link = apply_filters('sensei_use_wp_register_link', false); |
| 2714 | 2714 | |
| 2715 | 2715 | $settings = Sensei()->settings->get_settings(); |
| 2716 | - if( isset( $settings[ 'my_course_page' ] ) |
|
| 2717 | - && 0 < intval( $settings[ 'my_course_page' ] ) ){ |
|
| 2716 | + if (isset($settings['my_course_page']) |
|
| 2717 | + && 0 < intval($settings['my_course_page'])) { |
|
| 2718 | 2718 | |
| 2719 | - $my_courses_page_id = $settings[ 'my_course_page' ]; |
|
| 2719 | + $my_courses_page_id = $settings['my_course_page']; |
|
| 2720 | 2720 | |
| 2721 | 2721 | } |
| 2722 | 2722 | |
| 2723 | 2723 | // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link' |
| 2724 | 2724 | // is false, link to My Courses. If not, link to default WordPress registration page. |
| 2725 | - if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){ |
|
| 2725 | + if ( ! empty($my_courses_page_id) && $my_courses_page_id && ! $wp_register_link) { |
|
| 2726 | 2726 | |
| 2727 | - $my_courses_url = get_permalink( $my_courses_page_id ); |
|
| 2728 | - $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>'; |
|
| 2729 | - echo '<div class="status register">' . $register_link . '</div>' ; |
|
| 2727 | + $my_courses_url = get_permalink($my_courses_page_id); |
|
| 2728 | + $register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>'; |
|
| 2729 | + echo '<div class="status register">'.$register_link.'</div>'; |
|
| 2730 | 2730 | |
| 2731 | - } else{ |
|
| 2731 | + } else { |
|
| 2732 | 2732 | |
| 2733 | - wp_register( '<div class="status register">', '</div>' ); |
|
| 2733 | + wp_register('<div class="status register">', '</div>'); |
|
| 2734 | 2734 | |
| 2735 | 2735 | } |
| 2736 | 2736 | |
@@ -2749,19 +2749,19 @@ discard block |
||
| 2749 | 2749 | * |
| 2750 | 2750 | * @since 1.9.0 |
| 2751 | 2751 | */ |
| 2752 | - public static function the_course_video(){ |
|
| 2752 | + public static function the_course_video() { |
|
| 2753 | 2753 | |
| 2754 | 2754 | global $post; |
| 2755 | 2755 | // Get the meta info |
| 2756 | - $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true ); |
|
| 2756 | + $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true); |
|
| 2757 | 2757 | |
| 2758 | - if ( 'http' == substr( $course_video_embed, 0, 4) ) { |
|
| 2758 | + if ('http' == substr($course_video_embed, 0, 4)) { |
|
| 2759 | 2759 | |
| 2760 | - $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) ); |
|
| 2760 | + $course_video_embed = wp_oembed_get(esc_url($course_video_embed)); |
|
| 2761 | 2761 | |
| 2762 | 2762 | } // End If Statement |
| 2763 | 2763 | |
| 2764 | - if ( '' != $course_video_embed ) { ?> |
|
| 2764 | + if ('' != $course_video_embed) { ?> |
|
| 2765 | 2765 | |
| 2766 | 2766 | <div class="course-video"> |
| 2767 | 2767 | <?php echo html_entity_decode($course_video_embed); ?> |
@@ -2776,7 +2776,7 @@ discard block |
||
| 2776 | 2776 | * @global $post |
| 2777 | 2777 | * @since 1.9.0 |
| 2778 | 2778 | */ |
| 2779 | - public static function the_title(){ |
|
| 2779 | + public static function the_title() { |
|
| 2780 | 2780 | |
| 2781 | 2781 | global $post; |
| 2782 | 2782 | |
@@ -2789,7 +2789,7 @@ discard block |
||
| 2789 | 2789 | /** |
| 2790 | 2790 | * Filter documented in class-sensei-messages.php the_title |
| 2791 | 2791 | */ |
| 2792 | - echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 2792 | + echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type); |
|
| 2793 | 2793 | ?> |
| 2794 | 2794 | |
| 2795 | 2795 | </h1> |
@@ -2805,30 +2805,30 @@ discard block |
||
| 2805 | 2805 | * |
| 2806 | 2806 | * @since 1.9.0 |
| 2807 | 2807 | */ |
| 2808 | - public static function course_category_title(){ |
|
| 2808 | + public static function course_category_title() { |
|
| 2809 | 2809 | |
| 2810 | - if( ! is_tax( 'course-category' ) ){ |
|
| 2810 | + if ( ! is_tax('course-category')) { |
|
| 2811 | 2811 | return; |
| 2812 | 2812 | } |
| 2813 | 2813 | |
| 2814 | 2814 | $category_slug = get_query_var('course-category'); |
| 2815 | - $term = get_term_by('slug',$category_slug,'course-category'); |
|
| 2815 | + $term = get_term_by('slug', $category_slug, 'course-category'); |
|
| 2816 | 2816 | |
| 2817 | - if( ! empty($term) ){ |
|
| 2817 | + if ( ! empty($term)) { |
|
| 2818 | 2818 | |
| 2819 | 2819 | $title = $term->name; |
| 2820 | 2820 | |
| 2821 | - }else{ |
|
| 2821 | + } else { |
|
| 2822 | 2822 | |
| 2823 | 2823 | $title = 'Course Category'; |
| 2824 | 2824 | |
| 2825 | 2825 | } |
| 2826 | 2826 | |
| 2827 | 2827 | $html = '<h2 class="sensei-category-title">'; |
| 2828 | - $html .= __('Category') . ' ' . $title; |
|
| 2828 | + $html .= __('Category').' '.$title; |
|
| 2829 | 2829 | $html .= '</h2>'; |
| 2830 | 2830 | |
| 2831 | - echo apply_filters( 'course_category_title', $html , $term->term_id ); |
|
| 2831 | + echo apply_filters('course_category_title', $html, $term->term_id); |
|
| 2832 | 2832 | |
| 2833 | 2833 | }// course_category_title |
| 2834 | 2834 | |
@@ -2841,16 +2841,16 @@ discard block |
||
| 2841 | 2841 | * @param WP_Query $query |
| 2842 | 2842 | * @return WP_Query |
| 2843 | 2843 | */ |
| 2844 | - public static function alter_course_category_order( $query ){ |
|
| 2844 | + public static function alter_course_category_order($query) { |
|
| 2845 | 2845 | |
| 2846 | - if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){ |
|
| 2846 | + if ( ! is_tax('course-category') || ! $query->is_main_query()) { |
|
| 2847 | 2847 | return $query; |
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | - $order = get_option( 'sensei_course_order', '' ); |
|
| 2851 | - if( !empty( $order ) ){ |
|
| 2852 | - $query->set('orderby', 'menu_order' ); |
|
| 2853 | - $query->set('order', 'ASC' ); |
|
| 2850 | + $order = get_option('sensei_course_order', ''); |
|
| 2851 | + if ( ! empty($order)) { |
|
| 2852 | + $query->set('orderby', 'menu_order'); |
|
| 2853 | + $query->set('order', 'ASC'); |
|
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | 2856 | return $query; |
@@ -2871,7 +2871,7 @@ discard block |
||
| 2871 | 2871 | * |
| 2872 | 2872 | * @return array |
| 2873 | 2873 | */ |
| 2874 | - public static function get_default_query_args(){ |
|
| 2874 | + public static function get_default_query_args() { |
|
| 2875 | 2875 | return array( |
| 2876 | 2876 | 'post_type' => 'course', |
| 2877 | 2877 | 'posts_per_page' => 1000, |
@@ -2889,14 +2889,14 @@ discard block |
||
| 2889 | 2889 | * @param $course_id |
| 2890 | 2890 | * @return bool |
| 2891 | 2891 | */ |
| 2892 | - public static function is_prerequisite_complete( $course_id ){ |
|
| 2892 | + public static function is_prerequisite_complete($course_id) { |
|
| 2893 | 2893 | |
| 2894 | - $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true ); |
|
| 2894 | + $course_prerequisite_id = get_post_meta($course_id, '_course_prerequisite', true); |
|
| 2895 | 2895 | |
| 2896 | 2896 | // if it has a pre requisite course check it |
| 2897 | - if( ! empty( $course_prerequisite_id ) ){ |
|
| 2897 | + if ( ! empty($course_prerequisite_id)) { |
|
| 2898 | 2898 | |
| 2899 | - return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() ); |
|
| 2899 | + return Sensei_Utils::user_completed_course($course_prerequisite_id, get_current_user_id()); |
|
| 2900 | 2900 | |
| 2901 | 2901 | } |
| 2902 | 2902 | |
@@ -2912,4 +2912,4 @@ discard block |
||
| 2912 | 2912 | * for backward compatibility |
| 2913 | 2913 | * @since 1.9.0 |
| 2914 | 2914 | */ |
| 2915 | -class WooThemes_Sensei_Course extends Sensei_Course{} |
|
| 2915 | +class WooThemes_Sensei_Course extends Sensei_Course {} |
|
@@ -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 Learners Overview List Table Class |
@@ -23,28 +23,28 @@ discard block |
||
| 23 | 23 | * @since 1.6.0 |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | - public function __construct ( $course_id = 0, $lesson_id = 0 ) { |
|
| 27 | - $this->course_id = intval( $course_id ); |
|
| 28 | - $this->lesson_id = intval( $lesson_id ); |
|
| 26 | + public function __construct($course_id = 0, $lesson_id = 0) { |
|
| 27 | + $this->course_id = intval($course_id); |
|
| 28 | + $this->lesson_id = intval($lesson_id); |
|
| 29 | 29 | |
| 30 | - if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'courses', 'lessons', 'learners' ) ) ) { |
|
| 30 | + if (isset($_GET['view']) && in_array($_GET['view'], array('courses', 'lessons', 'learners'))) { |
|
| 31 | 31 | $this->view = $_GET['view']; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // Viewing a single lesson always sets the view to Learners |
| 35 | - if( $this->lesson_id ) { |
|
| 35 | + if ($this->lesson_id) { |
|
| 36 | 36 | $this->view = 'learners'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Load Parent token into constructor |
| 40 | - parent::__construct( 'learners_main' ); |
|
| 40 | + parent::__construct('learners_main'); |
|
| 41 | 41 | |
| 42 | 42 | // Actions |
| 43 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 44 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 45 | - add_action( 'sensei_learners_extra', array( $this, 'add_learners_box' ) ); |
|
| 43 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 44 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 45 | + add_action('sensei_learners_extra', array($this, 'add_learners_box')); |
|
| 46 | 46 | |
| 47 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 47 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 48 | 48 | } // End __construct() |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -54,38 +54,38 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function get_columns() { |
| 56 | 56 | $columns = array(); |
| 57 | - switch( $this->view ) { |
|
| 57 | + switch ($this->view) { |
|
| 58 | 58 | case 'learners': |
| 59 | 59 | $columns = array( |
| 60 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 61 | - 'date_started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 62 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
| 60 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 61 | + 'date_started' => __('Date Started', 'woothemes-sensei'), |
|
| 62 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
| 63 | 63 | ); |
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case 'lessons': |
| 67 | 67 | $columns = array( |
| 68 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 69 | - 'num_learners' => __( '# Learners', 'woothemes-sensei' ), |
|
| 70 | - 'updated' => __( 'Last Updated', 'woothemes-sensei' ), |
|
| 68 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 69 | + 'num_learners' => __('# Learners', 'woothemes-sensei'), |
|
| 70 | + 'updated' => __('Last Updated', 'woothemes-sensei'), |
|
| 71 | 71 | ); |
| 72 | 72 | break; |
| 73 | 73 | |
| 74 | 74 | case 'courses': |
| 75 | 75 | default: |
| 76 | 76 | $columns = array( |
| 77 | - 'title' => __( 'Course', 'woothemes-sensei' ), |
|
| 78 | - 'num_learners' => __( '# Learners', 'woothemes-sensei' ), |
|
| 79 | - 'updated' => __( 'Last Updated', 'woothemes-sensei' ), |
|
| 77 | + 'title' => __('Course', 'woothemes-sensei'), |
|
| 78 | + 'num_learners' => __('# Learners', 'woothemes-sensei'), |
|
| 79 | + 'updated' => __('Last Updated', 'woothemes-sensei'), |
|
| 80 | 80 | ); |
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | $columns['actions'] = ''; |
| 84 | 84 | // Backwards compatible |
| 85 | - if ( 'learners' == $this->view ) { |
|
| 86 | - $columns = apply_filters( 'sensei_learners_learners_columns', $columns, $this ); |
|
| 85 | + if ('learners' == $this->view) { |
|
| 86 | + $columns = apply_filters('sensei_learners_learners_columns', $columns, $this); |
|
| 87 | 87 | } |
| 88 | - $columns = apply_filters( 'sensei_learners_default_columns', $columns, $this ); |
|
| 88 | + $columns = apply_filters('sensei_learners_default_columns', $columns, $this); |
|
| 89 | 89 | return $columns; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -96,32 +96,32 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | function get_sortable_columns() { |
| 98 | 98 | $columns = array(); |
| 99 | - switch( $this->view ) { |
|
| 99 | + switch ($this->view) { |
|
| 100 | 100 | case 'learners': |
| 101 | 101 | $columns = array( |
| 102 | - 'title' => array( 'title', false ), |
|
| 102 | + 'title' => array('title', false), |
|
| 103 | 103 | ); |
| 104 | 104 | break; |
| 105 | 105 | |
| 106 | 106 | case 'lessons': |
| 107 | 107 | $columns = array( |
| 108 | - 'title' => array( 'title', false ), |
|
| 109 | - 'updated' => array( 'post_modified', false ), |
|
| 108 | + 'title' => array('title', false), |
|
| 109 | + 'updated' => array('post_modified', false), |
|
| 110 | 110 | ); |
| 111 | 111 | break; |
| 112 | 112 | |
| 113 | 113 | default: |
| 114 | 114 | $columns = array( |
| 115 | - 'title' => array( 'title', false ), |
|
| 116 | - 'updated' => array( 'post_modified', false ), |
|
| 115 | + 'title' => array('title', false), |
|
| 116 | + 'updated' => array('post_modified', false), |
|
| 117 | 117 | ); |
| 118 | 118 | break; |
| 119 | 119 | } |
| 120 | 120 | // Backwards compatible |
| 121 | - if ( 'learners' == $this->view ) { |
|
| 122 | - $columns = apply_filters( 'sensei_learners_learners_columns_sortable', $columns, $this ); |
|
| 121 | + if ('learners' == $this->view) { |
|
| 122 | + $columns = apply_filters('sensei_learners_learners_columns_sortable', $columns, $this); |
|
| 123 | 123 | } |
| 124 | - $columns = apply_filters( 'sensei_learners_default_columns_sortable', $columns, $this ); |
|
| 124 | + $columns = apply_filters('sensei_learners_default_columns_sortable', $columns, $this); |
|
| 125 | 125 | return $columns; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,72 +135,72 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | // Handle orderby |
| 137 | 137 | $orderby = ''; |
| 138 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 139 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 140 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 138 | + if ( ! empty($_GET['orderby'])) { |
|
| 139 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 140 | + $orderby = esc_html($_GET['orderby']); |
|
| 141 | 141 | } // End If Statement |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Handle order |
| 145 | 145 | $order = 'DESC'; |
| 146 | - if ( !empty( $_GET['order'] ) ) { |
|
| 147 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 146 | + if ( ! empty($_GET['order'])) { |
|
| 147 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Handle category selection |
| 151 | 151 | $category = false; |
| 152 | - if ( !empty( $_GET['course_cat'] ) ) { |
|
| 153 | - $category = intval( $_GET['course_cat'] ); |
|
| 152 | + if ( ! empty($_GET['course_cat'])) { |
|
| 153 | + $category = intval($_GET['course_cat']); |
|
| 154 | 154 | } // End If Statement |
| 155 | 155 | |
| 156 | 156 | // Handle search |
| 157 | 157 | $search = false; |
| 158 | - if ( !empty( $_GET['s'] ) ) { |
|
| 159 | - $search = esc_html( $_GET['s'] ); |
|
| 158 | + if ( ! empty($_GET['s'])) { |
|
| 159 | + $search = esc_html($_GET['s']); |
|
| 160 | 160 | } // End If Statement |
| 161 | 161 | |
| 162 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 163 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 162 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 163 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 164 | 164 | |
| 165 | 165 | $paged = $this->get_pagenum(); |
| 166 | 166 | $offset = 0; |
| 167 | - if ( !empty($paged) ) { |
|
| 168 | - $offset = $per_page * ( $paged - 1 ); |
|
| 167 | + if ( ! empty($paged)) { |
|
| 168 | + $offset = $per_page * ($paged - 1); |
|
| 169 | 169 | } // End If Statement |
| 170 | 170 | |
| 171 | - switch( $this->view ) { |
|
| 171 | + switch ($this->view) { |
|
| 172 | 172 | case 'learners': |
| 173 | - if ( empty($orderby) ) { |
|
| 173 | + if (empty($orderby)) { |
|
| 174 | 174 | $orderby = ''; |
| 175 | 175 | } |
| 176 | - $this->items = $this->get_learners( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) ); |
|
| 176 | + $this->items = $this->get_learners(compact('per_page', 'offset', 'orderby', 'order', 'search')); |
|
| 177 | 177 | |
| 178 | 178 | break; |
| 179 | 179 | |
| 180 | 180 | case 'lessons': |
| 181 | - if ( empty($orderby) ) { |
|
| 181 | + if (empty($orderby)) { |
|
| 182 | 182 | $orderby = 'post_modified'; |
| 183 | 183 | } |
| 184 | - $this->items = $this->get_lessons( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) ); |
|
| 184 | + $this->items = $this->get_lessons(compact('per_page', 'offset', 'orderby', 'order', 'search')); |
|
| 185 | 185 | |
| 186 | 186 | break; |
| 187 | 187 | |
| 188 | 188 | default: |
| 189 | - if ( empty($orderby) ) { |
|
| 189 | + if (empty($orderby)) { |
|
| 190 | 190 | $orderby = 'post_modified'; |
| 191 | 191 | } |
| 192 | - $this->items = $this->get_courses( compact( 'per_page', 'offset', 'orderby', 'order', 'category', 'search' ) ); |
|
| 192 | + $this->items = $this->get_courses(compact('per_page', 'offset', 'orderby', 'order', 'category', 'search')); |
|
| 193 | 193 | |
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $total_items = $this->total_items; |
| 198 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 199 | - $this->set_pagination_args( array( |
|
| 198 | + $total_pages = ceil($total_items / $per_page); |
|
| 199 | + $this->set_pagination_args(array( |
|
| 200 | 200 | 'total_items' => $total_items, |
| 201 | 201 | 'total_pages' => $total_pages, |
| 202 | 202 | 'per_page' => $per_page |
| 203 | - ) ); |
|
| 203 | + )); |
|
| 204 | 204 | |
| 205 | 205 | } // End prepare_items() |
| 206 | 206 | |
@@ -214,53 +214,53 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | - protected function get_row_data( $item ) { |
|
| 217 | + protected function get_row_data($item) { |
|
| 218 | 218 | global $wp_version; |
| 219 | 219 | |
| 220 | - switch ( $this->view ) { |
|
| 220 | + switch ($this->view) { |
|
| 221 | 221 | case 'learners' : |
| 222 | 222 | |
| 223 | 223 | // in this case the item passed in is actually the users activity on course of lesson |
| 224 | 224 | $user_activity = $item; |
| 225 | 225 | $post_id = false; |
| 226 | 226 | |
| 227 | - if( $this->lesson_id ) { |
|
| 227 | + if ($this->lesson_id) { |
|
| 228 | 228 | |
| 229 | - $post_id = intval( $this->lesson_id ); |
|
| 230 | - $object_type = __( 'lesson', 'woothemes-sensei' ); |
|
| 229 | + $post_id = intval($this->lesson_id); |
|
| 230 | + $object_type = __('lesson', 'woothemes-sensei'); |
|
| 231 | 231 | $post_type = 'lesson'; |
| 232 | 232 | |
| 233 | - } elseif( $this->course_id ) { |
|
| 233 | + } elseif ($this->course_id) { |
|
| 234 | 234 | |
| 235 | - $post_id = intval( $this->course_id ); |
|
| 236 | - $object_type = __( 'course', 'woothemes-sensei' ); |
|
| 235 | + $post_id = intval($this->course_id); |
|
| 236 | + $object_type = __('course', 'woothemes-sensei'); |
|
| 237 | 237 | $post_type = 'course'; |
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) { |
|
| 241 | + if ('complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved) { |
|
| 242 | 242 | |
| 243 | - $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>'; |
|
| 243 | + $status_html = '<span class="graded">'.__('Completed', 'woothemes-sensei').'</span>'; |
|
| 244 | 244 | |
| 245 | 245 | } else { |
| 246 | 246 | |
| 247 | - $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>'; |
|
| 247 | + $status_html = '<span class="in-progress">'.__('In Progress', 'woothemes-sensei').'</span>'; |
|
| 248 | 248 | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $title = Sensei_Student::get_full_name( $user_activity->user_id ); |
|
| 252 | - $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
|
| 251 | + $title = Sensei_Student::get_full_name($user_activity->user_id); |
|
| 252 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
| 253 | 253 | |
| 254 | 254 | // get the learners order for this course if the course was purchased |
| 255 | 255 | |
| 256 | 256 | $course_order_id_attribute = ''; |
| 257 | - if( Sensei_WC::is_woocommerce_active() ){ |
|
| 257 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 258 | 258 | |
| 259 | - $course_product_order_id = Sensei_WC::get_learner_course_active_order_id( $user_activity->user_id, $post_id ); |
|
| 259 | + $course_product_order_id = Sensei_WC::get_learner_course_active_order_id($user_activity->user_id, $post_id); |
|
| 260 | 260 | |
| 261 | - if( $course_product_order_id ){ |
|
| 261 | + if ($course_product_order_id) { |
|
| 262 | 262 | |
| 263 | - $course_order_id_attribute = ' data-order_id="' . $course_product_order_id . '" '; |
|
| 263 | + $course_order_id_attribute = ' data-order_id="'.$course_product_order_id.'" '; |
|
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | |
@@ -279,50 +279,50 @@ discard block |
||
| 279 | 279 | * type html $action_buttons |
| 280 | 280 | * } |
| 281 | 281 | */ |
| 282 | - $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
|
| 283 | - 'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
|
| 284 | - 'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true), |
|
| 282 | + $column_data = apply_filters('sensei_learners_main_column_data', array( |
|
| 283 | + 'title' => '<strong><a class="row-title" href="'.admin_url('user-edit.php?user_id='.$user_activity->user_id).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>', |
|
| 284 | + 'date_started' => get_comment_meta($user_activity->comment_ID, 'start', true), |
|
| 285 | 285 | 'user_status' => $status_html, |
| 286 | - 'actions' => '<a class="remove-learner button" data-user_id="' . $user_activity->user_id . '" data-post_id="' . $post_id . '" data-post_type="' . $post_type . '" '. $course_order_id_attribute . '">' . sprintf( __( 'Remove from %1$s', 'woothemes-sensei' ), $object_type ) . '</a>', |
|
| 287 | - ), $item, $post_id, $post_type ); |
|
| 286 | + 'actions' => '<a class="remove-learner button" data-user_id="'.$user_activity->user_id.'" data-post_id="'.$post_id.'" data-post_type="'.$post_type.'" '.$course_order_id_attribute.'">'.sprintf(__('Remove from %1$s', 'woothemes-sensei'), $object_type).'</a>', |
|
| 287 | + ), $item, $post_id, $post_type); |
|
| 288 | 288 | |
| 289 | 289 | break; |
| 290 | 290 | |
| 291 | 291 | case 'lessons' : |
| 292 | - $lesson_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_lesson_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any' ) ) ); |
|
| 293 | - $title = get_the_title( $item ); |
|
| 294 | - $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
|
| 292 | + $lesson_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_lesson_learners', array('post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any'))); |
|
| 293 | + $title = get_the_title($item); |
|
| 294 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
| 295 | 295 | |
| 296 | 296 | $grading_action = ''; |
| 297 | - if ( get_post_meta( $item->ID, '_quiz_has_questions', true ) ) { |
|
| 298 | - $grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>'; |
|
| 297 | + if (get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
| 298 | + $grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>'; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
|
| 302 | - 'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
|
| 301 | + $column_data = apply_filters('sensei_learners_main_column_data', array( |
|
| 302 | + 'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>', |
|
| 303 | 303 | 'num_learners' => $lesson_learners, |
| 304 | 304 | 'updated' => $item->post_modified, |
| 305 | - 'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action, |
|
| 306 | - ), $item, $this->course_id ); |
|
| 305 | + 'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action, |
|
| 306 | + ), $item, $this->course_id); |
|
| 307 | 307 | break; |
| 308 | 308 | |
| 309 | 309 | case 'courses' : |
| 310 | 310 | default: |
| 311 | - $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) ); |
|
| 312 | - $title = get_the_title( $item ); |
|
| 313 | - $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
|
| 311 | + $course_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_course_learners', array('post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any'))); |
|
| 312 | + $title = get_the_title($item); |
|
| 313 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
| 314 | 314 | |
| 315 | 315 | $grading_action = ''; |
| 316 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
| 317 | - $grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $item->ID ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>'; |
|
| 316 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
| 317 | + $grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $item->ID), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>'; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
|
| 321 | - 'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
|
| 320 | + $column_data = apply_filters('sensei_learners_main_column_data', array( |
|
| 321 | + 'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>', |
|
| 322 | 322 | 'num_learners' => $course_learners, |
| 323 | 323 | 'updated' => $item->post_modified, |
| 324 | - 'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action, |
|
| 325 | - ), $item ); |
|
| 324 | + 'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action, |
|
| 325 | + ), $item); |
|
| 326 | 326 | |
| 327 | 327 | break; |
| 328 | 328 | } // switch |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @since 1.7.0 |
| 336 | 336 | * @return array courses |
| 337 | 337 | */ |
| 338 | - private function get_courses( $args ) { |
|
| 338 | + private function get_courses($args) { |
|
| 339 | 339 | $course_args = array( |
| 340 | 340 | 'post_type' => 'course', |
| 341 | 341 | 'post_status' => 'publish', |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | 'order' => $args['order'], |
| 346 | 346 | ); |
| 347 | 347 | |
| 348 | - if( $args['category'] ) { |
|
| 348 | + if ($args['category']) { |
|
| 349 | 349 | $course_args['tax_query'][] = array( |
| 350 | 350 | 'taxonomy' => 'course-category', |
| 351 | 351 | 'field' => 'id', |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | ); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if( $args['search'] ) { |
|
| 356 | + if ($args['search']) { |
|
| 357 | 357 | $course_args['s'] = $args['search']; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $courses_query = new WP_Query( apply_filters( 'sensei_learners_filter_courses', $course_args ) ); |
|
| 360 | + $courses_query = new WP_Query(apply_filters('sensei_learners_filter_courses', $course_args)); |
|
| 361 | 361 | |
| 362 | 362 | $this->total_items = $courses_query->found_posts; |
| 363 | 363 | return $courses_query->posts; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @since 1.7.0 |
| 369 | 369 | * @return array lessons |
| 370 | 370 | */ |
| 371 | - private function get_lessons( $args ) { |
|
| 371 | + private function get_lessons($args) { |
|
| 372 | 372 | $lesson_args = array( |
| 373 | 373 | 'post_type' => 'lesson', |
| 374 | 374 | 'post_status' => 'publish', |
@@ -378,18 +378,18 @@ discard block |
||
| 378 | 378 | 'order' => $args['order'], |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | - if( $this->course_id ) { |
|
| 381 | + if ($this->course_id) { |
|
| 382 | 382 | $lesson_args['meta_query'][] = array( |
| 383 | 383 | 'key' => '_lesson_course', |
| 384 | 384 | 'value' => $this->course_id, |
| 385 | 385 | ); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if( $args['search'] ) { |
|
| 388 | + if ($args['search']) { |
|
| 389 | 389 | $lesson_args['s'] = $args['search']; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $lessons_query = new WP_Query( apply_filters( 'sensei_learners_filter_lessons', $lesson_args ) ); |
|
| 392 | + $lessons_query = new WP_Query(apply_filters('sensei_learners_filter_lessons', $lesson_args)); |
|
| 393 | 393 | |
| 394 | 394 | $this->total_items = $lessons_query->found_posts; |
| 395 | 395 | return $lessons_query->posts; |
@@ -400,22 +400,22 @@ discard block |
||
| 400 | 400 | * @since 1.7.0 |
| 401 | 401 | * @return array learners |
| 402 | 402 | */ |
| 403 | - private function get_learners( $args ) { |
|
| 403 | + private function get_learners($args) { |
|
| 404 | 404 | |
| 405 | 405 | $user_ids = false; |
| 406 | 406 | $post_id = 0; |
| 407 | 407 | $activity = ''; |
| 408 | 408 | |
| 409 | - if( $this->lesson_id ) { |
|
| 410 | - $post_id = intval( $this->lesson_id ); |
|
| 409 | + if ($this->lesson_id) { |
|
| 410 | + $post_id = intval($this->lesson_id); |
|
| 411 | 411 | $activity = 'sensei_lesson_status'; |
| 412 | 412 | } |
| 413 | - elseif( $this->course_id ) { |
|
| 414 | - $post_id = intval( $this->course_id ); |
|
| 413 | + elseif ($this->course_id) { |
|
| 414 | + $post_id = intval($this->course_id); |
|
| 415 | 415 | $activity = 'sensei_course_status'; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if( ! $post_id || ! $activity ) { |
|
| 418 | + if ( ! $post_id || ! $activity) { |
|
| 419 | 419 | $this->total_items = 0; |
| 420 | 420 | return array(); |
| 421 | 421 | } |
@@ -431,32 +431,32 @@ discard block |
||
| 431 | 431 | ); |
| 432 | 432 | |
| 433 | 433 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
| 434 | - if ( $args['search'] ) { |
|
| 434 | + if ($args['search']) { |
|
| 435 | 435 | $user_args = array( |
| 436 | - 'search' => '*' . $args['search'] . '*', |
|
| 436 | + 'search' => '*'.$args['search'].'*', |
|
| 437 | 437 | 'fields' => 'ID' |
| 438 | 438 | ); |
| 439 | 439 | // Filter for extending |
| 440 | - $user_args = apply_filters( 'sensei_learners_search_users', $user_args ); |
|
| 441 | - if ( !empty( $user_args ) ) { |
|
| 442 | - $learners_search = new WP_User_Query( $user_args ); |
|
| 440 | + $user_args = apply_filters('sensei_learners_search_users', $user_args); |
|
| 441 | + if ( ! empty($user_args)) { |
|
| 442 | + $learners_search = new WP_User_Query($user_args); |
|
| 443 | 443 | $activity_args['user_id'] = $learners_search->get_results(); |
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - $activity_args = apply_filters( 'sensei_learners_filter_users', $activity_args ); |
|
| 447 | + $activity_args = apply_filters('sensei_learners_filter_users', $activity_args); |
|
| 448 | 448 | |
| 449 | 449 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
| 450 | - $total_learners = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
| 450 | + $total_learners = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
| 451 | 451 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
| 452 | - if ( $total_learners < $activity_args['offset'] ) { |
|
| 453 | - $new_paged = floor( $total_learners / $activity_args['number'] ); |
|
| 452 | + if ($total_learners < $activity_args['offset']) { |
|
| 453 | + $new_paged = floor($total_learners / $activity_args['number']); |
|
| 454 | 454 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
| 455 | 455 | } |
| 456 | - $learners = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
| 456 | + $learners = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
| 457 | 457 | // Need to always return an array, even with only 1 item |
| 458 | - if ( !is_array($learners) ) { |
|
| 459 | - $learners = array( $learners ); |
|
| 458 | + if ( ! is_array($learners)) { |
|
| 459 | + $learners = array($learners); |
|
| 460 | 460 | } |
| 461 | 461 | $this->total_items = $total_learners; |
| 462 | 462 | return $learners; |
@@ -469,22 +469,22 @@ discard block |
||
| 469 | 469 | * @return void |
| 470 | 470 | */ |
| 471 | 471 | public function no_items() { |
| 472 | - switch( $this->view ) { |
|
| 472 | + switch ($this->view) { |
|
| 473 | 473 | case 'learners' : |
| 474 | - $text = __( 'No learners found.', 'woothemes-sensei' ); |
|
| 474 | + $text = __('No learners found.', 'woothemes-sensei'); |
|
| 475 | 475 | break; |
| 476 | 476 | |
| 477 | 477 | case 'lessons' : |
| 478 | - $text = __( 'No lessons found.', 'woothemes-sensei' ); |
|
| 478 | + $text = __('No lessons found.', 'woothemes-sensei'); |
|
| 479 | 479 | break; |
| 480 | 480 | |
| 481 | 481 | case 'courses': |
| 482 | 482 | case 'default': |
| 483 | 483 | default: |
| 484 | - $text = __( 'No courses found.', 'woothemes-sensei' ); |
|
| 484 | + $text = __('No courses found.', 'woothemes-sensei'); |
|
| 485 | 485 | break; |
| 486 | 486 | } |
| 487 | - echo apply_filters( 'sensei_learners_no_items_text', $text ); |
|
| 487 | + echo apply_filters('sensei_learners_no_items_text', $text); |
|
| 488 | 488 | } // End no_items() |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -495,40 +495,40 @@ discard block |
||
| 495 | 495 | public function data_table_header() { |
| 496 | 496 | |
| 497 | 497 | echo '<div class="learners-selects">'; |
| 498 | - do_action( 'sensei_learners_before_dropdown_filters' ); |
|
| 498 | + do_action('sensei_learners_before_dropdown_filters'); |
|
| 499 | 499 | |
| 500 | 500 | // Display Course Categories only on default view |
| 501 | - if( 'courses' == $this->view ) { |
|
| 501 | + if ('courses' == $this->view) { |
|
| 502 | 502 | |
| 503 | 503 | $selected_cat = 0; |
| 504 | - if ( isset( $_GET['course_cat'] ) && '' != esc_html( $_GET['course_cat'] ) ) { |
|
| 505 | - $selected_cat = intval( $_GET['course_cat'] ); |
|
| 504 | + if (isset($_GET['course_cat']) && '' != esc_html($_GET['course_cat'])) { |
|
| 505 | + $selected_cat = intval($_GET['course_cat']); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $cats = get_terms( 'course-category', array( 'hide_empty' => false ) ); |
|
| 508 | + $cats = get_terms('course-category', array('hide_empty' => false)); |
|
| 509 | 509 | |
| 510 | - echo '<div class="select-box">' . "\n"; |
|
| 510 | + echo '<div class="select-box">'."\n"; |
|
| 511 | 511 | |
| 512 | - echo '<select id="course-category-options" data-placeholder="' . __( 'Course Category', 'woothemes-sensei' ) . '" name="learners_course_cat" class="chosen_select widefat">' . "\n"; |
|
| 512 | + echo '<select id="course-category-options" data-placeholder="'.__('Course Category', 'woothemes-sensei').'" name="learners_course_cat" class="chosen_select widefat">'."\n"; |
|
| 513 | 513 | |
| 514 | - echo '<option value="0">' . __( 'All Course Categories', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
| 514 | + echo '<option value="0">'.__('All Course Categories', 'woothemes-sensei').'</option>'."\n"; |
|
| 515 | 515 | |
| 516 | - foreach( $cats as $cat ) { |
|
| 517 | - echo '<option value="' . $cat->term_id . '"' . selected( $cat->term_id, $selected_cat, false ) . '>' . $cat->name . '</option>' . "\n"; |
|
| 516 | + foreach ($cats as $cat) { |
|
| 517 | + echo '<option value="'.$cat->term_id.'"'.selected($cat->term_id, $selected_cat, false).'>'.$cat->name.'</option>'."\n"; |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - echo '</select>' . "\n"; |
|
| 520 | + echo '</select>'."\n"; |
|
| 521 | 521 | |
| 522 | - echo '</div>' . "\n"; |
|
| 522 | + echo '</div>'."\n"; |
|
| 523 | 523 | } |
| 524 | 524 | echo '</div><!-- /.learners-selects -->'; |
| 525 | 525 | |
| 526 | 526 | $menu = array(); |
| 527 | 527 | // Have Course no Lesson |
| 528 | - if( $this->course_id && ! $this->lesson_id ) { |
|
| 528 | + if ($this->course_id && ! $this->lesson_id) { |
|
| 529 | 529 | |
| 530 | 530 | $learners_class = $lessons_class = ''; |
| 531 | - switch( $this->view ) { |
|
| 531 | + switch ($this->view) { |
|
| 532 | 532 | case 'learners': |
| 533 | 533 | $learners_class = 'current'; |
| 534 | 534 | break; |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | $learner_args['view'] = 'learners'; |
| 548 | 548 | $lesson_args['view'] = 'lessons'; |
| 549 | 549 | |
| 550 | - $menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>'; |
|
| 551 | - $menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>'; |
|
| 550 | + $menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>'; |
|
| 551 | + $menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>'; |
|
| 552 | 552 | |
| 553 | 553 | } |
| 554 | 554 | // Have Course and Lesson |
| 555 | - elseif( $this->course_id && $this->lesson_id ) { |
|
| 555 | + elseif ($this->course_id && $this->lesson_id) { |
|
| 556 | 556 | |
| 557 | 557 | $query_args = array( |
| 558 | 558 | 'page' => $this->page_slug, |
@@ -560,18 +560,18 @@ discard block |
||
| 560 | 560 | 'view' => 'lessons' |
| 561 | 561 | ); |
| 562 | 562 | |
| 563 | - $course = get_the_title( $this->course_id ); |
|
| 563 | + $course = get_the_title($this->course_id); |
|
| 564 | 564 | |
| 565 | - $menu['back'] = '<a href="' . esc_url( add_query_arg( $query_args, admin_url( 'admin.php' ) ) ) . '">' . sprintf( __( '%1$sBack to %2$s%3$s', 'woothemes-sensei' ), '<em>← ', $course, '</em>' ) . '</a>'; |
|
| 565 | + $menu['back'] = '<a href="'.esc_url(add_query_arg($query_args, admin_url('admin.php'))).'">'.sprintf(__('%1$sBack to %2$s%3$s', 'woothemes-sensei'), '<em>← ', $course, '</em>').'</a>'; |
|
| 566 | 566 | } |
| 567 | - $menu = apply_filters( 'sensei_learners_sub_menu', $menu ); |
|
| 568 | - if ( !empty($menu) ) { |
|
| 569 | - echo '<ul class="subsubsub">' . "\n"; |
|
| 570 | - foreach ( $menu as $class => $item ) { |
|
| 571 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
| 567 | + $menu = apply_filters('sensei_learners_sub_menu', $menu); |
|
| 568 | + if ( ! empty($menu)) { |
|
| 569 | + echo '<ul class="subsubsub">'."\n"; |
|
| 570 | + foreach ($menu as $class => $item) { |
|
| 571 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
| 572 | 572 | } |
| 573 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
| 574 | - echo '</ul>' . "\n"; |
|
| 573 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
| 574 | + echo '</ul>'."\n"; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | } // End data_table_header() |
@@ -596,50 +596,50 @@ discard block |
||
| 596 | 596 | $form_post_type = ''; |
| 597 | 597 | $form_course_id = 0; |
| 598 | 598 | $form_lesson_id = 0; |
| 599 | - if( $this->course_id && ! $this->lesson_id ) { |
|
| 600 | - $post_title = get_the_title( $this->course_id ); |
|
| 601 | - $post_type = __( 'Course', 'woothemes-sensei' ); |
|
| 599 | + if ($this->course_id && ! $this->lesson_id) { |
|
| 600 | + $post_title = get_the_title($this->course_id); |
|
| 601 | + $post_type = __('Course', 'woothemes-sensei'); |
|
| 602 | 602 | $form_post_type = 'course'; |
| 603 | 603 | $form_course_id = $this->course_id; |
| 604 | 604 | } |
| 605 | - elseif( $this->course_id && $this->lesson_id ) { |
|
| 606 | - $post_title = get_the_title( $this->lesson_id ); |
|
| 607 | - $post_type = __( 'Lesson', 'woothemes-sensei' ); |
|
| 605 | + elseif ($this->course_id && $this->lesson_id) { |
|
| 606 | + $post_title = get_the_title($this->lesson_id); |
|
| 607 | + $post_type = __('Lesson', 'woothemes-sensei'); |
|
| 608 | 608 | $form_post_type = 'lesson'; |
| 609 | 609 | $form_course_id = $this->course_id; |
| 610 | 610 | $form_lesson_id = $this->lesson_id; |
| 611 | - $course_title = get_the_title( $this->course_id ); |
|
| 611 | + $course_title = get_the_title($this->course_id); |
|
| 612 | 612 | } |
| 613 | - if ( empty($form_post_type) ) { |
|
| 613 | + if (empty($form_post_type)) { |
|
| 614 | 614 | return; |
| 615 | 615 | } |
| 616 | 616 | ?> |
| 617 | 617 | <div class="postbox"> |
| 618 | - <h3><span><?php printf( __( 'Add Learner to %1$s', 'woothemes-sensei' ), $post_type ); ?></span></h3> |
|
| 618 | + <h3><span><?php printf(__('Add Learner to %1$s', 'woothemes-sensei'), $post_type); ?></span></h3> |
|
| 619 | 619 | <div class="inside"> |
| 620 | 620 | <form name="add_learner" action="" method="post"> |
| 621 | 621 | <p> |
| 622 | - <input name="add_user_id" placeholder="<?php _e( 'Find learner', 'woothemes-sensei' ) ;?>" id="add_learner_search" style="min-width:300px;" /> |
|
| 623 | - <?php if( 'lesson' == $form_post_type ) { ?> |
|
| 624 | - <label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson" value="yes" /> <?php _e( 'Complete lesson for learner', 'woothemes-sensei' ); ?></label> |
|
| 625 | - <?php } elseif( 'course' == $form_post_type ) { ?> |
|
| 626 | - <label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course" value="yes" /> <?php _e( 'Complete course for learner', 'woothemes-sensei' ); ?></label> |
|
| 622 | + <input name="add_user_id" placeholder="<?php _e('Find learner', 'woothemes-sensei'); ?>" id="add_learner_search" style="min-width:300px;" /> |
|
| 623 | + <?php if ('lesson' == $form_post_type) { ?> |
|
| 624 | + <label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson" value="yes" /> <?php _e('Complete lesson for learner', 'woothemes-sensei'); ?></label> |
|
| 625 | + <?php } elseif ('course' == $form_post_type) { ?> |
|
| 626 | + <label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course" value="yes" /> <?php _e('Complete course for learner', 'woothemes-sensei'); ?></label> |
|
| 627 | 627 | <?php } ?> |
| 628 | 628 | <br/> |
| 629 | - <span class="description"><?php _e( 'Search for a user by typing their name or username.', 'woothemes-sensei' ); ?></span> |
|
| 629 | + <span class="description"><?php _e('Search for a user by typing their name or username.', 'woothemes-sensei'); ?></span> |
|
| 630 | 630 | </p> |
| 631 | - <p><?php submit_button( sprintf( __( 'Add to \'%1$s\'', 'woothemes-sensei' ), $post_title ), 'primary', 'add_learner_submit', false, array() ); ?></p> |
|
| 632 | - <?php if( 'lesson' == $form_post_type ) { ?> |
|
| 633 | - <p><span class="description"><?php printf( __( 'Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei' ), $course_title ); ?></span></p> |
|
| 631 | + <p><?php submit_button(sprintf(__('Add to \'%1$s\'', 'woothemes-sensei'), $post_title), 'primary', 'add_learner_submit', false, array()); ?></p> |
|
| 632 | + <?php if ('lesson' == $form_post_type) { ?> |
|
| 633 | + <p><span class="description"><?php printf(__('Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei'), $course_title); ?></span></p> |
|
| 634 | 634 | <?php } ?> |
| 635 | 635 | |
| 636 | 636 | <input type="hidden" name="add_post_type" value="<?php echo $form_post_type; ?>" /> |
| 637 | 637 | <input type="hidden" name="add_course_id" value="<?php echo $form_course_id; ?>" /> |
| 638 | 638 | <input type="hidden" name="add_lesson_id" value="<?php echo $form_lesson_id; ?>" /> |
| 639 | 639 | <?php |
| 640 | - do_action( 'sensei_learners_add_learner_form' ); |
|
| 640 | + do_action('sensei_learners_add_learner_form'); |
|
| 641 | 641 | ?> |
| 642 | - <?php wp_nonce_field( 'add_learner_to_sensei', 'add_learner_nonce' ); ?> |
|
| 642 | + <?php wp_nonce_field('add_learner_to_sensei', 'add_learner_nonce'); ?> |
|
| 643 | 643 | </form> |
| 644 | 644 | </div> |
| 645 | 645 | </div> |
@@ -651,19 +651,19 @@ discard block |
||
| 651 | 651 | * @since 1.7.0 |
| 652 | 652 | * @return void |
| 653 | 653 | */ |
| 654 | - public function search_button( $text = '' ) { |
|
| 654 | + public function search_button($text = '') { |
|
| 655 | 655 | |
| 656 | - switch( $this->view ) { |
|
| 656 | + switch ($this->view) { |
|
| 657 | 657 | case 'learners': |
| 658 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
| 658 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
| 659 | 659 | break; |
| 660 | 660 | |
| 661 | 661 | case 'lessons': |
| 662 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
| 662 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
| 663 | 663 | break; |
| 664 | 664 | |
| 665 | 665 | default: |
| 666 | - $text = __( 'Search Courses', 'woothemes-sensei' ); |
|
| 666 | + $text = __('Search Courses', 'woothemes-sensei'); |
|
| 667 | 667 | break; |
| 668 | 668 | } |
| 669 | 669 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Analysis Course List Table Class |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | * @since 1.2.0 |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - public function __construct ( $course_id = 0, $user_id = 0 ) { |
|
| 29 | - $this->course_id = intval( $course_id ); |
|
| 30 | - $this->user_id = intval( $user_id ); |
|
| 28 | + public function __construct($course_id = 0, $user_id = 0) { |
|
| 29 | + $this->course_id = intval($course_id); |
|
| 30 | + $this->user_id = intval($user_id); |
|
| 31 | 31 | |
| 32 | - if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'user', 'lesson' ) ) ) { |
|
| 32 | + if (isset($_GET['view']) && in_array($_GET['view'], array('user', 'lesson'))) { |
|
| 33 | 33 | $this->view = $_GET['view']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // Viewing a single Learner always sets the view to Lessons |
| 37 | - if( $this->user_id ) { |
|
| 37 | + if ($this->user_id) { |
|
| 38 | 38 | $this->view = 'lesson'; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Load Parent token into constructor |
| 42 | - parent::__construct( 'analysis_course' ); |
|
| 42 | + parent::__construct('analysis_course'); |
|
| 43 | 43 | |
| 44 | 44 | // Actions |
| 45 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 46 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 45 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 46 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 47 | 47 | |
| 48 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 48 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 49 | 49 | |
| 50 | 50 | } // End __construct() |
| 51 | 51 | |
@@ -56,45 +56,45 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function get_columns() { |
| 58 | 58 | |
| 59 | - switch( $this->view ) { |
|
| 59 | + switch ($this->view) { |
|
| 60 | 60 | case 'user' : |
| 61 | 61 | $columns = array( |
| 62 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 63 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 64 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
| 65 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
| 66 | - 'percent' => __( 'Percent Complete', 'woothemes-sensei' ), |
|
| 62 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 63 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
| 64 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
| 65 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
| 66 | + 'percent' => __('Percent Complete', 'woothemes-sensei'), |
|
| 67 | 67 | ); |
| 68 | 68 | break; |
| 69 | 69 | |
| 70 | 70 | case 'lesson' : |
| 71 | 71 | default: |
| 72 | - if ( $this->user_id ) { |
|
| 72 | + if ($this->user_id) { |
|
| 73 | 73 | |
| 74 | 74 | $columns = array( |
| 75 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 76 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 77 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
| 78 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
| 79 | - 'grade' => __( 'Grade', 'woothemes-sensei' ), |
|
| 75 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 76 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
| 77 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
| 78 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
| 79 | + 'grade' => __('Grade', 'woothemes-sensei'), |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | } else { |
| 83 | 83 | |
| 84 | 84 | $columns = array( |
| 85 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 86 | - 'num_learners' => __( 'Learners', 'woothemes-sensei' ), |
|
| 87 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
| 88 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
| 85 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 86 | + 'num_learners' => __('Learners', 'woothemes-sensei'), |
|
| 87 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
| 88 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | } |
| 94 | 94 | // Backwards compatible |
| 95 | - $columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns', $columns, $this ); |
|
| 95 | + $columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns', $columns, $this); |
|
| 96 | 96 | // Moving forward, single filter with args |
| 97 | - $columns = apply_filters( 'sensei_analysis_course_columns', $columns, $this ); |
|
| 97 | + $columns = apply_filters('sensei_analysis_course_columns', $columns, $this); |
|
| 98 | 98 | return $columns; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,46 +105,46 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | function get_sortable_columns() { |
| 107 | 107 | |
| 108 | - switch( $this->view ) { |
|
| 108 | + switch ($this->view) { |
|
| 109 | 109 | case 'user' : |
| 110 | 110 | $columns = array( |
| 111 | - 'title' => array( 'title', false ), |
|
| 112 | - 'started' => array( 'started', false ), |
|
| 113 | - 'completed' => array( 'completed', false ), |
|
| 114 | - 'user_status' => array( 'user_status', false ), |
|
| 111 | + 'title' => array('title', false), |
|
| 112 | + 'started' => array('started', false), |
|
| 113 | + 'completed' => array('completed', false), |
|
| 114 | + 'user_status' => array('user_status', false), |
|
| 115 | 115 | // 'grade' => array( 'grade', false ), |
| 116 | - 'percent' => array( 'percent', false ) |
|
| 116 | + 'percent' => array('percent', false) |
|
| 117 | 117 | ); |
| 118 | 118 | break; |
| 119 | 119 | |
| 120 | 120 | case 'lesson' : |
| 121 | 121 | default: |
| 122 | - if ( $this->user_id ) { |
|
| 122 | + if ($this->user_id) { |
|
| 123 | 123 | |
| 124 | 124 | $columns = array( |
| 125 | - 'title' => array( 'title', false ), |
|
| 126 | - 'started' => array( 'started', false ), |
|
| 127 | - 'completed' => array( 'completed', false ), |
|
| 128 | - 'user_status' => array( 'user_status', false ), |
|
| 129 | - 'grade' => array( 'grade', false ), |
|
| 125 | + 'title' => array('title', false), |
|
| 126 | + 'started' => array('started', false), |
|
| 127 | + 'completed' => array('completed', false), |
|
| 128 | + 'user_status' => array('user_status', false), |
|
| 129 | + 'grade' => array('grade', false), |
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | } else { |
| 133 | 133 | |
| 134 | 134 | $columns = array( |
| 135 | - 'title' => array( 'title', false ), |
|
| 136 | - 'num_learners' => array( 'num_learners', false ), |
|
| 137 | - 'completions' => array( 'completions', false ), |
|
| 138 | - 'average_grade' => array( 'average_grade', false ) |
|
| 135 | + 'title' => array('title', false), |
|
| 136 | + 'num_learners' => array('num_learners', false), |
|
| 137 | + 'completions' => array('completions', false), |
|
| 138 | + 'average_grade' => array('average_grade', false) |
|
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | break; |
| 143 | 143 | } |
| 144 | 144 | // Backwards compatible |
| 145 | - $columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns_sortable', $columns, $this ); |
|
| 145 | + $columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns_sortable', $columns, $this); |
|
| 146 | 146 | // Moving forward, single filter with args |
| 147 | - $columns = apply_filters( 'sensei_analysis_course_columns_sortable', $columns, $this ); |
|
| 147 | + $columns = apply_filters('sensei_analysis_course_columns_sortable', $columns, $this); |
|
| 148 | 148 | return $columns; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -158,32 +158,32 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | // Handle orderby (needs work) |
| 160 | 160 | $orderby = ''; |
| 161 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 162 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 163 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 161 | + if ( ! empty($_GET['orderby'])) { |
|
| 162 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 163 | + $orderby = esc_html($_GET['orderby']); |
|
| 164 | 164 | } // End If Statement |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Handle order |
| 168 | 168 | $order = 'ASC'; |
| 169 | - if ( !empty( $_GET['order'] ) ) { |
|
| 170 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 169 | + if ( ! empty($_GET['order'])) { |
|
| 170 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
| 174 | 174 | $search = false; |
| 175 | - if ( !empty( $_GET['s'] ) ) { |
|
| 176 | - $search = esc_html( $_GET['s'] ); |
|
| 175 | + if ( ! empty($_GET['s'])) { |
|
| 176 | + $search = esc_html($_GET['s']); |
|
| 177 | 177 | } // End If Statement |
| 178 | 178 | $this->search = $search; |
| 179 | 179 | |
| 180 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 181 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 180 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 181 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 182 | 182 | |
| 183 | 183 | $paged = $this->get_pagenum(); |
| 184 | 184 | $offset = 0; |
| 185 | - if ( !empty($paged) ) { |
|
| 186 | - $offset = $per_page * ( $paged - 1 ); |
|
| 185 | + if ( ! empty($paged)) { |
|
| 186 | + $offset = $per_page * ($paged - 1); |
|
| 187 | 187 | } // End If Statement |
| 188 | 188 | |
| 189 | 189 | $args = array( |
@@ -192,28 +192,28 @@ discard block |
||
| 192 | 192 | 'orderby' => $orderby, |
| 193 | 193 | 'order' => $order, |
| 194 | 194 | ); |
| 195 | - if ( $this->search ) { |
|
| 195 | + if ($this->search) { |
|
| 196 | 196 | $args['search'] = $this->search; |
| 197 | 197 | } // End If Statement |
| 198 | 198 | |
| 199 | - switch( $this->view ) { |
|
| 199 | + switch ($this->view) { |
|
| 200 | 200 | case 'user' : |
| 201 | - $this->items = $this->get_course_statuses( $args ); |
|
| 201 | + $this->items = $this->get_course_statuses($args); |
|
| 202 | 202 | break; |
| 203 | 203 | |
| 204 | 204 | case 'lesson': |
| 205 | 205 | default: |
| 206 | - $this->items = $this->get_lessons( $args ); |
|
| 206 | + $this->items = $this->get_lessons($args); |
|
| 207 | 207 | break; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $total_items = $this->total_items; |
| 211 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 212 | - $this->set_pagination_args( array( |
|
| 211 | + $total_pages = ceil($total_items / $per_page); |
|
| 212 | + $this->set_pagination_args(array( |
|
| 213 | 213 | 'total_items' => $total_items, |
| 214 | 214 | 'total_pages' => $total_pages, |
| 215 | 215 | 'per_page' => $per_page |
| 216 | - ) ); |
|
| 216 | + )); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @since 1.7.0 |
| 222 | 222 | * @return data |
| 223 | 223 | */ |
| 224 | - public function generate_report( $report ) { |
|
| 224 | + public function generate_report($report) { |
|
| 225 | 225 | |
| 226 | 226 | $data = array(); |
| 227 | 227 | |
@@ -229,22 +229,22 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | // Handle orderby |
| 231 | 231 | $orderby = ''; |
| 232 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 233 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 234 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 232 | + if ( ! empty($_GET['orderby'])) { |
|
| 233 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 234 | + $orderby = esc_html($_GET['orderby']); |
|
| 235 | 235 | } // End If Statement |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Handle order |
| 239 | 239 | $order = 'ASC'; |
| 240 | - if ( !empty( $_GET['order'] ) ) { |
|
| 241 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 240 | + if ( ! empty($_GET['order'])) { |
|
| 241 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Handle search |
| 245 | 245 | $search = false; |
| 246 | - if ( !empty( $_GET['s'] ) ) { |
|
| 247 | - $search = esc_html( $_GET['s'] ); |
|
| 246 | + if ( ! empty($_GET['s'])) { |
|
| 247 | + $search = esc_html($_GET['s']); |
|
| 248 | 248 | } // End If Statement |
| 249 | 249 | $this->search = $search; |
| 250 | 250 | |
@@ -252,32 +252,32 @@ discard block |
||
| 252 | 252 | 'orderby' => $orderby, |
| 253 | 253 | 'order' => $order, |
| 254 | 254 | ); |
| 255 | - if ( $this->search ) { |
|
| 255 | + if ($this->search) { |
|
| 256 | 256 | $args['search'] = $this->search; |
| 257 | 257 | } // End If Statement |
| 258 | 258 | |
| 259 | 259 | // Start the csv with the column headings |
| 260 | 260 | $column_headers = array(); |
| 261 | 261 | $columns = $this->get_columns(); |
| 262 | - foreach( $columns AS $key => $title ) { |
|
| 262 | + foreach ($columns AS $key => $title) { |
|
| 263 | 263 | $column_headers[] = $title; |
| 264 | 264 | } |
| 265 | 265 | $data[] = $column_headers; |
| 266 | 266 | |
| 267 | - switch( $this->view ) { |
|
| 267 | + switch ($this->view) { |
|
| 268 | 268 | case 'user' : |
| 269 | - $this->items = $this->get_course_statuses( $args ); |
|
| 269 | + $this->items = $this->get_course_statuses($args); |
|
| 270 | 270 | break; |
| 271 | 271 | |
| 272 | 272 | case 'lesson': |
| 273 | 273 | default: |
| 274 | - $this->items = $this->get_lessons( $args ); |
|
| 274 | + $this->items = $this->get_lessons($args); |
|
| 275 | 275 | break; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Process each row |
| 279 | - foreach( $this->items AS $item) { |
|
| 280 | - $data[] = $this->get_row_data( $item ); |
|
| 279 | + foreach ($this->items AS $item) { |
|
| 280 | + $data[] = $this->get_row_data($item); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | return $data; |
@@ -289,37 +289,37 @@ discard block |
||
| 289 | 289 | * @since 1.7.0 |
| 290 | 290 | * @param object $item The current item |
| 291 | 291 | */ |
| 292 | - protected function get_row_data( $item ) { |
|
| 292 | + protected function get_row_data($item) { |
|
| 293 | 293 | |
| 294 | - switch( $this->view ) { |
|
| 294 | + switch ($this->view) { |
|
| 295 | 295 | case 'user' : |
| 296 | - $user_start_date = get_comment_meta( $item->comment_ID, 'start', true ); |
|
| 296 | + $user_start_date = get_comment_meta($item->comment_ID, 'start', true); |
|
| 297 | 297 | $user_end_date = $item->comment_date; |
| 298 | 298 | |
| 299 | - if( 'complete' == $item->comment_approved ) { |
|
| 299 | + if ('complete' == $item->comment_approved) { |
|
| 300 | 300 | |
| 301 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
| 301 | + $status = __('Completed', 'woothemes-sensei'); |
|
| 302 | 302 | $status_class = 'graded'; |
| 303 | 303 | |
| 304 | 304 | } else { |
| 305 | 305 | |
| 306 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
| 306 | + $status = __('In Progress', 'woothemes-sensei'); |
|
| 307 | 307 | $status_class = 'in-progress'; |
| 308 | 308 | $user_end_date = ''; |
| 309 | 309 | |
| 310 | 310 | } |
| 311 | - $course_percent = get_comment_meta( $item->comment_ID, 'percent', true ); |
|
| 311 | + $course_percent = get_comment_meta($item->comment_ID, 'percent', true); |
|
| 312 | 312 | |
| 313 | 313 | // Output users data |
| 314 | - $user_name = Sensei_Student::get_full_name( $item->user_id ); |
|
| 314 | + $user_name = Sensei_Student::get_full_name($item->user_id); |
|
| 315 | 315 | |
| 316 | - if ( !$this->csv_output ) { |
|
| 316 | + if ( ! $this->csv_output) { |
|
| 317 | 317 | |
| 318 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ); |
|
| 318 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php')); |
|
| 319 | 319 | |
| 320 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>'; |
|
| 321 | - $status = sprintf( '<span class="%s">%s</span>', $status_class, $status ); |
|
| 322 | - if ( is_numeric($course_percent) ) { |
|
| 320 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>'; |
|
| 321 | + $status = sprintf('<span class="%s">%s</span>', $status_class, $status); |
|
| 322 | + if (is_numeric($course_percent)) { |
|
| 323 | 323 | |
| 324 | 324 | $course_percent .= '%'; |
| 325 | 325 | |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | } // End If Statement |
| 329 | 329 | |
| 330 | - $column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $user_name, |
|
| 330 | + $column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $user_name, |
|
| 331 | 331 | 'started' => $user_start_date, |
| 332 | 332 | 'completed' => $user_end_date, |
| 333 | 333 | 'user_status' => $status, |
| 334 | 334 | 'percent' => $course_percent, |
| 335 | - ), $item, $this ); |
|
| 335 | + ), $item, $this); |
|
| 336 | 336 | break; |
| 337 | 337 | |
| 338 | 338 | case 'lesson': |
| 339 | 339 | default: |
| 340 | 340 | // Displaying lessons for this Course for a specific User |
| 341 | - if ( $this->user_id ) { |
|
| 342 | - $status = __( 'Not started', 'woothemes-sensei' ); |
|
| 341 | + if ($this->user_id) { |
|
| 342 | + $status = __('Not started', 'woothemes-sensei'); |
|
| 343 | 343 | $user_start_date = $user_end_date = $status_class = $grade = ''; |
| 344 | 344 | |
| 345 | 345 | $lesson_args = array( |
@@ -348,66 +348,66 @@ discard block |
||
| 348 | 348 | 'type' => 'sensei_lesson_status', |
| 349 | 349 | 'status' => 'any', |
| 350 | 350 | ); |
| 351 | - $lesson_status = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id ), true ); |
|
| 351 | + $lesson_status = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id), true); |
|
| 352 | 352 | |
| 353 | - if ( !empty($lesson_status) ) { |
|
| 354 | - $user_start_date = get_comment_meta( $lesson_status->comment_ID, 'start', true ); |
|
| 353 | + if ( ! empty($lesson_status)) { |
|
| 354 | + $user_start_date = get_comment_meta($lesson_status->comment_ID, 'start', true); |
|
| 355 | 355 | $user_end_date = $lesson_status->comment_date; |
| 356 | 356 | |
| 357 | - if( 'complete' == $lesson_status->comment_approved ) { |
|
| 358 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
| 357 | + if ('complete' == $lesson_status->comment_approved) { |
|
| 358 | + $status = __('Completed', 'woothemes-sensei'); |
|
| 359 | 359 | $status_class = 'graded'; |
| 360 | 360 | |
| 361 | - $grade = __( 'No Grade', 'woothemes-sensei' ); |
|
| 361 | + $grade = __('No Grade', 'woothemes-sensei'); |
|
| 362 | 362 | } |
| 363 | - elseif( 'graded' == $lesson_status->comment_approved ) { |
|
| 364 | - $status = __( 'Graded', 'woothemes-sensei' ); |
|
| 363 | + elseif ('graded' == $lesson_status->comment_approved) { |
|
| 364 | + $status = __('Graded', 'woothemes-sensei'); |
|
| 365 | 365 | $status_class = 'graded'; |
| 366 | 366 | |
| 367 | - $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
|
| 367 | + $grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
| 368 | 368 | } |
| 369 | - elseif( 'passed' == $lesson_status->comment_approved ) { |
|
| 370 | - $status = __( 'Passed', 'woothemes-sensei' ); |
|
| 369 | + elseif ('passed' == $lesson_status->comment_approved) { |
|
| 370 | + $status = __('Passed', 'woothemes-sensei'); |
|
| 371 | 371 | $status_class = 'graded'; |
| 372 | 372 | |
| 373 | - $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
|
| 373 | + $grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
| 374 | 374 | } |
| 375 | - elseif( 'failed' == $lesson_status->comment_approved ) { |
|
| 376 | - $status = __( 'Failed', 'woothemes-sensei' ); |
|
| 375 | + elseif ('failed' == $lesson_status->comment_approved) { |
|
| 376 | + $status = __('Failed', 'woothemes-sensei'); |
|
| 377 | 377 | $status_class = 'failed'; |
| 378 | 378 | |
| 379 | - $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
|
| 379 | + $grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
| 380 | 380 | } |
| 381 | - elseif( 'ungraded' == $lesson_status->comment_approved ) { |
|
| 382 | - $status = __( 'Ungraded', 'woothemes-sensei' ); |
|
| 381 | + elseif ('ungraded' == $lesson_status->comment_approved) { |
|
| 382 | + $status = __('Ungraded', 'woothemes-sensei'); |
|
| 383 | 383 | $status_class = 'ungraded'; |
| 384 | 384 | |
| 385 | 385 | } |
| 386 | - elseif( 'in-progress' == $lesson_status->comment_approved ) { |
|
| 387 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
| 386 | + elseif ('in-progress' == $lesson_status->comment_approved) { |
|
| 387 | + $status = __('In Progress', 'woothemes-sensei'); |
|
| 388 | 388 | $user_end_date = ''; |
| 389 | 389 | } |
| 390 | 390 | } // END lesson_status |
| 391 | 391 | |
| 392 | 392 | // Output users data |
| 393 | - if ( $this->csv_output ) { |
|
| 394 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 393 | + if ($this->csv_output) { |
|
| 394 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 395 | 395 | } |
| 396 | 396 | else { |
| 397 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 398 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 397 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
| 398 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 399 | 399 | |
| 400 | - $status = sprintf( '<span class="%s">%s</span>', $status_class, $status ); |
|
| 401 | - if ( is_numeric($grade) ) { |
|
| 400 | + $status = sprintf('<span class="%s">%s</span>', $status_class, $status); |
|
| 401 | + if (is_numeric($grade)) { |
|
| 402 | 402 | $grade .= '%'; |
| 403 | 403 | } |
| 404 | 404 | } // End If Statement |
| 405 | - $column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title, |
|
| 405 | + $column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title, |
|
| 406 | 406 | 'started' => $user_start_date, |
| 407 | 407 | 'completed' => $user_end_date, |
| 408 | 408 | 'user_status' => $status, |
| 409 | 409 | 'grade' => $grade, |
| 410 | - ), $item, $this ); |
|
| 410 | + ), $item, $this); |
|
| 411 | 411 | } |
| 412 | 412 | // Display lessons for this Course regardless of users |
| 413 | 413 | else { |
@@ -417,51 +417,51 @@ discard block |
||
| 417 | 417 | 'type' => 'sensei_lesson_status', |
| 418 | 418 | 'status' => 'any', |
| 419 | 419 | ); |
| 420 | - $lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) ); |
|
| 420 | + $lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item)); |
|
| 421 | 421 | |
| 422 | 422 | // Get Course Completions |
| 423 | 423 | $lesson_args = array( |
| 424 | 424 | 'post_id' => $item->ID, |
| 425 | 425 | 'type' => 'sensei_lesson_status', |
| 426 | - 'status' => array( 'complete', 'graded', 'passed', 'failed' ), |
|
| 426 | + 'status' => array('complete', 'graded', 'passed', 'failed'), |
|
| 427 | 427 | 'count' => true, |
| 428 | 428 | ); |
| 429 | - $lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) ); |
|
| 429 | + $lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item)); |
|
| 430 | 430 | |
| 431 | 431 | $lesson_average_grade = __('n/a', 'woothemes-sensei'); |
| 432 | - if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) { |
|
| 432 | + if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
| 433 | 433 | // Get Percent Complete |
| 434 | 434 | $grade_args = array( |
| 435 | 435 | 'post_id' => $item->ID, |
| 436 | 436 | 'type' => 'sensei_lesson_status', |
| 437 | - 'status' => array( 'graded', 'passed', 'failed' ), |
|
| 437 | + 'status' => array('graded', 'passed', 'failed'), |
|
| 438 | 438 | 'meta_key' => 'grade', |
| 439 | 439 | ); |
| 440 | - add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
| 441 | - $lesson_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true ); |
|
| 442 | - remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
| 440 | + add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
| 441 | + $lesson_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true); |
|
| 442 | + remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
| 443 | 443 | |
| 444 | - $grade_count = !empty( $lesson_grades->total ) ? $lesson_grades->total : 1; |
|
| 445 | - $grade_total = !empty( $lesson_grades->meta_sum ) ? doubleval( $lesson_grades->meta_sum ) : 0; |
|
| 446 | - $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 444 | + $grade_count = ! empty($lesson_grades->total) ? $lesson_grades->total : 1; |
|
| 445 | + $grade_total = ! empty($lesson_grades->meta_sum) ? doubleval($lesson_grades->meta_sum) : 0; |
|
| 446 | + $lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
| 447 | 447 | } |
| 448 | 448 | // Output lesson data |
| 449 | - if ( $this->csv_output ) { |
|
| 450 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 449 | + if ($this->csv_output) { |
|
| 450 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 451 | 451 | } |
| 452 | 452 | else { |
| 453 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 454 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 453 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
| 454 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 455 | 455 | |
| 456 | - if ( is_numeric( $lesson_average_grade ) ) { |
|
| 456 | + if (is_numeric($lesson_average_grade)) { |
|
| 457 | 457 | $lesson_average_grade .= '%'; |
| 458 | 458 | } |
| 459 | 459 | } // End If Statement |
| 460 | - $column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title, |
|
| 460 | + $column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title, |
|
| 461 | 461 | 'num_learners' => $lesson_students, |
| 462 | 462 | 'completions' => $lesson_completions, |
| 463 | 463 | 'average_grade' => $lesson_average_grade, |
| 464 | - ), $item, $this ); |
|
| 464 | + ), $item, $this); |
|
| 465 | 465 | } // END if |
| 466 | 466 | break; |
| 467 | 467 | } // END switch |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | * @since 1.7.0 |
| 475 | 475 | * @return array statuses |
| 476 | 476 | */ |
| 477 | - private function get_course_statuses( $args ) { |
|
| 477 | + private function get_course_statuses($args) { |
|
| 478 | 478 | |
| 479 | 479 | $activity_args = array( |
| 480 | 480 | 'post_id' => $this->course_id, |
@@ -487,34 +487,34 @@ discard block |
||
| 487 | 487 | ); |
| 488 | 488 | |
| 489 | 489 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
| 490 | - if ( $this->search ) { |
|
| 490 | + if ($this->search) { |
|
| 491 | 491 | $user_args = array( |
| 492 | - 'search' => '*' . $this->search . '*', |
|
| 492 | + 'search' => '*'.$this->search.'*', |
|
| 493 | 493 | 'fields' => 'ID', |
| 494 | 494 | ); |
| 495 | 495 | // Filter for extending |
| 496 | - $user_args = apply_filters( 'sensei_analysis_course_search_users', $user_args ); |
|
| 497 | - if ( !empty( $user_args ) ) { |
|
| 498 | - $learners_search = new WP_User_Query( $user_args ); |
|
| 496 | + $user_args = apply_filters('sensei_analysis_course_search_users', $user_args); |
|
| 497 | + if ( ! empty($user_args)) { |
|
| 498 | + $learners_search = new WP_User_Query($user_args); |
|
| 499 | 499 | // Store for reuse on counts |
| 500 | 500 | $activity_args['user_id'] = (array) $learners_search->get_results(); |
| 501 | 501 | } |
| 502 | 502 | } // End If Statement |
| 503 | 503 | |
| 504 | - $activity_args = apply_filters( 'sensei_analysis_course_filter_statuses', $activity_args ); |
|
| 504 | + $activity_args = apply_filters('sensei_analysis_course_filter_statuses', $activity_args); |
|
| 505 | 505 | |
| 506 | 506 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
| 507 | - $this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
| 507 | + $this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
| 508 | 508 | |
| 509 | 509 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
| 510 | - if ( $this->total_items < $activity_args['offset'] ) { |
|
| 511 | - $new_paged = floor( $this->total_items / $activity_args['number'] ); |
|
| 510 | + if ($this->total_items < $activity_args['offset']) { |
|
| 511 | + $new_paged = floor($this->total_items / $activity_args['number']); |
|
| 512 | 512 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
| 513 | 513 | } |
| 514 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
| 514 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
| 515 | 515 | // Need to always return an array, even with only 1 item |
| 516 | - if ( !is_array($statuses) ) { |
|
| 517 | - $statuses = array( $statuses ); |
|
| 516 | + if ( ! is_array($statuses)) { |
|
| 517 | + $statuses = array($statuses); |
|
| 518 | 518 | } |
| 519 | 519 | return $statuses; |
| 520 | 520 | } // End get_course_statuses() |
@@ -524,32 +524,32 @@ discard block |
||
| 524 | 524 | * @since 1.7.0 |
| 525 | 525 | * @return array statuses |
| 526 | 526 | */ |
| 527 | - private function get_lessons( $args ) { |
|
| 527 | + private function get_lessons($args) { |
|
| 528 | 528 | |
| 529 | - $lessons_args = array( 'post_type' => 'lesson', |
|
| 529 | + $lessons_args = array('post_type' => 'lesson', |
|
| 530 | 530 | 'posts_per_page' => $args['number'], |
| 531 | 531 | 'offset' => $args['offset'], |
| 532 | - 'meta_key' => '_order_' . $this->course_id, |
|
| 532 | + 'meta_key' => '_order_'.$this->course_id, |
|
| 533 | 533 | // 'orderby' => $args['orderby'], |
| 534 | 534 | 'order' => $args['order'], |
| 535 | 535 | 'meta_query' => array( |
| 536 | 536 | array( |
| 537 | 537 | 'key' => '_lesson_course', |
| 538 | - 'value' => intval( $this->course_id ), |
|
| 538 | + 'value' => intval($this->course_id), |
|
| 539 | 539 | ), |
| 540 | 540 | ), |
| 541 | 541 | 'post_status' => array('publish', 'private'), |
| 542 | 542 | 'suppress_filters' => 0 |
| 543 | 543 | ); |
| 544 | - if ( $this->search ) { |
|
| 544 | + if ($this->search) { |
|
| 545 | 545 | $lessons_args['s'] = $this->search; |
| 546 | 546 | } |
| 547 | - if ( $this->csv_output ) { |
|
| 547 | + if ($this->csv_output) { |
|
| 548 | 548 | $lessons_args['posts_per_page'] = '-1'; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
| 552 | - $lessons_query = new WP_Query( apply_filters( 'sensei_analysis_course_filter_lessons', $lessons_args ) ); |
|
| 552 | + $lessons_query = new WP_Query(apply_filters('sensei_analysis_course_filter_lessons', $lessons_args)); |
|
| 553 | 553 | $this->total_items = $lessons_query->found_posts; |
| 554 | 554 | return $lessons_query->posts; |
| 555 | 555 | } // End get_lessons() |
@@ -561,17 +561,17 @@ discard block |
||
| 561 | 561 | * @return void |
| 562 | 562 | */ |
| 563 | 563 | public function no_items() { |
| 564 | - switch( $this->view ) { |
|
| 564 | + switch ($this->view) { |
|
| 565 | 565 | case 'user' : |
| 566 | - $text = __( 'No learners found.', 'woothemes-sensei' ); |
|
| 566 | + $text = __('No learners found.', 'woothemes-sensei'); |
|
| 567 | 567 | break; |
| 568 | 568 | |
| 569 | 569 | case 'lesson': |
| 570 | 570 | default: |
| 571 | - $text = __( 'No lessons found.', 'woothemes-sensei' ); |
|
| 571 | + $text = __('No lessons found.', 'woothemes-sensei'); |
|
| 572 | 572 | break; |
| 573 | 573 | } |
| 574 | - echo apply_filters( 'sensei_analysis_course_no_items_text', $text ); |
|
| 574 | + echo apply_filters('sensei_analysis_course_no_items_text', $text); |
|
| 575 | 575 | } // End no_items() |
| 576 | 576 | |
| 577 | 577 | /** |
@@ -580,25 +580,25 @@ discard block |
||
| 580 | 580 | * @return void |
| 581 | 581 | */ |
| 582 | 582 | public function data_table_header() { |
| 583 | - if ( $this->user_id ) { |
|
| 584 | - $learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' ); |
|
| 583 | + if ($this->user_id) { |
|
| 584 | + $learners_text = __('Other Learners taking this Course', 'woothemes-sensei'); |
|
| 585 | 585 | } |
| 586 | 586 | else { |
| 587 | - $learners_text = __( 'Learners taking this Course', 'woothemes-sensei' ); |
|
| 587 | + $learners_text = __('Learners taking this Course', 'woothemes-sensei'); |
|
| 588 | 588 | } |
| 589 | - $lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' ); |
|
| 589 | + $lessons_text = __('Lessons in this Course', 'woothemes-sensei'); |
|
| 590 | 590 | |
| 591 | 591 | $url_args = array( |
| 592 | 592 | 'page' => $this->page_slug, |
| 593 | 593 | 'course_id' => $this->course_id, |
| 594 | 594 | ); |
| 595 | - $learners_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'user' ) ), admin_url( 'admin.php' ) ) ); |
|
| 596 | - $lessons_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'lesson' ) ), admin_url( 'admin.php' ) ) ); |
|
| 595 | + $learners_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'user')), admin_url('admin.php'))); |
|
| 596 | + $lessons_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'lesson')), admin_url('admin.php'))); |
|
| 597 | 597 | |
| 598 | 598 | $learners_class = $lessons_class = ''; |
| 599 | 599 | |
| 600 | 600 | $menu = array(); |
| 601 | - switch( $this->view ) { |
|
| 601 | + switch ($this->view) { |
|
| 602 | 602 | case 'user' : |
| 603 | 603 | $learners_class = 'current'; |
| 604 | 604 | break; |
@@ -608,17 +608,17 @@ discard block |
||
| 608 | 608 | $lessons_class = 'current'; |
| 609 | 609 | break; |
| 610 | 610 | } |
| 611 | - $menu['lesson'] = sprintf( '<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text ); |
|
| 612 | - $menu['user'] = sprintf( '<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text ); |
|
| 613 | - |
|
| 614 | - $menu = apply_filters( 'sensei_analysis_course_sub_menu', $menu ); |
|
| 615 | - if ( !empty($menu) ) { |
|
| 616 | - echo '<ul class="subsubsub">' . "\n"; |
|
| 617 | - foreach ( $menu as $class => $item ) { |
|
| 618 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
| 611 | + $menu['lesson'] = sprintf('<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text); |
|
| 612 | + $menu['user'] = sprintf('<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text); |
|
| 613 | + |
|
| 614 | + $menu = apply_filters('sensei_analysis_course_sub_menu', $menu); |
|
| 615 | + if ( ! empty($menu)) { |
|
| 616 | + echo '<ul class="subsubsub">'."\n"; |
|
| 617 | + foreach ($menu as $class => $item) { |
|
| 618 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
| 619 | 619 | } |
| 620 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
| 621 | - echo '</ul>' . "\n"; |
|
| 620 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
| 621 | + echo '</ul>'."\n"; |
|
| 622 | 622 | } |
| 623 | 623 | } // End data_table_header() |
| 624 | 624 | |
@@ -629,19 +629,19 @@ discard block |
||
| 629 | 629 | */ |
| 630 | 630 | public function data_table_footer() { |
| 631 | 631 | |
| 632 | - $course = get_post( $this->course_id ); |
|
| 633 | - $report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview'; |
|
| 634 | - if ( $this->user_id ) { |
|
| 635 | - $user_name = Sensei_Student::get_full_name( $this->user_id ); |
|
| 636 | - $report = sanitize_title( $user_name ) . '-' . $report; |
|
| 632 | + $course = get_post($this->course_id); |
|
| 633 | + $report = sanitize_title($course->post_title).'-'.$this->view.'s-overview'; |
|
| 634 | + if ($this->user_id) { |
|
| 635 | + $user_name = Sensei_Student::get_full_name($this->user_id); |
|
| 636 | + $report = sanitize_title($user_name).'-'.$report; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - $url_args = array( 'page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report ); |
|
| 640 | - if ( $this->user_id ) { |
|
| 639 | + $url_args = array('page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report); |
|
| 640 | + if ($this->user_id) { |
|
| 641 | 641 | $url_args['user_id'] = $this->user_id; |
| 642 | 642 | } |
| 643 | - $url = add_query_arg( $url_args, admin_url( 'admin.php' ) ); |
|
| 644 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
| 643 | + $url = add_query_arg($url_args, admin_url('admin.php')); |
|
| 644 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
| 645 | 645 | } // End data_table_footer() |
| 646 | 646 | |
| 647 | 647 | /** |
@@ -649,15 +649,15 @@ discard block |
||
| 649 | 649 | * @since 1.7.0 |
| 650 | 650 | * @return void |
| 651 | 651 | */ |
| 652 | - public function search_button( $text = '' ) { |
|
| 653 | - switch( $this->view ) { |
|
| 652 | + public function search_button($text = '') { |
|
| 653 | + switch ($this->view) { |
|
| 654 | 654 | case 'user': |
| 655 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
| 655 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
| 656 | 656 | break; |
| 657 | 657 | |
| 658 | 658 | case 'lesson': |
| 659 | 659 | default: |
| 660 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
| 660 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
| 661 | 661 | break; |
| 662 | 662 | } // End Switch Statement |
| 663 | 663 | |
@@ -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 Updates Class |
@@ -27,59 +27,59 @@ discard block |
||
| 27 | 27 | * @param string $parent The main Sensei object by Ref. |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | - public function __construct ( $parent ) { |
|
| 30 | + public function __construct($parent) { |
|
| 31 | 31 | |
| 32 | 32 | // Setup object data |
| 33 | 33 | $this->parent = $parent; |
| 34 | - $this->updates_run = get_option( 'woothemes-sensei-upgrades', array() ); |
|
| 34 | + $this->updates_run = get_option('woothemes-sensei-upgrades', array()); |
|
| 35 | 35 | |
| 36 | 36 | // The list of upgrades to run |
| 37 | - $this->updates = array( '1.1.0' => array( 'auto' => array( 'assign_role_caps' => array( 'title' => __( 'Assign role capabilities', 'woothemes-sensei' ), 'desc' => __( 'Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei' ), 'product' => 'Sensei' ) ), |
|
| 37 | + $this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')), |
|
| 38 | 38 | 'manual' => array() |
| 39 | 39 | ), |
| 40 | - '1.3.0' => array( 'auto' => array( 'set_default_quiz_grade_type' => array( 'title' => __( 'Set default quiz grade type', 'woothemes-sensei' ), 'desc' => __( 'Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei' ) ), |
|
| 41 | - 'set_default_question_type' => array( 'title' => __( 'Set default question type', 'woothemes-sensei' ), 'desc' => __( 'Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei' ) ) |
|
| 40 | + '1.3.0' => array('auto' => array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')), |
|
| 41 | + 'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei')) |
|
| 42 | 42 | ), |
| 43 | - 'manual' => array( 'update_question_answer_data' => array( 'title' => __( 'Update question answer data', 'woothemes-sensei' ), 'desc' => __( 'Updates questions to use the new question types structure.', 'woothemes-sensei' ) ) ) |
|
| 43 | + 'manual' => array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei'))) |
|
| 44 | 44 | ), |
| 45 | - '1.4.0' => array( 'auto' => array( 'update_question_grade_points' => array( 'title' => __( 'Update question grade points', 'woothemes-sensei' ), 'desc' => __( 'Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei' ) ) ), |
|
| 45 | + '1.4.0' => array('auto' => array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))), |
|
| 46 | 46 | 'manual' => array() |
| 47 | 47 | ), |
| 48 | - '1.5.0' => array( 'auto' => array( 'convert_essay_paste_questions' => array( 'title' => __( 'Convert essay paste questions into multi-line questions', 'woothemes-sensei' ), 'desc' => __( 'Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei' ) ) ), |
|
| 49 | - 'manual' => array( 'set_random_question_order' => array( 'title' => __( 'Set all quizzes to have a random question order', 'woothemes-sensei' ), 'desc' => __( 'Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei' ) ), |
|
| 50 | - 'set_default_show_question_count' => array( 'title' => __( 'Set all quizzes to show all questions', 'woothemes-sensei' ), 'desc' => __( 'Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei' ) ), |
|
| 51 | - 'remove_deleted_user_activity' => array( 'title' => __( 'Remove Sensei activity for deleted users', 'woothemes-sensei' ), 'desc' => __( 'Removes all course, lesson & quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei' ) ) ) |
|
| 48 | + '1.5.0' => array('auto' => array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))), |
|
| 49 | + 'manual' => array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')), |
|
| 50 | + 'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')), |
|
| 51 | + 'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson & quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei'))) |
|
| 52 | 52 | ), |
| 53 | - '1.6.0' => array( 'auto' => array( 'add_teacher_role' => array( 'title' => __( 'Add \'Teacher\' role', 'woothemes-sensei' ), 'desc' => __( 'Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei' ) ), |
|
| 54 | - 'add_sensei_caps' => array( 'title' => __( 'Add administrator capabilities', 'woothemes-sensei' ), 'desc' => __( 'Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei' ) ), |
|
| 55 | - 'restructure_question_meta' => array( 'title' => __( 'Restructure question meta data', 'woothemes-sensei' ), 'desc' => __( 'Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei' ) ), |
|
| 56 | - 'update_quiz_settings' => array( 'title' => __( 'Add new quiz settings', 'woothemes-sensei' ), 'desc' => __( 'Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei' ) ), |
|
| 57 | - 'reset_lesson_order_meta' => array( 'title' => __( 'Set default order of lessons', 'woothemes-sensei' ), 'desc' => __( 'Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei' ) ), ), |
|
| 53 | + '1.6.0' => array('auto' => array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')), |
|
| 54 | + 'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')), |
|
| 55 | + 'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')), |
|
| 56 | + 'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')), |
|
| 57 | + 'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),), |
|
| 58 | 58 | 'manual' => array() |
| 59 | 59 | ), |
| 60 | - '1.7.0' => array( 'auto' => array( 'add_editor_caps' => array( 'title' => __( 'Add Editor capabilities', 'woothemes-sensei' ), 'desc' => __( 'Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei' ) ), ), |
|
| 61 | - 'forced' => array( 'update_question_gap_fill_separators' => array( 'title' => __( 'Update Gap Fill questions', 'woothemes-sensei' ), 'desc' => __( 'Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei' ) ), |
|
| 62 | - 'update_quiz_lesson_relationship' => array( 'title' => __( 'Restructure quiz lesson relationship', 'woothemes-sensei' ), 'desc' => __( 'Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei' ) ), |
|
| 63 | - 'status_changes_fix_lessons' => array( 'title' => __( 'Update lesson statuses', 'woothemes-sensei' ), 'desc' => __( 'Update existing lesson statuses.', 'woothemes-sensei' ) ), |
|
| 64 | - 'status_changes_convert_lessons' => array( 'title' => __( 'Convert lesson statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new lesson statuses.', 'woothemes-sensei' ) ), |
|
| 65 | - 'status_changes_convert_courses' => array( 'title' => __( 'Convert course statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new course statuses.', 'woothemes-sensei' ) ), |
|
| 66 | - 'status_changes_convert_questions' => array( 'title' => __( 'Convert question statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new question statuses.', 'woothemes-sensei' ) ), |
|
| 67 | - 'update_legacy_sensei_comments_status' => array( 'title' => __( 'Convert legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei' ) ), |
|
| 68 | - 'update_comment_course_lesson_comment_counts' => array( 'title' => __( 'Update comment counts', 'woothemes-sensei' ), 'desc' => __( 'Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei' ) ), ), |
|
| 60 | + '1.7.0' => array('auto' => array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),), |
|
| 61 | + 'forced' => array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')), |
|
| 62 | + 'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')), |
|
| 63 | + 'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')), |
|
| 64 | + 'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')), |
|
| 65 | + 'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')), |
|
| 66 | + 'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')), |
|
| 67 | + 'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')), |
|
| 68 | + 'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),), |
|
| 69 | 69 | ), |
| 70 | - '1.7.2' => array( 'auto' => array( 'index_comment_status_field' => array( 'title' => __( 'Add database index to comment statuses', 'woothemes-sensei' ), 'desc' => __( 'This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei' ) ), ), |
|
| 70 | + '1.7.2' => array('auto' => array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),), |
|
| 71 | 71 | /*'manual' => array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/ |
| 72 | 72 | ), |
| 73 | - '1.8.0' => array( 'auto' => array( 'enhance_teacher_role' => array( 'title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.' ), ), |
|
| 73 | + '1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),), |
|
| 74 | 74 | 'manual' => array() |
| 75 | 75 | ), |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates ); |
|
| 79 | - $this->version = get_option( 'woothemes-sensei-version' ); |
|
| 78 | + $this->updates = apply_filters('sensei_upgrade_functions', $this->updates, $this->updates); |
|
| 79 | + $this->version = get_option('woothemes-sensei-version'); |
|
| 80 | 80 | |
| 81 | 81 | // Manual Update Screen |
| 82 | - add_action('admin_menu', array( $this, 'add_update_admin_screen' ), 50 ); |
|
| 82 | + add_action('admin_menu', array($this, 'add_update_admin_screen'), 50); |
|
| 83 | 83 | |
| 84 | 84 | } // End __construct() |
| 85 | 85 | |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | 93 | public function add_update_admin_screen() { |
| 94 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 95 | - add_submenu_page( 'sensei', __( 'Sensei Updates', 'woothemes-sensei' ), __( 'Data Updates', 'woothemes-sensei' ), 'manage_options', 'sensei_updates', array( $this, 'sensei_updates_page' ) ); |
|
| 94 | + if (current_user_can('manage_options')) { |
|
| 95 | + add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page')); |
|
| 96 | 96 | } |
| 97 | 97 | } // End add_update_admin_screen() |
| 98 | 98 | |
@@ -106,80 +106,80 @@ discard block |
||
| 106 | 106 | public function sensei_updates_page() { |
| 107 | 107 | |
| 108 | 108 | // Only allow admins to load this page and run the update functions |
| 109 | - if( current_user_can( 'manage_options' ) ) { |
|
| 109 | + if (current_user_can('manage_options')) { |
|
| 110 | 110 | ?> |
| 111 | 111 | <div class="wrap"> |
| 112 | 112 | |
| 113 | 113 | <div id="icon-woothemes-sensei" class="icon32"><br></div> |
| 114 | - <h2><?php _e( 'Sensei Updates', 'woothemes-sensei' ); ?></h2> |
|
| 114 | + <h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2> |
|
| 115 | 115 | |
| 116 | 116 | <?php |
| 117 | - if ( isset( $_GET['action'] ) && $_GET['action'] == 'update' && isset( $_GET['n'] ) && intval( $_GET['n'] ) >= 0 && ( ( isset( $_POST['checked'][0] ) && '' != $_POST['checked'][0] ) || ( isset( $_GET['functions'] ) && '' != $_GET['functions'] ) ) ) { |
|
| 117 | + if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($_GET['n']) && intval($_GET['n']) >= 0 && ((isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) { |
|
| 118 | 118 | |
| 119 | 119 | // Setup the data variables |
| 120 | - $n = intval( $_GET['n'] ); |
|
| 120 | + $n = intval($_GET['n']); |
|
| 121 | 121 | $functions_list = ''; |
| 122 | 122 | $done_processing = false; |
| 123 | 123 | |
| 124 | 124 | // Check for updates to run |
| 125 | - if ( isset( $_POST['checked'][0] ) && '' != $_POST['checked'][0] ) { |
|
| 125 | + if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) { |
|
| 126 | 126 | |
| 127 | - foreach ( $_POST['checked'] as $key => $value ) { |
|
| 127 | + foreach ($_POST['checked'] as $key => $value) { |
|
| 128 | 128 | |
| 129 | 129 | // Dynamic function call |
| 130 | - if ( method_exists( $this, $value) ) { |
|
| 131 | - $done_processing = call_user_func_array( array( $this, $value ), array( 50, $n ) ); |
|
| 130 | + if (method_exists($this, $value)) { |
|
| 131 | + $done_processing = call_user_func_array(array($this, $value), array(50, $n)); |
|
| 132 | 132 | } else { |
| 133 | - $done_processing = call_user_func_array( $value, array( 50, $n ) ); |
|
| 133 | + $done_processing = call_user_func_array($value, array(50, $n)); |
|
| 134 | 134 | } // End If Statement |
| 135 | 135 | |
| 136 | 136 | // Add to functions list get args |
| 137 | - if ( '' == $functions_list ) { |
|
| 137 | + if ('' == $functions_list) { |
|
| 138 | 138 | $functions_list .= $value; |
| 139 | 139 | } else { |
| 140 | - $functions_list .= '+' . $value; |
|
| 140 | + $functions_list .= '+'.$value; |
|
| 141 | 141 | } // End If Statement |
| 142 | 142 | |
| 143 | 143 | // Mark update has having been run |
| 144 | - $this->set_update_run( $value ); |
|
| 144 | + $this->set_update_run($value); |
|
| 145 | 145 | |
| 146 | 146 | } // End For Loop |
| 147 | 147 | |
| 148 | 148 | } // End If Statement |
| 149 | 149 | |
| 150 | 150 | // Check for updates to run |
| 151 | - if ( isset( $_GET['functions'] ) && '' != $_GET['functions'] ) { |
|
| 151 | + if (isset($_GET['functions']) && '' != $_GET['functions']) { |
|
| 152 | 152 | |
| 153 | 153 | // Existing functions from GET variables instead of POST |
| 154 | 154 | $functions_array = $_GET['functions']; |
| 155 | 155 | |
| 156 | - foreach ( $functions_array as $key => $value ) { |
|
| 156 | + foreach ($functions_array as $key => $value) { |
|
| 157 | 157 | |
| 158 | 158 | // Dynamic function call |
| 159 | - if ( method_exists( $this, $value) ) { |
|
| 160 | - $done_processing = call_user_func_array( array( $this, $value ), array( 50, $n ) ); |
|
| 159 | + if (method_exists($this, $value)) { |
|
| 160 | + $done_processing = call_user_func_array(array($this, $value), array(50, $n)); |
|
| 161 | 161 | } else { |
| 162 | - $done_processing = call_user_func_array( $value, array( 50, $n ) ); |
|
| 162 | + $done_processing = call_user_func_array($value, array(50, $n)); |
|
| 163 | 163 | } // End If Statement |
| 164 | 164 | |
| 165 | 165 | // Add to functions list get args |
| 166 | - if ( '' == $functions_list ) { |
|
| 166 | + if ('' == $functions_list) { |
|
| 167 | 167 | $functions_list .= $value; |
| 168 | 168 | } else { |
| 169 | - $functions_list .= '+' . $value; |
|
| 169 | + $functions_list .= '+'.$value; |
|
| 170 | 170 | } // End If Statement |
| 171 | 171 | |
| 172 | - $this->set_update_run( $value ); |
|
| 172 | + $this->set_update_run($value); |
|
| 173 | 173 | |
| 174 | 174 | } // End For Loop |
| 175 | 175 | |
| 176 | 176 | } // End If Statement |
| 177 | 177 | |
| 178 | - if ( ! $done_processing ) { ?> |
|
| 178 | + if ( ! $done_processing) { ?> |
|
| 179 | 179 | |
| 180 | - <h3><?php _e( 'Processing Updates...', 'woothemes-sensei' ); ?></h3> |
|
| 180 | + <h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3> |
|
| 181 | 181 | |
| 182 | - <p><?php _e( 'If your browser doesn’t start loading the next page automatically, click this button:', 'woothemes-sensei' ); ?> <a class="button" href="admin.php?page=sensei_updates&action=update&n=<?php echo ($n + 50) ?>&functions[]=<?php echo $functions_list; ?>"><?php _e( 'Next', 'woothemes-sensei' ); ?></a></p> |
|
| 182 | + <p><?php _e('If your browser doesn’t start loading the next page automatically, click this button:', 'woothemes-sensei'); ?> <a class="button" href="admin.php?page=sensei_updates&action=update&n=<?php echo ($n + 50) ?>&functions[]=<?php echo $functions_list; ?>"><?php _e('Next', 'woothemes-sensei'); ?></a></p> |
|
| 183 | 183 | <script type='text/javascript'> |
| 184 | 184 | <!-- |
| 185 | 185 | function sensei_nextpage() { |
@@ -191,48 +191,48 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | } else { ?> |
| 193 | 193 | |
| 194 | - <p><strong><?php _e( 'Update completed successfully!', 'woothemes-sensei' ); ?></strong></p> |
|
| 195 | - <p><a href="<?php echo admin_url('edit.php?post_type=lesson'); ?>"><?php _e( 'Create a new lesson', 'woothemes-sensei' ); ?></a> or <a href="<?php echo admin_url('admin.php?page=sensei_updates'); ?>"><?php _e( 'run some more updates', 'woothemes-sensei' ); ?></a>.</p> |
|
| 194 | + <p><strong><?php _e('Update completed successfully!', 'woothemes-sensei'); ?></strong></p> |
|
| 195 | + <p><a href="<?php echo admin_url('edit.php?post_type=lesson'); ?>"><?php _e('Create a new lesson', 'woothemes-sensei'); ?></a> or <a href="<?php echo admin_url('admin.php?page=sensei_updates'); ?>"><?php _e('run some more updates', 'woothemes-sensei'); ?></a>.</p> |
|
| 196 | 196 | |
| 197 | 197 | <?php } // End If Statement |
| 198 | 198 | |
| 199 | 199 | } else { ?> |
| 200 | 200 | |
| 201 | - <h3><?php _e( 'Updates', 'woothemes-sensei' ); ?></h3> |
|
| 202 | - <p><?php printf( __( 'These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei' ), '<code>', '</code>' ); ?></p> |
|
| 201 | + <h3><?php _e('Updates', 'woothemes-sensei'); ?></h3> |
|
| 202 | + <p><?php printf(__('These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei'), '<code>', '</code>'); ?></p> |
|
| 203 | 203 | |
| 204 | - <div class="updated"><p><strong><?php _e( 'Only run these updates if you have been instructed to do so by WooThemes support staff.', 'woothemes-sensei' ); ?></strong></p></div> |
|
| 204 | + <div class="updated"><p><strong><?php _e('Only run these updates if you have been instructed to do so by WooThemes support staff.', 'woothemes-sensei'); ?></strong></p></div> |
|
| 205 | 205 | |
| 206 | 206 | <table class="widefat" cellspacing="0" id="update-plugins-table"> |
| 207 | 207 | |
| 208 | 208 | <thead> |
| 209 | 209 | <tr> |
| 210 | - <th scope="col" class="manage-column"><?php _e( 'Update', 'woothemes-sensei' ); ?></th> |
|
| 211 | - <th scope="col" class="manage-column"><?php _e( 'Type', 'woothemes-sensei' ); ?></th> |
|
| 212 | - <th scope="col" class="manage-column"><?php _e( 'Action', 'woothemes-sensei' ); ?></th> |
|
| 210 | + <th scope="col" class="manage-column"><?php _e('Update', 'woothemes-sensei'); ?></th> |
|
| 211 | + <th scope="col" class="manage-column"><?php _e('Type', 'woothemes-sensei'); ?></th> |
|
| 212 | + <th scope="col" class="manage-column"><?php _e('Action', 'woothemes-sensei'); ?></th> |
|
| 213 | 213 | </tr> |
| 214 | 214 | </thead> |
| 215 | 215 | |
| 216 | 216 | <tfoot> |
| 217 | 217 | <tr> |
| 218 | - <th scope="col" class="manage-column"><?php _e( 'Update', 'woothemes-sensei' ); ?></th> |
|
| 219 | - <th scope="col" class="manage-column"><?php _e( 'Type', 'woothemes-sensei' ); ?></th> |
|
| 220 | - <th scope="col" class="manage-column"><?php _e( 'Action', 'woothemes-sensei' ); ?></th> |
|
| 218 | + <th scope="col" class="manage-column"><?php _e('Update', 'woothemes-sensei'); ?></th> |
|
| 219 | + <th scope="col" class="manage-column"><?php _e('Type', 'woothemes-sensei'); ?></th> |
|
| 220 | + <th scope="col" class="manage-column"><?php _e('Action', 'woothemes-sensei'); ?></th> |
|
| 221 | 221 | </tr> |
| 222 | 222 | </tfoot> |
| 223 | 223 | |
| 224 | 224 | <tbody class="updates"> |
| 225 | 225 | <?php |
| 226 | 226 | // Sort updates with the latest at the top |
| 227 | - uksort( $this->updates, array( $this, 'sort_updates' ) ); |
|
| 228 | - $this->updates = array_reverse( $this->updates, true ); |
|
| 227 | + uksort($this->updates, array($this, 'sort_updates')); |
|
| 228 | + $this->updates = array_reverse($this->updates, true); |
|
| 229 | 229 | $class = 'alternate'; |
| 230 | - foreach( $this->updates as $version => $version_updates ) { |
|
| 231 | - foreach( $version_updates as $type => $updates ) { |
|
| 232 | - foreach( $updates as $update => $data ) { |
|
| 233 | - $update_run = $this->has_update_run( $update ); |
|
| 230 | + foreach ($this->updates as $version => $version_updates) { |
|
| 231 | + foreach ($version_updates as $type => $updates) { |
|
| 232 | + foreach ($updates as $update => $data) { |
|
| 233 | + $update_run = $this->has_update_run($update); |
|
| 234 | 234 | $product = 'Sensei'; |
| 235 | - if ( isset( $data['product'] ) && '' != $data['product'] ) { |
|
| 235 | + if (isset($data['product']) && '' != $data['product']) { |
|
| 236 | 236 | $product = $data['product']; |
| 237 | 237 | } // End If Statement |
| 238 | 238 | ?> |
@@ -242,21 +242,21 @@ discard block |
||
| 242 | 242 | <p> |
| 243 | 243 | <input type="hidden" name="checked[]" value="<?php echo $update; ?>"> |
| 244 | 244 | <strong><?php echo $data['title']; ?></strong><br><?php echo $data['desc']; ?><br> |
| 245 | - <em><?php printf( __( 'Originally included in %s v%s', 'woothemes-sensei' ), $product, $version ); ?></em> |
|
| 245 | + <em><?php printf(__('Originally included in %s v%s', 'woothemes-sensei'), $product, $version); ?></em> |
|
| 246 | 246 | </p> |
| 247 | 247 | </td> |
| 248 | 248 | <?php |
| 249 | - $type_label = __( 'Auto', 'woothemes-sensei' ); |
|
| 250 | - if( $type != 'auto' ) { |
|
| 251 | - $type_label = __( 'Manual', 'woothemes-sensei' ); |
|
| 249 | + $type_label = __('Auto', 'woothemes-sensei'); |
|
| 250 | + if ($type != 'auto') { |
|
| 251 | + $type_label = __('Manual', 'woothemes-sensei'); |
|
| 252 | 252 | } |
| 253 | 253 | ?> |
| 254 | 254 | <td><p><?php echo $type_label; ?></p></td> |
| 255 | - <td><p><input onclick="javascript:return confirm('<?php echo addslashes( sprintf( __( 'Are you sure you want to run the \'%s\' update?', 'woothemes-sensei' ), $data['title'] ) ); ?>');" id="update-sensei" class="button<?php if( ! $update_run ) { echo ' button-primary'; } ?>" type="submit" value="<?php if( $update_run ) { _e( 'Re-run Update', 'woothemes-sensei' ); } else { _e( 'Run Update', 'woothemes-sensei' ); } ?>" name="update"></p></td> |
|
| 255 | + <td><p><input onclick="javascript:return confirm('<?php echo addslashes(sprintf(__('Are you sure you want to run the \'%s\' update?', 'woothemes-sensei'), $data['title'])); ?>');" id="update-sensei" class="button<?php if ( ! $update_run) { echo ' button-primary'; } ?>" type="submit" value="<?php if ($update_run) { _e('Re-run Update', 'woothemes-sensei'); } else { _e('Run Update', 'woothemes-sensei'); } ?>" name="update"></p></td> |
|
| 256 | 256 | </tr> |
| 257 | 257 | </form> |
| 258 | 258 | <?php |
| 259 | - if( 'alternate' == $class ) { |
|
| 259 | + if ('alternate' == $class) { |
|
| 260 | 260 | $class = ''; |
| 261 | 261 | } else { |
| 262 | 262 | $class = 'alternate'; |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | * @param string $b Second key |
| 284 | 284 | * @return integer |
| 285 | 285 | */ |
| 286 | - private function sort_updates( $a, $b ) { |
|
| 287 | - return strcmp( $a, $b ); |
|
| 286 | + private function sort_updates($a, $b) { |
|
| 287 | + return strcmp($a, $b); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -295,32 +295,32 @@ discard block |
||
| 295 | 295 | * @access public |
| 296 | 296 | * @return boolean |
| 297 | 297 | */ |
| 298 | - public function update ( $type = 'auto' ) { |
|
| 298 | + public function update($type = 'auto') { |
|
| 299 | 299 | |
| 300 | 300 | // Only allow admins to run update functions |
| 301 | - if( current_user_can( 'manage_options' ) ) { |
|
| 301 | + if (current_user_can('manage_options')) { |
|
| 302 | 302 | |
| 303 | 303 | $this->force_updates(); |
| 304 | 304 | |
| 305 | 305 | // Run through all functions |
| 306 | - foreach ( $this->updates as $version => $value ) { |
|
| 307 | - foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) { |
|
| 308 | - if ( $upgrade_type == $type ) { |
|
| 306 | + foreach ($this->updates as $version => $value) { |
|
| 307 | + foreach ($this->updates[$version] as $upgrade_type => $function_to_run) { |
|
| 308 | + if ($upgrade_type == $type) { |
|
| 309 | 309 | $updated = false; |
| 310 | 310 | // Run the update function |
| 311 | - foreach ( $function_to_run as $function_name => $update_data ) { |
|
| 312 | - if ( isset( $function_name ) && '' != $function_name ) { |
|
| 313 | - if ( ! in_array( $function_name, $this->updates_run ) ) { |
|
| 311 | + foreach ($function_to_run as $function_name => $update_data) { |
|
| 312 | + if (isset($function_name) && '' != $function_name) { |
|
| 313 | + if ( ! in_array($function_name, $this->updates_run)) { |
|
| 314 | 314 | $updated = false; |
| 315 | - if ( method_exists( $this, $function_name ) ) { |
|
| 316 | - $updated = call_user_func( array( $this, $function_name ) ); |
|
| 317 | - } elseif( function_exists( $function_name ) ) { |
|
| 318 | - $updated = call_user_func( $function_name ); |
|
| 315 | + if (method_exists($this, $function_name)) { |
|
| 316 | + $updated = call_user_func(array($this, $function_name)); |
|
| 317 | + } elseif (function_exists($function_name)) { |
|
| 318 | + $updated = call_user_func($function_name); |
|
| 319 | 319 | } else { |
| 320 | 320 | // Nothing to see here... |
| 321 | 321 | } // End If Statement |
| 322 | - if ( $updated ) { |
|
| 323 | - array_push( $this->updates_run, $function_name ); |
|
| 322 | + if ($updated) { |
|
| 323 | + array_push($this->updates_run, $function_name); |
|
| 324 | 324 | } // End If Statement |
| 325 | 325 | } |
| 326 | 326 | } // End If Statement |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | } // End For Loop |
| 330 | 330 | } // End For Loop |
| 331 | 331 | |
| 332 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
| 333 | - update_option( Sensei()->token . '-upgrades', $this->updates_run ); |
|
| 332 | + $this->updates_run = array_unique($this->updates_run); // we only need one reference per update |
|
| 333 | + update_option(Sensei()->token.'-upgrades', $this->updates_run); |
|
| 334 | 334 | return true; |
| 335 | 335 | |
| 336 | 336 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | private function force_updates() { |
| 341 | 341 | |
| 342 | - if( ! isset( $_GET['page'] ) || 'sensei_updates' != $_GET['page'] ) { |
|
| 342 | + if ( ! isset($_GET['page']) || 'sensei_updates' != $_GET['page']) { |
|
| 343 | 343 | |
| 344 | 344 | // $skip_forced_updates = false; |
| 345 | 345 | // if( ! get_option( 'woothemes-sensei-force-updates', false ) ) { |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | // Force critical updates if only if lessons already exist |
| 350 | 350 | $skip_forced_updates = false; |
| 351 | - $lesson_posts = wp_count_posts( 'lesson' ); |
|
| 352 | - if( ! isset( $lesson_posts->publish ) || ! $lesson_posts->publish ) { |
|
| 351 | + $lesson_posts = wp_count_posts('lesson'); |
|
| 352 | + if ( ! isset($lesson_posts->publish) || ! $lesson_posts->publish) { |
|
| 353 | 353 | $skip_forced_updates = true; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -357,69 +357,69 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | $updates_to_run = array(); |
| 359 | 359 | |
| 360 | - foreach ( $this->updates as $version => $value ) { |
|
| 361 | - foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) { |
|
| 362 | - if ( $upgrade_type == 'forced' ) { |
|
| 363 | - foreach ( $function_to_run as $function_name => $update_data ) { |
|
| 360 | + foreach ($this->updates as $version => $value) { |
|
| 361 | + foreach ($this->updates[$version] as $upgrade_type => $function_to_run) { |
|
| 362 | + if ($upgrade_type == 'forced') { |
|
| 363 | + foreach ($function_to_run as $function_name => $update_data) { |
|
| 364 | 364 | |
| 365 | - if( $skip_forced_updates ) { |
|
| 366 | - $this->set_update_run( $function_name ); |
|
| 365 | + if ($skip_forced_updates) { |
|
| 366 | + $this->set_update_run($function_name); |
|
| 367 | 367 | continue; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - $update_run = $this->has_update_run( $function_name ); |
|
| 370 | + $update_run = $this->has_update_run($function_name); |
|
| 371 | 371 | |
| 372 | - if( ! $update_run ) { |
|
| 372 | + if ( ! $update_run) { |
|
| 373 | 373 | $use_the_force = true; |
| 374 | - $updates_to_run[ $function_name ] = $update_data; |
|
| 374 | + $updates_to_run[$function_name] = $update_data; |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if( $skip_forced_updates ) { |
|
| 381 | + if ($skip_forced_updates) { |
|
| 382 | 382 | return; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if( $use_the_force && 0 < count( $updates_to_run ) ) { |
|
| 385 | + if ($use_the_force && 0 < count($updates_to_run)) { |
|
| 386 | 386 | |
| 387 | - $update_title = __( 'Important Sensei updates required', 'woothemes-sensei' ); |
|
| 387 | + $update_title = __('Important Sensei updates required', 'woothemes-sensei'); |
|
| 388 | 388 | |
| 389 | - $update_message = '<h1>' . __( 'Important Sensei upgrades required!', 'woothemes-sensei' ) . '</h1>' . "\n"; |
|
| 389 | + $update_message = '<h1>'.__('Important Sensei upgrades required!', 'woothemes-sensei').'</h1>'."\n"; |
|
| 390 | 390 | |
| 391 | 391 | // $update_message .= '<h4>' . sprintf( __( 'These updates are only required if you are updating from a previous version of Sensei. If you are installing Sensei for the first time, %1$syou can dismiss this page by clicking here%2$s.', 'woothemes-sensei' ), '<a href="' . add_query_arg( array( 'sensei_skip_forced_updates' => 'true' ) ) . '">', '</a>' ) . '</h4>' ."\n"; |
| 392 | 392 | |
| 393 | - $update_message .= '<p>' . __( 'The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
| 393 | + $update_message .= '<p>'.__('The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei').'</p>'."\n"; |
|
| 394 | 394 | |
| 395 | - $update_message .= '<p><b>' . __( 'To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei' ) . '</b></p>' . "\n"; |
|
| 395 | + $update_message .= '<p><b>'.__('To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei').'</b></p>'."\n"; |
|
| 396 | 396 | |
| 397 | - $update_message .= '<p>' . __( 'Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
| 397 | + $update_message .= '<p>'.__('Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei').'</p>'."\n"; |
|
| 398 | 398 | |
| 399 | - $update_message .= '<p><b>' . __( 'Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei' ) . '</b></p>' . "\n"; |
|
| 399 | + $update_message .= '<p><b>'.__('Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei').'</b></p>'."\n"; |
|
| 400 | 400 | |
| 401 | - $update_message .= '<ol>' . "\n"; |
|
| 401 | + $update_message .= '<ol>'."\n"; |
|
| 402 | 402 | |
| 403 | - foreach( $updates_to_run as $function => $data ) { |
|
| 403 | + foreach ($updates_to_run as $function => $data) { |
|
| 404 | 404 | |
| 405 | - if( ! isset( $data['title'] ) ) { |
|
| 405 | + if ( ! isset($data['title'])) { |
|
| 406 | 406 | break; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - $update_message .= '<li style="margin:5px 0;"><a href="' . admin_url( 'admin.php?page=sensei_updates&action=update&n=0&functions[]=' . $function ) . '" target="_blank">' . $data['title'] . '</a></li>'; |
|
| 409 | + $update_message .= '<li style="margin:5px 0;"><a href="'.admin_url('admin.php?page=sensei_updates&action=update&n=0&functions[]='.$function).'" target="_blank">'.$data['title'].'</a></li>'; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - $update_message .= '</ol>' . "\n"; |
|
| 412 | + $update_message .= '</ol>'."\n"; |
|
| 413 | 413 | |
| 414 | - switch( $version ) { |
|
| 414 | + switch ($version) { |
|
| 415 | 415 | |
| 416 | 416 | case '1.7.0': |
| 417 | - $update_message .= '<p><em>' . sprintf( __( 'Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei' ), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>' ) . '</em></p>' . "\n"; |
|
| 417 | + $update_message .= '<p><em>'.sprintf(__('Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei'), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>').'</em></p>'."\n"; |
|
| 418 | 418 | break; |
| 419 | 419 | |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - wp_die( $update_message, $update_title ); |
|
| 422 | + wp_die($update_message, $update_title); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | } |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | * @since 1.4.0 |
| 432 | 432 | * @return boolean |
| 433 | 433 | */ |
| 434 | - private function has_update_run( $update ) { |
|
| 435 | - if ( in_array( $update, $this->updates_run ) ) { |
|
| 434 | + private function has_update_run($update) { |
|
| 435 | + if (in_array($update, $this->updates_run)) { |
|
| 436 | 436 | return true; |
| 437 | 437 | } |
| 438 | 438 | return false; |
@@ -444,10 +444,10 @@ discard block |
||
| 444 | 444 | * @param string $update Update to process |
| 445 | 445 | * @since 1.4.0 |
| 446 | 446 | */ |
| 447 | - private function set_update_run( $update ) { |
|
| 448 | - array_push( $this->updates_run, $update ); |
|
| 449 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
| 450 | - update_option( Sensei()->token . '-upgrades', $this->updates_run ); |
|
| 447 | + private function set_update_run($update) { |
|
| 448 | + array_push($this->updates_run, $update); |
|
| 449 | + $this->updates_run = array_unique($this->updates_run); // we only need one reference per update |
|
| 450 | + update_option(Sensei()->token.'-upgrades', $this->updates_run); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /** |
@@ -458,15 +458,15 @@ discard block |
||
| 458 | 458 | * @return void |
| 459 | 459 | */ |
| 460 | 460 | public function assign_role_caps() { |
| 461 | - foreach ( $this->parent->post_types->role_caps as $role_cap_set ) { |
|
| 462 | - foreach ( $role_cap_set as $role_key => $capabilities_array ) { |
|
| 461 | + foreach ($this->parent->post_types->role_caps as $role_cap_set) { |
|
| 462 | + foreach ($role_cap_set as $role_key => $capabilities_array) { |
|
| 463 | 463 | /* Get the role. */ |
| 464 | - $role = get_role( $role_key ); |
|
| 465 | - foreach ( $capabilities_array as $cap_name ) { |
|
| 464 | + $role = get_role($role_key); |
|
| 465 | + foreach ($capabilities_array as $cap_name) { |
|
| 466 | 466 | /* If the role exists, add required capabilities for the plugin. */ |
| 467 | - if ( !empty( $role ) ) { |
|
| 468 | - if ( !$role->has_cap( $cap_name ) ) { |
|
| 469 | - $role->add_cap( $cap_name ); |
|
| 467 | + if ( ! empty($role)) { |
|
| 468 | + if ( ! $role->has_cap($cap_name)) { |
|
| 469 | + $role->add_cap($cap_name); |
|
| 470 | 470 | } // End If Statement |
| 471 | 471 | } // End If Statement |
| 472 | 472 | } // End For Loop |
@@ -483,16 +483,16 @@ discard block |
||
| 483 | 483 | * @return void |
| 484 | 484 | */ |
| 485 | 485 | public function set_default_quiz_grade_type() { |
| 486 | - $args = array( 'post_type' => 'quiz', |
|
| 486 | + $args = array('post_type' => 'quiz', |
|
| 487 | 487 | 'posts_per_page' => -1, |
| 488 | 488 | 'post_status' => 'publish', |
| 489 | 489 | 'suppress_filters' => 0 |
| 490 | 490 | ); |
| 491 | - $quizzes = get_posts( $args ); |
|
| 491 | + $quizzes = get_posts($args); |
|
| 492 | 492 | |
| 493 | - foreach( $quizzes as $quiz ) { |
|
| 494 | - update_post_meta( $quiz->ID, '_quiz_grade_type', 'auto' ); |
|
| 495 | - update_post_meta( $quiz->ID, '_quiz_grade_type_disabled', '' ); |
|
| 493 | + foreach ($quizzes as $quiz) { |
|
| 494 | + update_post_meta($quiz->ID, '_quiz_grade_type', 'auto'); |
|
| 495 | + update_post_meta($quiz->ID, '_quiz_grade_type_disabled', ''); |
|
| 496 | 496 | } |
| 497 | 497 | return true; |
| 498 | 498 | } // End set_default_quiz_grade_type |
@@ -505,23 +505,23 @@ discard block |
||
| 505 | 505 | * @return void |
| 506 | 506 | */ |
| 507 | 507 | public function set_default_question_type() { |
| 508 | - $args = array( 'post_type' => 'question', |
|
| 508 | + $args = array('post_type' => 'question', |
|
| 509 | 509 | 'posts_per_page' => -1, |
| 510 | 510 | 'post_status' => 'publish', |
| 511 | 511 | 'suppress_filters' => 0 |
| 512 | 512 | ); |
| 513 | - $questions = get_posts( $args ); |
|
| 513 | + $questions = get_posts($args); |
|
| 514 | 514 | |
| 515 | 515 | $already_run = true; |
| 516 | - foreach( $questions as $question ) { |
|
| 517 | - if( $already_run ) { |
|
| 518 | - $terms = wp_get_post_terms( $question->ID, 'question-type' ); |
|
| 519 | - if( is_array( $terms ) && count( $terms ) > 0 ) { |
|
| 516 | + foreach ($questions as $question) { |
|
| 517 | + if ($already_run) { |
|
| 518 | + $terms = wp_get_post_terms($question->ID, 'question-type'); |
|
| 519 | + if (is_array($terms) && count($terms) > 0) { |
|
| 520 | 520 | break; |
| 521 | 521 | } |
| 522 | 522 | } |
| 523 | 523 | $already_run = false; |
| 524 | - wp_set_post_terms( $question->ID, array( 'multiple-choice' ), 'question-type' ); |
|
| 524 | + wp_set_post_terms($question->ID, array('multiple-choice'), 'question-type'); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | return true; |
@@ -534,90 +534,90 @@ discard block |
||
| 534 | 534 | * @access public |
| 535 | 535 | * @return void |
| 536 | 536 | */ |
| 537 | - public function update_question_answer_data( $n = 50, $offset = 0 ) { |
|
| 537 | + public function update_question_answer_data($n = 50, $offset = 0) { |
|
| 538 | 538 | |
| 539 | 539 | // Get Total Number of Updates to run |
| 540 | - $quiz_count_object = wp_count_posts( 'quiz' ); |
|
| 540 | + $quiz_count_object = wp_count_posts('quiz'); |
|
| 541 | 541 | $quiz_count_published = $quiz_count_object->publish; |
| 542 | 542 | |
| 543 | 543 | // Calculate if this is the last page |
| 544 | - if ( 0 == $offset ) { |
|
| 544 | + if (0 == $offset) { |
|
| 545 | 545 | $current_page = 1; |
| 546 | 546 | } else { |
| 547 | - $current_page = intval( $offset / $n ); |
|
| 547 | + $current_page = intval($offset / $n); |
|
| 548 | 548 | } // End If Statement |
| 549 | - $total_pages = intval( $quiz_count_published / $n ); |
|
| 549 | + $total_pages = intval($quiz_count_published / $n); |
|
| 550 | 550 | |
| 551 | 551 | |
| 552 | - $args = array( 'post_type' => 'quiz', |
|
| 552 | + $args = array('post_type' => 'quiz', |
|
| 553 | 553 | 'posts_per_page' => $n, |
| 554 | 554 | 'offset' => $offset, |
| 555 | 555 | 'post_status' => 'publish', |
| 556 | 556 | 'suppress_filters' => 0 |
| 557 | 557 | ); |
| 558 | - $quizzes = get_posts( $args ); |
|
| 558 | + $quizzes = get_posts($args); |
|
| 559 | 559 | |
| 560 | 560 | $old_answers = array(); |
| 561 | 561 | $right_answers = array(); |
| 562 | 562 | $old_user_answers = array(); |
| 563 | 563 | |
| 564 | - if( is_array( $quizzes ) ) { |
|
| 565 | - foreach( $quizzes as $quiz ) { |
|
| 564 | + if (is_array($quizzes)) { |
|
| 565 | + foreach ($quizzes as $quiz) { |
|
| 566 | 566 | $quiz_id = $quiz->ID; |
| 567 | 567 | |
| 568 | 568 | // Get current user answers |
| 569 | - $comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $quiz_id, 'type' => 'sensei_quiz_answers' ), true ); |
|
| 569 | + $comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $quiz_id, 'type' => 'sensei_quiz_answers'), true); |
|
| 570 | 570 | // Need to always return an array, even with only 1 item |
| 571 | - if ( !is_array($comments) ) { |
|
| 572 | - $comments = array( $comments ); |
|
| 571 | + if ( ! is_array($comments)) { |
|
| 572 | + $comments = array($comments); |
|
| 573 | 573 | } |
| 574 | - foreach ( $comments as $comment ) { |
|
| 574 | + foreach ($comments as $comment) { |
|
| 575 | 575 | $user_id = $comment->user_id; |
| 576 | - $content = maybe_unserialize( base64_decode( $comment->comment_content ) ); |
|
| 577 | - $old_user_answers[ $quiz_id ][ $user_id ] = $content; |
|
| 576 | + $content = maybe_unserialize(base64_decode($comment->comment_content)); |
|
| 577 | + $old_user_answers[$quiz_id][$user_id] = $content; |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | // Get correct answers |
| 581 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); |
|
| 582 | - if( is_array( $questions ) ) { |
|
| 583 | - foreach( $questions as $question ) { |
|
| 584 | - $right_answer = get_post_meta( $question->ID, '_question_right_answer', true ); |
|
| 585 | - $right_answers[ $quiz_id ][ $question->ID ] = $right_answer; |
|
| 581 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); |
|
| 582 | + if (is_array($questions)) { |
|
| 583 | + foreach ($questions as $question) { |
|
| 584 | + $right_answer = get_post_meta($question->ID, '_question_right_answer', true); |
|
| 585 | + $right_answers[$quiz_id][$question->ID] = $right_answer; |
|
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - if( is_array( $right_answers ) ) { |
|
| 592 | - foreach( $right_answers as $quiz_id => $question ) { |
|
| 591 | + if (is_array($right_answers)) { |
|
| 592 | + foreach ($right_answers as $quiz_id => $question) { |
|
| 593 | 593 | $count = 0; |
| 594 | - if( is_array( $question ) ) { |
|
| 595 | - foreach( $question as $question_id => $answer ) { |
|
| 594 | + if (is_array($question)) { |
|
| 595 | + foreach ($question as $question_id => $answer) { |
|
| 596 | 596 | ++$count; |
| 597 | - if( isset( $old_user_answers[ $quiz_id ] ) ) { |
|
| 598 | - $answers_linkup[ $quiz_id ][ $count ] = $question_id; |
|
| 597 | + if (isset($old_user_answers[$quiz_id])) { |
|
| 598 | + $answers_linkup[$quiz_id][$count] = $question_id; |
|
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - if( is_array( $old_user_answers ) ) { |
|
| 606 | - foreach( $old_user_answers as $quiz_id => $user_answers ) { |
|
| 607 | - foreach( $user_answers as $user_id => $answers ) { |
|
| 608 | - foreach( $answers as $answer_id => $user_answer ) { |
|
| 609 | - $question_id = $answers_linkup[ $quiz_id ][ $answer_id ]; |
|
| 610 | - $new_user_answers[ $question_id ] = $user_answer; |
|
| 611 | - Sensei_Utils::sensei_grade_question_auto( $question_id, '', $user_answer, $user_id ); |
|
| 605 | + if (is_array($old_user_answers)) { |
|
| 606 | + foreach ($old_user_answers as $quiz_id => $user_answers) { |
|
| 607 | + foreach ($user_answers as $user_id => $answers) { |
|
| 608 | + foreach ($answers as $answer_id => $user_answer) { |
|
| 609 | + $question_id = $answers_linkup[$quiz_id][$answer_id]; |
|
| 610 | + $new_user_answers[$question_id] = $user_answer; |
|
| 611 | + Sensei_Utils::sensei_grade_question_auto($question_id, '', $user_answer, $user_id); |
|
| 612 | 612 | } |
| 613 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 614 | - Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id ); |
|
| 615 | - Sensei_Utils::sensei_save_quiz_answers( $new_user_answers, $user_id ); |
|
| 613 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 614 | + Sensei_Utils::sensei_start_lesson($lesson_id, $user_id); |
|
| 615 | + Sensei_Utils::sensei_save_quiz_answers($new_user_answers, $user_id); |
|
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - if ( $current_page == $total_pages ) { |
|
| 620 | + if ($current_page == $total_pages) { |
|
| 621 | 621 | return true; |
| 622 | 622 | } else { |
| 623 | 623 | return false; |
@@ -632,15 +632,15 @@ discard block |
||
| 632 | 632 | * @return boolean |
| 633 | 633 | */ |
| 634 | 634 | public function update_question_grade_points() { |
| 635 | - $args = array( 'post_type' => 'question', |
|
| 635 | + $args = array('post_type' => 'question', |
|
| 636 | 636 | 'posts_per_page' => -1, |
| 637 | 637 | 'post_status' => 'publish', |
| 638 | 638 | 'suppress_filters' => 0 |
| 639 | 639 | ); |
| 640 | - $questions = get_posts( $args ); |
|
| 640 | + $questions = get_posts($args); |
|
| 641 | 641 | |
| 642 | - foreach( $questions as $question ) { |
|
| 643 | - update_post_meta( $question->ID, '_question_grade', '1' ); |
|
| 642 | + foreach ($questions as $question) { |
|
| 643 | + update_post_meta($question->ID, '_question_grade', '1'); |
|
| 644 | 644 | } |
| 645 | 645 | return true; |
| 646 | 646 | } // End update_question_grade_points |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | * @return boolean |
| 653 | 653 | */ |
| 654 | 654 | public function convert_essay_paste_questions() { |
| 655 | - $args = array( 'post_type' => 'question', |
|
| 655 | + $args = array('post_type' => 'question', |
|
| 656 | 656 | 'posts_per_page' => -1, |
| 657 | 657 | 'post_status' => 'publish', |
| 658 | 658 | 'tax_query' => array( |
@@ -664,14 +664,14 @@ discard block |
||
| 664 | 664 | ), |
| 665 | 665 | 'suppress_filters' => 0 |
| 666 | 666 | ); |
| 667 | - $questions = get_posts( $args ); |
|
| 667 | + $questions = get_posts($args); |
|
| 668 | 668 | |
| 669 | - foreach( $questions as $question ) { |
|
| 670 | - wp_set_object_terms( $question->ID, 'multi-line', 'question-type', false ); |
|
| 669 | + foreach ($questions as $question) { |
|
| 670 | + wp_set_object_terms($question->ID, 'multi-line', 'question-type', false); |
|
| 671 | 671 | |
| 672 | - $quiz_id = get_post_meta( $question->ID, '_quiz_id', true ); |
|
| 673 | - if( 0 < intval( $quiz_id ) ) { |
|
| 674 | - add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '0000', true ); |
|
| 672 | + $quiz_id = get_post_meta($question->ID, '_quiz_id', true); |
|
| 673 | + if (0 < intval($quiz_id)) { |
|
| 674 | + add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'0000', true); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | return true; |
@@ -683,33 +683,33 @@ discard block |
||
| 683 | 683 | * @since 1.5.0 |
| 684 | 684 | * @return boolean |
| 685 | 685 | */ |
| 686 | - public function set_random_question_order( $n = 50, $offset = 0 ) { |
|
| 686 | + public function set_random_question_order($n = 50, $offset = 0) { |
|
| 687 | 687 | |
| 688 | 688 | // Get Total Number of Updates to run |
| 689 | - $quiz_count_object = wp_count_posts( 'quiz' ); |
|
| 689 | + $quiz_count_object = wp_count_posts('quiz'); |
|
| 690 | 690 | $quiz_count_published = $quiz_count_object->publish; |
| 691 | 691 | |
| 692 | 692 | // Calculate if this is the last page |
| 693 | - if ( 0 == $offset ) { |
|
| 693 | + if (0 == $offset) { |
|
| 694 | 694 | $current_page = 1; |
| 695 | 695 | } else { |
| 696 | - $current_page = intval( $offset / $n ); |
|
| 696 | + $current_page = intval($offset / $n); |
|
| 697 | 697 | } // End If Statement |
| 698 | - $total_pages = intval( $quiz_count_published / $n ); |
|
| 698 | + $total_pages = intval($quiz_count_published / $n); |
|
| 699 | 699 | |
| 700 | - $args = array( 'post_type' => 'quiz', |
|
| 700 | + $args = array('post_type' => 'quiz', |
|
| 701 | 701 | 'post_status' => 'any', |
| 702 | 702 | 'posts_per_page' => $n, |
| 703 | 703 | 'offset' => $offset, |
| 704 | 704 | 'suppress_filters' => 0 |
| 705 | 705 | ); |
| 706 | - $quizzes = get_posts( $args ); |
|
| 706 | + $quizzes = get_posts($args); |
|
| 707 | 707 | |
| 708 | - foreach( $quizzes as $quiz ) { |
|
| 709 | - update_post_meta( $quiz->ID, '_random_question_order', 'yes' ); |
|
| 708 | + foreach ($quizzes as $quiz) { |
|
| 709 | + update_post_meta($quiz->ID, '_random_question_order', 'yes'); |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - if ( $current_page == $total_pages ) { |
|
| 712 | + if ($current_page == $total_pages) { |
|
| 713 | 713 | return true; |
| 714 | 714 | } else { |
| 715 | 715 | return false; |
@@ -723,37 +723,37 @@ discard block |
||
| 723 | 723 | * @since 1.5.0 |
| 724 | 724 | * @return boolean |
| 725 | 725 | */ |
| 726 | - public function set_default_show_question_count( $n = 50, $offset = 0 ) { |
|
| 726 | + public function set_default_show_question_count($n = 50, $offset = 0) { |
|
| 727 | 727 | |
| 728 | - $args = array( 'post_type' => 'quiz', |
|
| 728 | + $args = array('post_type' => 'quiz', |
|
| 729 | 729 | 'post_status' => 'any', |
| 730 | 730 | 'posts_per_page' => $n, |
| 731 | 731 | 'offset' => $offset, |
| 732 | 732 | 'meta_key' => '_show_questions', |
| 733 | 733 | 'suppress_filters' => 0 |
| 734 | 734 | ); |
| 735 | - $quizzes = get_posts( $args ); |
|
| 735 | + $quizzes = get_posts($args); |
|
| 736 | 736 | |
| 737 | - $total_quizzes = count( $quizzes ); |
|
| 737 | + $total_quizzes = count($quizzes); |
|
| 738 | 738 | |
| 739 | - if( 0 == intval( $total_quizzes ) ) { |
|
| 739 | + if (0 == intval($total_quizzes)) { |
|
| 740 | 740 | return true; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - foreach( $quizzes as $quiz ) { |
|
| 744 | - delete_post_meta( $quiz->ID, '_show_questions' ); |
|
| 743 | + foreach ($quizzes as $quiz) { |
|
| 744 | + delete_post_meta($quiz->ID, '_show_questions'); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - $total_pages = intval( $total_quizzes / $n ); |
|
| 747 | + $total_pages = intval($total_quizzes / $n); |
|
| 748 | 748 | |
| 749 | 749 | // Calculate if this is the last page |
| 750 | - if ( 0 == $offset ) { |
|
| 750 | + if (0 == $offset) { |
|
| 751 | 751 | $current_page = 1; |
| 752 | 752 | } else { |
| 753 | - $current_page = intval( $offset / $n ); |
|
| 753 | + $current_page = intval($offset / $n); |
|
| 754 | 754 | } // End If Statement |
| 755 | 755 | |
| 756 | - if ( $current_page == $total_pages ) { |
|
| 756 | + if ($current_page == $total_pages) { |
|
| 757 | 757 | return true; |
| 758 | 758 | } else { |
| 759 | 759 | return false; |
@@ -761,17 +761,17 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - public function remove_deleted_user_activity( $n = 50, $offset = 0 ) { |
|
| 764 | + public function remove_deleted_user_activity($n = 50, $offset = 0) { |
|
| 765 | 765 | |
| 766 | 766 | |
| 767 | 767 | // remove_filter( 'comments_clauses', array( Sensei()->admin, 'comments_admin_filter' ) ); |
| 768 | 768 | |
| 769 | - $all_activity = get_comments( array( 'status' => 'approve' ) ); |
|
| 769 | + $all_activity = get_comments(array('status' => 'approve')); |
|
| 770 | 770 | $activity_count = array(); |
| 771 | - foreach( $all_activity as $activity ) { |
|
| 772 | - if( '' == $activity->comment_type ) continue; |
|
| 773 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 774 | - if( 0 == $activity->user_id ) continue; |
|
| 771 | + foreach ($all_activity as $activity) { |
|
| 772 | + if ('' == $activity->comment_type) continue; |
|
| 773 | + if (strpos('sensei_', $activity->comment_type) != 0) continue; |
|
| 774 | + if (0 == $activity->user_id) continue; |
|
| 775 | 775 | $activity_count[] = $activity->comment_ID; |
| 776 | 776 | } |
| 777 | 777 | |
@@ -781,35 +781,35 @@ discard block |
||
| 781 | 781 | 'status' => 'approve' |
| 782 | 782 | ); |
| 783 | 783 | |
| 784 | - $activities = get_comments( $args ); |
|
| 784 | + $activities = get_comments($args); |
|
| 785 | 785 | |
| 786 | - foreach( $activities as $activity ) { |
|
| 787 | - if( '' == $activity->comment_type ) continue; |
|
| 788 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 789 | - if( 0 == $activity->user_id ) continue; |
|
| 786 | + foreach ($activities as $activity) { |
|
| 787 | + if ('' == $activity->comment_type) continue; |
|
| 788 | + if (strpos('sensei_', $activity->comment_type) != 0) continue; |
|
| 789 | + if (0 == $activity->user_id) continue; |
|
| 790 | 790 | |
| 791 | - $user_exists = get_userdata( $activity->user_id ); |
|
| 791 | + $user_exists = get_userdata($activity->user_id); |
|
| 792 | 792 | |
| 793 | - if( ! $user_exists ) { |
|
| 794 | - wp_delete_comment( intval( $activity->comment_ID ), true ); |
|
| 793 | + if ( ! $user_exists) { |
|
| 794 | + wp_delete_comment(intval($activity->comment_ID), true); |
|
| 795 | 795 | wp_cache_flush(); |
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - $total_activities = count( $activity_count ); |
|
| 799 | + $total_activities = count($activity_count); |
|
| 800 | 800 | |
| 801 | - $total_pages = intval( $total_activities / $n ); |
|
| 801 | + $total_pages = intval($total_activities / $n); |
|
| 802 | 802 | |
| 803 | 803 | // Calculate if this is the last page |
| 804 | - if ( 0 == $offset ) { |
|
| 804 | + if (0 == $offset) { |
|
| 805 | 805 | $current_page = 1; |
| 806 | 806 | } else { |
| 807 | - $current_page = intval( $offset / $n ); |
|
| 807 | + $current_page = intval($offset / $n); |
|
| 808 | 808 | } // End If Statement |
| 809 | 809 | |
| 810 | 810 | // add_filter( 'comments_clauses', array( Sensei()->admin, 'comments_admin_filter' ) ); |
| 811 | 811 | |
| 812 | - if ( $current_page >= $total_pages ) { |
|
| 812 | + if ($current_page >= $total_pages) { |
|
| 813 | 813 | return true; |
| 814 | 814 | } else { |
| 815 | 815 | return false; |
@@ -818,16 +818,16 @@ discard block |
||
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | public function add_teacher_role() { |
| 821 | - add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ), array( 'read' => true, 'manage_sensei_grades' => true ) ); |
|
| 821 | + add_role('teacher', __('Teacher', 'woothemes-sensei'), array('read' => true, 'manage_sensei_grades' => true)); |
|
| 822 | 822 | return true; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | public function add_sensei_caps() { |
| 826 | - $role = get_role( 'administrator' ); |
|
| 826 | + $role = get_role('administrator'); |
|
| 827 | 827 | |
| 828 | - if( ! is_null( $role ) ) { |
|
| 829 | - $role->add_cap( 'manage_sensei' ); |
|
| 830 | - $role->add_cap( 'manage_sensei_grades' ); |
|
| 828 | + if ( ! is_null($role)) { |
|
| 829 | + $role->add_cap('manage_sensei'); |
|
| 830 | + $role->add_cap('manage_sensei_grades'); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | return true; |
@@ -841,16 +841,16 @@ discard block |
||
| 841 | 841 | 'suppress_filters' => 0 |
| 842 | 842 | ); |
| 843 | 843 | |
| 844 | - $questions = get_posts( $args ); |
|
| 844 | + $questions = get_posts($args); |
|
| 845 | 845 | |
| 846 | - foreach( $questions as $question ) { |
|
| 846 | + foreach ($questions as $question) { |
|
| 847 | 847 | |
| 848 | - if( ! isset( $question->ID ) ) continue; |
|
| 848 | + if ( ! isset($question->ID)) continue; |
|
| 849 | 849 | |
| 850 | - $quiz_id = get_post_meta( $question->ID, '_quiz_id', true ); |
|
| 850 | + $quiz_id = get_post_meta($question->ID, '_quiz_id', true); |
|
| 851 | 851 | |
| 852 | - $question_order = get_post_meta( $question->ID, '_quiz_question_order', true ); |
|
| 853 | - update_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $question_order ); |
|
| 852 | + $question_order = get_post_meta($question->ID, '_quiz_question_order', true); |
|
| 853 | + update_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $question_order); |
|
| 854 | 854 | |
| 855 | 855 | } |
| 856 | 856 | |
@@ -859,15 +859,15 @@ discard block |
||
| 859 | 859 | |
| 860 | 860 | public function update_quiz_settings() { |
| 861 | 861 | |
| 862 | - $settings = get_option( 'woothemes-sensei-settings', array() ); |
|
| 862 | + $settings = get_option('woothemes-sensei-settings', array()); |
|
| 863 | 863 | |
| 864 | 864 | $lesson_completion = false; |
| 865 | - if( isset( $settings['lesson_completion'] ) ) { |
|
| 865 | + if (isset($settings['lesson_completion'])) { |
|
| 866 | 866 | $lesson_completion = $settings['lesson_completion']; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | $reset_quiz_allowed = false; |
| 870 | - if( isset( $settings['quiz_reset_allowed'] ) ) { |
|
| 870 | + if (isset($settings['quiz_reset_allowed'])) { |
|
| 871 | 871 | $reset_quiz_allowed = $settings['quiz_reset_allowed']; |
| 872 | 872 | } |
| 873 | 873 | |
@@ -878,20 +878,20 @@ discard block |
||
| 878 | 878 | 'suppress_filters' => 0 |
| 879 | 879 | ); |
| 880 | 880 | |
| 881 | - $quizzes = get_posts( $args ); |
|
| 881 | + $quizzes = get_posts($args); |
|
| 882 | 882 | |
| 883 | - foreach( $quizzes as $quiz ) { |
|
| 883 | + foreach ($quizzes as $quiz) { |
|
| 884 | 884 | |
| 885 | - if( ! isset( $quiz->ID ) ) continue; |
|
| 885 | + if ( ! isset($quiz->ID)) continue; |
|
| 886 | 886 | |
| 887 | - if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) { |
|
| 888 | - update_post_meta( $quiz->ID, '_pass_required', 'on' ); |
|
| 887 | + if (isset($lesson_completion) && 'passed' == $lesson_completion) { |
|
| 888 | + update_post_meta($quiz->ID, '_pass_required', 'on'); |
|
| 889 | 889 | } else { |
| 890 | - update_post_meta( $quiz->ID, '_quiz_passmark', 0 ); |
|
| 890 | + update_post_meta($quiz->ID, '_quiz_passmark', 0); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - if( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) { |
|
| 894 | - update_post_meta( $quiz->ID, '_enable_quiz_reset', 'on' ); |
|
| 893 | + if (isset($reset_quiz_allowed) && $reset_quiz_allowed) { |
|
| 894 | + update_post_meta($quiz->ID, '_enable_quiz_reset', 'on'); |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
@@ -906,22 +906,22 @@ discard block |
||
| 906 | 906 | 'suppress_filters' => 0 |
| 907 | 907 | ); |
| 908 | 908 | |
| 909 | - $lessons = get_posts( $args ); |
|
| 909 | + $lessons = get_posts($args); |
|
| 910 | 910 | |
| 911 | - foreach( $lessons as $lesson ) { |
|
| 911 | + foreach ($lessons as $lesson) { |
|
| 912 | 912 | |
| 913 | - if( ! isset( $lesson->ID ) ) continue; |
|
| 913 | + if ( ! isset($lesson->ID)) continue; |
|
| 914 | 914 | |
| 915 | - $course_id = get_post_meta( $lesson->ID, '_lesson_course', true); |
|
| 915 | + $course_id = get_post_meta($lesson->ID, '_lesson_course', true); |
|
| 916 | 916 | |
| 917 | - if( $course_id ) { |
|
| 918 | - update_post_meta( $lesson->ID, '_order_' . $course_id, 0 ); |
|
| 917 | + if ($course_id) { |
|
| 918 | + update_post_meta($lesson->ID, '_order_'.$course_id, 0); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | - $module = Sensei()->modules->get_lesson_module( $lesson->ID ); |
|
| 921 | + $module = Sensei()->modules->get_lesson_module($lesson->ID); |
|
| 922 | 922 | |
| 923 | - if( $module ) { |
|
| 924 | - update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 ); |
|
| 923 | + if ($module) { |
|
| 924 | + update_post_meta($lesson->ID, '_order_module_'.$module->term_id, 0); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | } |
@@ -930,10 +930,10 @@ discard block |
||
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | public function add_editor_caps() { |
| 933 | - $role = get_role( 'editor' ); |
|
| 933 | + $role = get_role('editor'); |
|
| 934 | 934 | |
| 935 | - if( ! is_null( $role ) ) { |
|
| 936 | - $role->add_cap( 'manage_sensei_grades' ); |
|
| 935 | + if ( ! is_null($role)) { |
|
| 936 | + $role->add_cap('manage_sensei_grades'); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | return true; |
@@ -952,26 +952,26 @@ discard block |
||
| 952 | 952 | WHERE m.meta_key = '_question_right_answer' AND m.meta_value LIKE '%|%' AND m.meta_value NOT LIKE '%||%' |
| 953 | 953 | AND m.post_id = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id = t.term_id |
| 954 | 954 | AND tt.taxonomy = 'question-type' AND t.slug = 'gap-fill'"; |
| 955 | - $wpdb->query( $sql ); |
|
| 955 | + $wpdb->query($sql); |
|
| 956 | 956 | |
| 957 | 957 | return true; |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - public function update_quiz_lesson_relationship( $n = 50, $offset = 0 ) { |
|
| 961 | - $count_object = wp_count_posts( 'quiz' ); |
|
| 960 | + public function update_quiz_lesson_relationship($n = 50, $offset = 0) { |
|
| 961 | + $count_object = wp_count_posts('quiz'); |
|
| 962 | 962 | |
| 963 | 963 | $count_published = 0; |
| 964 | - foreach ( $count_object AS $status => $count ) { |
|
| 964 | + foreach ($count_object AS $status => $count) { |
|
| 965 | 965 | $count_published += $count; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | // Calculate if this is the last page |
| 969 | - if ( 0 == $offset ) { |
|
| 969 | + if (0 == $offset) { |
|
| 970 | 970 | $current_page = 1; |
| 971 | 971 | } else { |
| 972 | - $current_page = intval( $offset / $n ); |
|
| 972 | + $current_page = intval($offset / $n); |
|
| 973 | 973 | } |
| 974 | - $total_pages = ceil( $count_published / $n ); |
|
| 974 | + $total_pages = ceil($count_published / $n); |
|
| 975 | 975 | |
| 976 | 976 | $args = array( |
| 977 | 977 | 'post_type' => 'quiz', |
@@ -980,52 +980,52 @@ discard block |
||
| 980 | 980 | 'post_status' => 'any' |
| 981 | 981 | ); |
| 982 | 982 | |
| 983 | - $quizzes = get_posts( $args ); |
|
| 983 | + $quizzes = get_posts($args); |
|
| 984 | 984 | |
| 985 | - foreach( $quizzes as $quiz ) { |
|
| 985 | + foreach ($quizzes as $quiz) { |
|
| 986 | 986 | |
| 987 | - if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue; |
|
| 987 | + if ( ! isset($quiz->ID) || 0 != $quiz->post_parent) continue; |
|
| 988 | 988 | |
| 989 | - $lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true ); |
|
| 989 | + $lesson_id = get_post_meta($quiz->ID, '_quiz_lesson', true); |
|
| 990 | 990 | |
| 991 | - if( empty( $lesson_id ) ) continue; |
|
| 991 | + if (empty($lesson_id)) continue; |
|
| 992 | 992 | |
| 993 | 993 | $data = array( |
| 994 | 994 | 'ID' => $quiz->ID, |
| 995 | 995 | 'post_parent' => $lesson_id, |
| 996 | 996 | ); |
| 997 | - wp_update_post( $data ); |
|
| 997 | + wp_update_post($data); |
|
| 998 | 998 | |
| 999 | - update_post_meta( $lesson_id, '_lesson_quiz', $quiz->ID ); |
|
| 999 | + update_post_meta($lesson_id, '_lesson_quiz', $quiz->ID); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - if ( $current_page == $total_pages || 0 == $total_pages ) { |
|
| 1002 | + if ($current_page == $total_pages || 0 == $total_pages) { |
|
| 1003 | 1003 | return true; |
| 1004 | 1004 | } else { |
| 1005 | 1005 | return false; |
| 1006 | 1006 | } |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - function status_changes_fix_lessons( $n = 50, $offset = 0 ) { |
|
| 1009 | + function status_changes_fix_lessons($n = 50, $offset = 0) { |
|
| 1010 | 1010 | global $wpdb; |
| 1011 | 1011 | |
| 1012 | - $count_object = wp_count_posts( 'lesson' ); |
|
| 1012 | + $count_object = wp_count_posts('lesson'); |
|
| 1013 | 1013 | $count_published = 0; |
| 1014 | - foreach ( $count_object AS $status => $count ) { |
|
| 1014 | + foreach ($count_object AS $status => $count) { |
|
| 1015 | 1015 | $count_published += $count; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - if ( 0 == $count_published ) { |
|
| 1018 | + if (0 == $count_published) { |
|
| 1019 | 1019 | return true; |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | // Calculate if this is the last page |
| 1023 | - if ( 0 == $offset ) { |
|
| 1023 | + if (0 == $offset) { |
|
| 1024 | 1024 | $current_page = 1; |
| 1025 | 1025 | } else { |
| 1026 | - $current_page = intval( $offset / $n ); |
|
| 1026 | + $current_page = intval($offset / $n); |
|
| 1027 | 1027 | } |
| 1028 | - $total_pages = ceil( $count_published / $n ); |
|
| 1028 | + $total_pages = ceil($count_published / $n); |
|
| 1029 | 1029 | |
| 1030 | 1030 | // Get all Lessons with (and without) Quizzes... |
| 1031 | 1031 | $args = array( |
@@ -1035,26 +1035,26 @@ discard block |
||
| 1035 | 1035 | 'offset' => $offset, |
| 1036 | 1036 | 'fields' => 'ids' |
| 1037 | 1037 | ); |
| 1038 | - $lesson_ids = get_posts( $args ); |
|
| 1038 | + $lesson_ids = get_posts($args); |
|
| 1039 | 1039 | |
| 1040 | 1040 | // ...get all Quiz IDs for the above Lessons |
| 1041 | - $id_list = join( ',', $lesson_ids ); |
|
| 1042 | - $meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A ); |
|
| 1041 | + $id_list = join(',', $lesson_ids); |
|
| 1042 | + $meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A); |
|
| 1043 | 1043 | $lesson_quiz_ids = array(); |
| 1044 | - if ( !empty($meta_list) ) { |
|
| 1045 | - foreach ( $meta_list as $metarow ) { |
|
| 1044 | + if ( ! empty($meta_list)) { |
|
| 1045 | + foreach ($meta_list as $metarow) { |
|
| 1046 | 1046 | $lesson_id = $metarow['meta_value']; |
| 1047 | 1047 | $quiz_id = $metarow['post_id']; |
| 1048 | - $lesson_quiz_ids[ $lesson_id ] = $quiz_id; |
|
| 1048 | + $lesson_quiz_ids[$lesson_id] = $quiz_id; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | // ...check all Quiz IDs for questions |
| 1053 | - $id_list = join( ',', array_values($lesson_quiz_ids) ); |
|
| 1054 | - $meta_list = $wpdb->get_results( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A ); |
|
| 1053 | + $id_list = join(',', array_values($lesson_quiz_ids)); |
|
| 1054 | + $meta_list = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A); |
|
| 1055 | 1055 | $lesson_quiz_ids_with_questions = array(); |
| 1056 | - if ( !empty($meta_list) ) { |
|
| 1057 | - foreach ( $meta_list as $metarow ) { |
|
| 1056 | + if ( ! empty($meta_list)) { |
|
| 1057 | + foreach ($meta_list as $metarow) { |
|
| 1058 | 1058 | $quiz_id = $metarow['meta_value']; |
| 1059 | 1059 | $lesson_quiz_ids_with_questions[] = $quiz_id; |
| 1060 | 1060 | } |
@@ -1062,49 +1062,49 @@ discard block |
||
| 1062 | 1062 | |
| 1063 | 1063 | // For each quiz check there are questions, if not remove the corresponding meta keys from Quizzes and Lessons |
| 1064 | 1064 | // if there are questions on the quiz add the corresponding meta keys to Quizzes and Lessons |
| 1065 | - $d_count = $a_count =0; |
|
| 1066 | - foreach ( $lesson_quiz_ids AS $lesson_id => $quiz_id ) { |
|
| 1067 | - if ( !in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) { |
|
| 1065 | + $d_count = $a_count = 0; |
|
| 1066 | + foreach ($lesson_quiz_ids AS $lesson_id => $quiz_id) { |
|
| 1067 | + if ( ! in_array($quiz_id, $lesson_quiz_ids_with_questions)) { |
|
| 1068 | 1068 | |
| 1069 | 1069 | // Quiz has no questions, drop the corresponding data |
| 1070 | - delete_post_meta( $quiz_id, '_pass_required' ); |
|
| 1071 | - delete_post_meta( $quiz_id, '_quiz_passmark' ); |
|
| 1072 | - delete_post_meta( $lesson_id, '_quiz_has_questions' ); |
|
| 1070 | + delete_post_meta($quiz_id, '_pass_required'); |
|
| 1071 | + delete_post_meta($quiz_id, '_quiz_passmark'); |
|
| 1072 | + delete_post_meta($lesson_id, '_quiz_has_questions'); |
|
| 1073 | 1073 | $d_count++; |
| 1074 | 1074 | } |
| 1075 | - else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) { |
|
| 1075 | + else if (in_array($quiz_id, $lesson_quiz_ids_with_questions)) { |
|
| 1076 | 1076 | |
| 1077 | 1077 | // Quiz has no questions, drop the corresponding data |
| 1078 | - update_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 1078 | + update_post_meta($lesson_id, '_quiz_has_questions', true); |
|
| 1079 | 1079 | $a_count++; |
| 1080 | 1080 | } |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - if ( $current_page == $total_pages ) { |
|
| 1083 | + if ($current_page == $total_pages) { |
|
| 1084 | 1084 | return true; |
| 1085 | 1085 | } else { |
| 1086 | 1086 | return false; |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - function status_changes_convert_lessons( $n = 50, $offset = 0 ) { |
|
| 1090 | + function status_changes_convert_lessons($n = 50, $offset = 0) { |
|
| 1091 | 1091 | global $wpdb; |
| 1092 | 1092 | |
| 1093 | - wp_defer_comment_counting( true ); |
|
| 1093 | + wp_defer_comment_counting(true); |
|
| 1094 | 1094 | |
| 1095 | - $user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " ); |
|
| 1095 | + $user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users "); |
|
| 1096 | 1096 | |
| 1097 | - if ( 0 == $user_count_result ) { |
|
| 1097 | + if (0 == $user_count_result) { |
|
| 1098 | 1098 | return true; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - if ( 0 == $offset ) { |
|
| 1101 | + if (0 == $offset) { |
|
| 1102 | 1102 | $current_page = 1; |
| 1103 | 1103 | } else { |
| 1104 | - $current_page = intval( $offset / $n ); |
|
| 1104 | + $current_page = intval($offset / $n); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | - $total_pages = ceil( $user_count_result / $n ); |
|
| 1107 | + $total_pages = ceil($user_count_result / $n); |
|
| 1108 | 1108 | |
| 1109 | 1109 | // Get all Lessons with Quizzes... |
| 1110 | 1110 | $args = array( |
@@ -1119,34 +1119,34 @@ discard block |
||
| 1119 | 1119 | ), |
| 1120 | 1120 | 'fields' => 'ids' |
| 1121 | 1121 | ); |
| 1122 | - $lesson_ids_with_quizzes = get_posts( $args ); |
|
| 1122 | + $lesson_ids_with_quizzes = get_posts($args); |
|
| 1123 | 1123 | // ...get all Quiz IDs for the above Lessons |
| 1124 | - $id_list = join( ',', $lesson_ids_with_quizzes ); |
|
| 1125 | - $meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A ); |
|
| 1124 | + $id_list = join(',', $lesson_ids_with_quizzes); |
|
| 1125 | + $meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A); |
|
| 1126 | 1126 | $lesson_quiz_ids = array(); |
| 1127 | - if ( !empty($meta_list) ) { |
|
| 1128 | - foreach ( $meta_list as $metarow ) { |
|
| 1127 | + if ( ! empty($meta_list)) { |
|
| 1128 | + foreach ($meta_list as $metarow) { |
|
| 1129 | 1129 | $lesson_id = $metarow['meta_value']; |
| 1130 | 1130 | $quiz_id = $metarow['post_id']; |
| 1131 | - $lesson_quiz_ids[ $lesson_id ] = $quiz_id; |
|
| 1131 | + $lesson_quiz_ids[$lesson_id] = $quiz_id; |
|
| 1132 | 1132 | } |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | // ...get all Pass Required & Passmarks for the above Lesson/Quizzes |
| 1136 | - $id_list = join( ',', array_values($lesson_quiz_ids) ); |
|
| 1137 | - $meta_list = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A ); |
|
| 1136 | + $id_list = join(',', array_values($lesson_quiz_ids)); |
|
| 1137 | + $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A); |
|
| 1138 | 1138 | $quizzes_pass_required = $quizzes_passmarks = array(); |
| 1139 | - if ( !empty($meta_list) ) { |
|
| 1140 | - foreach ( $meta_list as $metarow ) { |
|
| 1141 | - if ( !empty($metarow['meta_value']) ) { |
|
| 1139 | + if ( ! empty($meta_list)) { |
|
| 1140 | + foreach ($meta_list as $metarow) { |
|
| 1141 | + if ( ! empty($metarow['meta_value'])) { |
|
| 1142 | 1142 | $quiz_id = $metarow['post_id']; |
| 1143 | 1143 | $key = $metarow['meta_key']; |
| 1144 | 1144 | $value = $metarow['meta_value']; |
| 1145 | - if ( '_pass_required' == $key ) { |
|
| 1146 | - $quizzes_pass_required[ $quiz_id ] = $value; |
|
| 1145 | + if ('_pass_required' == $key) { |
|
| 1146 | + $quizzes_pass_required[$quiz_id] = $value; |
|
| 1147 | 1147 | } |
| 1148 | - if ( '_quiz_passmark' == $key ) { |
|
| 1149 | - $quizzes_passmarks[ $quiz_id ] = $value; |
|
| 1148 | + if ('_quiz_passmark' == $key) { |
|
| 1149 | + $quizzes_passmarks[$quiz_id] = $value; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | } |
| 1152 | 1152 | } |
@@ -1160,41 +1160,41 @@ discard block |
||
| 1160 | 1160 | $check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_lesson_status' "; |
| 1161 | 1161 | |
| 1162 | 1162 | // $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time? |
| 1163 | - $user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) ); |
|
| 1163 | + $user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset)); |
|
| 1164 | 1164 | |
| 1165 | - foreach ( $user_ids AS $user_id ) { |
|
| 1165 | + foreach ($user_ids AS $user_id) { |
|
| 1166 | 1166 | |
| 1167 | 1167 | $lesson_ends = $lesson_grades = $lesson_answers = array(); |
| 1168 | 1168 | |
| 1169 | 1169 | // Pre-process the lesson ends |
| 1170 | - $_lesson_ends = $wpdb->get_results( $wpdb->prepare($end_sql, $user_id), ARRAY_A ); |
|
| 1171 | - foreach ( $_lesson_ends as $lesson_end ) { |
|
| 1170 | + $_lesson_ends = $wpdb->get_results($wpdb->prepare($end_sql, $user_id), ARRAY_A); |
|
| 1171 | + foreach ($_lesson_ends as $lesson_end) { |
|
| 1172 | 1172 | // This will overwrite existing entries with the newer ones |
| 1173 | - $lesson_ends[ $lesson_end['comment_post_ID'] ] = $lesson_end['comment_date']; |
|
| 1173 | + $lesson_ends[$lesson_end['comment_post_ID']] = $lesson_end['comment_date']; |
|
| 1174 | 1174 | } |
| 1175 | - unset( $_lesson_ends ); |
|
| 1175 | + unset($_lesson_ends); |
|
| 1176 | 1176 | |
| 1177 | 1177 | // Pre-process the lesson grades |
| 1178 | - $_lesson_grades = $wpdb->get_results( $wpdb->prepare($grade_sql, $user_id), ARRAY_A ); |
|
| 1179 | - foreach ( $_lesson_grades as $lesson_grade ) { |
|
| 1178 | + $_lesson_grades = $wpdb->get_results($wpdb->prepare($grade_sql, $user_id), ARRAY_A); |
|
| 1179 | + foreach ($_lesson_grades as $lesson_grade) { |
|
| 1180 | 1180 | // This will overwrite existing entries with the newer ones (assuming the grade is higher) |
| 1181 | - if ( empty($lesson_grades[ $lesson_grade['comment_post_ID'] ]) || $lesson_grades[ $lesson_grade['comment_post_ID'] ] < $lesson_grade['comment_content'] ) { |
|
| 1182 | - $lesson_grades[ $lesson_grade['comment_post_ID'] ] = $lesson_grade['comment_content']; |
|
| 1181 | + if (empty($lesson_grades[$lesson_grade['comment_post_ID']]) || $lesson_grades[$lesson_grade['comment_post_ID']] < $lesson_grade['comment_content']) { |
|
| 1182 | + $lesson_grades[$lesson_grade['comment_post_ID']] = $lesson_grade['comment_content']; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | } |
| 1185 | - unset( $_lesson_grades ); |
|
| 1185 | + unset($_lesson_grades); |
|
| 1186 | 1186 | |
| 1187 | 1187 | // Pre-process the lesson answers |
| 1188 | - $_lesson_answers = $wpdb->get_results( $wpdb->prepare($answers_sql, $user_id), ARRAY_A ); |
|
| 1189 | - foreach ( $_lesson_answers as $lesson_answer ) { |
|
| 1188 | + $_lesson_answers = $wpdb->get_results($wpdb->prepare($answers_sql, $user_id), ARRAY_A); |
|
| 1189 | + foreach ($_lesson_answers as $lesson_answer) { |
|
| 1190 | 1190 | // This will overwrite existing entries with the newer ones |
| 1191 | - $lesson_answers[ $lesson_answer['comment_post_ID'] ] = $lesson_answer['comment_content']; |
|
| 1191 | + $lesson_answers[$lesson_answer['comment_post_ID']] = $lesson_answer['comment_content']; |
|
| 1192 | 1192 | } |
| 1193 | - unset( $_lesson_answers ); |
|
| 1193 | + unset($_lesson_answers); |
|
| 1194 | 1194 | |
| 1195 | 1195 | // Grab all the lesson starts for the user |
| 1196 | - $lesson_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A ); |
|
| 1197 | - foreach ( $lesson_starts as $lesson_log ) { |
|
| 1196 | + $lesson_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A); |
|
| 1197 | + foreach ($lesson_starts as $lesson_log) { |
|
| 1198 | 1198 | |
| 1199 | 1199 | $lesson_id = $lesson_log['comment_post_ID']; |
| 1200 | 1200 | |
@@ -1207,23 +1207,23 @@ discard block |
||
| 1207 | 1207 | 'start' => $status_date, |
| 1208 | 1208 | ); |
| 1209 | 1209 | // Check if there is a lesson end |
| 1210 | - if ( !empty($lesson_ends[$lesson_id]) ) { |
|
| 1210 | + if ( ! empty($lesson_ends[$lesson_id])) { |
|
| 1211 | 1211 | $status_date = $lesson_ends[$lesson_id]; |
| 1212 | 1212 | // Check lesson has quiz |
| 1213 | - if ( !empty( $lesson_quiz_ids[$lesson_id] ) ) { |
|
| 1213 | + if ( ! empty($lesson_quiz_ids[$lesson_id])) { |
|
| 1214 | 1214 | // Check for the quiz answers |
| 1215 | - if ( !empty($lesson_answers[$quiz_id]) ) { |
|
| 1215 | + if ( ! empty($lesson_answers[$quiz_id])) { |
|
| 1216 | 1216 | $meta_data['questions_asked'] = $lesson_answers[$quiz_id]; |
| 1217 | 1217 | } |
| 1218 | 1218 | // Check if there is a quiz grade |
| 1219 | 1219 | $quiz_id = $lesson_quiz_ids[$lesson_id]; |
| 1220 | - if ( !empty($lesson_grades[$quiz_id]) ) { |
|
| 1220 | + if ( ! empty($lesson_grades[$quiz_id])) { |
|
| 1221 | 1221 | $meta_data['grade'] = $quiz_grade = $lesson_grades[$quiz_id]; |
| 1222 | 1222 | // Check if the user has to get the passmark and has or not |
| 1223 | - if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) { |
|
| 1223 | + if ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] <= $quiz_grade) { |
|
| 1224 | 1224 | $status = 'passed'; |
| 1225 | 1225 | } |
| 1226 | - elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) { |
|
| 1226 | + elseif ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] > $quiz_grade) { |
|
| 1227 | 1227 | $status = 'failed'; |
| 1228 | 1228 | } |
| 1229 | 1229 | else { |
@@ -1251,26 +1251,26 @@ discard block |
||
| 1251 | 1251 | 'comment_author' => '', |
| 1252 | 1252 | ); |
| 1253 | 1253 | // Check it doesn't already exist |
| 1254 | - $sql = $wpdb->prepare( $check_existing_sql, $lesson_id, $user_id ); |
|
| 1255 | - $comment_ID = $wpdb->get_var( $sql ); |
|
| 1256 | - if ( !$comment_ID ) { |
|
| 1254 | + $sql = $wpdb->prepare($check_existing_sql, $lesson_id, $user_id); |
|
| 1255 | + $comment_ID = $wpdb->get_var($sql); |
|
| 1256 | + if ( ! $comment_ID) { |
|
| 1257 | 1257 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
| 1258 | 1258 | $wpdb->insert($wpdb->comments, $data); |
| 1259 | 1259 | $comment_ID = (int) $wpdb->insert_id; |
| 1260 | 1260 | |
| 1261 | - if ( $comment_ID && !empty($meta_data) ) { |
|
| 1262 | - foreach ( $meta_data as $key => $value ) { |
|
| 1261 | + if ($comment_ID && ! empty($meta_data)) { |
|
| 1262 | + foreach ($meta_data as $key => $value) { |
|
| 1263 | 1263 | // Bypassing WP add_comment_meta(() so no actions/filters are run |
| 1264 | - if ( $wpdb->get_var( $wpdb->prepare( |
|
| 1264 | + if ($wpdb->get_var($wpdb->prepare( |
|
| 1265 | 1265 | "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ", |
| 1266 | - $comment_ID, $key ) ) ) { |
|
| 1266 | + $comment_ID, $key ))) { |
|
| 1267 | 1267 | continue; // Found the meta data already |
| 1268 | 1268 | } |
| 1269 | - $result = $wpdb->insert( $wpdb->commentmeta, array( |
|
| 1269 | + $result = $wpdb->insert($wpdb->commentmeta, array( |
|
| 1270 | 1270 | 'comment_id' => $comment_ID, |
| 1271 | 1271 | 'meta_key' => $key, |
| 1272 | 1272 | 'meta_value' => $value |
| 1273 | - ) ); |
|
| 1273 | + )); |
|
| 1274 | 1274 | } |
| 1275 | 1275 | } |
| 1276 | 1276 | } |
@@ -1278,40 +1278,40 @@ discard block |
||
| 1278 | 1278 | } |
| 1279 | 1279 | $wpdb->flush(); |
| 1280 | 1280 | |
| 1281 | - if ( $current_page == $total_pages ) { |
|
| 1281 | + if ($current_page == $total_pages) { |
|
| 1282 | 1282 | return true; |
| 1283 | 1283 | } else { |
| 1284 | 1284 | return false; |
| 1285 | 1285 | } |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | - function status_changes_convert_courses( $n = 50, $offset = 0 ) { |
|
| 1288 | + function status_changes_convert_courses($n = 50, $offset = 0) { |
|
| 1289 | 1289 | global $wpdb; |
| 1290 | 1290 | |
| 1291 | - wp_defer_comment_counting( true ); |
|
| 1291 | + wp_defer_comment_counting(true); |
|
| 1292 | 1292 | |
| 1293 | - $user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " ); |
|
| 1293 | + $user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users "); |
|
| 1294 | 1294 | |
| 1295 | - if ( 0 == $user_count_result ) { |
|
| 1295 | + if (0 == $user_count_result) { |
|
| 1296 | 1296 | return true; |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | - if ( 0 == $offset ) { |
|
| 1299 | + if (0 == $offset) { |
|
| 1300 | 1300 | $current_page = 1; |
| 1301 | 1301 | } else { |
| 1302 | - $current_page = intval( $offset / $n ); |
|
| 1302 | + $current_page = intval($offset / $n); |
|
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | - $total_pages = ceil( $user_count_result / $n ); |
|
| 1305 | + $total_pages = ceil($user_count_result / $n); |
|
| 1306 | 1306 | |
| 1307 | 1307 | // Get all Lesson => Course relationships |
| 1308 | - $meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A ); |
|
| 1308 | + $meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A); |
|
| 1309 | 1309 | $course_lesson_ids = array(); |
| 1310 | - if ( !empty($meta_list) ) { |
|
| 1311 | - foreach ( $meta_list as $metarow ) { |
|
| 1310 | + if ( ! empty($meta_list)) { |
|
| 1311 | + foreach ($meta_list as $metarow) { |
|
| 1312 | 1312 | $lesson_id = $metarow['post_id']; |
| 1313 | 1313 | $course_id = $metarow['meta_value']; |
| 1314 | - $course_lesson_ids[ $course_id ][] = $lesson_id; |
|
| 1314 | + $course_lesson_ids[$course_id][] = $lesson_id; |
|
| 1315 | 1315 | } |
| 1316 | 1316 | } |
| 1317 | 1317 | |
@@ -1321,13 +1321,13 @@ discard block |
||
| 1321 | 1321 | $check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_course_status' "; |
| 1322 | 1322 | |
| 1323 | 1323 | // $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time? |
| 1324 | - $user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) ); |
|
| 1324 | + $user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset)); |
|
| 1325 | 1325 | |
| 1326 | - foreach ( $user_ids AS $user_id ) { |
|
| 1326 | + foreach ($user_ids AS $user_id) { |
|
| 1327 | 1327 | |
| 1328 | 1328 | // Grab all the course starts for the user |
| 1329 | - $course_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A ); |
|
| 1330 | - foreach ( $course_starts as $course_log ) { |
|
| 1329 | + $course_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A); |
|
| 1330 | + foreach ($course_starts as $course_log) { |
|
| 1331 | 1331 | |
| 1332 | 1332 | $course_id = $course_log['comment_post_ID']; |
| 1333 | 1333 | |
@@ -1342,23 +1342,23 @@ discard block |
||
| 1342 | 1342 | 'percent' => 0, |
| 1343 | 1343 | ); |
| 1344 | 1344 | // Check if the course has lessons |
| 1345 | - if ( !empty( $course_lesson_ids[$course_id] ) ) { |
|
| 1345 | + if ( ! empty($course_lesson_ids[$course_id])) { |
|
| 1346 | 1346 | |
| 1347 | 1347 | $lessons_completed = 0; |
| 1348 | - $total_lessons = count( $course_lesson_ids[ $course_id ] ); |
|
| 1348 | + $total_lessons = count($course_lesson_ids[$course_id]); |
|
| 1349 | 1349 | |
| 1350 | 1350 | // Don't use prepare as we need to provide the id join |
| 1351 | - $sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[ $course_id ]) ); |
|
| 1351 | + $sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[$course_id])); |
|
| 1352 | 1352 | // Get all lesson statuses for this Courses' lessons |
| 1353 | - $lesson_statuses = $wpdb->get_results( $sql, ARRAY_A ); |
|
| 1353 | + $lesson_statuses = $wpdb->get_results($sql, ARRAY_A); |
|
| 1354 | 1354 | // Not enough lesson statuses, thus cannot be complete |
| 1355 | - if ( $total_lessons > count($lesson_statuses) ) { |
|
| 1355 | + if ($total_lessons > count($lesson_statuses)) { |
|
| 1356 | 1356 | $status = 'in-progress'; |
| 1357 | 1357 | } |
| 1358 | 1358 | // Count each lesson to work out the overall percentage |
| 1359 | - foreach ( $lesson_statuses as $lesson_status ) { |
|
| 1359 | + foreach ($lesson_statuses as $lesson_status) { |
|
| 1360 | 1360 | $status_date = $lesson_status['comment_date']; |
| 1361 | - switch ( $lesson_status['status'] ) { |
|
| 1361 | + switch ($lesson_status['status']) { |
|
| 1362 | 1362 | case 'complete': // Lesson has no quiz/questions |
| 1363 | 1363 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
| 1364 | 1364 | case 'passed': |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | } |
| 1374 | 1374 | } |
| 1375 | 1375 | $meta_data['complete'] = $lessons_completed; |
| 1376 | - $meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ); |
|
| 1376 | + $meta_data['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)); |
|
| 1377 | 1377 | } |
| 1378 | 1378 | else { |
| 1379 | 1379 | // Course has no lessons, therefore cannot be 'complete' |
@@ -1390,26 +1390,26 @@ discard block |
||
| 1390 | 1390 | 'comment_author' => '', |
| 1391 | 1391 | ); |
| 1392 | 1392 | // Check it doesn't already exist |
| 1393 | - $sql = $wpdb->prepare( $check_existing_sql, $course_id, $user_id ); |
|
| 1394 | - $comment_ID = $wpdb->get_var( $sql ); |
|
| 1395 | - if ( !$comment_ID ) { |
|
| 1393 | + $sql = $wpdb->prepare($check_existing_sql, $course_id, $user_id); |
|
| 1394 | + $comment_ID = $wpdb->get_var($sql); |
|
| 1395 | + if ( ! $comment_ID) { |
|
| 1396 | 1396 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
| 1397 | 1397 | $wpdb->insert($wpdb->comments, $data); |
| 1398 | 1398 | $comment_ID = (int) $wpdb->insert_id; |
| 1399 | 1399 | |
| 1400 | - if ( $comment_ID && !empty($meta_data) ) { |
|
| 1401 | - foreach ( $meta_data as $key => $value ) { |
|
| 1400 | + if ($comment_ID && ! empty($meta_data)) { |
|
| 1401 | + foreach ($meta_data as $key => $value) { |
|
| 1402 | 1402 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
| 1403 | - if ( $wpdb->get_var( $wpdb->prepare( |
|
| 1403 | + if ($wpdb->get_var($wpdb->prepare( |
|
| 1404 | 1404 | "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ", |
| 1405 | - $comment_ID, $key ) ) ) { |
|
| 1405 | + $comment_ID, $key ))) { |
|
| 1406 | 1406 | continue; // Found the meta data already |
| 1407 | 1407 | } |
| 1408 | - $result = $wpdb->insert( $wpdb->commentmeta, array( |
|
| 1408 | + $result = $wpdb->insert($wpdb->commentmeta, array( |
|
| 1409 | 1409 | 'comment_id' => $comment_ID, |
| 1410 | 1410 | 'meta_key' => $key, |
| 1411 | 1411 | 'meta_value' => $value |
| 1412 | - ) ); |
|
| 1412 | + )); |
|
| 1413 | 1413 | } |
| 1414 | 1414 | } |
| 1415 | 1415 | } |
@@ -1417,7 +1417,7 @@ discard block |
||
| 1417 | 1417 | } |
| 1418 | 1418 | $wpdb->flush(); |
| 1419 | 1419 | |
| 1420 | - if ( $current_page == $total_pages ) { |
|
| 1420 | + if ($current_page == $total_pages) { |
|
| 1421 | 1421 | return true; |
| 1422 | 1422 | } else { |
| 1423 | 1423 | return false; |
@@ -1433,70 +1433,70 @@ discard block |
||
| 1433 | 1433 | * @param type $offset |
| 1434 | 1434 | * @return boolean |
| 1435 | 1435 | */ |
| 1436 | - function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) { |
|
| 1436 | + function status_changes_repair_course_statuses($n = 50, $offset = 0) { |
|
| 1437 | 1437 | global $wpdb; |
| 1438 | 1438 | |
| 1439 | - $count_object = wp_count_posts( 'lesson' ); |
|
| 1439 | + $count_object = wp_count_posts('lesson'); |
|
| 1440 | 1440 | $count_published = $count_object->publish; |
| 1441 | 1441 | |
| 1442 | - if ( 0 == $count_published ) { |
|
| 1442 | + if (0 == $count_published) { |
|
| 1443 | 1443 | return true; |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | // Calculate if this is the last page |
| 1447 | - if ( 0 == $offset ) { |
|
| 1447 | + if (0 == $offset) { |
|
| 1448 | 1448 | $current_page = 1; |
| 1449 | 1449 | } else { |
| 1450 | - $current_page = intval( $offset / $n ); |
|
| 1450 | + $current_page = intval($offset / $n); |
|
| 1451 | 1451 | } |
| 1452 | - $total_pages = ceil( $count_published / $n ); |
|
| 1452 | + $total_pages = ceil($count_published / $n); |
|
| 1453 | 1453 | |
| 1454 | 1454 | $course_lesson_ids = $lesson_user_statuses = array(); |
| 1455 | 1455 | |
| 1456 | 1456 | // Get all Lesson => Course relationships |
| 1457 | - $meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A ); |
|
| 1458 | - if ( !empty($meta_list) ) { |
|
| 1459 | - foreach ( $meta_list as $metarow ) { |
|
| 1457 | + $meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A); |
|
| 1458 | + if ( ! empty($meta_list)) { |
|
| 1459 | + foreach ($meta_list as $metarow) { |
|
| 1460 | 1460 | $lesson_id = $metarow['post_id']; |
| 1461 | 1461 | $course_id = $metarow['meta_value']; |
| 1462 | - $course_lesson_ids[ $course_id ][] = $lesson_id; |
|
| 1462 | + $course_lesson_ids[$course_id][] = $lesson_id; |
|
| 1463 | 1463 | } |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | // Get all Lesson => Course relationships |
| 1467 | - $status_list = $wpdb->get_results( "SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A ); |
|
| 1468 | - if ( !empty($status_list) ) { |
|
| 1469 | - foreach ( $status_list as $status ) { |
|
| 1470 | - $lesson_user_statuses[ $status['comment_post_ID'] ][ $status['user_id'] ] = $status['comment_approved']; |
|
| 1467 | + $status_list = $wpdb->get_results("SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A); |
|
| 1468 | + if ( ! empty($status_list)) { |
|
| 1469 | + foreach ($status_list as $status) { |
|
| 1470 | + $lesson_user_statuses[$status['comment_post_ID']][$status['user_id']] = $status['comment_approved']; |
|
| 1471 | 1471 | } |
| 1472 | 1472 | } |
| 1473 | 1473 | |
| 1474 | - $course_completion = Sensei()->settings->settings[ 'course_completion' ]; |
|
| 1474 | + $course_completion = Sensei()->settings->settings['course_completion']; |
|
| 1475 | 1475 | |
| 1476 | 1476 | $per_page = 40; |
| 1477 | 1477 | $comment_id_offset = $count = 0; |
| 1478 | 1478 | |
| 1479 | 1479 | $course_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_course_status' AND comment_ID > %d LIMIT $per_page"; |
| 1480 | 1480 | // $per_page users at a time |
| 1481 | - while ( $course_statuses = $wpdb->get_results( $wpdb->prepare($course_sql, $comment_id_offset) ) ) { |
|
| 1481 | + while ($course_statuses = $wpdb->get_results($wpdb->prepare($course_sql, $comment_id_offset))) { |
|
| 1482 | 1482 | |
| 1483 | - foreach ( $course_statuses AS $course_status ) { |
|
| 1483 | + foreach ($course_statuses AS $course_status) { |
|
| 1484 | 1484 | $user_id = $course_status->user_id; |
| 1485 | 1485 | $course_id = $course_status->comment_post_ID; |
| 1486 | - $total_lessons = count( $course_lesson_ids[ $course_id ] ); |
|
| 1487 | - if ( $total_lessons <= 0 ) { |
|
| 1486 | + $total_lessons = count($course_lesson_ids[$course_id]); |
|
| 1487 | + if ($total_lessons <= 0) { |
|
| 1488 | 1488 | $total_lessons = 1; // Fix division of zero error, some courses have no lessons |
| 1489 | 1489 | } |
| 1490 | 1490 | $lessons_completed = 0; |
| 1491 | 1491 | $status = 'in-progress'; |
| 1492 | 1492 | |
| 1493 | 1493 | // Some Courses have no lessons... (can they ever be complete?) |
| 1494 | - if ( !empty($course_lesson_ids[ $course_id ]) ) { |
|
| 1495 | - foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) { |
|
| 1496 | - $lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ]; |
|
| 1494 | + if ( ! empty($course_lesson_ids[$course_id])) { |
|
| 1495 | + foreach ($course_lesson_ids[$course_id] AS $lesson_id) { |
|
| 1496 | + $lesson_status = $lesson_user_statuses[$lesson_id][$user_id]; |
|
| 1497 | 1497 | // If lessons are complete without needing quizzes to be passed |
| 1498 | - if ( 'passed' != $course_completion ) { |
|
| 1499 | - switch ( $lesson_status ) { |
|
| 1498 | + if ('passed' != $course_completion) { |
|
| 1499 | + switch ($lesson_status) { |
|
| 1500 | 1500 | // A user cannot 'complete' a course if a lesson... |
| 1501 | 1501 | case 'in-progress': // ...is still in progress |
| 1502 | 1502 | case 'ungraded': // ...hasn't yet been graded |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | } |
| 1509 | 1509 | } |
| 1510 | 1510 | else { |
| 1511 | - switch ( $lesson_status ) { |
|
| 1511 | + switch ($lesson_status) { |
|
| 1512 | 1512 | case 'complete': // Lesson has no quiz/questions |
| 1513 | 1513 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
| 1514 | 1514 | case 'passed': // Lesson has quiz and the user passed |
@@ -1523,79 +1523,79 @@ discard block |
||
| 1523 | 1523 | } |
| 1524 | 1524 | } // Each lesson |
| 1525 | 1525 | } // Check for lessons |
| 1526 | - if ( $lessons_completed == $total_lessons ) { |
|
| 1526 | + if ($lessons_completed == $total_lessons) { |
|
| 1527 | 1527 | $status = 'complete'; |
| 1528 | 1528 | } |
| 1529 | 1529 | // update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above |
| 1530 | 1530 | $metadata = array( |
| 1531 | 1531 | 'complete' => $lessons_completed, |
| 1532 | - 'percent' => abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ), |
|
| 1532 | + 'percent' => abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)), |
|
| 1533 | 1533 | ); |
| 1534 | - Sensei_Utils::update_course_status( $user_id, $course_id, $status, $metadata ); |
|
| 1534 | + Sensei_Utils::update_course_status($user_id, $course_id, $status, $metadata); |
|
| 1535 | 1535 | $count++; |
| 1536 | 1536 | |
| 1537 | 1537 | } // per course status |
| 1538 | 1538 | $comment_id_offset = $course_status->comment_ID; |
| 1539 | 1539 | } // all course statuses |
| 1540 | 1540 | |
| 1541 | - if ( $current_page == $total_pages ) { |
|
| 1541 | + if ($current_page == $total_pages) { |
|
| 1542 | 1542 | return true; |
| 1543 | 1543 | } else { |
| 1544 | 1544 | return false; |
| 1545 | 1545 | } |
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | - function status_changes_convert_questions( $n = 50, $offset = 0 ) { |
|
| 1548 | + function status_changes_convert_questions($n = 50, $offset = 0) { |
|
| 1549 | 1549 | global $wpdb; |
| 1550 | 1550 | |
| 1551 | - wp_defer_comment_counting( true ); |
|
| 1551 | + wp_defer_comment_counting(true); |
|
| 1552 | 1552 | |
| 1553 | - $user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " ); |
|
| 1553 | + $user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users "); |
|
| 1554 | 1554 | |
| 1555 | - if ( 0 == $user_count_result ) { |
|
| 1555 | + if (0 == $user_count_result) { |
|
| 1556 | 1556 | return true; |
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | // Calculate if this is the last page |
| 1560 | - if ( 0 == $offset ) { |
|
| 1560 | + if (0 == $offset) { |
|
| 1561 | 1561 | $current_page = 1; |
| 1562 | 1562 | } else { |
| 1563 | - $current_page = intval( $offset / $n ); |
|
| 1563 | + $current_page = intval($offset / $n); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | - $total_pages = ceil( $user_count_result / $n ); |
|
| 1566 | + $total_pages = ceil($user_count_result / $n); |
|
| 1567 | 1567 | |
| 1568 | 1568 | $users_sql = "SELECT ID FROM $wpdb->users ORDER BY ID ASC LIMIT %d OFFSET %d"; |
| 1569 | 1569 | $answers_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID "; |
| 1570 | 1570 | $grades_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_user_grade' AND user_id = %d GROUP BY comment_post_ID "; |
| 1571 | 1571 | $notes_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_answer_notes' AND user_id = %d GROUP BY comment_post_ID "; |
| 1572 | 1572 | |
| 1573 | - $user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) ); |
|
| 1573 | + $user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset)); |
|
| 1574 | 1574 | |
| 1575 | - foreach ( $user_ids AS $user_id ) { |
|
| 1575 | + foreach ($user_ids AS $user_id) { |
|
| 1576 | 1576 | |
| 1577 | 1577 | $answer_grades = $answer_notes = array(); |
| 1578 | 1578 | |
| 1579 | 1579 | // Pre-process the answer grades |
| 1580 | - $_answer_grades = $wpdb->get_results( $wpdb->prepare($grades_sql, $user_id), ARRAY_A ); |
|
| 1581 | - foreach ( $_answer_grades as $answer_grade ) { |
|
| 1580 | + $_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A); |
|
| 1581 | + foreach ($_answer_grades as $answer_grade) { |
|
| 1582 | 1582 | // This will overwrite existing entries with the newer ones |
| 1583 | - $answer_grades[ $answer_grade['comment_post_ID'] ] = $answer_grade['comment_content']; |
|
| 1583 | + $answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content']; |
|
| 1584 | 1584 | } |
| 1585 | - unset( $_answer_grades ); |
|
| 1585 | + unset($_answer_grades); |
|
| 1586 | 1586 | |
| 1587 | 1587 | // Pre-process the answer notes |
| 1588 | - $_answer_notes = $wpdb->get_results( $wpdb->prepare($notes_sql, $user_id), ARRAY_A ); |
|
| 1589 | - foreach ( $_answer_notes as $answer_note ) { |
|
| 1588 | + $_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A); |
|
| 1589 | + foreach ($_answer_notes as $answer_note) { |
|
| 1590 | 1590 | // This will overwrite existing entries with the newer ones |
| 1591 | - $answer_notes[ $answer_note['comment_post_ID'] ] = $answer_note['comment_content']; |
|
| 1591 | + $answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content']; |
|
| 1592 | 1592 | } |
| 1593 | - unset( $_answer_notes ); |
|
| 1593 | + unset($_answer_notes); |
|
| 1594 | 1594 | |
| 1595 | 1595 | // Grab all the questions for the user |
| 1596 | 1596 | $sql = $wpdb->prepare($answers_sql, $user_id); |
| 1597 | - $answers = $wpdb->get_results( $sql, ARRAY_A ); |
|
| 1598 | - foreach ( $answers as $answer ) { |
|
| 1597 | + $answers = $wpdb->get_results($sql, ARRAY_A); |
|
| 1598 | + foreach ($answers as $answer) { |
|
| 1599 | 1599 | |
| 1600 | 1600 | // Excape data |
| 1601 | 1601 | $answer = wp_slash($answer); |
@@ -1605,12 +1605,12 @@ discard block |
||
| 1605 | 1605 | $meta_data = array(); |
| 1606 | 1606 | |
| 1607 | 1607 | // Check if the question has been graded, add as meta |
| 1608 | - if ( !empty($answer_grades[ $answer['comment_post_ID'] ]) ) { |
|
| 1609 | - $meta_data['user_grade'] = $answer_grades[ $answer['comment_post_ID'] ]; |
|
| 1608 | + if ( ! empty($answer_grades[$answer['comment_post_ID']])) { |
|
| 1609 | + $meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']]; |
|
| 1610 | 1610 | } |
| 1611 | 1611 | // Check if there is an answer note, add as meta |
| 1612 | - if ( !empty($answer_notes[ $answer['comment_post_ID'] ]) ) { |
|
| 1613 | - $meta_data['answer_note'] = $answer_notes[ $answer['comment_post_ID'] ]; |
|
| 1612 | + if ( ! empty($answer_notes[$answer['comment_post_ID']])) { |
|
| 1613 | + $meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']]; |
|
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | 1616 | // Wipe the unnessary data from the main comment |
@@ -1623,21 +1623,21 @@ discard block |
||
| 1623 | 1623 | ); |
| 1624 | 1624 | $data = array_merge($answer, $data); |
| 1625 | 1625 | |
| 1626 | - $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); |
|
| 1627 | - if ( $rval ) { |
|
| 1628 | - if ( !empty($meta_data) ) { |
|
| 1629 | - foreach ( $meta_data as $key => $value ) { |
|
| 1626 | + $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID')); |
|
| 1627 | + if ($rval) { |
|
| 1628 | + if ( ! empty($meta_data)) { |
|
| 1629 | + foreach ($meta_data as $key => $value) { |
|
| 1630 | 1630 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
| 1631 | - if ( $wpdb->get_var( $wpdb->prepare( |
|
| 1631 | + if ($wpdb->get_var($wpdb->prepare( |
|
| 1632 | 1632 | "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ", |
| 1633 | - $comment_ID, $key ) ) ) { |
|
| 1633 | + $comment_ID, $key ))) { |
|
| 1634 | 1634 | continue; // Found the meta data already |
| 1635 | 1635 | } |
| 1636 | - $result = $wpdb->insert( $wpdb->commentmeta, array( |
|
| 1636 | + $result = $wpdb->insert($wpdb->commentmeta, array( |
|
| 1637 | 1637 | 'comment_id' => $comment_ID, |
| 1638 | 1638 | 'meta_key' => $key, |
| 1639 | 1639 | 'meta_value' => $value |
| 1640 | - ) ); |
|
| 1640 | + )); |
|
| 1641 | 1641 | } |
| 1642 | 1642 | } |
| 1643 | 1643 | } |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | } |
| 1646 | 1646 | $wpdb->flush(); |
| 1647 | 1647 | |
| 1648 | - if ( $current_page == $total_pages ) { |
|
| 1648 | + if ($current_page == $total_pages) { |
|
| 1649 | 1649 | return true; |
| 1650 | 1650 | } else { |
| 1651 | 1651 | return false; |
@@ -1662,10 +1662,10 @@ discard block |
||
| 1662 | 1662 | global $wpdb; |
| 1663 | 1663 | |
| 1664 | 1664 | // Update 'sensei_user_answer' entries to use comment_approved = 'log' so they don't appear in counts |
| 1665 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' " ); |
|
| 1665 | + $wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' "); |
|
| 1666 | 1666 | |
| 1667 | 1667 | // Mark all old Sensei comment types with comment_approved = 'legacy' so they no longer appear in counts, but can be restored if required |
| 1668 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') " ); |
|
| 1668 | + $wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') "); |
|
| 1669 | 1669 | |
| 1670 | 1670 | return true; |
| 1671 | 1671 | } |
@@ -1678,50 +1678,50 @@ discard block |
||
| 1678 | 1678 | * @param type $offset |
| 1679 | 1679 | * @return boolean |
| 1680 | 1680 | */ |
| 1681 | - public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) { |
|
| 1681 | + public function update_comment_course_lesson_comment_counts($n = 50, $offset = 0) { |
|
| 1682 | 1682 | global $wpdb; |
| 1683 | 1683 | |
| 1684 | - $item_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') " ); |
|
| 1684 | + $item_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') "); |
|
| 1685 | 1685 | |
| 1686 | - if ( 0 == $item_count_result ) { |
|
| 1686 | + if (0 == $item_count_result) { |
|
| 1687 | 1687 | return true; |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | // Calculate if this is the last page |
| 1691 | - if ( 0 == $offset ) { |
|
| 1691 | + if (0 == $offset) { |
|
| 1692 | 1692 | $current_page = 1; |
| 1693 | 1693 | } else { |
| 1694 | - $current_page = intval( $offset / $n ); |
|
| 1694 | + $current_page = intval($offset / $n); |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | - $total_pages = ceil( $item_count_result / $n ); |
|
| 1697 | + $total_pages = ceil($item_count_result / $n); |
|
| 1698 | 1698 | |
| 1699 | 1699 | // Recalculate all counts |
| 1700 | - $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset ) ); |
|
| 1701 | - foreach ( (array) $items as $post ) { |
|
| 1700 | + $items = $wpdb->get_results($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset)); |
|
| 1701 | + foreach ((array) $items as $post) { |
|
| 1702 | 1702 | // Code copied from wp_update_comment_count_now() |
| 1703 | - $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID) ); |
|
| 1704 | - $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID) ); |
|
| 1703 | + $new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID)); |
|
| 1704 | + $wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID)); |
|
| 1705 | 1705 | |
| 1706 | - clean_post_cache( $post->ID ); |
|
| 1706 | + clean_post_cache($post->ID); |
|
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | - if ( $current_page == $total_pages ) { |
|
| 1709 | + if ($current_page == $total_pages) { |
|
| 1710 | 1710 | return true; |
| 1711 | 1711 | } else { |
| 1712 | 1712 | return false; |
| 1713 | 1713 | } |
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | - public function remove_legacy_comments () { |
|
| 1716 | + public function remove_legacy_comments() { |
|
| 1717 | 1717 | global $wpdb; |
| 1718 | 1718 | |
| 1719 | - $result = $wpdb->delete( $wpdb->comments, array( 'comment_approved' => 'legacy' ) ); |
|
| 1719 | + $result = $wpdb->delete($wpdb->comments, array('comment_approved' => 'legacy')); |
|
| 1720 | 1720 | |
| 1721 | 1721 | return true; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | - public function index_comment_status_field () { |
|
| 1724 | + public function index_comment_status_field() { |
|
| 1725 | 1725 | global $wpdb; |
| 1726 | 1726 | |
| 1727 | 1727 | $wpdb->query("ALTER TABLE `$wpdb->comments` ADD INDEX `comment_type` ( `comment_type` )"); |
@@ -1740,7 +1740,7 @@ discard block |
||
| 1740 | 1740 | * @since 1.8.0 |
| 1741 | 1741 | * @return bool; |
| 1742 | 1742 | */ |
| 1743 | - public function enhance_teacher_role ( ) { |
|
| 1743 | + public function enhance_teacher_role( ) { |
|
| 1744 | 1744 | |
| 1745 | 1745 | require_once('class-sensei-teacher.php'); |
| 1746 | 1746 | $teacher = new Sensei_Teacher(); |
@@ -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 Settings Class |
@@ -20,18 +20,18 @@ discard block |
||
| 20 | 20 | * @since 1.0.0 |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - public function __construct () { |
|
| 23 | + public function __construct() { |
|
| 24 | 24 | parent::__construct(); // Required in extended classes. |
| 25 | 25 | |
| 26 | 26 | $this->token = 'woothemes-sensei-settings'; |
| 27 | - add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 27 | + add_action('init', array(__CLASS__, 'flush_rewrite_rules')); |
|
| 28 | 28 | |
| 29 | 29 | // Setup Admin Settings data |
| 30 | - if ( is_admin() ) { |
|
| 30 | + if (is_admin()) { |
|
| 31 | 31 | |
| 32 | 32 | $this->has_tabs = true; |
| 33 | - $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
|
| 34 | - $this->menu_label = __( 'Settings', 'woothemes-sensei' ); |
|
| 33 | + $this->name = __('Sensei Settings', 'woothemes-sensei'); |
|
| 34 | + $this->menu_label = __('Settings', 'woothemes-sensei'); |
|
| 35 | 35 | $this->page_slug = 'woothemes-sensei-settings'; |
| 36 | 36 | |
| 37 | 37 | } // End If Statement |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | * @param string $setting_name |
| 49 | 49 | * @return mixed |
| 50 | 50 | */ |
| 51 | - public function get( $setting_name ){ |
|
| 51 | + public function get($setting_name) { |
|
| 52 | 52 | |
| 53 | - if( isset( $this->settings[ $setting_name ] ) ){ |
|
| 53 | + if (isset($this->settings[$setting_name])) { |
|
| 54 | 54 | |
| 55 | - return $this->settings[ $setting_name ]; |
|
| 55 | + return $this->settings[$setting_name]; |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | * @since 1.0.0 |
| 66 | 66 | * @return void |
| 67 | 67 | */ |
| 68 | - public function register_settings_screen () { |
|
| 68 | + public function register_settings_screen() { |
|
| 69 | 69 | |
| 70 | 70 | $this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen. |
| 71 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
|
| 71 | + $hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); |
|
| 72 | 72 | $this->hook = $hook; |
| 73 | 73 | |
| 74 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 75 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
|
| 76 | - add_action( 'admin_notices', array( $this, 'language_pack_notices' ) ); |
|
| 77 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 78 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 74 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 75 | + add_action('admin_notices', array($this, 'settings_errors')); |
|
| 76 | + add_action('admin_notices', array($this, 'language_pack_notices')); |
|
| 77 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 78 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 79 | 79 | } |
| 80 | 80 | } // End register_settings_screen() |
| 81 | 81 | |
@@ -85,49 +85,49 @@ discard block |
||
| 85 | 85 | * @since 1.0.0 |
| 86 | 86 | * @return void |
| 87 | 87 | */ |
| 88 | - public function init_sections () { |
|
| 88 | + public function init_sections() { |
|
| 89 | 89 | $sections = array(); |
| 90 | 90 | |
| 91 | 91 | $sections['default-settings'] = array( |
| 92 | - 'name' => __( 'General', 'woothemes-sensei' ), |
|
| 93 | - 'description' => __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' ) |
|
| 92 | + 'name' => __('General', 'woothemes-sensei'), |
|
| 93 | + 'description' => __('Settings that apply to the entire plugin.', 'woothemes-sensei') |
|
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | $sections['course-settings'] = array( |
| 97 | - 'name' => __( 'Courses', 'woothemes-sensei' ), |
|
| 98 | - 'description' => __( 'Settings that apply to all Courses.', 'woothemes-sensei' ) |
|
| 97 | + 'name' => __('Courses', 'woothemes-sensei'), |
|
| 98 | + 'description' => __('Settings that apply to all Courses.', 'woothemes-sensei') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | $sections['lesson-settings'] = array( |
| 102 | - 'name' => __( 'Lessons', 'woothemes-sensei' ), |
|
| 103 | - 'description' => __( 'Settings that apply to all Lessons.', 'woothemes-sensei' ) |
|
| 102 | + 'name' => __('Lessons', 'woothemes-sensei'), |
|
| 103 | + 'description' => __('Settings that apply to all Lessons.', 'woothemes-sensei') |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | $sections['email-notification-settings'] = array( |
| 107 | - 'name' => __( 'Email Notifications', 'woothemes-sensei' ), |
|
| 108 | - 'description' => __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' ) |
|
| 107 | + 'name' => __('Email Notifications', 'woothemes-sensei'), |
|
| 108 | + 'description' => __('Settings for email notifications sent from your site.', 'woothemes-sensei') |
|
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | 111 | $sections['learner-profile-settings'] = array( |
| 112 | - 'name' => __( 'Learner Profiles', 'woothemes-sensei' ), |
|
| 113 | - 'description' => __( 'Settings for public Learner Profiles.', 'woothemes-sensei' ) |
|
| 112 | + 'name' => __('Learner Profiles', 'woothemes-sensei'), |
|
| 113 | + 'description' => __('Settings for public Learner Profiles.', 'woothemes-sensei') |
|
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | - if ( Sensei_WC::is_woocommerce_present() ) { |
|
| 116 | + if (Sensei_WC::is_woocommerce_present()) { |
|
| 117 | 117 | $sections['woocommerce-settings'] = array( |
| 118 | - 'name' => __( 'WooCommerce', 'woothemes-sensei' ), |
|
| 119 | - 'description' => __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' ) |
|
| 118 | + 'name' => __('WooCommerce', 'woothemes-sensei'), |
|
| 119 | + 'description' => __('Optional settings for WooCommerce functions.', 'woothemes-sensei') |
|
| 120 | 120 | ); |
| 121 | 121 | } // End If Statement |
| 122 | 122 | |
| 123 | - if ( 'en_US' !== get_locale() ) { |
|
| 123 | + if ('en_US' !== get_locale()) { |
|
| 124 | 124 | $sections['language-settings'] = array( |
| 125 | - 'name' => __( 'Language', 'woothemes-sensei' ), |
|
| 126 | - 'description' => __( 'Language options.', 'woothemes-sensei' ) |
|
| 125 | + 'name' => __('Language', 'woothemes-sensei'), |
|
| 126 | + 'description' => __('Language options.', 'woothemes-sensei') |
|
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $this->sections = apply_filters( 'sensei_settings_tabs', $sections ); |
|
| 130 | + $this->sections = apply_filters('sensei_settings_tabs', $sections); |
|
| 131 | 131 | } // End init_sections() |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -137,71 +137,71 @@ discard block |
||
| 137 | 137 | * @uses Sensei_Utils::get_slider_types() |
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | - public function init_fields () { |
|
| 140 | + public function init_fields() { |
|
| 141 | 141 | global $pagenow; |
| 142 | 142 | |
| 143 | 143 | $pages_array = $this->pages_array(); |
| 144 | - $posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' ); |
|
| 145 | - $complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) ); |
|
| 146 | - $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
|
| 144 | + $posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20'); |
|
| 145 | + $complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei')); |
|
| 146 | + $course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei')); |
|
| 147 | 147 | |
| 148 | 148 | $fields = array(); |
| 149 | 149 | |
| 150 | 150 | $fields['access_permission'] = array( |
| 151 | - 'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
|
| 152 | - 'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ), |
|
| 151 | + 'name' => __('Access Permissions', 'woothemes-sensei'), |
|
| 152 | + 'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'), |
|
| 153 | 153 | 'type' => 'checkbox', |
| 154 | 154 | 'default' => true, |
| 155 | 155 | 'section' => 'default-settings' |
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | 158 | $fields['messages_disable'] = array( |
| 159 | - 'name' => __( 'Disable Private Messages', 'woothemes-sensei' ), |
|
| 160 | - 'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ), |
|
| 159 | + 'name' => __('Disable Private Messages', 'woothemes-sensei'), |
|
| 160 | + 'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'), |
|
| 161 | 161 | 'type' => 'checkbox', |
| 162 | 162 | 'default' => false, |
| 163 | 163 | 'section' => 'default-settings' |
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $fields['course_page'] = array( |
| 167 | - 'name' => __( 'Course Archive Page', 'woothemes-sensei' ), |
|
| 168 | - 'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ), |
|
| 167 | + 'name' => __('Course Archive Page', 'woothemes-sensei'), |
|
| 168 | + 'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'), |
|
| 169 | 169 | 'type' => 'select', |
| 170 | - 'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ), |
|
| 170 | + 'default' => get_option('woothemes-sensei_courses_page_id', 0), |
|
| 171 | 171 | 'section' => 'default-settings', |
| 172 | 172 | 'required' => 0, |
| 173 | 173 | 'options' => $pages_array |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | 176 | $fields['my_course_page'] = array( |
| 177 | - 'name' => __( 'My Courses Page', 'woothemes-sensei' ), |
|
| 178 | - 'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ), |
|
| 177 | + 'name' => __('My Courses Page', 'woothemes-sensei'), |
|
| 178 | + 'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'), |
|
| 179 | 179 | 'type' => 'select', |
| 180 | - 'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ), |
|
| 180 | + 'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0), |
|
| 181 | 181 | 'section' => 'default-settings', |
| 182 | 182 | 'required' => 0, |
| 183 | 183 | 'options' => $pages_array |
| 184 | 184 | ); |
| 185 | 185 | |
| 186 | 186 | $fields['placeholder_images_enable'] = array( |
| 187 | - 'name' => __( 'Use placeholder images', 'woothemes-sensei' ), |
|
| 188 | - 'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ), |
|
| 187 | + 'name' => __('Use placeholder images', 'woothemes-sensei'), |
|
| 188 | + 'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'), |
|
| 189 | 189 | 'type' => 'checkbox', |
| 190 | 190 | 'default' => false, |
| 191 | 191 | 'section' => 'default-settings' |
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | 194 | $fields['styles_disable'] = array( |
| 195 | - 'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ), |
|
| 196 | - 'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ), |
|
| 195 | + 'name' => __('Disable Sensei Styles', 'woothemes-sensei'), |
|
| 196 | + 'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'), |
|
| 197 | 197 | 'type' => 'checkbox', |
| 198 | 198 | 'default' => false, |
| 199 | 199 | 'section' => 'default-settings' |
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | $fields['js_disable'] = array( |
| 203 | - 'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ), |
|
| 204 | - 'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ), |
|
| 203 | + 'name' => __('Disable Sensei Javascript', 'woothemes-sensei'), |
|
| 204 | + 'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'), |
|
| 205 | 205 | 'type' => 'checkbox', |
| 206 | 206 | 'default' => false, |
| 207 | 207 | 'section' => 'default-settings' |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | // Course Settings |
| 211 | 211 | |
| 212 | 212 | $fields['course_completion'] = array( |
| 213 | - 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
|
| 214 | - 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
|
| 213 | + 'name' => __('Courses are complete:', 'woothemes-sensei'), |
|
| 214 | + 'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'), |
|
| 215 | 215 | 'type' => 'select', |
| 216 | 216 | 'default' => 'passed', |
| 217 | 217 | 'section' => 'course-settings', |
@@ -220,16 +220,16 @@ discard block |
||
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | 222 | $fields['course_author'] = array( |
| 223 | - 'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
|
| 224 | - 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
|
| 223 | + 'name' => __('Display Course Author', 'woothemes-sensei'), |
|
| 224 | + 'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'), |
|
| 225 | 225 | 'type' => 'checkbox', |
| 226 | 226 | 'default' => true, |
| 227 | 227 | 'section' => 'course-settings' |
| 228 | 228 | ); |
| 229 | 229 | |
| 230 | 230 | $fields['my_course_amount'] = array( |
| 231 | - 'name' => __( 'My Courses Pagination', 'woothemes-sensei' ), |
|
| 232 | - 'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ), |
|
| 231 | + 'name' => __('My Courses Pagination', 'woothemes-sensei'), |
|
| 232 | + 'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'), |
|
| 233 | 233 | 'type' => 'range', |
| 234 | 234 | 'default' => '0', |
| 235 | 235 | 'section' => 'course-settings', |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | $fields['course_archive_image_enable'] = array( |
| 241 | - 'name' => __( 'Course Archive Image', 'woothemes-sensei' ), |
|
| 242 | - 'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 241 | + 'name' => __('Course Archive Image', 'woothemes-sensei'), |
|
| 242 | + 'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'), |
|
| 243 | 243 | 'type' => 'checkbox', |
| 244 | 244 | 'default' => true, |
| 245 | 245 | 'section' => 'course-settings' |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | 248 | $fields['course_archive_image_width'] = array( |
| 249 | - 'name' => __( 'Image Width - Archive', 'woothemes-sensei' ), |
|
| 250 | - 'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
|
| 249 | + 'name' => __('Image Width - Archive', 'woothemes-sensei'), |
|
| 250 | + 'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), |
|
| 251 | 251 | 'type' => 'text', |
| 252 | 252 | 'default' => '100', |
| 253 | 253 | 'section' => 'course-settings', |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | ); |
| 256 | 256 | |
| 257 | 257 | $fields['course_archive_image_height'] = array( |
| 258 | - 'name' => __( 'Image Height - Archive', 'woothemes-sensei' ), |
|
| 259 | - 'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
|
| 258 | + 'name' => __('Image Height - Archive', 'woothemes-sensei'), |
|
| 259 | + 'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), |
|
| 260 | 260 | 'type' => 'text', |
| 261 | 261 | 'default' => '100', |
| 262 | 262 | 'section' => 'course-settings', |
@@ -264,24 +264,24 @@ discard block |
||
| 264 | 264 | ); |
| 265 | 265 | |
| 266 | 266 | $fields['course_archive_image_hard_crop'] = array( |
| 267 | - 'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ), |
|
| 268 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 267 | + 'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'), |
|
| 268 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 269 | 269 | 'type' => 'checkbox', |
| 270 | 270 | 'default' => false, |
| 271 | 271 | 'section' => 'course-settings' |
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | 274 | $fields['course_single_image_enable'] = array( |
| 275 | - 'name' => __( 'Single Course Image', 'woothemes-sensei' ), |
|
| 276 | - 'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ), |
|
| 275 | + 'name' => __('Single Course Image', 'woothemes-sensei'), |
|
| 276 | + 'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'), |
|
| 277 | 277 | 'type' => 'checkbox', |
| 278 | 278 | 'default' => false, |
| 279 | 279 | 'section' => 'course-settings' |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | 282 | $fields['course_single_image_width'] = array( |
| 283 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
|
| 284 | - 'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
|
| 283 | + 'name' => __('Image Width - Single', 'woothemes-sensei'), |
|
| 284 | + 'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), |
|
| 285 | 285 | 'type' => 'text', |
| 286 | 286 | 'default' => '100', |
| 287 | 287 | 'section' => 'course-settings', |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | ); |
| 290 | 290 | |
| 291 | 291 | $fields['course_single_image_height'] = array( |
| 292 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
|
| 293 | - 'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
|
| 292 | + 'name' => __('Image Height - Single', 'woothemes-sensei'), |
|
| 293 | + 'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), |
|
| 294 | 294 | 'type' => 'text', |
| 295 | 295 | 'default' => '100', |
| 296 | 296 | 'section' => 'course-settings', |
@@ -298,16 +298,16 @@ discard block |
||
| 298 | 298 | ); |
| 299 | 299 | |
| 300 | 300 | $fields['course_single_image_hard_crop'] = array( |
| 301 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
|
| 302 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 301 | + 'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), |
|
| 302 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 303 | 303 | 'type' => 'checkbox', |
| 304 | 304 | 'default' => false, |
| 305 | 305 | 'section' => 'course-settings' |
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | 308 | $fields['course_single_content_display'] = array( |
| 309 | - 'name' => __( 'Single Course page displays:', 'woothemes-sensei' ), |
|
| 310 | - 'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ), |
|
| 309 | + 'name' => __('Single Course page displays:', 'woothemes-sensei'), |
|
| 310 | + 'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'), |
|
| 311 | 311 | 'type' => 'select', |
| 312 | 312 | 'default' => 'excerpt', |
| 313 | 313 | 'section' => 'course-settings', |
@@ -316,18 +316,18 @@ discard block |
||
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | 318 | $fields['course_archive_featured_enable'] = array( |
| 319 | - 'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ), |
|
| 320 | - 'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 319 | + 'name' => __('Featured Courses Panel', 'woothemes-sensei'), |
|
| 320 | + 'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
| 321 | 321 | 'type' => 'checkbox', |
| 322 | 322 | 'default' => true, |
| 323 | 323 | 'section' => 'course-settings' |
| 324 | 324 | ); |
| 325 | 325 | |
| 326 | 326 | $fields['course_archive_more_link_text'] = array( |
| 327 | - 'name' => __( 'More link text', 'woothemes-sensei' ), |
|
| 328 | - 'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ), |
|
| 327 | + 'name' => __('More link text', 'woothemes-sensei'), |
|
| 328 | + 'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'), |
|
| 329 | 329 | 'type' => 'text', |
| 330 | - 'default' => __ ( 'More', 'woothemes-sensei' ), |
|
| 330 | + 'default' => __('More', 'woothemes-sensei'), |
|
| 331 | 331 | 'section' => 'course-settings', |
| 332 | 332 | 'required' => 0 |
| 333 | 333 | ); |
@@ -335,32 +335,32 @@ discard block |
||
| 335 | 335 | // Lesson Settings |
| 336 | 336 | |
| 337 | 337 | $fields['lesson_comments'] = array( |
| 338 | - 'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ), |
|
| 339 | - 'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ), |
|
| 338 | + 'name' => __('Allow Comments for Lessons', 'woothemes-sensei'), |
|
| 339 | + 'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'), |
|
| 340 | 340 | 'type' => 'checkbox', |
| 341 | 341 | 'default' => true, |
| 342 | 342 | 'section' => 'lesson-settings' |
| 343 | 343 | ); |
| 344 | 344 | |
| 345 | 345 | $fields['lesson_author'] = array( |
| 346 | - 'name' => __( 'Display Lesson Author', 'woothemes-sensei' ), |
|
| 347 | - 'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ), |
|
| 346 | + 'name' => __('Display Lesson Author', 'woothemes-sensei'), |
|
| 347 | + 'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'), |
|
| 348 | 348 | 'type' => 'checkbox', |
| 349 | 349 | 'default' => true, |
| 350 | 350 | 'section' => 'lesson-settings' |
| 351 | 351 | ); |
| 352 | 352 | |
| 353 | 353 | $fields['course_lesson_image_enable'] = array( |
| 354 | - 'name' => __( 'Course Lesson Images', 'woothemes-sensei' ), |
|
| 355 | - 'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ), |
|
| 354 | + 'name' => __('Course Lesson Images', 'woothemes-sensei'), |
|
| 355 | + 'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'), |
|
| 356 | 356 | 'type' => 'checkbox', |
| 357 | 357 | 'default' => false, |
| 358 | 358 | 'section' => 'lesson-settings' |
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | $fields['lesson_archive_image_width'] = array( |
| 362 | - 'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ), |
|
| 363 | - 'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
|
| 362 | + 'name' => __('Image Width - Course Lessons', 'woothemes-sensei'), |
|
| 363 | + 'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), |
|
| 364 | 364 | 'type' => 'text', |
| 365 | 365 | 'default' => '100', |
| 366 | 366 | 'section' => 'lesson-settings', |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | ); |
| 369 | 369 | |
| 370 | 370 | $fields['lesson_archive_image_height'] = array( |
| 371 | - 'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ), |
|
| 372 | - 'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
|
| 371 | + 'name' => __('Image Height - Course Lessons', 'woothemes-sensei'), |
|
| 372 | + 'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), |
|
| 373 | 373 | 'type' => 'text', |
| 374 | 374 | 'default' => '100', |
| 375 | 375 | 'section' => 'lesson-settings', |
@@ -377,24 +377,24 @@ discard block |
||
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | 379 | $fields['lesson_archive_image_hard_crop'] = array( |
| 380 | - 'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ), |
|
| 381 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 380 | + 'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'), |
|
| 381 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 382 | 382 | 'type' => 'checkbox', |
| 383 | 383 | 'default' => false, |
| 384 | 384 | 'section' => 'lesson-settings' |
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | $fields['lesson_single_image_enable'] = array( |
| 388 | - 'name' => __( 'Single Lesson Images', 'woothemes-sensei' ), |
|
| 389 | - 'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ), |
|
| 388 | + 'name' => __('Single Lesson Images', 'woothemes-sensei'), |
|
| 389 | + 'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'), |
|
| 390 | 390 | 'type' => 'checkbox', |
| 391 | 391 | 'default' => false, |
| 392 | 392 | 'section' => 'lesson-settings' |
| 393 | 393 | ); |
| 394 | 394 | |
| 395 | 395 | $fields['lesson_single_image_width'] = array( |
| 396 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
|
| 397 | - 'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
|
| 396 | + 'name' => __('Image Width - Single', 'woothemes-sensei'), |
|
| 397 | + 'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), |
|
| 398 | 398 | 'type' => 'text', |
| 399 | 399 | 'default' => '100', |
| 400 | 400 | 'section' => 'lesson-settings', |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | ); |
| 403 | 403 | |
| 404 | 404 | $fields['lesson_single_image_height'] = array( |
| 405 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
|
| 406 | - 'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
|
| 405 | + 'name' => __('Image Height - Single', 'woothemes-sensei'), |
|
| 406 | + 'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), |
|
| 407 | 407 | 'type' => 'text', |
| 408 | 408 | 'default' => '100', |
| 409 | 409 | 'section' => 'lesson-settings', |
@@ -411,8 +411,8 @@ discard block |
||
| 411 | 411 | ); |
| 412 | 412 | |
| 413 | 413 | $fields['lesson_single_image_hard_crop'] = array( |
| 414 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
|
| 415 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 414 | + 'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), |
|
| 415 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 416 | 416 | 'type' => 'checkbox', |
| 417 | 417 | 'default' => false, |
| 418 | 418 | 'section' => 'lesson-settings' |
@@ -420,20 +420,20 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // Learner Profile settings |
| 422 | 422 | |
| 423 | - $profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
|
| 424 | - $profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%'; |
|
| 423 | + $profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei')); |
|
| 424 | + $profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%'; |
|
| 425 | 425 | |
| 426 | 426 | $fields['learner_profile_enable'] = array( |
| 427 | - 'name' => __( 'Public learner profiles', 'woothemes-sensei' ), |
|
| 428 | - 'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ), |
|
| 427 | + 'name' => __('Public learner profiles', 'woothemes-sensei'), |
|
| 428 | + 'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example), |
|
| 429 | 429 | 'type' => 'checkbox', |
| 430 | 430 | 'default' => true, |
| 431 | 431 | 'section' => 'learner-profile-settings' |
| 432 | 432 | ); |
| 433 | 433 | |
| 434 | 434 | $fields['learner_profile_show_courses'] = array( |
| 435 | - 'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ), |
|
| 436 | - 'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ), |
|
| 435 | + 'name' => __('Show learner\'s courses', 'woothemes-sensei'), |
|
| 436 | + 'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'), |
|
| 437 | 437 | 'type' => 'checkbox', |
| 438 | 438 | 'default' => true, |
| 439 | 439 | 'section' => 'learner-profile-settings' |
@@ -442,70 +442,70 @@ discard block |
||
| 442 | 442 | // Email notifications |
| 443 | 443 | |
| 444 | 444 | $learner_email_options = array( |
| 445 | - 'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ), |
|
| 446 | - 'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ), |
|
| 445 | + 'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'), |
|
| 446 | + 'learner-completed-course' => __('They complete a course', 'woothemes-sensei'), |
|
| 447 | 447 | ); |
| 448 | 448 | |
| 449 | 449 | $teacher_email_options = array( |
| 450 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
| 451 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
| 452 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
| 453 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
| 454 | - 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
|
| 450 | + 'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'), |
|
| 451 | + 'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'), |
|
| 452 | + 'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'), |
|
| 453 | + 'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'), |
|
| 454 | + 'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'), |
|
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | 457 | $global_email_options = array( |
| 458 | - 'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ), |
|
| 458 | + 'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'), |
|
| 459 | 459 | ); |
| 460 | 460 | |
| 461 | 461 | $fields['email_learners'] = array( |
| 462 | - 'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ), |
|
| 463 | - 'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ), |
|
| 462 | + 'name' => __('Emails Sent to Learners', 'woothemes-sensei'), |
|
| 463 | + 'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'), |
|
| 464 | 464 | 'type' => 'multicheck', |
| 465 | 465 | 'options' => $learner_email_options, |
| 466 | - 'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ), |
|
| 466 | + 'defaults' => array('learner-graded-quiz', 'learner-completed-course'), |
|
| 467 | 467 | 'section' => 'email-notification-settings' |
| 468 | 468 | ); |
| 469 | 469 | |
| 470 | 470 | $fields['email_teachers'] = array( |
| 471 | - 'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ), |
|
| 472 | - 'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ), |
|
| 471 | + 'name' => __('Emails Sent to Teachers', 'woothemes-sensei'), |
|
| 472 | + 'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'), |
|
| 473 | 473 | 'type' => 'multicheck', |
| 474 | 474 | 'options' => $teacher_email_options, |
| 475 | - 'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ), |
|
| 475 | + 'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'), |
|
| 476 | 476 | 'section' => 'email-notification-settings' |
| 477 | 477 | ); |
| 478 | 478 | |
| 479 | 479 | $fields['email_global'] = array( |
| 480 | - 'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ), |
|
| 481 | - 'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ), |
|
| 480 | + 'name' => __('Emails Sent to All Users', 'woothemes-sensei'), |
|
| 481 | + 'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'), |
|
| 482 | 482 | 'type' => 'multicheck', |
| 483 | 483 | 'options' => $global_email_options, |
| 484 | - 'defaults' => array( 'new-message-reply' ), |
|
| 484 | + 'defaults' => array('new-message-reply'), |
|
| 485 | 485 | 'section' => 'email-notification-settings' |
| 486 | 486 | ); |
| 487 | 487 | |
| 488 | 488 | $fields['email_from_name'] = array( |
| 489 | - 'name' => __( '"From" Name', 'woothemes-sensei' ), |
|
| 490 | - 'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ), |
|
| 489 | + 'name' => __('"From" Name', 'woothemes-sensei'), |
|
| 490 | + 'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'), |
|
| 491 | 491 | 'type' => 'text', |
| 492 | - 'default' => get_bloginfo( 'name' ), |
|
| 492 | + 'default' => get_bloginfo('name'), |
|
| 493 | 493 | 'section' => 'email-notification-settings', |
| 494 | 494 | 'required' => 1 |
| 495 | 495 | ); |
| 496 | 496 | |
| 497 | 497 | $fields['email_from_address'] = array( |
| 498 | - 'name' => __( '"From" Address', 'woothemes-sensei' ), |
|
| 499 | - 'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ), |
|
| 498 | + 'name' => __('"From" Address', 'woothemes-sensei'), |
|
| 499 | + 'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'), |
|
| 500 | 500 | 'type' => 'text', |
| 501 | - 'default' => get_bloginfo( 'admin_email' ), |
|
| 501 | + 'default' => get_bloginfo('admin_email'), |
|
| 502 | 502 | 'section' => 'email-notification-settings', |
| 503 | 503 | 'required' => 1 |
| 504 | 504 | ); |
| 505 | 505 | |
| 506 | 506 | $fields['email_header_image'] = array( |
| 507 | - 'name' => __( 'Header Image', 'woothemes-sensei' ), |
|
| 508 | - 'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ), |
|
| 507 | + 'name' => __('Header Image', 'woothemes-sensei'), |
|
| 508 | + 'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'), |
|
| 509 | 509 | 'type' => 'text', |
| 510 | 510 | 'default' => '', |
| 511 | 511 | 'section' => 'email-notification-settings', |
@@ -513,17 +513,17 @@ discard block |
||
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | 515 | $fields['email_footer_text'] = array( |
| 516 | - 'name' => __( 'Email Footer Text', 'woothemes-sensei' ), |
|
| 517 | - 'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ), |
|
| 516 | + 'name' => __('Email Footer Text', 'woothemes-sensei'), |
|
| 517 | + 'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'), |
|
| 518 | 518 | 'type' => 'textarea', |
| 519 | - 'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), |
|
| 519 | + 'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')), |
|
| 520 | 520 | 'section' => 'email-notification-settings', |
| 521 | 521 | 'required' => 0 |
| 522 | 522 | ); |
| 523 | 523 | |
| 524 | 524 | $fields['email_base_color'] = array( |
| 525 | - 'name' => __( 'Base Colour', 'woothemes-sensei' ), |
|
| 526 | - 'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 525 | + 'name' => __('Base Colour', 'woothemes-sensei'), |
|
| 526 | + 'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 527 | 527 | 'type' => 'color', |
| 528 | 528 | 'default' => '#557da1', |
| 529 | 529 | 'section' => 'email-notification-settings', |
@@ -531,8 +531,8 @@ discard block |
||
| 531 | 531 | ); |
| 532 | 532 | |
| 533 | 533 | $fields['email_background_color'] = array( |
| 534 | - 'name' => __( 'Background Colour', 'woothemes-sensei' ), |
|
| 535 | - 'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 534 | + 'name' => __('Background Colour', 'woothemes-sensei'), |
|
| 535 | + 'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 536 | 536 | 'type' => 'color', |
| 537 | 537 | 'default' => '#f5f5f5', |
| 538 | 538 | 'section' => 'email-notification-settings', |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | ); |
| 541 | 541 | |
| 542 | 542 | $fields['email_body_background_color'] = array( |
| 543 | - 'name' => __( 'Body Background Colour', 'woothemes-sensei' ), |
|
| 544 | - 'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 543 | + 'name' => __('Body Background Colour', 'woothemes-sensei'), |
|
| 544 | + 'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 545 | 545 | 'type' => 'color', |
| 546 | 546 | 'default' => '#fdfdfd', |
| 547 | 547 | 'section' => 'email-notification-settings', |
@@ -549,35 +549,35 @@ discard block |
||
| 549 | 549 | ); |
| 550 | 550 | |
| 551 | 551 | $fields['email_text_color'] = array( |
| 552 | - 'name' => __( 'Body Text Colour', 'woothemes-sensei' ), |
|
| 553 | - 'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 552 | + 'name' => __('Body Text Colour', 'woothemes-sensei'), |
|
| 553 | + 'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 554 | 554 | 'type' => 'color', |
| 555 | 555 | 'default' => '#505050', |
| 556 | 556 | 'section' => 'email-notification-settings', |
| 557 | 557 | 'required' => 1 |
| 558 | 558 | ); |
| 559 | 559 | |
| 560 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 560 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 561 | 561 | // WooCommerce Settings |
| 562 | 562 | $fields['woocommerce_enabled'] = array( |
| 563 | - 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
|
| 564 | - 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
|
| 563 | + 'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'), |
|
| 564 | + 'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'), |
|
| 565 | 565 | 'type' => 'checkbox', |
| 566 | 566 | 'default' => true, |
| 567 | 567 | 'section' => 'woocommerce-settings' |
| 568 | 568 | ); |
| 569 | 569 | |
| 570 | 570 | $fields['course_archive_free_enable'] = array( |
| 571 | - 'name' => __( 'Free Courses Panel', 'woothemes-sensei' ), |
|
| 572 | - 'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 571 | + 'name' => __('Free Courses Panel', 'woothemes-sensei'), |
|
| 572 | + 'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
| 573 | 573 | 'type' => 'checkbox', |
| 574 | 574 | 'default' => true, |
| 575 | 575 | 'section' => 'woocommerce-settings' |
| 576 | 576 | ); |
| 577 | 577 | |
| 578 | 578 | $fields['course_archive_paid_enable'] = array( |
| 579 | - 'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ), |
|
| 580 | - 'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 579 | + 'name' => __('Paid Courses Panel', 'woothemes-sensei'), |
|
| 580 | + 'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
| 581 | 581 | 'type' => 'checkbox', |
| 582 | 582 | 'default' => true, |
| 583 | 583 | 'section' => 'woocommerce-settings' |
@@ -585,18 +585,18 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | } // End If Statement |
| 587 | 587 | |
| 588 | - if ( 'en_US' !== get_locale() ) { |
|
| 588 | + if ('en_US' !== get_locale()) { |
|
| 589 | 589 | $fields['install_language_pack'] = array( |
| 590 | - 'name' => __( 'Install Language Pack', 'woothemes-sensei' ), |
|
| 591 | - 'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ), |
|
| 590 | + 'name' => __('Install Language Pack', 'woothemes-sensei'), |
|
| 591 | + 'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'), |
|
| 592 | 592 | 'type' => 'button', |
| 593 | 593 | 'section' => 'language-settings', |
| 594 | 594 | 'target' => Sensei_Language_Pack_Manager::get_install_uri(), |
| 595 | - 'label' => __( 'Install', 'woothemes-sensei' ) |
|
| 595 | + 'label' => __('Install', 'woothemes-sensei') |
|
| 596 | 596 | ); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $this->fields = apply_filters( 'sensei_settings_fields', $fields ); |
|
| 599 | + $this->fields = apply_filters('sensei_settings_fields', $fields); |
|
| 600 | 600 | |
| 601 | 601 | } // End init_fields() |
| 602 | 602 | |
@@ -606,20 +606,20 @@ discard block |
||
| 606 | 606 | * @param $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1. |
| 607 | 607 | * @return array Options between 0.1 and 10 seconds. |
| 608 | 608 | */ |
| 609 | - private function get_duration_options ( $include_milliseconds = true ) { |
|
| 610 | - $numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' ); |
|
| 609 | + private function get_duration_options($include_milliseconds = true) { |
|
| 610 | + $numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0'); |
|
| 611 | 611 | $options = array(); |
| 612 | 612 | |
| 613 | - if ( true == (bool)$include_milliseconds ) { |
|
| 614 | - $milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' ); |
|
| 615 | - foreach ( $milliseconds as $k => $v ) { |
|
| 613 | + if (true == (bool) $include_milliseconds) { |
|
| 614 | + $milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9'); |
|
| 615 | + foreach ($milliseconds as $k => $v) { |
|
| 616 | 616 | $options[$v] = $v; |
| 617 | 617 | } |
| 618 | 618 | } else { |
| 619 | 619 | $options['0.5'] = '0.5'; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - foreach ( $numbers as $k => $v ) { |
|
| 622 | + foreach ($numbers as $k => $v) { |
|
| 623 | 623 | $options[$v] = $v; |
| 624 | 624 | } |
| 625 | 625 | |
@@ -635,25 +635,25 @@ discard block |
||
| 635 | 635 | private function pages_array() { |
| 636 | 636 | // REFACTOR - Transform this into a field type instead. |
| 637 | 637 | // Setup an array of portfolio gallery terms for a dropdown. |
| 638 | - $args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ); |
|
| 639 | - $pages_dropdown = wp_dropdown_pages( $args ); |
|
| 638 | + $args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC'); |
|
| 639 | + $pages_dropdown = wp_dropdown_pages($args); |
|
| 640 | 640 | $page_items = array(); |
| 641 | 641 | |
| 642 | 642 | // Quick string hack to make sure we get the pages with the indents. |
| 643 | - $pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown ); |
|
| 644 | - $pages_dropdown = str_replace( '</select>', '', $pages_dropdown ); |
|
| 645 | - $pages_split = explode( '</option>', $pages_dropdown ); |
|
| 643 | + $pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown); |
|
| 644 | + $pages_dropdown = str_replace('</select>', '', $pages_dropdown); |
|
| 645 | + $pages_split = explode('</option>', $pages_dropdown); |
|
| 646 | 646 | |
| 647 | - $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
|
| 647 | + $page_items[] = __('Select a Page:', 'woothemes-sensei'); |
|
| 648 | 648 | |
| 649 | - foreach ( $pages_split as $k => $v ) { |
|
| 649 | + foreach ($pages_split as $k => $v) { |
|
| 650 | 650 | $id = ''; |
| 651 | 651 | // Get the ID value. |
| 652 | - preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
| 652 | + preg_match('/value="(.*?)"/i', $v, $matches); |
|
| 653 | 653 | |
| 654 | - if ( isset( $matches[1] ) ) { |
|
| 654 | + if (isset($matches[1])) { |
|
| 655 | 655 | $id = $matches[1]; |
| 656 | - $page_items[$id] = trim( strip_tags( $v ) ); |
|
| 656 | + $page_items[$id] = trim(strip_tags($v)); |
|
| 657 | 657 | } // End If Statement |
| 658 | 658 | } // End For Loop |
| 659 | 659 | |
@@ -677,10 +677,10 @@ discard block |
||
| 677 | 677 | * |
| 678 | 678 | * @since 1.9.0 |
| 679 | 679 | */ |
| 680 | - public static function flush_rewrite_rules(){ |
|
| 680 | + public static function flush_rewrite_rules() { |
|
| 681 | 681 | |
| 682 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
| 683 | - && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
| 682 | + if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page'] |
|
| 683 | + && isset($_POST['action']) && 'update' == $_POST['action']) { |
|
| 684 | 684 | |
| 685 | 685 | Sensei()->initiate_rewrite_rules_flush(); |
| 686 | 686 | |
@@ -694,4 +694,4 @@ discard block |
||
| 694 | 694 | * for backward compatibility |
| 695 | 695 | * @since 1.9.0 |
| 696 | 696 | */ |
| 697 | -class WooThemes_Sensei_Settings extends Sensei_Settings{} |
|
| 697 | +class WooThemes_Sensei_Settings extends Sensei_Settings {} |
|