@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 2 | +if ( ! defined('ABSPATH')) exit; |
|
| 3 | 3 | /** |
| 4 | 4 | * The Template for displaying all single course meta information. |
| 5 | 5 | * |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | * @hooked WooThemes_Sensei_Course::load_single_course_lessons_query |
| 23 | 23 | * @since 1.9.0 |
| 24 | 24 | */ |
| 25 | - do_action( 'sensei_single_course_lessons_before' ); |
|
| 25 | + do_action('sensei_single_course_lessons_before'); |
|
| 26 | 26 | |
| 27 | 27 | ?> |
| 28 | 28 | |
| 29 | 29 | <?php |
| 30 | 30 | |
| 31 | 31 | //lessons loaded into loop in the sensei_single_course_lessons_before hook |
| 32 | - if( have_posts() ): |
|
| 32 | + if (have_posts()): |
|
| 33 | 33 | |
| 34 | 34 | // start course lessons loop |
| 35 | - while ( have_posts() ): the_post(); ?> |
|
| 35 | + while (have_posts()): the_post(); ?> |
|
| 36 | 36 | |
| 37 | 37 | <article <?php post_class(); ?> > |
| 38 | 38 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @hooked WooThemes_Sensei_Lesson::the_lesson_thumbnail - 8 |
| 51 | 51 | * |
| 52 | 52 | */ |
| 53 | - do_action( 'sensei_single_course_inside_before_lesson', get_the_ID() ); |
|
| 53 | + do_action('sensei_single_course_inside_before_lesson', get_the_ID()); |
|
| 54 | 54 | |
| 55 | 55 | ?> |
| 56 | 56 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @since 1.9.0 |
| 77 | 77 | */ |
| 78 | - do_action( 'sensei_single_course_inside_after_lesson', get_the_ID() ); |
|
| 78 | + do_action('sensei_single_course_inside_after_lesson', get_the_ID()); |
|
| 79 | 79 | |
| 80 | 80 | ?> |
| 81 | 81 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @since 1.9.0 |
| 96 | 96 | */ |
| 97 | - do_action( 'sensei_single_course_lessons_after' ); |
|
| 97 | + do_action('sensei_single_course_lessons_after'); |
|
| 98 | 98 | |
| 99 | 99 | ?> |
| 100 | 100 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | -<?php get_sensei_header(); ?> |
|
| 14 | +<?php get_sensei_header(); ?> |
|
| 15 | 15 | |
| 16 | 16 | <?php |
| 17 | 17 | /** |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @hooked Sensei_Course_Results::deprecate_sensei_course_results_content_hook() - 20 |
| 23 | 23 | */ |
| 24 | -do_action( 'sensei_course_results_content_before' ); |
|
| 24 | +do_action('sensei_course_results_content_before'); |
|
| 25 | 25 | ?> |
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | global $course; |
| 29 | -$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' ); |
|
| 29 | +$course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course'); |
|
| 30 | 30 | ?> |
| 31 | 31 | |
| 32 | -<article <?php post_class( array( 'course', 'post','course-results' ) ); ?> > |
|
| 32 | +<article <?php post_class(array('course', 'post', 'course-results')); ?> > |
|
| 33 | 33 | |
| 34 | 34 | <section class="entry fix"> |
| 35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param integer $course_id |
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | - do_action( 'sensei_course_results_content_inside_before', $course->ID ); |
|
| 45 | + do_action('sensei_course_results_content_inside_before', $course->ID); |
|
| 46 | 46 | ?> |
| 47 | 47 | |
| 48 | 48 | <header> |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | </header> |
| 55 | 55 | |
| 56 | - <?php if ( is_user_logged_in() ):?> |
|
| 56 | + <?php if (is_user_logged_in()):?> |
|
| 57 | 57 | |
| 58 | 58 | <?php |
| 59 | 59 | /** |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @hooked Sensei_Course_Results::course_info() - 20 |
| 67 | 67 | */ |
| 68 | - do_action( 'sensei_course_results_content_inside_before_lessons', $course->ID ); |
|
| 68 | + do_action('sensei_course_results_content_inside_before_lessons', $course->ID); |
|
| 69 | 69 | ?> |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | <section class="course-results-lessons"> |
| 73 | 73 | <?php |
| 74 | - $started_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 75 | - if( $started_course ) { |
|
| 74 | + $started_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id()); |
|
| 75 | + if ($started_course) { |
|
| 76 | 76 | |
| 77 | 77 | sensei_the_course_results_lessons(); |
| 78 | 78 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @hooked Sensei()->course_results->course_info - 20 |
| 94 | 94 | */ |
| 95 | - do_action( 'sensei_course_results_content_inside_after', $course->ID ); |
|
| 95 | + do_action('sensei_course_results_content_inside_after', $course->ID); |
|
| 96 | 96 | ?> |
| 97 | 97 | |
| 98 | 98 | </section> |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @since 1.9.0 |
| 107 | 107 | * |
| 108 | 108 | */ |
| 109 | -do_action( 'sensei_course_results_content_after' ); |
|
| 109 | +do_action('sensei_course_results_content_after'); |
|
| 110 | 110 | ?> |
| 111 | 111 | |
| 112 | 112 | |
@@ -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 | * This class is loaded int WP by the shortcode loader class. |
| 5 | 5 | * |
@@ -61,28 +61,28 @@ discard block |
||
| 61 | 61 | * @param string $content |
| 62 | 62 | * @param string $shortcode the shortcode that was called for this instance |
| 63 | 63 | */ |
| 64 | - public function __construct( $attributes, $content, $shortcode ){ |
|
| 64 | + public function __construct($attributes, $content, $shortcode) { |
|
| 65 | 65 | |
| 66 | - if(! is_user_logged_in() ) { |
|
| 66 | + if ( ! is_user_logged_in()) { |
|
| 67 | 67 | // show the login form |
| 68 | 68 | Sensei_Templates::get_template('user/login-form.php'); |
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // set up all argument need for constructing the course query |
| 73 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
| 74 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title'; |
|
| 75 | - $this->status = isset( $attributes['status'] ) ? $attributes['status'] : 'all'; |
|
| 73 | + $this->number = isset($attributes['number']) ? $attributes['number'] : '10'; |
|
| 74 | + $this->orderby = isset($attributes['orderby']) ? $attributes['orderby'] : 'title'; |
|
| 75 | + $this->status = isset($attributes['status']) ? $attributes['status'] : 'all'; |
|
| 76 | 76 | |
| 77 | 77 | // set the default for menu_order to be ASC |
| 78 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
| 78 | + if ('menu_order' == $this->orderby && ! isset($attributes['order'])) { |
|
| 79 | 79 | |
| 80 | - $this->order = 'ASC'; |
|
| 80 | + $this->order = 'ASC'; |
|
| 81 | 81 | |
| 82 | - }else{ |
|
| 82 | + } else { |
|
| 83 | 83 | |
| 84 | 84 | // for everything else use the value passed or the default DESC |
| 85 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC'; |
|
| 85 | + $this->order = isset($attributes['order']) ? $attributes['order'] : 'ASC'; |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
@@ -96,20 +96,20 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @since 1.9.0 |
| 98 | 98 | */ |
| 99 | - protected function setup_course_query(){ |
|
| 99 | + protected function setup_course_query() { |
|
| 100 | 100 | |
| 101 | - $status_query = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status' ); |
|
| 102 | - $user_courses_logs = Sensei_Utils::sensei_check_for_activity( $status_query , true ); |
|
| 103 | - if ( !is_array($user_courses_logs) ) { |
|
| 101 | + $status_query = array('user_id' => get_current_user_id(), 'type' => 'sensei_course_status'); |
|
| 102 | + $user_courses_logs = Sensei_Utils::sensei_check_for_activity($status_query, true); |
|
| 103 | + if ( ! is_array($user_courses_logs)) { |
|
| 104 | 104 | |
| 105 | - $user_courses_logs = array( $user_courses_logs ); |
|
| 105 | + $user_courses_logs = array($user_courses_logs); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $completed_ids = $active_ids = array(); |
| 110 | - foreach( $user_courses_logs as $course_status ) { |
|
| 110 | + foreach ($user_courses_logs as $course_status) { |
|
| 111 | 111 | |
| 112 | - if ( Sensei_Utils::user_completed_course( $course_status, get_current_user_id() ) ) { |
|
| 112 | + if (Sensei_Utils::user_completed_course($course_status, get_current_user_id())) { |
|
| 113 | 113 | |
| 114 | 114 | $completed_ids[] = $course_status->comment_post_ID; |
| 115 | 115 | |
@@ -120,34 +120,34 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if( 'completed' == $this->status ){ |
|
| 123 | + if ('completed' == $this->status) { |
|
| 124 | 124 | |
| 125 | - $included_courses = $completed_ids; |
|
| 125 | + $included_courses = $completed_ids; |
|
| 126 | 126 | |
| 127 | 127 | |
| 128 | - }elseif( 'active'==$this->status ){ |
|
| 128 | + }elseif ('active' == $this->status) { |
|
| 129 | 129 | |
| 130 | - $included_courses = $active_ids; |
|
| 130 | + $included_courses = $active_ids; |
|
| 131 | 131 | |
| 132 | - }else{ // all courses |
|
| 132 | + } else { // all courses |
|
| 133 | 133 | |
| 134 | - if( empty( $completed_ids ) ){ |
|
| 134 | + if (empty($completed_ids)) { |
|
| 135 | 135 | |
| 136 | - add_action( 'sensei_loop_course_inside_before', array( $this, 'completed_no_course_message_output' ) ); |
|
| 136 | + add_action('sensei_loop_course_inside_before', array($this, 'completed_no_course_message_output')); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if( empty( $active_ids ) ){ |
|
| 139 | + if (empty($active_ids)) { |
|
| 140 | 140 | |
| 141 | - add_action( 'sensei_loop_course_inside_before', array( $this, 'active_no_course_message_output' ) ); |
|
| 141 | + add_action('sensei_loop_course_inside_before', array($this, 'active_no_course_message_output')); |
|
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if( empty( $completed_ids ) && empty( $active_ids ) ){ |
|
| 145 | + if (empty($completed_ids) && empty($active_ids)) { |
|
| 146 | 146 | |
| 147 | 147 | $included_courses = array('-1000'); // don't show any courses |
| 148 | 148 | |
| 149 | - }else{ |
|
| 150 | - $included_courses = Sensei_Utils::array_zip_merge( (array)$active_ids, (array)$completed_ids ); |
|
| 149 | + } else { |
|
| 150 | + $included_courses = Sensei_Utils::array_zip_merge((array) $active_ids, (array) $completed_ids); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // if the shortcode is not active or in active and the active and completed |
| 159 | 159 | // tabs show up. |
| 160 | 160 | $number_of_posts = $this->number; |
| 161 | - if( 'active' != $this->status && 'complete' != $this->status ){ |
|
| 161 | + if ('active' != $this->status && 'complete' != $this->status) { |
|
| 162 | 162 | $number_of_posts = 1000; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | 'post_status' => 'publish', |
| 170 | 170 | 'orderby' => $this->orderby, |
| 171 | 171 | 'order' => $this->order, |
| 172 | - 'paged' => empty( $query_var_paged )? 1 : $query_var_paged, |
|
| 172 | + 'paged' => empty($query_var_paged) ? 1 : $query_var_paged, |
|
| 173 | 173 | 'posts_per_page' => $number_of_posts, |
| 174 | 174 | 'post__in' => $included_courses, |
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | - $this->query = new WP_Query( $query_args ); |
|
| 177 | + $this->query = new WP_Query($query_args); |
|
| 178 | 178 | |
| 179 | 179 | }// end setup _course_query |
| 180 | 180 | |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @since 1.9.0 |
| 186 | 186 | */ |
| 187 | - public function completed_no_course_message_output(){ |
|
| 187 | + public function completed_no_course_message_output() { |
|
| 188 | 188 | ?> |
| 189 | 189 | <li class="user-completed"> |
| 190 | 190 | <div class="sensei-message info"> |
| 191 | 191 | |
| 192 | - <?php _e( 'You have not completed any courses yet.', 'woothemes-sensei' ); ?> |
|
| 192 | + <?php _e('You have not completed any courses yet.', 'woothemes-sensei'); ?> |
|
| 193 | 193 | |
| 194 | 194 | </div> |
| 195 | 195 | </li> |
@@ -202,17 +202,17 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @since 1.9.0 |
| 204 | 204 | */ |
| 205 | - public function active_no_course_message_output(){ |
|
| 205 | + public function active_no_course_message_output() { |
|
| 206 | 206 | ?> |
| 207 | 207 | |
| 208 | 208 | <li class="user-active"> |
| 209 | 209 | <div class="sensei-message info"> |
| 210 | 210 | |
| 211 | - <?php _e( 'You have no active courses.', 'woothemes-sensei' ); ?> |
|
| 211 | + <?php _e('You have no active courses.', 'woothemes-sensei'); ?> |
|
| 212 | 212 | |
| 213 | - <a href="<?php esc_attr_e( Sensei_Course::get_courses_page_url() ); ?>"> |
|
| 213 | + <a href="<?php esc_attr_e(Sensei_Course::get_courses_page_url()); ?>"> |
|
| 214 | 214 | |
| 215 | - <?php _e( 'Start a Course!', 'woothemes-sensei' ); ?> |
|
| 215 | + <?php _e('Start a Course!', 'woothemes-sensei'); ?> |
|
| 216 | 216 | |
| 217 | 217 | </a> |
| 218 | 218 | |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return string $content |
| 228 | 228 | */ |
| 229 | - public function render(){ |
|
| 229 | + public function render() { |
|
| 230 | 230 | |
| 231 | 231 | global $wp_query; |
| 232 | 232 | |
| 233 | - if(! is_user_logged_in() ) { |
|
| 233 | + if ( ! is_user_logged_in()) { |
|
| 234 | 234 | return ''; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | Sensei_Templates::get_template('globals/pagination.php'); |
| 250 | 250 | echo '</section>'; |
| 251 | 251 | |
| 252 | - $shortcode_output = ob_get_clean(); |
|
| 252 | + $shortcode_output = ob_get_clean(); |
|
| 253 | 253 | |
| 254 | 254 | $this->detach_shortcode_hooks(); |
| 255 | 255 | |
@@ -265,23 +265,23 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @since 1.9.0 |
| 267 | 267 | */ |
| 268 | - public function attach_shortcode_hooks(){ |
|
| 268 | + public function attach_shortcode_hooks() { |
|
| 269 | 269 | |
| 270 | 270 | // attach the toggle functionality |
| 271 | 271 | // don't show the toggle action if the user specified complete or active for this shortcode |
| 272 | - if( ! in_array( $this->status, array( 'active', 'complete' ) ) ){ |
|
| 272 | + if ( ! in_array($this->status, array('active', 'complete'))) { |
|
| 273 | 273 | |
| 274 | - add_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) ); |
|
| 275 | - add_action( 'wp_footer', array( $this, 'print_course_toggle_actions_inline_script' ), 90 ); |
|
| 274 | + add_action('sensei_loop_course_before', array($this, 'course_toggle_actions')); |
|
| 275 | + add_action('wp_footer', array($this, 'print_course_toggle_actions_inline_script'), 90); |
|
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // add extra classes to distinguish the course based on user completed or active |
| 280 | - add_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 ); |
|
| 280 | + add_filter('sensei_course_loop_content_class', array($this, 'course_status_class_tagging'), 20, 2); |
|
| 281 | 281 | |
| 282 | 282 | // attach progress meter below course |
| 283 | - add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) ); |
|
| 284 | - add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) ); |
|
| 283 | + add_action('sensei_course_content_inside_after', array($this, 'attach_course_progress')); |
|
| 284 | + add_action('sensei_course_content_inside_after', array($this, 'attach_course_buttons')); |
|
| 285 | 285 | |
| 286 | 286 | } |
| 287 | 287 | |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @since 1.9.0 |
| 292 | 292 | */ |
| 293 | - public function detach_shortcode_hooks(){ |
|
| 293 | + public function detach_shortcode_hooks() { |
|
| 294 | 294 | |
| 295 | 295 | //remove all hooks after the output is generated |
| 296 | - remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) ); |
|
| 297 | - remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) ); |
|
| 298 | - remove_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 ); |
|
| 299 | - remove_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) ); |
|
| 296 | + remove_action('sensei_course_content_inside_after', array($this, 'attach_course_progress')); |
|
| 297 | + remove_action('sensei_course_content_inside_after', array($this, 'attach_course_buttons')); |
|
| 298 | + remove_filter('sensei_course_loop_content_class', array($this, 'course_status_class_tagging'), 20, 2); |
|
| 299 | + remove_action('sensei_loop_course_before', array($this, 'course_toggle_actions')); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @param $course |
| 306 | 306 | */ |
| 307 | - public function attach_course_progress( $course_id ){ |
|
| 307 | + public function attach_course_progress($course_id) { |
|
| 308 | 308 | |
| 309 | - $percentage = Sensei()->course->get_completion_percentage( $course_id, get_current_user_id() ); |
|
| 310 | - echo Sensei()->course->get_progress_meter( $percentage ); |
|
| 309 | + $percentage = Sensei()->course->get_completion_percentage($course_id, get_current_user_id()); |
|
| 310 | + echo Sensei()->course->get_progress_meter($percentage); |
|
| 311 | 311 | |
| 312 | 312 | }// attach_course_progress |
| 313 | 313 | |
@@ -319,9 +319,9 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | * @param integer $course_id |
| 321 | 321 | */ |
| 322 | - public function attach_course_buttons( $course_id ){ |
|
| 322 | + public function attach_course_buttons($course_id) { |
|
| 323 | 323 | |
| 324 | - Sensei()->course->the_course_action_buttons( get_post( $course_id ) ); |
|
| 324 | + Sensei()->course->the_course_action_buttons(get_post($course_id)); |
|
| 325 | 325 | |
| 326 | 326 | }// attach_course_buttons |
| 327 | 327 | |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | * @param WP_Post $course |
| 335 | 335 | * @return array $classes |
| 336 | 336 | */ |
| 337 | - public function course_status_class_tagging($classes, $course){ |
|
| 337 | + public function course_status_class_tagging($classes, $course) { |
|
| 338 | 338 | |
| 339 | - if ( Sensei_Utils::user_completed_course( $course, get_current_user_id() ) ) { |
|
| 339 | + if (Sensei_Utils::user_completed_course($course, get_current_user_id())) { |
|
| 340 | 340 | |
| 341 | 341 | $classes[] = 'user-completed'; |
| 342 | 342 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | /** |
| 354 | 354 | * Output the course toggle functionality |
| 355 | 355 | */ |
| 356 | - public function course_toggle_actions(){ ?> |
|
| 356 | + public function course_toggle_actions() { ?> |
|
| 357 | 357 | |
| 358 | 358 | <section id="user-course-status-toggle"> |
| 359 | 359 | <a id="sensei-user-courses-active-action" href=""><?php _e('Active Courses'); ?></a> |
@@ -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 Quiz Class |
@@ -22,25 +22,25 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param $file |
| 24 | 24 | */ |
| 25 | - public function __construct ( $file = __FILE__ ) { |
|
| 25 | + public function __construct($file = __FILE__) { |
|
| 26 | 26 | $this->file = $file; |
| 27 | 27 | $this->token = 'quiz'; |
| 28 | - $this->meta_fields = array( 'quiz_passmark', 'quiz_lesson', 'quiz_type', 'quiz_grade_type', 'pass_required','enable_quiz_reset' ); |
|
| 29 | - add_action( 'save_post', array( $this, 'update_author' )); |
|
| 28 | + $this->meta_fields = array('quiz_passmark', 'quiz_lesson', 'quiz_type', 'quiz_grade_type', 'pass_required', 'enable_quiz_reset'); |
|
| 29 | + add_action('save_post', array($this, 'update_author')); |
|
| 30 | 30 | |
| 31 | 31 | // listen to the reset button click |
| 32 | - add_action( 'template_redirect', array( $this, 'reset_button_click_listener' ) ); |
|
| 32 | + add_action('template_redirect', array($this, 'reset_button_click_listener')); |
|
| 33 | 33 | |
| 34 | 34 | // fire the complete quiz button submit for grading action |
| 35 | - add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_quiz_submit_listener' ) ); |
|
| 35 | + add_action('sensei_single_quiz_content_inside_before', array($this, 'user_quiz_submit_listener')); |
|
| 36 | 36 | |
| 37 | 37 | // fire the save user answers quiz button click responder |
| 38 | - add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_save_quiz_answers_listener' ) ); |
|
| 38 | + add_action('sensei_single_quiz_content_inside_before', array($this, 'user_save_quiz_answers_listener')); |
|
| 39 | 39 | |
| 40 | 40 | // fire the load global data function |
| 41 | - add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'load_global_quiz_data' ), 80 ); |
|
| 41 | + add_action('sensei_single_quiz_content_inside_before', array($this, 'load_global_quiz_data'), 80); |
|
| 42 | 42 | |
| 43 | - add_action( 'template_redirect', array ( $this, 'quiz_has_no_questions') ); |
|
| 43 | + add_action('template_redirect', array($this, 'quiz_has_no_questions')); |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | } // End __construct() |
@@ -51,25 +51,25 @@ discard block |
||
| 51 | 51 | * @param int $post_id |
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | - public function update_author( $post_id ){ |
|
| 54 | + public function update_author($post_id) { |
|
| 55 | 55 | |
| 56 | 56 | // If this isn't a 'lesson' post, don't update it. |
| 57 | 57 | // if this is a revision don't save it |
| 58 | - if ( isset( $_POST['post_type'] ) && 'lesson' != $_POST['post_type'] |
|
| 59 | - || wp_is_post_revision( $post_id ) ) { |
|
| 58 | + if (isset($_POST['post_type']) && 'lesson' != $_POST['post_type'] |
|
| 59 | + || wp_is_post_revision($post_id)) { |
|
| 60 | 60 | |
| 61 | 61 | return; |
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | // get the lesson author id to be use late |
| 65 | - $saved_post = get_post( $post_id ); |
|
| 66 | - $new_lesson_author_id = $saved_post->post_author; |
|
| 65 | + $saved_post = get_post($post_id); |
|
| 66 | + $new_lesson_author_id = $saved_post->post_author; |
|
| 67 | 67 | |
| 68 | 68 | //get the lessons quiz |
| 69 | - $lesson_quizzes = Sensei()->lesson->lesson_quizzes( $post_id ); |
|
| 70 | - foreach ( (array) $lesson_quizzes as $quiz_item ) { |
|
| 69 | + $lesson_quizzes = Sensei()->lesson->lesson_quizzes($post_id); |
|
| 70 | + foreach ((array) $lesson_quizzes as $quiz_item) { |
|
| 71 | 71 | |
| 72 | - if( ! $quiz_item ) { |
|
| 72 | + if ( ! $quiz_item) { |
|
| 73 | 73 | continue; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | // remove the action so that it doesn't fire again |
| 83 | - remove_action( 'save_post', array( $this, 'update_author' )); |
|
| 83 | + remove_action('save_post', array($this, 'update_author')); |
|
| 84 | 84 | |
| 85 | 85 | // Update the post into the database |
| 86 | - wp_update_post( $my_post ); |
|
| 86 | + wp_update_post($my_post); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | return; |
@@ -97,19 +97,19 @@ discard block |
||
| 97 | 97 | * @param int $quiz_id |
| 98 | 98 | * @return int @lesson_id |
| 99 | 99 | */ |
| 100 | - public function get_lesson_id( $quiz_id ){ |
|
| 100 | + public function get_lesson_id($quiz_id) { |
|
| 101 | 101 | |
| 102 | - if( empty( $quiz_id ) || ! intval( $quiz_id ) > 0 ){ |
|
| 102 | + if (empty($quiz_id) || ! intval($quiz_id) > 0) { |
|
| 103 | 103 | global $post; |
| 104 | - if( 'quiz' == get_post_type( $post ) ){ |
|
| 104 | + if ('quiz' == get_post_type($post)) { |
|
| 105 | 105 | $quiz_id = $post->ID; |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | return false; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $quiz = get_post( $quiz_id ); |
|
| 112 | + $quiz = get_post($quiz_id); |
|
| 113 | 113 | $lesson_id = $quiz->post_parent; |
| 114 | 114 | |
| 115 | 115 | return $lesson_id; |
@@ -124,23 +124,23 @@ discard block |
||
| 124 | 124 | * @since 1.7.3 |
| 125 | 125 | * @return bool $saved; |
| 126 | 126 | */ |
| 127 | - public function user_save_quiz_answers_listener(){ |
|
| 127 | + public function user_save_quiz_answers_listener() { |
|
| 128 | 128 | |
| 129 | - if( ! isset( $_POST[ 'quiz_save' ]) |
|
| 130 | - || !isset( $_POST[ 'sensei_question' ] ) |
|
| 131 | - || empty( $_POST[ 'sensei_question' ] ) |
|
| 132 | - || ! wp_verify_nonce( $_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce' ) > 1 ) { |
|
| 129 | + if ( ! isset($_POST['quiz_save']) |
|
| 130 | + || ! isset($_POST['sensei_question']) |
|
| 131 | + || empty($_POST['sensei_question']) |
|
| 132 | + || ! wp_verify_nonce($_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce') > 1) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | global $post; |
| 137 | - $lesson_id = $this->get_lesson_id( $post->ID ); |
|
| 138 | - $quiz_answers = $_POST[ 'sensei_question' ]; |
|
| 137 | + $lesson_id = $this->get_lesson_id($post->ID); |
|
| 138 | + $quiz_answers = $_POST['sensei_question']; |
|
| 139 | 139 | // call the save function |
| 140 | - self::save_user_answers( $quiz_answers, $_FILES , $lesson_id , get_current_user_id() ); |
|
| 140 | + self::save_user_answers($quiz_answers, $_FILES, $lesson_id, get_current_user_id()); |
|
| 141 | 141 | |
| 142 | 142 | // remove the hook as it should only fire once per click |
| 143 | - remove_action( 'sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener' ); |
|
| 143 | + remove_action('sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener'); |
|
| 144 | 144 | |
| 145 | 145 | } // end user_save_quiz_answers_listener |
| 146 | 146 | |
@@ -159,17 +159,17 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return false or int $answers_saved |
| 161 | 161 | */ |
| 162 | - public static function save_user_answers( $quiz_answers, $files = array(), $lesson_id , $user_id = 0 ){ |
|
| 162 | + public static function save_user_answers($quiz_answers, $files = array(), $lesson_id, $user_id = 0) { |
|
| 163 | 163 | |
| 164 | - if( ! ( $user_id > 0 ) ){ |
|
| 164 | + if ( ! ($user_id > 0)) { |
|
| 165 | 165 | $user_id = get_current_user_id(); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // make sure the parameters are valid before continuing |
| 169 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 170 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 171 | - ||!get_userdata( $user_id ) |
|
| 172 | - || !is_array( $quiz_answers ) ){ |
|
| 169 | + if (empty($lesson_id) || empty($user_id) |
|
| 170 | + || 'lesson' != get_post_type($lesson_id) |
|
| 171 | + ||! get_userdata($user_id) |
|
| 172 | + || ! is_array($quiz_answers)) { |
|
| 173 | 173 | |
| 174 | 174 | return false; |
| 175 | 175 | |
@@ -177,23 +177,23 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | // start the lesson before saving the data in case the user has not started the lesson |
| 180 | - $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id ); |
|
| 180 | + $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id); |
|
| 181 | 181 | |
| 182 | 182 | //prepare the answers |
| 183 | - $prepared_answers = self::prepare_form_submitted_answers( $quiz_answers , $files ); |
|
| 183 | + $prepared_answers = self::prepare_form_submitted_answers($quiz_answers, $files); |
|
| 184 | 184 | |
| 185 | 185 | // save the user data |
| 186 | - $answers_saved = Sensei_Utils::add_user_data( 'quiz_answers', $lesson_id, $prepared_answers, $user_id ) ; |
|
| 186 | + $answers_saved = Sensei_Utils::add_user_data('quiz_answers', $lesson_id, $prepared_answers, $user_id); |
|
| 187 | 187 | |
| 188 | 188 | // were the answers saved correctly? |
| 189 | - if( intval( $answers_saved ) > 0){ |
|
| 189 | + if (intval($answers_saved) > 0) { |
|
| 190 | 190 | |
| 191 | 191 | // save transient to make retrieval faster |
| 192 | 192 | $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id; |
| 193 | - set_transient( $transient_key, $prepared_answers, 10 * DAY_IN_SECONDS ); |
|
| 193 | + set_transient($transient_key, $prepared_answers, 10 * DAY_IN_SECONDS); |
|
| 194 | 194 | |
| 195 | 195 | // update the message showed to user |
| 196 | - Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Saved Successfully.', 'woothemes-sensei' ) . '</div>'; |
|
| 196 | + Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Saved Successfully.', 'woothemes-sensei').'</div>'; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $answers_saved; |
@@ -215,41 +215,41 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return array $answers or false |
| 217 | 217 | */ |
| 218 | - public function get_user_answers( $lesson_id, $user_id ){ |
|
| 218 | + public function get_user_answers($lesson_id, $user_id) { |
|
| 219 | 219 | |
| 220 | 220 | $answers = false; |
| 221 | 221 | |
| 222 | - if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id ) |
|
| 223 | - || ! intval( $user_id ) > 0 || !get_userdata( $user_id ) ) { |
|
| 222 | + if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id) |
|
| 223 | + || ! intval($user_id) > 0 || ! get_userdata($user_id)) { |
|
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // save some time and get the transient cached data |
| 228 | 228 | $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id; |
| 229 | - $transient_cached_answers = get_transient( $transient_key ); |
|
| 229 | + $transient_cached_answers = get_transient($transient_key); |
|
| 230 | 230 | |
| 231 | 231 | // return the transient or get the values get the values from the comment meta |
| 232 | - if( !empty( $transient_cached_answers ) && false != $transient_cached_answers ){ |
|
| 232 | + if ( ! empty($transient_cached_answers) && false != $transient_cached_answers) { |
|
| 233 | 233 | |
| 234 | 234 | $encoded_user_answers = $transient_cached_answers; |
| 235 | 235 | |
| 236 | - }else{ |
|
| 236 | + } else { |
|
| 237 | 237 | |
| 238 | - $encoded_user_answers = Sensei_Utils::get_user_data( 'quiz_answers', $lesson_id , $user_id ); |
|
| 238 | + $encoded_user_answers = Sensei_Utils::get_user_data('quiz_answers', $lesson_id, $user_id); |
|
| 239 | 239 | |
| 240 | 240 | } // end if transient check |
| 241 | 241 | |
| 242 | - if( ! is_array( $encoded_user_answers ) ){ |
|
| 242 | + if ( ! is_array($encoded_user_answers)) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | //set the transient with the new valid data for faster retrieval in future |
| 247 | - set_transient( $transient_key, $encoded_user_answers, 10 * DAY_IN_SECONDS); |
|
| 247 | + set_transient($transient_key, $encoded_user_answers, 10 * DAY_IN_SECONDS); |
|
| 248 | 248 | |
| 249 | 249 | // decode an unserialize all answers |
| 250 | - foreach( $encoded_user_answers as $question_id => $encoded_answer ) { |
|
| 251 | - $decoded_answer = base64_decode( $encoded_answer ); |
|
| 252 | - $answers[$question_id] = maybe_unserialize( $decoded_answer ); |
|
| 250 | + foreach ($encoded_user_answers as $question_id => $encoded_answer) { |
|
| 251 | + $decoded_answer = base64_decode($encoded_answer); |
|
| 252 | + $answers[$question_id] = maybe_unserialize($decoded_answer); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | return $answers; |
@@ -266,23 +266,23 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @return void; |
| 268 | 268 | */ |
| 269 | - public function reset_button_click_listener( ){ |
|
| 269 | + public function reset_button_click_listener( ) { |
|
| 270 | 270 | |
| 271 | - if( ! isset( $_POST[ 'quiz_reset' ]) |
|
| 272 | - || ! wp_verify_nonce( $_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce' ) > 1 ) { |
|
| 271 | + if ( ! isset($_POST['quiz_reset']) |
|
| 272 | + || ! wp_verify_nonce($_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce') > 1) { |
|
| 273 | 273 | |
| 274 | 274 | return; // exit |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | global $post; |
| 278 | 278 | $current_quiz_id = $post->ID; |
| 279 | - $lesson_id = $this->get_lesson_id( $current_quiz_id ); |
|
| 279 | + $lesson_id = $this->get_lesson_id($current_quiz_id); |
|
| 280 | 280 | |
| 281 | 281 | // reset all user data |
| 282 | - $this->reset_user_lesson_data( $lesson_id, get_current_user_id() ); |
|
| 282 | + $this->reset_user_lesson_data($lesson_id, get_current_user_id()); |
|
| 283 | 283 | |
| 284 | 284 | //this function should only run once |
| 285 | - remove_action( 'template_redirect', array( $this, 'reset_button_click_listener' ) ); |
|
| 285 | + remove_action('template_redirect', array($this, 'reset_button_click_listener')); |
|
| 286 | 286 | |
| 287 | 287 | } // end reset_button_click_listener |
| 288 | 288 | |
@@ -301,18 +301,18 @@ discard block |
||
| 301 | 301 | public function user_quiz_submit_listener() { |
| 302 | 302 | |
| 303 | 303 | // only respond to valid quiz completion submissions |
| 304 | - if( ! isset( $_POST[ 'quiz_complete' ]) |
|
| 305 | - || !isset( $_POST[ 'sensei_question' ] ) |
|
| 306 | - || empty( $_POST[ 'sensei_question' ] ) |
|
| 307 | - || ! wp_verify_nonce( $_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce' ) > 1 ) { |
|
| 304 | + if ( ! isset($_POST['quiz_complete']) |
|
| 305 | + || ! isset($_POST['sensei_question']) |
|
| 306 | + || empty($_POST['sensei_question']) |
|
| 307 | + || ! wp_verify_nonce($_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce') > 1) { |
|
| 308 | 308 | return; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | global $post, $current_user; |
| 312 | - $lesson_id = $this->get_lesson_id( $post->ID ); |
|
| 313 | - $quiz_answers = $_POST[ 'sensei_question' ]; |
|
| 312 | + $lesson_id = $this->get_lesson_id($post->ID); |
|
| 313 | + $quiz_answers = $_POST['sensei_question']; |
|
| 314 | 314 | |
| 315 | - self::submit_answers_for_grading( $quiz_answers, $_FILES , $lesson_id , $current_user->ID ); |
|
| 315 | + self::submit_answers_for_grading($quiz_answers, $_FILES, $lesson_id, $current_user->ID); |
|
| 316 | 316 | |
| 317 | 317 | } // End sensei_complete_quiz() |
| 318 | 318 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @access public |
| 327 | 327 | * |
| 328 | 328 | */ |
| 329 | - public function load_global_quiz_data(){ |
|
| 329 | + public function load_global_quiz_data() { |
|
| 330 | 330 | |
| 331 | 331 | global $post, $current_user; |
| 332 | 332 | $this->data = new stdClass(); |
@@ -335,46 +335,46 @@ discard block |
||
| 335 | 335 | $grade = 0; |
| 336 | 336 | |
| 337 | 337 | // Get Quiz Questions |
| 338 | - $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $post->ID ); |
|
| 338 | + $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($post->ID); |
|
| 339 | 339 | |
| 340 | - $quiz_lesson_id = absint( get_post_meta( $post->ID, '_quiz_lesson', true ) ); |
|
| 340 | + $quiz_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true)); |
|
| 341 | 341 | |
| 342 | 342 | // Get quiz grade type |
| 343 | - $quiz_grade_type = get_post_meta( $post->ID, '_quiz_grade_type', true ); |
|
| 343 | + $quiz_grade_type = get_post_meta($post->ID, '_quiz_grade_type', true); |
|
| 344 | 344 | |
| 345 | 345 | // Get quiz pass setting |
| 346 | - $pass_required = get_post_meta( $post->ID, '_pass_required', true ); |
|
| 346 | + $pass_required = get_post_meta($post->ID, '_pass_required', true); |
|
| 347 | 347 | |
| 348 | 348 | // Get quiz pass mark |
| 349 | - $quiz_passmark = abs( round( doubleval( get_post_meta( $post->ID, '_quiz_passmark', true ) ), 2 ) ); |
|
| 349 | + $quiz_passmark = abs(round(doubleval(get_post_meta($post->ID, '_quiz_passmark', true)), 2)); |
|
| 350 | 350 | |
| 351 | 351 | // Get latest quiz answers and grades |
| 352 | - $lesson_id = Sensei()->quiz->get_lesson_id( $post->ID ); |
|
| 353 | - $user_quizzes = Sensei()->quiz->get_user_answers( $lesson_id, get_current_user_id() ); |
|
| 354 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $current_user->ID ); |
|
| 352 | + $lesson_id = Sensei()->quiz->get_lesson_id($post->ID); |
|
| 353 | + $user_quizzes = Sensei()->quiz->get_user_answers($lesson_id, get_current_user_id()); |
|
| 354 | + $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $current_user->ID); |
|
| 355 | 355 | $user_quiz_grade = 0; |
| 356 | - if( isset( $user_lesson_status->comment_ID ) ) { |
|
| 357 | - $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); |
|
| 356 | + if (isset($user_lesson_status->comment_ID)) { |
|
| 357 | + $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if ( ! is_array($user_quizzes) ) { $user_quizzes = array(); } |
|
| 360 | + if ( ! is_array($user_quizzes)) { $user_quizzes = array(); } |
|
| 361 | 361 | |
| 362 | 362 | // Check again that the lesson is complete |
| 363 | - $user_lesson_end = Sensei_Utils::user_completed_lesson( $user_lesson_status ); |
|
| 363 | + $user_lesson_end = Sensei_Utils::user_completed_lesson($user_lesson_status); |
|
| 364 | 364 | $user_lesson_complete = false; |
| 365 | - if ( $user_lesson_end ) { |
|
| 365 | + if ($user_lesson_end) { |
|
| 366 | 366 | $user_lesson_complete = true; |
| 367 | 367 | } // End If Statement |
| 368 | 368 | |
| 369 | - $reset_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true ); |
|
| 369 | + $reset_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true); |
|
| 370 | 370 | //backwards compatibility |
| 371 | - if( 'on' == $reset_allowed ) { |
|
| 371 | + if ('on' == $reset_allowed) { |
|
| 372 | 372 | $reset_allowed = 1; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | // Build frontend data object for backwards compatibility |
| 376 | 376 | // using this is no longer recommended |
| 377 | - $this->data->user_quiz_grade = $user_quiz_grade;// Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
| 377 | + $this->data->user_quiz_grade = $user_quiz_grade; // Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
| 378 | 378 | $this->data->quiz_passmark = $quiz_passmark; |
| 379 | 379 | $this->data->quiz_lesson = $quiz_lesson_id; |
| 380 | 380 | $this->data->quiz_grade_type = $quiz_grade_type; // get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
@@ -399,41 +399,41 @@ discard block |
||
| 399 | 399 | * @param $files |
| 400 | 400 | * @return array |
| 401 | 401 | */ |
| 402 | - public static function prepare_form_submitted_answers( $unprepared_answers, $files ){ |
|
| 402 | + public static function prepare_form_submitted_answers($unprepared_answers, $files) { |
|
| 403 | 403 | |
| 404 | 404 | |
| 405 | 405 | $prepared_answers = array(); |
| 406 | 406 | |
| 407 | 407 | // validate incoming answers |
| 408 | - if( empty( $unprepared_answers ) || ! is_array( $unprepared_answers ) ){ |
|
| 408 | + if (empty($unprepared_answers) || ! is_array($unprepared_answers)) { |
|
| 409 | 409 | return false; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // Loop through submitted quiz answers and save them appropriately |
| 413 | - foreach( $unprepared_answers as $question_id => $answer ) { |
|
| 413 | + foreach ($unprepared_answers as $question_id => $answer) { |
|
| 414 | 414 | |
| 415 | 415 | //get the current questions question type |
| 416 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 416 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 417 | 417 | |
| 418 | 418 | // Sanitise answer |
| 419 | - if( 0 == get_magic_quotes_gpc() ) { |
|
| 420 | - $answer = wp_unslash( $answer ); |
|
| 419 | + if (0 == get_magic_quotes_gpc()) { |
|
| 420 | + $answer = wp_unslash($answer); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | // compress the answer for saving |
| 424 | - if( 'multi-line' == $question_type ) { |
|
| 425 | - $answer = esc_html( $answer ); |
|
| 426 | - }elseif( 'file-upload' == $question_type ){ |
|
| 427 | - $file_key = 'file_upload_' . $question_id; |
|
| 428 | - if( isset( $files[ $file_key ] ) ) { |
|
| 429 | - $attachment_id = Sensei_Utils::upload_file( $files[ $file_key ] ); |
|
| 430 | - if( $attachment_id ) { |
|
| 424 | + if ('multi-line' == $question_type) { |
|
| 425 | + $answer = esc_html($answer); |
|
| 426 | + }elseif ('file-upload' == $question_type) { |
|
| 427 | + $file_key = 'file_upload_'.$question_id; |
|
| 428 | + if (isset($files[$file_key])) { |
|
| 429 | + $attachment_id = Sensei_Utils::upload_file($files[$file_key]); |
|
| 430 | + if ($attachment_id) { |
|
| 431 | 431 | $answer = $attachment_id; |
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | } // end if |
| 435 | 435 | |
| 436 | - $prepared_answers[ $question_id ] = base64_encode( maybe_serialize( $answer ) ); |
|
| 436 | + $prepared_answers[$question_id] = base64_encode(maybe_serialize($answer)); |
|
| 437 | 437 | |
| 438 | 438 | }// end for each $quiz_answers |
| 439 | 439 | |
@@ -453,54 +453,54 @@ discard block |
||
| 453 | 453 | * @param int $user_id |
| 454 | 454 | * @param int $lesson_id |
| 455 | 455 | */ |
| 456 | - public function reset_user_lesson_data( $lesson_id , $user_id = 0 ){ |
|
| 456 | + public function reset_user_lesson_data($lesson_id, $user_id = 0) { |
|
| 457 | 457 | |
| 458 | 458 | //make sure the parameters are valid |
| 459 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 460 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 461 | - || ! get_userdata( $user_id ) ){ |
|
| 459 | + if (empty($lesson_id) || empty($user_id) |
|
| 460 | + || 'lesson' != get_post_type($lesson_id) |
|
| 461 | + || ! get_userdata($user_id)) { |
|
| 462 | 462 | return false; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | |
| 466 | 466 | |
| 467 | 467 | //get the users lesson status to make |
| 468 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
| 469 | - if( ! isset( $user_lesson_status->comment_ID ) ) { |
|
| 468 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
| 469 | + if ( ! isset($user_lesson_status->comment_ID)) { |
|
| 470 | 470 | // this user is not taking this lesson so this process is not needed |
| 471 | 471 | return false; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | //get the lesson quiz and course |
| 475 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 476 | - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 475 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 476 | + $course_id = Sensei()->lesson->get_course_id($lesson_id); |
|
| 477 | 477 | |
| 478 | 478 | // reset the transients |
| 479 | 479 | $answers_transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id; |
| 480 | 480 | $grades_transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id; |
| 481 | 481 | $answers_feedback_transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id; |
| 482 | - delete_transient( $answers_transient_key ); |
|
| 483 | - delete_transient( $grades_transient_key ); |
|
| 484 | - delete_transient( $answers_feedback_transient_key ); |
|
| 482 | + delete_transient($answers_transient_key); |
|
| 483 | + delete_transient($grades_transient_key); |
|
| 484 | + delete_transient($answers_feedback_transient_key); |
|
| 485 | 485 | |
| 486 | 486 | // reset the quiz answers and feedback notes |
| 487 | - $deleted_answers = Sensei_Utils::delete_user_data( 'quiz_answers', $lesson_id, $user_id ); |
|
| 488 | - $deleted_grades = Sensei_Utils::delete_user_data( 'quiz_grades', $lesson_id, $user_id ); |
|
| 489 | - $deleted_user_feedback = Sensei_Utils::delete_user_data( 'quiz_answers_feedback', $lesson_id, $user_id ); |
|
| 487 | + $deleted_answers = Sensei_Utils::delete_user_data('quiz_answers', $lesson_id, $user_id); |
|
| 488 | + $deleted_grades = Sensei_Utils::delete_user_data('quiz_grades', $lesson_id, $user_id); |
|
| 489 | + $deleted_user_feedback = Sensei_Utils::delete_user_data('quiz_answers_feedback', $lesson_id, $user_id); |
|
| 490 | 490 | |
| 491 | 491 | // Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade |
| 492 | - Sensei_Utils::sensei_delete_quiz_answers( $quiz_id, $user_id ); |
|
| 492 | + Sensei_Utils::sensei_delete_quiz_answers($quiz_id, $user_id); |
|
| 493 | 493 | |
| 494 | - Sensei_Utils::update_lesson_status( $user_id , $lesson_id, 'in-progress', array( 'questions_asked' => '', 'grade' => '' ) ); |
|
| 494 | + Sensei_Utils::update_lesson_status($user_id, $lesson_id, 'in-progress', array('questions_asked' => '', 'grade' => '')); |
|
| 495 | 495 | |
| 496 | 496 | // Update course completion |
| 497 | - Sensei_Utils::update_course_status( $user_id, $course_id ); |
|
| 497 | + Sensei_Utils::update_course_status($user_id, $course_id); |
|
| 498 | 498 | |
| 499 | 499 | // Run any action on quiz/lesson reset (previously this didn't occur on resetting a quiz, see resetting a lesson in sensei_complete_lesson() |
| 500 | - do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id ); |
|
| 501 | - Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Reset Successfully.', 'woothemes-sensei' ) . '</div>'; |
|
| 500 | + do_action('sensei_user_lesson_reset', $user_id, $lesson_id); |
|
| 501 | + Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Reset Successfully.', 'woothemes-sensei').'</div>'; |
|
| 502 | 502 | |
| 503 | - return ( $deleted_answers && $deleted_grades ) ; |
|
| 503 | + return ($deleted_answers && $deleted_grades); |
|
| 504 | 504 | |
| 505 | 505 | } // end reset_user_lesson_data |
| 506 | 506 | |
@@ -520,20 +520,20 @@ discard block |
||
| 520 | 520 | * |
| 521 | 521 | * @return bool $answers_submitted |
| 522 | 522 | */ |
| 523 | - public static function submit_answers_for_grading( $quiz_answers , $files = array() , $lesson_id , $user_id = 0 ){ |
|
| 523 | + public static function submit_answers_for_grading($quiz_answers, $files = array(), $lesson_id, $user_id = 0) { |
|
| 524 | 524 | |
| 525 | 525 | $answers_submitted = false; |
| 526 | 526 | |
| 527 | 527 | // get the user_id if none was passed in use the current logged in user |
| 528 | - if( ! intval( $user_id ) > 0 ) { |
|
| 528 | + if ( ! intval($user_id) > 0) { |
|
| 529 | 529 | $user_id = get_current_user_id(); |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | // make sure the parameters are valid before continuing |
| 533 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 534 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 535 | - ||!get_userdata( $user_id ) |
|
| 536 | - || !is_array( $quiz_answers ) ){ |
|
| 533 | + if (empty($lesson_id) || empty($user_id) |
|
| 534 | + || 'lesson' != get_post_type($lesson_id) |
|
| 535 | + ||! get_userdata($user_id) |
|
| 536 | + || ! is_array($quiz_answers)) { |
|
| 537 | 537 | |
| 538 | 538 | return false; |
| 539 | 539 | |
@@ -543,38 +543,38 @@ discard block |
||
| 543 | 543 | $grade = 0; |
| 544 | 544 | |
| 545 | 545 | // Get Quiz ID |
| 546 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 546 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 547 | 547 | |
| 548 | 548 | // Get quiz grade type |
| 549 | - $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
|
| 549 | + $quiz_grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true); |
|
| 550 | 550 | |
| 551 | 551 | // Get quiz pass setting |
| 552 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
| 552 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
| 553 | 553 | |
| 554 | 554 | // Get the minimum percentage need to pass this quiz |
| 555 | - $quiz_pass_percentage = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) ); |
|
| 555 | + $quiz_pass_percentage = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2)); |
|
| 556 | 556 | |
| 557 | 557 | // Handle Quiz Questions asked |
| 558 | 558 | // This is to ensure we save the questions that we've asked this user and that this can't be change unless |
| 559 | 559 | // the quiz is reset by admin or user( user: only if the setting is enabled ). |
| 560 | 560 | // get the questions asked when when the quiz questions were generated for the user : Sensei_Lesson::lesson_quiz_questions |
| 561 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
| 562 | - $questions_asked = get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ); |
|
| 563 | - if( empty( $questions_asked ) ){ |
|
| 561 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
| 562 | + $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true); |
|
| 563 | + if (empty($questions_asked)) { |
|
| 564 | 564 | |
| 565 | - $questions_asked = array_keys( $quiz_answers ); |
|
| 566 | - $questions_asked_string = implode( ',', $questions_asked ); |
|
| 565 | + $questions_asked = array_keys($quiz_answers); |
|
| 566 | + $questions_asked_string = implode(',', $questions_asked); |
|
| 567 | 567 | |
| 568 | 568 | // Save questions that were asked in this quiz |
| 569 | - update_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string ); |
|
| 569 | + update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string); |
|
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | // Save Quiz Answers for grading, the save function also calls the sensei_start_lesson |
| 574 | - self::save_user_answers( $quiz_answers , $files , $lesson_id , $user_id ); |
|
| 574 | + self::save_user_answers($quiz_answers, $files, $lesson_id, $user_id); |
|
| 575 | 575 | |
| 576 | 576 | // Grade quiz |
| 577 | - $grade = Sensei_Grading::grade_quiz_auto( $quiz_id, $quiz_answers, 0 , $quiz_grade_type ); |
|
| 577 | + $grade = Sensei_Grading::grade_quiz_auto($quiz_id, $quiz_answers, 0, $quiz_grade_type); |
|
| 578 | 578 | |
| 579 | 579 | // Get Lesson Grading Setting |
| 580 | 580 | $lesson_metadata = array(); |
@@ -584,13 +584,13 @@ discard block |
||
| 584 | 584 | $answers_submitted = true; |
| 585 | 585 | |
| 586 | 586 | // if this condition is false the quiz should manually be graded by admin |
| 587 | - if ('auto' == $quiz_grade_type && ! is_wp_error( $grade ) ) { |
|
| 587 | + if ('auto' == $quiz_grade_type && ! is_wp_error($grade)) { |
|
| 588 | 588 | |
| 589 | 589 | // Quiz has been automatically Graded |
| 590 | - if ( 'on' == $pass_required ) { |
|
| 590 | + if ('on' == $pass_required) { |
|
| 591 | 591 | |
| 592 | 592 | // Student has reached the pass mark and lesson is complete |
| 593 | - if ( $quiz_pass_percentage <= $grade ) { |
|
| 593 | + if ($quiz_pass_percentage <= $grade) { |
|
| 594 | 594 | |
| 595 | 595 | $lesson_status = 'passed'; |
| 596 | 596 | |
@@ -611,9 +611,9 @@ discard block |
||
| 611 | 611 | |
| 612 | 612 | } // end if ! is_wp_error( $grade ... |
| 613 | 613 | |
| 614 | - Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $lesson_status, $lesson_metadata ); |
|
| 614 | + Sensei_Utils::update_lesson_status($user_id, $lesson_id, $lesson_status, $lesson_metadata); |
|
| 615 | 615 | |
| 616 | - if( 'passed' == $lesson_status || 'graded' == $lesson_status ){ |
|
| 616 | + if ('passed' == $lesson_status || 'graded' == $lesson_status) { |
|
| 617 | 617 | |
| 618 | 618 | /** |
| 619 | 619 | * Lesson end action hook |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | * @param int $user_id |
| 624 | 624 | * @param int $lesson_id |
| 625 | 625 | */ |
| 626 | - do_action( 'sensei_user_lesson_end', $user_id, $lesson_id ); |
|
| 626 | + do_action('sensei_user_lesson_end', $user_id, $lesson_id); |
|
| 627 | 627 | |
| 628 | 628 | } |
| 629 | 629 | |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | * @param string $quiz_pass_percentage |
| 640 | 640 | * @param string $quiz_grade_type |
| 641 | 641 | */ |
| 642 | - do_action( 'sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type ); |
|
| 642 | + do_action('sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type); |
|
| 643 | 643 | |
| 644 | 644 | return $answers_submitted; |
| 645 | 645 | |
@@ -659,38 +659,38 @@ discard block |
||
| 659 | 659 | * |
| 660 | 660 | * @return bool $answers_submitted |
| 661 | 661 | */ |
| 662 | - public function get_user_question_answer( $lesson_id, $question_id, $user_id = 0 ){ |
|
| 662 | + public function get_user_question_answer($lesson_id, $question_id, $user_id = 0) { |
|
| 663 | 663 | |
| 664 | 664 | // parameter validation |
| 665 | - if( empty( $lesson_id ) || empty( $question_id ) |
|
| 666 | - || ! ( intval( $lesson_id ) > 0 ) |
|
| 667 | - || ! ( intval( $question_id ) > 0 ) |
|
| 668 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 669 | - || 'question' != get_post_type( $question_id )) { |
|
| 665 | + if (empty($lesson_id) || empty($question_id) |
|
| 666 | + || ! (intval($lesson_id) > 0) |
|
| 667 | + || ! (intval($question_id) > 0) |
|
| 668 | + || 'lesson' != get_post_type($lesson_id) |
|
| 669 | + || 'question' != get_post_type($question_id)) { |
|
| 670 | 670 | |
| 671 | 671 | return false; |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - if( ! ( intval( $user_id ) > 0 ) ){ |
|
| 674 | + if ( ! (intval($user_id) > 0)) { |
|
| 675 | 675 | $user_id = get_current_user_id(); |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - $users_answers = $this->get_user_answers( $lesson_id, $user_id ); |
|
| 678 | + $users_answers = $this->get_user_answers($lesson_id, $user_id); |
|
| 679 | 679 | |
| 680 | - if( !$users_answers || empty( $users_answers ) |
|
| 681 | - || ! is_array( $users_answers ) || ! isset( $users_answers[ $question_id ] ) ){ |
|
| 680 | + if ( ! $users_answers || empty($users_answers) |
|
| 681 | + || ! is_array($users_answers) || ! isset($users_answers[$question_id])) { |
|
| 682 | 682 | |
| 683 | 683 | //Fallback for pre 1.7.4 data |
| 684 | - $comment = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ), true ); |
|
| 684 | + $comment = Sensei_Utils::sensei_check_for_activity(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer'), true); |
|
| 685 | 685 | |
| 686 | - if( ! isset( $comment->comment_content ) ){ |
|
| 686 | + if ( ! isset($comment->comment_content)) { |
|
| 687 | 687 | return false; |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - return maybe_unserialize( base64_decode( $comment->comment_content ) ); |
|
| 690 | + return maybe_unserialize(base64_decode($comment->comment_content)); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - return $users_answers[ $question_id ]; |
|
| 693 | + return $users_answers[$question_id]; |
|
| 694 | 694 | |
| 695 | 695 | }// end get_user_question_answer |
| 696 | 696 | |
@@ -711,18 +711,18 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @return bool |
| 713 | 713 | */ |
| 714 | - public function set_user_grades( $quiz_grades, $lesson_id, $user_id = 0 ){ |
|
| 714 | + public function set_user_grades($quiz_grades, $lesson_id, $user_id = 0) { |
|
| 715 | 715 | |
| 716 | 716 | // get the user_id if none was passed in use the current logged in user |
| 717 | - if( ! intval( $user_id ) > 0 ) { |
|
| 717 | + if ( ! intval($user_id) > 0) { |
|
| 718 | 718 | $user_id = get_current_user_id(); |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | // make sure the parameters are valid before continuing |
| 722 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 723 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 724 | - ||!get_userdata( $user_id ) |
|
| 725 | - || !is_array( $quiz_grades ) ){ |
|
| 722 | + if (empty($lesson_id) || empty($user_id) |
|
| 723 | + || 'lesson' != get_post_type($lesson_id) |
|
| 724 | + ||! get_userdata($user_id) |
|
| 725 | + || ! is_array($quiz_grades)) { |
|
| 726 | 726 | |
| 727 | 727 | return false; |
| 728 | 728 | |
@@ -731,15 +731,15 @@ discard block |
||
| 731 | 731 | $success = false; |
| 732 | 732 | |
| 733 | 733 | // save that data for the user on the lesson comment meta |
| 734 | - $comment_meta_id = Sensei_Utils::add_user_data( 'quiz_grades', $lesson_id, $quiz_grades, $user_id ); |
|
| 734 | + $comment_meta_id = Sensei_Utils::add_user_data('quiz_grades', $lesson_id, $quiz_grades, $user_id); |
|
| 735 | 735 | |
| 736 | 736 | // were the grades save successfully ? |
| 737 | - if( intval( $comment_meta_id ) > 0 ) { |
|
| 737 | + if (intval($comment_meta_id) > 0) { |
|
| 738 | 738 | |
| 739 | 739 | $success = true; |
| 740 | 740 | // save transient |
| 741 | - $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id; |
|
| 742 | - set_transient( $transient_key, $quiz_grades, 10 * DAY_IN_SECONDS ); |
|
| 741 | + $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id; |
|
| 742 | + set_transient($transient_key, $quiz_grades, 10 * DAY_IN_SECONDS); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | return $success; |
@@ -758,36 +758,36 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @return array $user_quiz_grades or false if none exists for this users |
| 760 | 760 | */ |
| 761 | - public function get_user_grades( $lesson_id, $user_id = 0 ){ |
|
| 761 | + public function get_user_grades($lesson_id, $user_id = 0) { |
|
| 762 | 762 | |
| 763 | 763 | $user_grades = array(); |
| 764 | 764 | |
| 765 | 765 | // get the user_id if none was passed in use the current logged in user |
| 766 | - if( ! intval( $user_id ) > 0 ) { |
|
| 766 | + if ( ! intval($user_id) > 0) { |
|
| 767 | 767 | $user_id = get_current_user_id(); |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id ) |
|
| 771 | - || ! intval( $user_id ) > 0 || !get_userdata( $user_id ) ) { |
|
| 770 | + if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id) |
|
| 771 | + || ! intval($user_id) > 0 || ! get_userdata($user_id)) { |
|
| 772 | 772 | return false; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | // save some time and get the transient cached data |
| 776 | - $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id; |
|
| 777 | - $user_grades = get_transient( $transient_key ); |
|
| 776 | + $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id; |
|
| 777 | + $user_grades = get_transient($transient_key); |
|
| 778 | 778 | |
| 779 | 779 | // get the data if nothing was stored in the transient |
| 780 | - if( empty( $user_grades ) || false != $user_grades ){ |
|
| 780 | + if (empty($user_grades) || false != $user_grades) { |
|
| 781 | 781 | |
| 782 | - $user_grades = Sensei_Utils::get_user_data( 'quiz_grades', $lesson_id, $user_id ); |
|
| 782 | + $user_grades = Sensei_Utils::get_user_data('quiz_grades', $lesson_id, $user_id); |
|
| 783 | 783 | |
| 784 | 784 | //set the transient with the new valid data for faster retrieval in future |
| 785 | - set_transient( $transient_key, $user_grades, 10 * DAY_IN_SECONDS ); |
|
| 785 | + set_transient($transient_key, $user_grades, 10 * DAY_IN_SECONDS); |
|
| 786 | 786 | |
| 787 | 787 | } // end if transient check |
| 788 | 788 | |
| 789 | 789 | // if there is no data for this user |
| 790 | - if( ! is_array( $user_grades ) ){ |
|
| 790 | + if ( ! is_array($user_grades)) { |
|
| 791 | 791 | return false; |
| 792 | 792 | } |
| 793 | 793 | |
@@ -810,21 +810,21 @@ discard block |
||
| 810 | 810 | * |
| 811 | 811 | * @return bool $question_grade |
| 812 | 812 | */ |
| 813 | - public function get_user_question_grade( $lesson_id, $question_id, $user_id = 0 ){ |
|
| 813 | + public function get_user_question_grade($lesson_id, $question_id, $user_id = 0) { |
|
| 814 | 814 | |
| 815 | 815 | // parameter validation |
| 816 | - if( empty( $lesson_id ) || empty( $question_id ) |
|
| 817 | - || ! ( intval( $lesson_id ) > 0 ) |
|
| 818 | - || ! ( intval( $question_id ) > 0 ) |
|
| 819 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 820 | - || 'question' != get_post_type( $question_id )) { |
|
| 816 | + if (empty($lesson_id) || empty($question_id) |
|
| 817 | + || ! (intval($lesson_id) > 0) |
|
| 818 | + || ! (intval($question_id) > 0) |
|
| 819 | + || 'lesson' != get_post_type($lesson_id) |
|
| 820 | + || 'question' != get_post_type($question_id)) { |
|
| 821 | 821 | |
| 822 | 822 | return false; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - $all_user_grades = self::get_user_grades( $lesson_id,$user_id ); |
|
| 825 | + $all_user_grades = self::get_user_grades($lesson_id, $user_id); |
|
| 826 | 826 | |
| 827 | - if( ! $all_user_grades || ! isset( $all_user_grades[ $question_id ] ) ){ |
|
| 827 | + if ( ! $all_user_grades || ! isset($all_user_grades[$question_id])) { |
|
| 828 | 828 | |
| 829 | 829 | //fallback to data pre 1.7.4 |
| 830 | 830 | $args = array( |
@@ -833,17 +833,17 @@ discard block |
||
| 833 | 833 | 'type' => 'sensei_user_answer' |
| 834 | 834 | ); |
| 835 | 835 | |
| 836 | - $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true ); |
|
| 836 | + $question_activity = Sensei_Utils::sensei_check_for_activity($args, true); |
|
| 837 | 837 | $fall_back_grade = false; |
| 838 | - if( isset( $question_activity->comment_ID ) ){ |
|
| 839 | - $fall_back_grade = get_comment_meta( $question_activity->comment_ID , 'user_grade', true ); |
|
| 838 | + if (isset($question_activity->comment_ID)) { |
|
| 839 | + $fall_back_grade = get_comment_meta($question_activity->comment_ID, 'user_grade', true); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | return $fall_back_grade; |
| 843 | 843 | |
| 844 | 844 | } // end if $all_user_grades... |
| 845 | 845 | |
| 846 | - return $all_user_grades[ $question_id ]; |
|
| 846 | + return $all_user_grades[$question_id]; |
|
| 847 | 847 | |
| 848 | 848 | }// end get_user_question_grade |
| 849 | 849 | |
@@ -865,13 +865,13 @@ discard block |
||
| 865 | 865 | * |
| 866 | 866 | * @return false or int $feedback_saved |
| 867 | 867 | */ |
| 868 | - public function save_user_answers_feedback( $answers_feedback, $lesson_id , $user_id = 0 ){ |
|
| 868 | + public function save_user_answers_feedback($answers_feedback, $lesson_id, $user_id = 0) { |
|
| 869 | 869 | |
| 870 | 870 | // make sure the parameters are valid before continuing |
| 871 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 872 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 873 | - ||!get_userdata( $user_id ) |
|
| 874 | - || !is_array( $answers_feedback ) ){ |
|
| 871 | + if (empty($lesson_id) || empty($user_id) |
|
| 872 | + || 'lesson' != get_post_type($lesson_id) |
|
| 873 | + ||! get_userdata($user_id) |
|
| 874 | + || ! is_array($answers_feedback)) { |
|
| 875 | 875 | |
| 876 | 876 | return false; |
| 877 | 877 | |
@@ -879,25 +879,25 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | |
| 881 | 881 | // check if the lesson is started before saving, if not start the lesson for the user |
| 882 | - if ( !( 0 < intval( Sensei_Utils::user_started_lesson( $lesson_id, $user_id) ) ) ) { |
|
| 883 | - Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id ); |
|
| 882 | + if ( ! (0 < intval(Sensei_Utils::user_started_lesson($lesson_id, $user_id)))) { |
|
| 883 | + Sensei_Utils::sensei_start_lesson($lesson_id, $user_id); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | // encode the feedback |
| 887 | - $encoded_answers_feedback = array(); |
|
| 888 | - foreach( $answers_feedback as $question_id => $feedback ){ |
|
| 889 | - $encoded_answers_feedback[ $question_id ] = base64_encode( $feedback ); |
|
| 887 | + $encoded_answers_feedback = array(); |
|
| 888 | + foreach ($answers_feedback as $question_id => $feedback) { |
|
| 889 | + $encoded_answers_feedback[$question_id] = base64_encode($feedback); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // save the user data |
| 893 | - $feedback_saved = Sensei_Utils::add_user_data( 'quiz_answers_feedback', $lesson_id , $encoded_answers_feedback, $user_id ) ; |
|
| 893 | + $feedback_saved = Sensei_Utils::add_user_data('quiz_answers_feedback', $lesson_id, $encoded_answers_feedback, $user_id); |
|
| 894 | 894 | |
| 895 | 895 | //Were the the question feedback save correctly? |
| 896 | - if( intval( $feedback_saved ) > 0){ |
|
| 896 | + if (intval($feedback_saved) > 0) { |
|
| 897 | 897 | |
| 898 | 898 | // save transient to make retrieval faster in future |
| 899 | 899 | $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id; |
| 900 | - set_transient( $transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS ); |
|
| 900 | + set_transient($transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS); |
|
| 901 | 901 | |
| 902 | 902 | } |
| 903 | 903 | |
@@ -922,42 +922,42 @@ discard block |
||
| 922 | 922 | * $type string $question_feedback |
| 923 | 923 | * } |
| 924 | 924 | */ |
| 925 | - public function get_user_answers_feedback( $lesson_id , $user_id = 0 ){ |
|
| 925 | + public function get_user_answers_feedback($lesson_id, $user_id = 0) { |
|
| 926 | 926 | |
| 927 | 927 | $answers_feedback = array(); |
| 928 | 928 | |
| 929 | 929 | // get the user_id if none was passed in use the current logged in user |
| 930 | - if( ! intval( $user_id ) > 0 ) { |
|
| 930 | + if ( ! intval($user_id) > 0) { |
|
| 931 | 931 | $user_id = get_current_user_id(); |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id ) |
|
| 935 | - || ! intval( $user_id ) > 0 || !get_userdata( $user_id ) ) { |
|
| 934 | + if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id) |
|
| 935 | + || ! intval($user_id) > 0 || ! get_userdata($user_id)) { |
|
| 936 | 936 | return false; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | // first check the transient to save a few split seconds |
| 940 | 940 | $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id; |
| 941 | - $encoded_feedback = get_transient( $transient_key ); |
|
| 941 | + $encoded_feedback = get_transient($transient_key); |
|
| 942 | 942 | |
| 943 | 943 | // get the data if nothing was stored in the transient |
| 944 | - if( empty( $encoded_feedback ) || !$encoded_feedback ){ |
|
| 944 | + if (empty($encoded_feedback) || ! $encoded_feedback) { |
|
| 945 | 945 | |
| 946 | - $encoded_feedback = Sensei_Utils::get_user_data( 'quiz_answers_feedback', $lesson_id, $user_id ); |
|
| 946 | + $encoded_feedback = Sensei_Utils::get_user_data('quiz_answers_feedback', $lesson_id, $user_id); |
|
| 947 | 947 | |
| 948 | 948 | //set the transient with the new valid data for faster retrieval in future |
| 949 | - set_transient( $transient_key, $encoded_feedback, 10 * DAY_IN_SECONDS); |
|
| 949 | + set_transient($transient_key, $encoded_feedback, 10 * DAY_IN_SECONDS); |
|
| 950 | 950 | |
| 951 | 951 | } // end if transient check |
| 952 | 952 | |
| 953 | 953 | // if there is no data for this user |
| 954 | - if( ! is_array( $encoded_feedback ) ){ |
|
| 954 | + if ( ! is_array($encoded_feedback)) { |
|
| 955 | 955 | return false; |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - foreach( $encoded_feedback as $question_id => $feedback ){ |
|
| 958 | + foreach ($encoded_feedback as $question_id => $feedback) { |
|
| 959 | 959 | |
| 960 | - $answers_feedback[ $question_id ] = base64_decode( $feedback ); |
|
| 960 | + $answers_feedback[$question_id] = base64_decode($feedback); |
|
| 961 | 961 | |
| 962 | 962 | } |
| 963 | 963 | |
@@ -980,25 +980,25 @@ discard block |
||
| 980 | 980 | * |
| 981 | 981 | * @return string $feedback or bool if false |
| 982 | 982 | */ |
| 983 | - public function get_user_question_feedback( $lesson_id, $question_id, $user_id = 0 ){ |
|
| 983 | + public function get_user_question_feedback($lesson_id, $question_id, $user_id = 0) { |
|
| 984 | 984 | |
| 985 | 985 | $feedback = false; |
| 986 | 986 | |
| 987 | 987 | // parameter validation |
| 988 | - if( empty( $lesson_id ) || empty( $question_id ) |
|
| 989 | - || ! ( intval( $lesson_id ) > 0 ) |
|
| 990 | - || ! ( intval( $question_id ) > 0 ) |
|
| 991 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 992 | - || 'question' != get_post_type( $question_id )) { |
|
| 988 | + if (empty($lesson_id) || empty($question_id) |
|
| 989 | + || ! (intval($lesson_id) > 0) |
|
| 990 | + || ! (intval($question_id) > 0) |
|
| 991 | + || 'lesson' != get_post_type($lesson_id) |
|
| 992 | + || 'question' != get_post_type($question_id)) { |
|
| 993 | 993 | |
| 994 | 994 | return false; |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | // get all the feedback for the user on the given lesson |
| 998 | - $all_feedback = $this->get_user_answers_feedback( $lesson_id, $user_id ); |
|
| 998 | + $all_feedback = $this->get_user_answers_feedback($lesson_id, $user_id); |
|
| 999 | 999 | |
| 1000 | - if( !$all_feedback || empty( $all_feedback ) |
|
| 1001 | - || ! is_array( $all_feedback ) || ! isset( $all_feedback[ $question_id ] ) ){ |
|
| 1000 | + if ( ! $all_feedback || empty($all_feedback) |
|
| 1001 | + || ! is_array($all_feedback) || ! isset($all_feedback[$question_id])) { |
|
| 1002 | 1002 | |
| 1003 | 1003 | //fallback to data pre 1.7.4 |
| 1004 | 1004 | |
@@ -1008,23 +1008,23 @@ discard block |
||
| 1008 | 1008 | 'user_id' => $user_id, |
| 1009 | 1009 | 'type' => 'sensei_user_answer' |
| 1010 | 1010 | ); |
| 1011 | - $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true ); |
|
| 1011 | + $question_activity = Sensei_Utils::sensei_check_for_activity($args, true); |
|
| 1012 | 1012 | |
| 1013 | 1013 | // set the default to false and return that if no old data is available. |
| 1014 | - if( isset( $question_activity->comment_ID ) ){ |
|
| 1015 | - $feedback = base64_decode( get_comment_meta( $question_activity->comment_ID , 'answer_note', true ) ); |
|
| 1014 | + if (isset($question_activity->comment_ID)) { |
|
| 1015 | + $feedback = base64_decode(get_comment_meta($question_activity->comment_ID, 'answer_note', true)); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | // finally use the default question feedback |
| 1019 | - if( empty( $feedback ) ){ |
|
| 1020 | - $feedback = get_post_meta( $question_id, '_answer_feedback', true ); |
|
| 1019 | + if (empty($feedback)) { |
|
| 1020 | + $feedback = get_post_meta($question_id, '_answer_feedback', true); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | return $feedback; |
| 1024 | 1024 | |
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | - return $all_feedback[ $question_id ]; |
|
| 1027 | + return $all_feedback[$question_id]; |
|
| 1028 | 1028 | |
| 1029 | 1029 | } // end get_user_question_feedback |
| 1030 | 1030 | |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | |
| 1043 | 1043 | public function quiz_has_no_questions() { |
| 1044 | 1044 | |
| 1045 | - if( ! is_singular( 'quiz' ) ) { |
|
| 1045 | + if ( ! is_singular('quiz')) { |
|
| 1046 | 1046 | return; |
| 1047 | 1047 | } |
| 1048 | 1048 | |
@@ -1050,11 +1050,11 @@ discard block |
||
| 1050 | 1050 | |
| 1051 | 1051 | $lesson_id = $this->get_lesson_id($post->ID); |
| 1052 | 1052 | |
| 1053 | - $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 1053 | + $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
| 1054 | 1054 | |
| 1055 | 1055 | $lesson = get_post($lesson_id); |
| 1056 | 1056 | |
| 1057 | - if ( is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name" ) { |
|
| 1057 | + if (is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name") { |
|
| 1058 | 1058 | |
| 1059 | 1059 | wp_redirect(get_permalink($lesson->ID), 301); |
| 1060 | 1060 | exit; |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | * |
| 1069 | 1069 | * @deprecated since 1.9.0 |
| 1070 | 1070 | */ |
| 1071 | - public static function deprecate_quiz_sensei_single_main_content_hook(){ |
|
| 1071 | + public static function deprecate_quiz_sensei_single_main_content_hook() { |
|
| 1072 | 1072 | |
| 1073 | 1073 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_quiz_content_inside_before or sensei_single_quiz_content_inside_after'); |
| 1074 | 1074 | |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | * |
| 1079 | 1079 | * @deprecated since 1.9.0 |
| 1080 | 1080 | */ |
| 1081 | - public static function deprecate_quiz_sensei_quiz_single_title_hook(){ |
|
| 1081 | + public static function deprecate_quiz_sensei_quiz_single_title_hook() { |
|
| 1082 | 1082 | |
| 1083 | 1083 | sensei_do_deprecated_action('sensei_quiz_single_title', '1.9.0', 'sensei_single_quiz_content_inside_before '); |
| 1084 | 1084 | |
@@ -1091,29 +1091,29 @@ discard block |
||
| 1091 | 1091 | * @param int $id title post id |
| 1092 | 1092 | * @return string $quiz_title |
| 1093 | 1093 | */ |
| 1094 | - public static function single_quiz_title( $title, $post_id ){ |
|
| 1094 | + public static function single_quiz_title($title, $post_id) { |
|
| 1095 | 1095 | |
| 1096 | - if( 'quiz' == get_post_type( $post_id ) ){ |
|
| 1096 | + if ('quiz' == get_post_type($post_id)) { |
|
| 1097 | 1097 | |
| 1098 | 1098 | $title_with_no_quizzes = $title; |
| 1099 | 1099 | |
| 1100 | 1100 | // if the title has quiz, remove it: legacy titles have the word quiz stored. |
| 1101 | - if( 1 < substr_count( strtoupper( $title_with_no_quizzes ), 'QUIZ' ) ){ |
|
| 1101 | + if (1 < substr_count(strtoupper($title_with_no_quizzes), 'QUIZ')) { |
|
| 1102 | 1102 | |
| 1103 | 1103 | // remove all possible appearances of quiz |
| 1104 | - $title_with_no_quizzes = str_replace( 'quiz', '', $title ); |
|
| 1105 | - $title_with_no_quizzes = str_replace( 'Quiz', '', $title_with_no_quizzes ); |
|
| 1106 | - $title_with_no_quizzes = str_replace( 'QUIZ', '', $title_with_no_quizzes ); |
|
| 1104 | + $title_with_no_quizzes = str_replace('quiz', '', $title); |
|
| 1105 | + $title_with_no_quizzes = str_replace('Quiz', '', $title_with_no_quizzes); |
|
| 1106 | + $title_with_no_quizzes = str_replace('QUIZ', '', $title_with_no_quizzes); |
|
| 1107 | 1107 | |
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | - $title = $title_with_no_quizzes . ' ' . __( 'Quiz', 'woothemes-sensei' ); |
|
| 1110 | + $title = $title_with_no_quizzes.' '.__('Quiz', 'woothemes-sensei'); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | /** |
| 1114 | 1114 | * hook document in class-woothemes-sensei-message.php |
| 1115 | 1115 | */ |
| 1116 | - return apply_filters( 'sensei_single_title', $title, get_post_type( ) ); |
|
| 1116 | + return apply_filters('sensei_single_title', $title, get_post_type( )); |
|
| 1117 | 1117 | |
| 1118 | 1118 | } |
| 1119 | 1119 | |
@@ -1125,21 +1125,21 @@ discard block |
||
| 1125 | 1125 | * @since 1.9.0 |
| 1126 | 1126 | * |
| 1127 | 1127 | */ |
| 1128 | - public static function start_quiz_questions_loop(){ |
|
| 1128 | + public static function start_quiz_questions_loop() { |
|
| 1129 | 1129 | |
| 1130 | 1130 | global $sensei_question_loop; |
| 1131 | 1131 | |
| 1132 | 1132 | //intialize the questions loop object |
| 1133 | 1133 | $sensei_question_loop['current'] = -1; |
| 1134 | - $sensei_question_loop['total'] = 0; |
|
| 1134 | + $sensei_question_loop['total'] = 0; |
|
| 1135 | 1135 | $sensei_question_loop['questions'] = array(); |
| 1136 | 1136 | |
| 1137 | 1137 | |
| 1138 | - $questions = Sensei()->lesson->lesson_quiz_questions( get_the_ID() ); |
|
| 1138 | + $questions = Sensei()->lesson->lesson_quiz_questions(get_the_ID()); |
|
| 1139 | 1139 | |
| 1140 | - if( count( $questions ) > 0 ){ |
|
| 1140 | + if (count($questions) > 0) { |
|
| 1141 | 1141 | |
| 1142 | - $sensei_question_loop['total'] = count( $questions ); |
|
| 1142 | + $sensei_question_loop['total'] = count($questions); |
|
| 1143 | 1143 | $sensei_question_loop['questions'] = $questions; |
| 1144 | 1144 | $sensei_question_loop['quiz_id'] = get_the_ID(); |
| 1145 | 1145 | |
@@ -1155,9 +1155,9 @@ discard block |
||
| 1155 | 1155 | * @since 1.9.0 |
| 1156 | 1156 | * |
| 1157 | 1157 | */ |
| 1158 | - public static function stop_quiz_questions_loop(){ |
|
| 1158 | + public static function stop_quiz_questions_loop() { |
|
| 1159 | 1159 | |
| 1160 | - $sensei_question_loop['total'] = 0; |
|
| 1160 | + $sensei_question_loop['total'] = 0; |
|
| 1161 | 1161 | $sensei_question_loop['questions'] = array(); |
| 1162 | 1162 | $sensei_question_loop['quiz_id'] = ''; |
| 1163 | 1163 | |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | * |
| 1169 | 1169 | * @since 1.9.0 |
| 1170 | 1170 | */ |
| 1171 | - public static function the_title(){ |
|
| 1171 | + public static function the_title() { |
|
| 1172 | 1172 | ?> |
| 1173 | 1173 | <header> |
| 1174 | 1174 | |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | /** |
| 1179 | 1179 | * Filter documented in class-sensei-messages.php the_title |
| 1180 | 1180 | */ |
| 1181 | - echo apply_filters( 'sensei_single_title', get_the_title( get_post() ), get_post_type( get_the_ID() ) ); |
|
| 1181 | + echo apply_filters('sensei_single_title', get_the_title(get_post()), get_post_type(get_the_ID())); |
|
| 1182 | 1182 | ?> |
| 1183 | 1183 | |
| 1184 | 1184 | </h1> |
@@ -1193,11 +1193,11 @@ discard block |
||
| 1193 | 1193 | * |
| 1194 | 1194 | * @param $quiz_id |
| 1195 | 1195 | */ |
| 1196 | - public static function the_user_status_message( $quiz_id ){ |
|
| 1196 | + public static function the_user_status_message($quiz_id) { |
|
| 1197 | 1197 | |
| 1198 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 1199 | - $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id , get_current_user_id() ); |
|
| 1200 | - echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>'; |
|
| 1198 | + $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id); |
|
| 1199 | + $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, get_current_user_id()); |
|
| 1200 | + echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>'; |
|
| 1201 | 1201 | |
| 1202 | 1202 | } |
| 1203 | 1203 | |
@@ -1208,9 +1208,9 @@ discard block |
||
| 1208 | 1208 | * @since 1.9.0 |
| 1209 | 1209 | * @deprecated |
| 1210 | 1210 | */ |
| 1211 | - public static function deprecate_sensei_quiz_action_buttons_hook(){ |
|
| 1211 | + public static function deprecate_sensei_quiz_action_buttons_hook() { |
|
| 1212 | 1212 | |
| 1213 | - sensei_do_deprecated_action( 'sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after'); |
|
| 1213 | + sensei_do_deprecated_action('sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after'); |
|
| 1214 | 1214 | |
| 1215 | 1215 | } |
| 1216 | 1216 | |
@@ -1224,50 +1224,50 @@ discard block |
||
| 1224 | 1224 | |
| 1225 | 1225 | global $post, $current_user; |
| 1226 | 1226 | |
| 1227 | - $lesson_id = (int) get_post_meta( $post->ID, '_quiz_lesson', true ); |
|
| 1228 | - $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 1229 | - $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true ); |
|
| 1227 | + $lesson_id = (int) get_post_meta($post->ID, '_quiz_lesson', true); |
|
| 1228 | + $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true); |
|
| 1229 | + $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
| 1230 | 1230 | $show_actions = true; |
| 1231 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $current_user->ID ); |
|
| 1231 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $current_user->ID); |
|
| 1232 | 1232 | |
| 1233 | 1233 | //setup quiz grade |
| 1234 | 1234 | $user_quiz_grade = ''; |
| 1235 | - if( ! empty( $user_lesson_status ) ){ |
|
| 1236 | - $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); |
|
| 1235 | + if ( ! empty($user_lesson_status)) { |
|
| 1236 | + $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); |
|
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | |
| 1240 | - if( intval( $lesson_prerequisite ) > 0 ) { |
|
| 1240 | + if (intval($lesson_prerequisite) > 0) { |
|
| 1241 | 1241 | |
| 1242 | 1242 | // If the user hasn't completed the prereq then hide the current actions |
| 1243 | - $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $current_user->ID ); |
|
| 1243 | + $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID); |
|
| 1244 | 1244 | |
| 1245 | 1245 | } |
| 1246 | - if ( $show_actions && is_user_logged_in() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
| 1246 | + if ($show_actions && is_user_logged_in() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
| 1247 | 1247 | |
| 1248 | 1248 | // Get Reset Settings |
| 1249 | - $reset_quiz_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true ); ?> |
|
| 1249 | + $reset_quiz_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true); ?> |
|
| 1250 | 1250 | |
| 1251 | 1251 | <!-- Action Nonce's --> |
| 1252 | 1252 | <input type="hidden" name="woothemes_sensei_complete_quiz_nonce" id="woothemes_sensei_complete_quiz_nonce" |
| 1253 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_quiz_nonce' ) ); ?>" /> |
|
| 1253 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_quiz_nonce')); ?>" /> |
|
| 1254 | 1254 | <input type="hidden" name="woothemes_sensei_reset_quiz_nonce" id="woothemes_sensei_reset_quiz_nonce" |
| 1255 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_reset_quiz_nonce' ) ); ?>" /> |
|
| 1255 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_reset_quiz_nonce')); ?>" /> |
|
| 1256 | 1256 | <input type="hidden" name="woothemes_sensei_save_quiz_nonce" id="woothemes_sensei_save_quiz_nonce" |
| 1257 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_save_quiz_nonce' ) ); ?>" /> |
|
| 1257 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_save_quiz_nonce')); ?>" /> |
|
| 1258 | 1258 | <!--#end Action Nonce's --> |
| 1259 | 1259 | |
| 1260 | - <?php if ( '' == $user_quiz_grade) { ?> |
|
| 1260 | + <?php if ('' == $user_quiz_grade) { ?> |
|
| 1261 | 1261 | |
| 1262 | - <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php _e( 'Complete Quiz', 'woothemes-sensei' ); ?>"/></span> |
|
| 1262 | + <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php _e('Complete Quiz', 'woothemes-sensei'); ?>"/></span> |
|
| 1263 | 1263 | |
| 1264 | - <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e( 'Save Quiz', 'woothemes-sensei' ); ?>"/></span> |
|
| 1264 | + <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e('Save Quiz', 'woothemes-sensei'); ?>"/></span> |
|
| 1265 | 1265 | |
| 1266 | 1266 | <?php } // End If Statement ?> |
| 1267 | 1267 | |
| 1268 | - <?php if ( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) { ?> |
|
| 1268 | + <?php if (isset($reset_quiz_allowed) && $reset_quiz_allowed) { ?> |
|
| 1269 | 1269 | |
| 1270 | - <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e( 'Reset Quiz', 'woothemes-sensei' ); ?>"/></span> |
|
| 1270 | + <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e('Reset Quiz', 'woothemes-sensei'); ?>"/></span> |
|
| 1271 | 1271 | |
| 1272 | 1272 | <?php } ?> |
| 1273 | 1273 | |
@@ -1285,13 +1285,13 @@ discard block |
||
| 1285 | 1285 | * |
| 1286 | 1286 | * @return double $user_quiz_grade |
| 1287 | 1287 | */ |
| 1288 | - public static function get_user_quiz_grade( $lesson_id, $user_id ){ |
|
| 1288 | + public static function get_user_quiz_grade($lesson_id, $user_id) { |
|
| 1289 | 1289 | |
| 1290 | 1290 | // get the quiz grade |
| 1291 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
| 1291 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
| 1292 | 1292 | $user_quiz_grade = 0; |
| 1293 | - if( isset( $user_lesson_status->comment_ID ) ) { |
|
| 1294 | - $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); |
|
| 1293 | + if (isset($user_lesson_status->comment_ID)) { |
|
| 1294 | + $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | return (double) $user_quiz_grade; |
@@ -1309,13 +1309,13 @@ discard block |
||
| 1309 | 1309 | * @param int $lesson_id |
| 1310 | 1310 | * @return bool |
| 1311 | 1311 | */ |
| 1312 | - public static function is_reset_allowed( $lesson_id ){ |
|
| 1312 | + public static function is_reset_allowed($lesson_id) { |
|
| 1313 | 1313 | |
| 1314 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 1314 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 1315 | 1315 | |
| 1316 | - $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
| 1316 | + $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true); |
|
| 1317 | 1317 | //backwards compatibility |
| 1318 | - if( 'on' == $reset_allowed ) { |
|
| 1318 | + if ('on' == $reset_allowed) { |
|
| 1319 | 1319 | $reset_allowed = 1; |
| 1320 | 1320 | } |
| 1321 | 1321 | |
@@ -1332,4 +1332,4 @@ discard block |
||
| 1332 | 1332 | * @ignore only for backward compatibility |
| 1333 | 1333 | * @since 1.9.0 |
| 1334 | 1334 | */ |
| 1335 | -class WooThemes_Sensei_Quiz extends Sensei_Quiz{} |
|
| 1335 | +class WooThemes_Sensei_Quiz extends Sensei_Quiz {} |
|
@@ -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 | * Handles all admin views, assets and navigation. |
@@ -14,51 +14,51 @@ discard block |
||
| 14 | 14 | * Constructor. |
| 15 | 15 | * @since 1.0.0 |
| 16 | 16 | */ |
| 17 | - public function __construct () { |
|
| 17 | + public function __construct() { |
|
| 18 | 18 | |
| 19 | 19 | //register admin styles |
| 20 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) ); |
|
| 20 | + add_action('admin_enqueue_scripts', array($this, 'admin_styles_global')); |
|
| 21 | 21 | |
| 22 | 22 | //register admin scripts |
| 23 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 23 | + add_action('admin_enqueue_scripts', array($this, 'register_scripts')); |
|
| 24 | 24 | |
| 25 | - add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) ); |
|
| 26 | - add_action( 'settings_before_form', array( $this, 'install_pages_output' ) ); |
|
| 27 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
| 28 | - add_action( 'menu_order', array( $this, 'admin_menu_order' ) ); |
|
| 29 | - add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) ); |
|
| 30 | - add_action( 'admin_init', array( $this, 'page_redirect' ) ); |
|
| 31 | - add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) ); |
|
| 32 | - add_action( 'admin_init', array( __CLASS__, 'install_pages' )); |
|
| 25 | + add_action('admin_print_styles', array($this, 'admin_notices_styles')); |
|
| 26 | + add_action('settings_before_form', array($this, 'install_pages_output')); |
|
| 27 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
| 28 | + add_action('menu_order', array($this, 'admin_menu_order')); |
|
| 29 | + add_action('admin_head', array($this, 'admin_menu_highlight')); |
|
| 30 | + add_action('admin_init', array($this, 'page_redirect')); |
|
| 31 | + add_action('admin_init', array($this, 'sensei_add_custom_menu_items')); |
|
| 32 | + add_action('admin_init', array(__CLASS__, 'install_pages')); |
|
| 33 | 33 | |
| 34 | 34 | // Duplicate lesson & courses |
| 35 | - add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 ); |
|
| 36 | - add_action( 'admin_action_duplicate_lesson', array( $this, 'duplicate_lesson_action' ) ); |
|
| 37 | - add_action( 'admin_action_duplicate_course', array( $this, 'duplicate_course_action' ) ); |
|
| 38 | - add_action( 'admin_action_duplicate_course_with_lessons', array( $this, 'duplicate_course_with_lessons_action' ) ); |
|
| 35 | + add_filter('post_row_actions', array($this, 'duplicate_action_link'), 10, 2); |
|
| 36 | + add_action('admin_action_duplicate_lesson', array($this, 'duplicate_lesson_action')); |
|
| 37 | + add_action('admin_action_duplicate_course', array($this, 'duplicate_course_action')); |
|
| 38 | + add_action('admin_action_duplicate_course_with_lessons', array($this, 'duplicate_course_with_lessons_action')); |
|
| 39 | 39 | |
| 40 | 40 | // Handle lessons list table filtering |
| 41 | - add_action( 'restrict_manage_posts', array( $this, 'lesson_filter_options' ) ); |
|
| 42 | - add_filter( 'request', array( $this, 'lesson_filter_actions' ) ); |
|
| 41 | + add_action('restrict_manage_posts', array($this, 'lesson_filter_options')); |
|
| 42 | + add_filter('request', array($this, 'lesson_filter_actions')); |
|
| 43 | 43 | |
| 44 | 44 | // Add Sensei items to 'at a glance' widget |
| 45 | - add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 ); |
|
| 45 | + add_filter('dashboard_glance_items', array($this, 'glance_items'), 10, 1); |
|
| 46 | 46 | |
| 47 | 47 | // Handle course and lesson deletions |
| 48 | - add_action( 'trash_course', array( $this, 'delete_content' ), 10, 2 ); |
|
| 49 | - add_action( 'trash_lesson', array( $this, 'delete_content' ), 10, 2 ); |
|
| 48 | + add_action('trash_course', array($this, 'delete_content'), 10, 2); |
|
| 49 | + add_action('trash_lesson', array($this, 'delete_content'), 10, 2); |
|
| 50 | 50 | |
| 51 | 51 | // Delete user activity when user is deleted |
| 52 | - add_action( 'deleted_user', array( $this, 'delete_user_activity' ), 10, 1 ); |
|
| 52 | + add_action('deleted_user', array($this, 'delete_user_activity'), 10, 1); |
|
| 53 | 53 | |
| 54 | 54 | // Add notices to WP dashboard |
| 55 | - add_action( 'admin_notices', array( $this, 'theme_compatibility_notices' ) ); |
|
| 55 | + add_action('admin_notices', array($this, 'theme_compatibility_notices')); |
|
| 56 | 56 | |
| 57 | 57 | // Reset theme notices when switching themes |
| 58 | - add_action( 'switch_theme', array( $this, 'reset_theme_check_notices' ) ); |
|
| 58 | + add_action('switch_theme', array($this, 'reset_theme_check_notices')); |
|
| 59 | 59 | |
| 60 | 60 | // Allow Teacher access the admin area |
| 61 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'admin_access' ) ); |
|
| 61 | + add_filter('woocommerce_prevent_admin_access', array($this, 'admin_access')); |
|
| 62 | 62 | |
| 63 | 63 | } // End __construct() |
| 64 | 64 | |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | public function admin_menu() { |
| 71 | 71 | global $menu; |
| 72 | 72 | $menu_cap = ''; |
| 73 | - if( current_user_can( 'manage_sensei' ) ) { |
|
| 73 | + if (current_user_can('manage_sensei')) { |
|
| 74 | 74 | $menu_cap = 'manage_sensei'; |
| 75 | 75 | } else { |
| 76 | - if( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 76 | + if (current_user_can('manage_sensei_grades')) { |
|
| 77 | 77 | $menu_cap = 'manage_sensei_grades'; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if( $menu_cap ) { |
|
| 82 | - $menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' ); |
|
| 83 | - add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' ); |
|
| 81 | + if ($menu_cap) { |
|
| 82 | + $menu[] = array('', 'read', 'separator-sensei', '', 'wp-menu-separator sensei'); |
|
| 83 | + add_menu_page('Sensei', 'Sensei', $menu_cap, 'sensei', array(Sensei()->analysis, 'analysis_page'), '', '50'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) ); |
|
| 87 | - add_submenu_page( 'edit.php?post_type=lesson', __( 'Order Lessons', 'woothemes-sensei' ), __( 'Order Lessons', 'woothemes-sensei' ), 'edit_lessons', 'lesson-order', array( $this, 'lesson_order_screen' ) ); |
|
| 86 | + add_submenu_page('edit.php?post_type=course', __('Order Courses', 'woothemes-sensei'), __('Order Courses', 'woothemes-sensei'), 'manage_sensei', 'course-order', array($this, 'course_order_screen')); |
|
| 87 | + add_submenu_page('edit.php?post_type=lesson', __('Order Lessons', 'woothemes-sensei'), __('Order Lessons', 'woothemes-sensei'), 'edit_lessons', 'lesson-order', array($this, 'lesson_order_screen')); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -93,22 +93,22 @@ discard block |
||
| 93 | 93 | * @param array $menu_order Existing menu order |
| 94 | 94 | * @return array Modified menu order for Sensei |
| 95 | 95 | */ |
| 96 | - public function admin_menu_order( $menu_order ) { |
|
| 96 | + public function admin_menu_order($menu_order) { |
|
| 97 | 97 | |
| 98 | 98 | // Initialize our custom order array |
| 99 | 99 | $sensei_menu_order = array(); |
| 100 | 100 | |
| 101 | 101 | // Get the index of our custom separator |
| 102 | - $sensei_separator = array_search( 'separator-sensei', $menu_order ); |
|
| 102 | + $sensei_separator = array_search('separator-sensei', $menu_order); |
|
| 103 | 103 | |
| 104 | 104 | // Loop through menu order and do some rearranging |
| 105 | - foreach ( $menu_order as $index => $item ) : |
|
| 105 | + foreach ($menu_order as $index => $item) : |
|
| 106 | 106 | |
| 107 | - if ( ( ( 'sensei' ) == $item ) ) : |
|
| 107 | + if ((('sensei') == $item)) : |
|
| 108 | 108 | $sensei_menu_order[] = 'separator-sensei'; |
| 109 | 109 | $sensei_menu_order[] = $item; |
| 110 | - unset( $menu_order[$sensei_separator] ); |
|
| 111 | - elseif ( !in_array( $item, array( 'separator-sensei' ) ) ) : |
|
| 110 | + unset($menu_order[$sensei_separator]); |
|
| 111 | + elseif ( ! in_array($item, array('separator-sensei'))) : |
|
| 112 | 112 | $sensei_menu_order[] = $item; |
| 113 | 113 | endif; |
| 114 | 114 | |
@@ -128,28 +128,28 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $screen = get_current_screen(); |
| 130 | 130 | |
| 131 | - if( empty( $screen ) ){ |
|
| 131 | + if (empty($screen)) { |
|
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if ( $screen->base == 'post' && $post_type == 'course' ) { |
|
| 135 | + if ($screen->base == 'post' && $post_type == 'course') { |
|
| 136 | 136 | |
| 137 | - $parent_file = 'edit.php?post_type=course'; |
|
| 137 | + $parent_file = 'edit.php?post_type=course'; |
|
| 138 | 138 | |
| 139 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) { |
|
| 139 | + } elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') { |
|
| 140 | 140 | |
| 141 | 141 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; |
| 142 | 142 | $parent_file = 'edit.php?post_type=course'; |
| 143 | 143 | |
| 144 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
| 144 | + } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') { |
|
| 145 | 145 | |
| 146 | 146 | $submenu_file = 'edit-tags.php?taxonomy=module'; |
| 147 | 147 | $parent_file = 'edit.php?post_type=course'; |
| 148 | 148 | |
| 149 | - } elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { |
|
| 149 | + } elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) { |
|
| 150 | 150 | |
| 151 | 151 | $submenu_file = 'edit.php?post_type=sensei_message'; |
| 152 | - $parent_file = 'sensei'; |
|
| 152 | + $parent_file = 'sensei'; |
|
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * @return void |
| 161 | 161 | */ |
| 162 | 162 | public function page_redirect() { |
| 163 | - if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) { |
|
| 164 | - wp_safe_redirect( 'admin.php?page=sensei_analysis' ); |
|
| 163 | + if (isset($_GET['page']) && $_GET['page'] == 'sensei') { |
|
| 164 | + wp_safe_redirect('admin.php?page=sensei_analysis'); |
|
| 165 | 165 | exit; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | function install_pages_output() { |
| 178 | 178 | |
| 179 | - if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
| 179 | + if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
| 180 | 180 | |
| 181 | 181 | ?> |
| 182 | 182 | <div id="message" class="updated sensei-message sensei-connect"> |
| 183 | - <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> |
|
| 183 | + <p><?php _e('<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei'); ?></p> |
|
| 184 | 184 | <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a> |
| 185 | 185 | <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p> |
| 186 | 186 | </div> |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | * @param int $post_parent (default: 0) |
| 203 | 203 | * @return integer $page_id |
| 204 | 204 | */ |
| 205 | - function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 205 | + function create_page($slug, $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 206 | 206 | global $wpdb; |
| 207 | 207 | |
| 208 | - $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); |
|
| 209 | - if ( $page_id ) : |
|
| 208 | + $page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug)); |
|
| 209 | + if ($page_id) : |
|
| 210 | 210 | return $page_id; |
| 211 | 211 | endif; |
| 212 | 212 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | 'comment_status' => 'closed' |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - $page_id = wp_insert_post( $page_data ); |
|
| 224 | + $page_id = wp_insert_post($page_data); |
|
| 225 | 225 | |
| 226 | 226 | return $page_id; |
| 227 | 227 | |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | function create_pages() { |
| 238 | 238 | |
| 239 | 239 | // Courses page |
| 240 | - $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), __('Courses', 'woothemes-sensei'), '' ); |
|
| 241 | - Sensei()->settings->set( 'course_page', $new_course_page_id ); |
|
| 240 | + $new_course_page_id = $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), __('Courses', 'woothemes-sensei'), ''); |
|
| 241 | + Sensei()->settings->set('course_page', $new_course_page_id); |
|
| 242 | 242 | |
| 243 | 243 | // User Dashboard page |
| 244 | - $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); |
|
| 245 | - Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); |
|
| 244 | + $new_my_course_page_id = $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]'); |
|
| 245 | + Sensei()->settings->set('my_course_page', $new_my_course_page_id); |
|
| 246 | 246 | |
| 247 | 247 | } // End create_pages() |
| 248 | 248 | |
@@ -252,25 +252,25 @@ discard block |
||
| 252 | 252 | * @since 1.0.0 |
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | - public function admin_styles_global ( $hook ) { |
|
| 255 | + public function admin_styles_global($hook) { |
|
| 256 | 256 | global $post_type; |
| 257 | 257 | |
| 258 | - $allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) ); |
|
| 259 | - $allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) ); |
|
| 260 | - $allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) ); |
|
| 258 | + $allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question')); |
|
| 259 | + $allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php')); |
|
| 260 | + $allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order')); |
|
| 261 | 261 | |
| 262 | 262 | // Global Styles for icons and menu items |
| 263 | - wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); |
|
| 264 | - wp_enqueue_style( 'woothemes-sensei-global' ); |
|
| 263 | + wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen'); |
|
| 264 | + wp_enqueue_style('woothemes-sensei-global'); |
|
| 265 | 265 | |
| 266 | 266 | // Select 2 styles |
| 267 | - wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
| 267 | + wp_enqueue_style('sensei-core-select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen'); |
|
| 268 | 268 | |
| 269 | 269 | // Test for Write Panel Pages |
| 270 | - if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) { |
|
| 270 | + if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) { |
|
| 271 | 271 | |
| 272 | - wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' ); |
|
| 273 | - wp_enqueue_style( 'woothemes-sensei-admin-custom' ); |
|
| 272 | + wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen'); |
|
| 273 | + wp_enqueue_style('woothemes-sensei-admin-custom'); |
|
| 274 | 274 | |
| 275 | 275 | } |
| 276 | 276 | |
@@ -285,20 +285,20 @@ discard block |
||
| 285 | 285 | * @since 1.8.2 |
| 286 | 286 | * @access public |
| 287 | 287 | */ |
| 288 | - public function register_scripts( $hook ){ |
|
| 288 | + public function register_scripts($hook) { |
|
| 289 | 289 | |
| 290 | 290 | $screen = get_current_screen(); |
| 291 | 291 | |
| 292 | 292 | // Allow developers to load non-minified versions of scripts |
| 293 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 293 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 294 | 294 | |
| 295 | 295 | // Select2 script used to enhance all select boxes |
| 296 | - wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
| 296 | + wp_register_script('sensei-core-select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version); |
|
| 297 | 297 | |
| 298 | 298 | // load edit module scripts |
| 299 | - if( 'edit-module' == $screen->id ){ |
|
| 299 | + if ('edit-module' == $screen->id) { |
|
| 300 | 300 | |
| 301 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
| 301 | + wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true); |
|
| 302 | 302 | |
| 303 | 303 | } |
| 304 | 304 | |
@@ -316,19 +316,19 @@ discard block |
||
| 316 | 316 | <div id="message" class="updated sensei-message sensei-connect"> |
| 317 | 317 | |
| 318 | 318 | <p> |
| 319 | - <?php _e( '<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?> |
|
| 319 | + <?php _e('<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei'); ?> |
|
| 320 | 320 | </p> |
| 321 | 321 | |
| 322 | 322 | <p class="submit"> |
| 323 | 323 | |
| 324 | - <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>" |
|
| 324 | + <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>" |
|
| 325 | 325 | class="button-primary"> |
| 326 | 326 | |
| 327 | - <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?> |
|
| 327 | + <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?> |
|
| 328 | 328 | |
| 329 | 329 | </a> |
| 330 | 330 | |
| 331 | - <a class="skip button" href="<?php echo esc_url( add_query_arg( 'skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings' ) ) ); ?>"> |
|
| 331 | + <a class="skip button" href="<?php echo esc_url(add_query_arg('skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>"> |
|
| 332 | 332 | |
| 333 | 333 | <?php _e('Skip setup', 'woothemes-sensei'); ?> |
| 334 | 334 | |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | <div id="message" class="updated sensei-message sensei-connect"> |
| 352 | 352 | |
| 353 | 353 | <p> |
| 354 | - <?php _e( '<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei' ); ?> |
|
| 354 | + <?php _e('<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei'); ?> |
|
| 355 | 355 | </p> |
| 356 | 356 | |
| 357 | 357 | <p class="submit"> |
| 358 | - <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/"> |
|
| 358 | + <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e('Settings', 'woothemes-sensei'); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/"> |
|
| 359 | 359 | <?php _e('Documentation', 'woothemes-sensei'); ?> |
| 360 | 360 | </a> |
| 361 | 361 | </p> |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | public function language_pack_install_notice() { |
| 389 | 389 | ?> |
| 390 | 390 | <div id="message" class="updated sensei-message sensei-connect"> |
| 391 | - <p><?php _e( '<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei' ); ?><p> |
|
| 391 | + <p><?php _e('<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei'); ?><p> |
|
| 392 | 392 | |
| 393 | 393 | <p class="submit"> |
| 394 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a> |
|
| 395 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a> |
|
| 394 | + <a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a> |
|
| 395 | + <a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a> |
|
| 396 | 396 | </p> |
| 397 | 397 | </div> |
| 398 | 398 | <?php |
@@ -408,20 +408,20 @@ discard block |
||
| 408 | 408 | function admin_notices_styles() { |
| 409 | 409 | |
| 410 | 410 | // Installed notices |
| 411 | - if ( 1 == get_option( 'sensei_installed' ) ) { |
|
| 411 | + if (1 == get_option('sensei_installed')) { |
|
| 412 | 412 | |
| 413 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
| 413 | + wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version); |
|
| 414 | 414 | |
| 415 | - if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) { |
|
| 416 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
| 417 | - } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
| 418 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
| 415 | + if (get_option('skip_install_sensei_pages') != 1 && Sensei()->get_page_id('course') < 1 && ! isset($_GET['install_sensei_pages']) && ! isset($_GET['skip_install_sensei_pages'])) { |
|
| 416 | + add_action('admin_notices', array($this, 'admin_install_notice')); |
|
| 417 | + } elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') { |
|
| 418 | + add_action('admin_notices', array($this, 'admin_installed_notice')); |
|
| 419 | 419 | } // End If Statement |
| 420 | 420 | |
| 421 | 421 | } // End If Statement |
| 422 | 422 | |
| 423 | - if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
| 424 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
| 423 | + if (Sensei_Language_Pack_Manager::has_language_pack_available()) { |
|
| 424 | + add_action('admin_notices', array($this, 'language_pack_install_notice')); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | } // End admin_notices_styles() |
@@ -432,17 +432,17 @@ discard block |
||
| 432 | 432 | * @param object $post Current post |
| 433 | 433 | * @return array Modified actions |
| 434 | 434 | */ |
| 435 | - public function duplicate_action_link( $actions, $post ) { |
|
| 436 | - switch( $post->post_type ) { |
|
| 435 | + public function duplicate_action_link($actions, $post) { |
|
| 436 | + switch ($post->post_type) { |
|
| 437 | 437 | case 'lesson': |
| 438 | - $confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' ); |
|
| 439 | - $actions['duplicate'] = "<a onclick='return confirm(\"" . $confirm . "\");' href='" . $this->get_duplicate_link( $post->ID ) . "' title='" . esc_attr(__( 'Duplicate this lesson', 'woothemes-sensei' ) ) . "'>" . __('Duplicate', 'woothemes-sensei' ) . "</a>"; |
|
| 438 | + $confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei'); |
|
| 439 | + $actions['duplicate'] = "<a onclick='return confirm(\"".$confirm."\");' href='".$this->get_duplicate_link($post->ID)."' title='".esc_attr(__('Duplicate this lesson', 'woothemes-sensei'))."'>".__('Duplicate', 'woothemes-sensei')."</a>"; |
|
| 440 | 440 | break; |
| 441 | 441 | |
| 442 | 442 | case 'course': |
| 443 | - $confirm = __( 'This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei' ); |
|
| 444 | - $actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' . __('Duplicate', 'woothemes-sensei' ) . '</a>'; |
|
| 445 | - $actions['duplicate_with_lessons'] = '<a onclick="return confirm(\'' . $confirm . '\');" href="' . $this->get_duplicate_link( $post->ID, true ) . '" title="' . esc_attr(__( 'Duplicate this course with its lessons', 'woothemes-sensei' ) ) . '">' . __('Duplicate (with lessons)', 'woothemes-sensei' ) . '</a>'; |
|
| 443 | + $confirm = __('This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei'); |
|
| 444 | + $actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>'; |
|
| 445 | + $actions['duplicate_with_lessons'] = '<a onclick="return confirm(\''.$confirm.'\');" href="'.$this->get_duplicate_link($post->ID, true).'" title="'.esc_attr(__('Duplicate this course with its lessons', 'woothemes-sensei')).'">'.__('Duplicate (with lessons)', 'woothemes-sensei').'</a>'; |
|
| 446 | 446 | break; |
| 447 | 447 | } |
| 448 | 448 | |
@@ -455,17 +455,17 @@ discard block |
||
| 455 | 455 | * @param boolean $with_lessons Include lessons or not |
| 456 | 456 | * @return string Duplication link |
| 457 | 457 | */ |
| 458 | - private function get_duplicate_link( $post_id = 0, $with_lessons = false ) { |
|
| 458 | + private function get_duplicate_link($post_id = 0, $with_lessons = false) { |
|
| 459 | 459 | |
| 460 | - $post = get_post( $post_id ); |
|
| 460 | + $post = get_post($post_id); |
|
| 461 | 461 | |
| 462 | - $action = 'duplicate_' . $post->post_type; |
|
| 462 | + $action = 'duplicate_'.$post->post_type; |
|
| 463 | 463 | |
| 464 | - if( 'course' == $post->post_type && $with_lessons ) { |
|
| 464 | + if ('course' == $post->post_type && $with_lessons) { |
|
| 465 | 465 | $action .= '_with_lessons'; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id ); |
|
| 468 | + return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | 475 | public function duplicate_lesson_action() { |
| 476 | - $this->duplicate_content( 'lesson' ); |
|
| 476 | + $this->duplicate_content('lesson'); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * @return void |
| 482 | 482 | */ |
| 483 | 483 | public function duplicate_course_action() { |
| 484 | - $this->duplicate_content( 'course' ); |
|
| 484 | + $this->duplicate_content('course'); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | * @return void |
| 490 | 490 | */ |
| 491 | 491 | public function duplicate_course_with_lessons_action() { |
| 492 | - $this->duplicate_content( 'course', true ); |
|
| 492 | + $this->duplicate_content('course', true); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -498,34 +498,34 @@ discard block |
||
| 498 | 498 | * @param boolean $with_lessons Include lessons or not |
| 499 | 499 | * @return void |
| 500 | 500 | */ |
| 501 | - private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) { |
|
| 502 | - if ( ! isset( $_GET['post'] ) ) { |
|
| 503 | - wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type ); |
|
| 501 | + private function duplicate_content($post_type = 'lesson', $with_lessons = false) { |
|
| 502 | + if ( ! isset($_GET['post'])) { |
|
| 503 | + wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $post_id = $_GET['post']; |
| 507 | - $post = get_post( $post_id ); |
|
| 507 | + $post = get_post($post_id); |
|
| 508 | 508 | |
| 509 | - if( ! is_wp_error( $post ) ) { |
|
| 509 | + if ( ! is_wp_error($post)) { |
|
| 510 | 510 | |
| 511 | - $new_post = $this->duplicate_post( $post ); |
|
| 511 | + $new_post = $this->duplicate_post($post); |
|
| 512 | 512 | |
| 513 | - if( $new_post && ! is_wp_error( $new_post ) ) { |
|
| 513 | + if ($new_post && ! is_wp_error($new_post)) { |
|
| 514 | 514 | |
| 515 | - if( 'lesson' == $new_post->post_type ) { |
|
| 516 | - $this->duplicate_lesson_quizzes( $post_id, $new_post->ID ); |
|
| 515 | + if ('lesson' == $new_post->post_type) { |
|
| 516 | + $this->duplicate_lesson_quizzes($post_id, $new_post->ID); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if( 'course' == $new_post->post_type && $with_lessons ) { |
|
| 520 | - $this->duplicate_course_lessons( $post_id, $new_post->ID ); |
|
| 519 | + if ('course' == $new_post->post_type && $with_lessons) { |
|
| 520 | + $this->duplicate_course_lessons($post_id, $new_post->ID); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' ); |
|
| 523 | + $redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit'); |
|
| 524 | 524 | } else { |
| 525 | - $redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' ); |
|
| 525 | + $redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed'); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - wp_safe_redirect( esc_url_raw( $redirect_url ) ); |
|
| 528 | + wp_safe_redirect(esc_url_raw($redirect_url)); |
|
| 529 | 529 | exit; |
| 530 | 530 | } |
| 531 | 531 | } |
@@ -536,19 +536,19 @@ discard block |
||
| 536 | 536 | * @param integer $new_lesson_id ID of duplicate lesson |
| 537 | 537 | * @return void |
| 538 | 538 | */ |
| 539 | - private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { |
|
| 539 | + private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) { |
|
| 540 | 540 | |
| 541 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
| 542 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
| 541 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id); |
|
| 542 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id); |
|
| 543 | 543 | |
| 544 | 544 | // duplicate the generic wp post information |
| 545 | - $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); |
|
| 545 | + $new_quiz = $this->duplicate_post(get_post($old_quiz_id), ''); |
|
| 546 | 546 | |
| 547 | 547 | //update the new lesson data |
| 548 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
| 548 | + add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID); |
|
| 549 | 549 | |
| 550 | 550 | //update the new quiz data |
| 551 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
| 551 | + add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id); |
|
| 552 | 552 | wp_update_post( |
| 553 | 553 | array( |
| 554 | 554 | 'ID' => $new_quiz->ID, |
@@ -556,15 +556,15 @@ discard block |
||
| 556 | 556 | ) |
| 557 | 557 | ); |
| 558 | 558 | |
| 559 | - foreach( $old_quiz_questions as $question ) { |
|
| 559 | + foreach ($old_quiz_questions as $question) { |
|
| 560 | 560 | |
| 561 | 561 | // copy the question order over to the new quiz |
| 562 | - $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); |
|
| 563 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
| 564 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
| 562 | + $old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true); |
|
| 563 | + $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order); |
|
| 564 | + add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order); |
|
| 565 | 565 | |
| 566 | 566 | // Add question to quiz |
| 567 | - add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); |
|
| 567 | + add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false); |
|
| 568 | 568 | |
| 569 | 569 | } |
| 570 | 570 | } |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @param integer $new_course_id ID of duplicated course |
| 576 | 576 | * @return void |
| 577 | 577 | */ |
| 578 | - private function duplicate_course_lessons( $old_course_id, $new_course_id ) { |
|
| 578 | + private function duplicate_course_lessons($old_course_id, $new_course_id) { |
|
| 579 | 579 | $lesson_args = array( |
| 580 | 580 | 'post_type' => 'lesson', |
| 581 | 581 | 'posts_per_page' => -1, |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | 'meta_value' => $old_course_id, |
| 584 | 584 | 'suppress_filters' => 0 |
| 585 | 585 | ); |
| 586 | - $lessons = get_posts( $lesson_args ); |
|
| 586 | + $lessons = get_posts($lesson_args); |
|
| 587 | 587 | |
| 588 | - foreach( $lessons as $lesson ) { |
|
| 589 | - $new_lesson = $this->duplicate_post( $lesson, '', true ); |
|
| 590 | - add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id ); |
|
| 588 | + foreach ($lessons as $lesson) { |
|
| 589 | + $new_lesson = $this->duplicate_post($lesson, '', true); |
|
| 590 | + add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id); |
|
| 591 | 591 | |
| 592 | - $this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID ); |
|
| 592 | + $this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID); |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
@@ -600,24 +600,24 @@ discard block |
||
| 600 | 600 | * @param boolean $ignore_course Ignore lesson course when dulicating |
| 601 | 601 | * @return object Duplicate post object |
| 602 | 602 | */ |
| 603 | - private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) { |
|
| 603 | + private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) { |
|
| 604 | 604 | |
| 605 | 605 | $new_post = array(); |
| 606 | 606 | |
| 607 | - foreach( $post as $k => $v ) { |
|
| 608 | - if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) { |
|
| 609 | - $new_post[ $k ] = $v; |
|
| 607 | + foreach ($post as $k => $v) { |
|
| 608 | + if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) { |
|
| 609 | + $new_post[$k] = $v; |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - $new_post['post_title'] .= __( $suffix, 'woothemes-sensei' ); |
|
| 613 | + $new_post['post_title'] .= __($suffix, 'woothemes-sensei'); |
|
| 614 | 614 | |
| 615 | - $new_post['post_date'] = current_time( 'mysql' ); |
|
| 616 | - $new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] ); |
|
| 615 | + $new_post['post_date'] = current_time('mysql'); |
|
| 616 | + $new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']); |
|
| 617 | 617 | $new_post['post_modified'] = $new_post['post_date']; |
| 618 | 618 | $new_post['post_modified_gmt'] = $new_post['post_date_gmt']; |
| 619 | 619 | |
| 620 | - switch( $post->post_type ) { |
|
| 620 | + switch ($post->post_type) { |
|
| 621 | 621 | case 'course': $new_post['post_status'] = 'draft'; break; |
| 622 | 622 | case 'lesson': $new_post['post_status'] = 'draft'; break; |
| 623 | 623 | case 'quiz': $new_post['post_status'] = 'publish'; break; |
@@ -625,45 +625,45 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // As per wp_update_post() we need to escape the data from the db. |
| 628 | - $new_post = wp_slash( $new_post ); |
|
| 628 | + $new_post = wp_slash($new_post); |
|
| 629 | 629 | |
| 630 | - $new_post_id = wp_insert_post( $new_post ); |
|
| 630 | + $new_post_id = wp_insert_post($new_post); |
|
| 631 | 631 | |
| 632 | - if( ! is_wp_error( $new_post_id ) ) { |
|
| 632 | + if ( ! is_wp_error($new_post_id)) { |
|
| 633 | 633 | |
| 634 | - $post_meta = get_post_custom( $post->ID ); |
|
| 635 | - if( $post_meta && count( $post_meta ) > 0 ) { |
|
| 634 | + $post_meta = get_post_custom($post->ID); |
|
| 635 | + if ($post_meta && count($post_meta) > 0) { |
|
| 636 | 636 | |
| 637 | - $ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' ); |
|
| 637 | + $ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz'); |
|
| 638 | 638 | |
| 639 | - if( $ignore_course ) { |
|
| 639 | + if ($ignore_course) { |
|
| 640 | 640 | $ignore_meta[] = '_lesson_course'; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - foreach( $post_meta as $key => $meta ) { |
|
| 644 | - foreach( $meta as $value ) { |
|
| 645 | - $value = maybe_unserialize( $value ); |
|
| 646 | - if( ! in_array( $key, $ignore_meta ) ) { |
|
| 647 | - add_post_meta( $new_post_id, $key, $value ); |
|
| 643 | + foreach ($post_meta as $key => $meta) { |
|
| 644 | + foreach ($meta as $value) { |
|
| 645 | + $value = maybe_unserialize($value); |
|
| 646 | + if ( ! in_array($key, $ignore_meta)) { |
|
| 647 | + add_post_meta($new_post_id, $key, $value); |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - add_post_meta( $new_post_id, '_duplicate', $post->ID ); |
|
| 653 | + add_post_meta($new_post_id, '_duplicate', $post->ID); |
|
| 654 | 654 | |
| 655 | - $taxonomies = get_object_taxonomies( $post->post_type, 'objects' ); |
|
| 655 | + $taxonomies = get_object_taxonomies($post->post_type, 'objects'); |
|
| 656 | 656 | |
| 657 | - foreach ( $taxonomies as $slug => $tax ) { |
|
| 658 | - $terms = get_the_terms( $post->ID, $slug ); |
|
| 659 | - if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) { |
|
| 660 | - foreach( $terms as $term ) { |
|
| 661 | - wp_set_object_terms( $new_post_id, $term->term_id, $slug, true ); |
|
| 657 | + foreach ($taxonomies as $slug => $tax) { |
|
| 658 | + $terms = get_the_terms($post->ID, $slug); |
|
| 659 | + if (isset($terms) && is_array($terms) && 0 < count($terms)) { |
|
| 660 | + foreach ($terms as $term) { |
|
| 661 | + wp_set_object_terms($new_post_id, $term->term_id, $slug, true); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - $new_post = get_post( $new_post_id ); |
|
| 666 | + $new_post = get_post($new_post_id); |
|
| 667 | 667 | |
| 668 | 668 | return $new_post; |
| 669 | 669 | } |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | public function lesson_filter_options() { |
| 679 | 679 | global $typenow; |
| 680 | 680 | |
| 681 | - if( is_admin() && 'lesson' == $typenow ) { |
|
| 681 | + if (is_admin() && 'lesson' == $typenow) { |
|
| 682 | 682 | |
| 683 | 683 | $args = array( |
| 684 | 684 | 'post_type' => 'course', |
@@ -688,16 +688,16 @@ discard block |
||
| 688 | 688 | 'orderby' => 'menu_order date', |
| 689 | 689 | 'order' => 'ASC', |
| 690 | 690 | ); |
| 691 | - $courses = get_posts( $args ); |
|
| 691 | + $courses = get_posts($args); |
|
| 692 | 692 | |
| 693 | - $selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; |
|
| 693 | + $selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; |
|
| 694 | 694 | $course_options = ''; |
| 695 | - foreach( $courses as $course ) { |
|
| 696 | - $course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>'; |
|
| 695 | + foreach ($courses as $course) { |
|
| 696 | + $course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>'; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | $output = '<select name="lesson_course" id="dropdown_lesson_course">'; |
| 700 | - $output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>'; |
|
| 700 | + $output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>'; |
|
| 701 | 701 | $output .= $course_options; |
| 702 | 702 | $output .= '</select>'; |
| 703 | 703 | |
@@ -710,13 +710,13 @@ discard block |
||
| 710 | 710 | * @param array $request Current request |
| 711 | 711 | * @return array Modified request |
| 712 | 712 | */ |
| 713 | - public function lesson_filter_actions( $request ) { |
|
| 713 | + public function lesson_filter_actions($request) { |
|
| 714 | 714 | global $typenow; |
| 715 | 715 | |
| 716 | - if( is_admin() && 'lesson' == $typenow ) { |
|
| 717 | - $lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; |
|
| 716 | + if (is_admin() && 'lesson' == $typenow) { |
|
| 717 | + $lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; |
|
| 718 | 718 | |
| 719 | - if( $lesson_course ) { |
|
| 719 | + if ($lesson_course) { |
|
| 720 | 720 | $request['meta_key'] = '_lesson_course'; |
| 721 | 721 | $request['meta_value'] = $lesson_course; |
| 722 | 722 | $request['meta_compare'] = '='; |
@@ -731,27 +731,27 @@ discard block |
||
| 731 | 731 | * @param array $items Existing items |
| 732 | 732 | * @return array Updated items |
| 733 | 733 | */ |
| 734 | - public function glance_items( $items = array() ) { |
|
| 734 | + public function glance_items($items = array()) { |
|
| 735 | 735 | |
| 736 | - $types = array( 'course', 'lesson', 'question' ); |
|
| 736 | + $types = array('course', 'lesson', 'question'); |
|
| 737 | 737 | |
| 738 | - foreach( $types as $type ) { |
|
| 739 | - if( ! post_type_exists( $type ) ) continue; |
|
| 738 | + foreach ($types as $type) { |
|
| 739 | + if ( ! post_type_exists($type)) continue; |
|
| 740 | 740 | |
| 741 | - $num_posts = wp_count_posts( $type ); |
|
| 741 | + $num_posts = wp_count_posts($type); |
|
| 742 | 742 | |
| 743 | - if( $num_posts ) { |
|
| 743 | + if ($num_posts) { |
|
| 744 | 744 | |
| 745 | - $published = intval( $num_posts->publish ); |
|
| 746 | - $post_type = get_post_type_object( $type ); |
|
| 745 | + $published = intval($num_posts->publish); |
|
| 746 | + $post_type = get_post_type_object($type); |
|
| 747 | 747 | |
| 748 | - $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' ); |
|
| 749 | - $text = sprintf( $text, number_format_i18n( $published ) ); |
|
| 748 | + $text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei'); |
|
| 749 | + $text = sprintf($text, number_format_i18n($published)); |
|
| 750 | 750 | |
| 751 | - if ( current_user_can( $post_type->cap->edit_posts ) ) { |
|
| 752 | - $items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n"; |
|
| 751 | + if (current_user_can($post_type->cap->edit_posts)) { |
|
| 752 | + $items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n"; |
|
| 753 | 753 | } else { |
| 754 | - $items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n"; |
|
| 754 | + $items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n"; |
|
| 755 | 755 | } |
| 756 | 756 | } |
| 757 | 757 | } |
@@ -765,13 +765,13 @@ discard block |
||
| 765 | 765 | * @param object $post Post object |
| 766 | 766 | * @return void |
| 767 | 767 | */ |
| 768 | - public function delete_content( $post_id, $post ) { |
|
| 768 | + public function delete_content($post_id, $post) { |
|
| 769 | 769 | |
| 770 | 770 | $type = $post->post_type; |
| 771 | 771 | |
| 772 | - if( in_array( $type, array( 'lesson', 'course' ) ) ) { |
|
| 772 | + if (in_array($type, array('lesson', 'course'))) { |
|
| 773 | 773 | |
| 774 | - $meta_key = '_' . $type . '_prerequisite'; |
|
| 774 | + $meta_key = '_'.$type.'_prerequisite'; |
|
| 775 | 775 | |
| 776 | 776 | $args = array( |
| 777 | 777 | 'post_type' => $type, |
@@ -781,10 +781,10 @@ discard block |
||
| 781 | 781 | 'meta_value' => $post_id |
| 782 | 782 | ); |
| 783 | 783 | |
| 784 | - $posts = get_posts( $args ); |
|
| 784 | + $posts = get_posts($args); |
|
| 785 | 785 | |
| 786 | - foreach( $posts as $post ) { |
|
| 787 | - delete_post_meta( $post->ID, $meta_key ); |
|
| 786 | + foreach ($posts as $post) { |
|
| 787 | + delete_post_meta($post->ID, $meta_key); |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | } |
@@ -794,181 +794,181 @@ discard block |
||
| 794 | 794 | * @param integer $user_id User ID |
| 795 | 795 | * @return void |
| 796 | 796 | */ |
| 797 | - public function delete_user_activity( $user_id = 0 ) { |
|
| 798 | - if( $user_id ) { |
|
| 799 | - Sensei_Utils::delete_all_user_activity( $user_id ); |
|
| 797 | + public function delete_user_activity($user_id = 0) { |
|
| 798 | + if ($user_id) { |
|
| 799 | + Sensei_Utils::delete_all_user_activity($user_id); |
|
| 800 | 800 | } |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | - public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) { |
|
| 803 | + public function render_settings($settings = array(), $post_id = 0, $group_id = '') { |
|
| 804 | 804 | |
| 805 | 805 | $html = ''; |
| 806 | 806 | |
| 807 | - if( 0 == count( $settings ) ) return $html; |
|
| 807 | + if (0 == count($settings)) return $html; |
|
| 808 | 808 | |
| 809 | - $html .= '<div class="sensei-options-panel">' . "\n"; |
|
| 809 | + $html .= '<div class="sensei-options-panel">'."\n"; |
|
| 810 | 810 | |
| 811 | - $html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n"; |
|
| 811 | + $html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n"; |
|
| 812 | 812 | |
| 813 | - foreach( $settings as $field ) { |
|
| 813 | + foreach ($settings as $field) { |
|
| 814 | 814 | |
| 815 | 815 | $data = ''; |
| 816 | 816 | |
| 817 | - if( $post_id ) { |
|
| 818 | - $data = get_post_meta( $post_id, '_' . $field['id'], true ); |
|
| 819 | - if( ! $data && isset( $field['default'] ) ) { |
|
| 817 | + if ($post_id) { |
|
| 818 | + $data = get_post_meta($post_id, '_'.$field['id'], true); |
|
| 819 | + if ( ! $data && isset($field['default'])) { |
|
| 820 | 820 | $data = $field['default']; |
| 821 | 821 | } |
| 822 | 822 | } else { |
| 823 | - $option = get_option( $field['id'] ); |
|
| 824 | - if( isset( $field['default'] ) ) { |
|
| 823 | + $option = get_option($field['id']); |
|
| 824 | + if (isset($field['default'])) { |
|
| 825 | 825 | $data = $field['default']; |
| 826 | - if( $option ) { |
|
| 826 | + if ($option) { |
|
| 827 | 827 | $data = $option; |
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $disabled = ''; |
| 833 | - if( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
| 834 | - $disabled = disabled( $field['disabled'], true, false ); |
|
| 833 | + if (isset($field['disabled']) && $field['disabled']) { |
|
| 834 | + $disabled = disabled($field['disabled'], true, false); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if( 'hidden' != $field['type'] ) { |
|
| 837 | + if ('hidden' != $field['type']) { |
|
| 838 | 838 | |
| 839 | 839 | $class_tail = ''; |
| 840 | 840 | |
| 841 | - if( isset( $field['class'] ) ) { |
|
| 841 | + if (isset($field['class'])) { |
|
| 842 | 842 | $class_tail .= $field['class']; |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
| 845 | + if (isset($field['disabled']) && $field['disabled']) { |
|
| 846 | 846 | $class_tail .= ' disabled'; |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - $html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n"; |
|
| 849 | + $html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n"; |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { |
|
| 853 | - $html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n"; |
|
| 852 | + if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { |
|
| 853 | + $html .= '<label for="'.esc_attr($field['id']).'">'."\n"; |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - if( $field['label'] ) { |
|
| 857 | - $html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>'; |
|
| 856 | + if ($field['label']) { |
|
| 857 | + $html .= '<span class="label">'.esc_html($field['label']).'</span>'; |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - switch( $field['type'] ) { |
|
| 860 | + switch ($field['type']) { |
|
| 861 | 861 | case 'text': |
| 862 | 862 | case 'password': |
| 863 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n"; |
|
| 863 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n"; |
|
| 864 | 864 | break; |
| 865 | 865 | |
| 866 | 866 | case 'number': |
| 867 | 867 | |
| 868 | 868 | $min = ''; |
| 869 | - if( isset( $field['min'] ) ) { |
|
| 870 | - $min = 'min="' . esc_attr( $field['min'] ) . '"'; |
|
| 869 | + if (isset($field['min'])) { |
|
| 870 | + $min = 'min="'.esc_attr($field['min']).'"'; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | $max = ''; |
| 874 | - if( isset( $field['max'] ) ) { |
|
| 875 | - $max = 'max="' . esc_attr( $field['max'] ) . '"'; |
|
| 874 | + if (isset($field['max'])) { |
|
| 875 | + $max = 'max="'.esc_attr($field['max']).'"'; |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $min . ' ' . $max . ' class="small-text" ' . $disabled . ' />' . "\n"; |
|
| 878 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$min.' '.$max.' class="small-text" '.$disabled.' />'."\n"; |
|
| 879 | 879 | break; |
| 880 | 880 | |
| 881 | 881 | case 'textarea': |
| 882 | - $html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . $disabled . '>' . $data . '</textarea><br/>'. "\n"; |
|
| 882 | + $html .= '<textarea id="'.esc_attr($field['id']).'" rows="5" cols="50" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" '.$disabled.'>'.$data.'</textarea><br/>'."\n"; |
|
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case 'checkbox': |
| 886 | 886 | //backwards compatibility |
| 887 | - if( empty( $data ) || 'on' == $data ){ |
|
| 887 | + if (empty($data) || 'on' == $data) { |
|
| 888 | 888 | $checked_value = 'on'; |
| 889 | - }elseif( 'yes' == $data ) { |
|
| 889 | + }elseif ('yes' == $data) { |
|
| 890 | 890 | |
| 891 | 891 | $checked_value = 'yes'; |
| 892 | 892 | |
| 893 | - }elseif( 'auto' == $data ) { |
|
| 893 | + }elseif ('auto' == $data) { |
|
| 894 | 894 | |
| 895 | 895 | $checked_value = 'auto'; |
| 896 | 896 | |
| 897 | 897 | } else { |
| 898 | 898 | $checked_value = 1; |
| 899 | - $data = intval( $data ); |
|
| 899 | + $data = intval($data); |
|
| 900 | 900 | } |
| 901 | - $checked = checked( $checked_value, $data, false ); |
|
| 902 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; |
|
| 901 | + $checked = checked($checked_value, $data, false); |
|
| 902 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n"; |
|
| 903 | 903 | break; |
| 904 | 904 | |
| 905 | 905 | case 'checkbox_multi': |
| 906 | - foreach( $field['options'] as $k => $v ) { |
|
| 906 | + foreach ($field['options'] as $k => $v) { |
|
| 907 | 907 | $checked = false; |
| 908 | - if( in_array( $k, $data ) ) { |
|
| 908 | + if (in_array($k, $data)) { |
|
| 909 | 909 | $checked = true; |
| 910 | 910 | } |
| 911 | - $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n"; |
|
| 911 | + $html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="checkbox" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'[]" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n"; |
|
| 912 | 912 | } |
| 913 | 913 | break; |
| 914 | 914 | |
| 915 | 915 | case 'radio': |
| 916 | - foreach( $field['options'] as $k => $v ) { |
|
| 916 | + foreach ($field['options'] as $k => $v) { |
|
| 917 | 917 | $checked = false; |
| 918 | - if( $k == $data ) { |
|
| 918 | + if ($k == $data) { |
|
| 919 | 919 | $checked = true; |
| 920 | 920 | } |
| 921 | - $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n"; |
|
| 921 | + $html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="radio" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n"; |
|
| 922 | 922 | } |
| 923 | 923 | break; |
| 924 | 924 | |
| 925 | 925 | case 'select': |
| 926 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n"; |
|
| 927 | - foreach( $field['options'] as $k => $v ) { |
|
| 926 | + $html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n"; |
|
| 927 | + foreach ($field['options'] as $k => $v) { |
|
| 928 | 928 | $selected = false; |
| 929 | - if( $k == $data ) { |
|
| 929 | + if ($k == $data) { |
|
| 930 | 930 | $selected = true; |
| 931 | 931 | } |
| 932 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n"; |
|
| 932 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n"; |
|
| 933 | 933 | } |
| 934 | - $html .= '</select><br/>' . "\n"; |
|
| 934 | + $html .= '</select><br/>'."\n"; |
|
| 935 | 935 | break; |
| 936 | 936 | |
| 937 | 937 | case 'select_multi': |
| 938 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n"; |
|
| 939 | - foreach( $field['options'] as $k => $v ) { |
|
| 938 | + $html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n"; |
|
| 939 | + foreach ($field['options'] as $k => $v) { |
|
| 940 | 940 | $selected = false; |
| 941 | - if( in_array( $k, $data ) ) { |
|
| 941 | + if (in_array($k, $data)) { |
|
| 942 | 942 | $selected = true; |
| 943 | 943 | } |
| 944 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n"; |
|
| 944 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n"; |
|
| 945 | 945 | } |
| 946 | 946 | $html .= '</select> . "\n"'; |
| 947 | 947 | break; |
| 948 | 948 | |
| 949 | 949 | case 'hidden': |
| 950 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n"; |
|
| 950 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n"; |
|
| 951 | 951 | break; |
| 952 | 952 | |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - if( $field['description'] ) { |
|
| 956 | - $html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n"; |
|
| 955 | + if ($field['description']) { |
|
| 956 | + $html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n"; |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { |
|
| 960 | - $html .= '</label>' . "\n"; |
|
| 959 | + if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { |
|
| 960 | + $html .= '</label>'."\n"; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - if( 'hidden' != $field['type'] ) { |
|
| 964 | - $html .= '</p>' . "\n"; |
|
| 963 | + if ('hidden' != $field['type']) { |
|
| 964 | + $html .= '</p>'."\n"; |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - $html .= '</div>' . "\n"; |
|
| 969 | + $html .= '</div>'."\n"; |
|
| 970 | 970 | |
| 971 | - $html .= '</div>' . "\n"; |
|
| 971 | + $html .= '</div>'."\n"; |
|
| 972 | 972 | |
| 973 | 973 | return $html; |
| 974 | 974 | } |
@@ -979,61 +979,61 @@ discard block |
||
| 979 | 979 | */ |
| 980 | 980 | public function course_order_screen() { |
| 981 | 981 | |
| 982 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 983 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); |
|
| 982 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 983 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); |
|
| 984 | 984 | |
| 985 | 985 | ?><div id="course-order" class="wrap course-order"> |
| 986 | - <h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php |
|
| 986 | + <h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php |
|
| 987 | 987 | |
| 988 | 988 | $html = ''; |
| 989 | 989 | |
| 990 | - if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) { |
|
| 991 | - $ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) ); |
|
| 990 | + if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) { |
|
| 991 | + $ordered = $this->save_course_order(esc_attr($_POST['course-order'])); |
|
| 992 | 992 | |
| 993 | - if( $ordered ) { |
|
| 994 | - $html .= '<div class="updated fade">' . "\n"; |
|
| 995 | - $html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
| 996 | - $html .= '</div>' . "\n"; |
|
| 993 | + if ($ordered) { |
|
| 994 | + $html .= '<div class="updated fade">'."\n"; |
|
| 995 | + $html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n"; |
|
| 996 | + $html .= '</div>'."\n"; |
|
| 997 | 997 | } |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | $courses = Sensei()->course->get_all_courses(); |
| 1001 | 1001 | |
| 1002 | - if( 0 < count( $courses ) ) { |
|
| 1002 | + if (0 < count($courses)) { |
|
| 1003 | 1003 | |
| 1004 | 1004 | // order the courses as set by the users |
| 1005 | 1005 | $all_course_ids = array(); |
| 1006 | - foreach( $courses as $course ){ |
|
| 1006 | + foreach ($courses as $course) { |
|
| 1007 | 1007 | |
| 1008 | - $all_course_ids[] = (string)$course->ID; |
|
| 1008 | + $all_course_ids[] = (string) $course->ID; |
|
| 1009 | 1009 | |
| 1010 | 1010 | } |
| 1011 | 1011 | $order_string = $this->get_course_order(); |
| 1012 | 1012 | |
| 1013 | - if( !empty( $order_string ) ){ |
|
| 1014 | - $ordered_course_ids = explode(',' , $order_string ); |
|
| 1015 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
| 1013 | + if ( ! empty($order_string)) { |
|
| 1014 | + $ordered_course_ids = explode(',', $order_string); |
|
| 1015 | + $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids)); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | |
| 1019 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
| 1020 | - $html .= '<ul class="sortable-course-list">' . "\n"; |
|
| 1019 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
| 1020 | + $html .= '<ul class="sortable-course-list">'."\n"; |
|
| 1021 | 1021 | $count = 0; |
| 1022 | - foreach ( $all_course_ids as $course_id ) { |
|
| 1023 | - $course = get_post( $course_id ); |
|
| 1022 | + foreach ($all_course_ids as $course_id) { |
|
| 1023 | + $course = get_post($course_id); |
|
| 1024 | 1024 | $count++; |
| 1025 | 1025 | $class = 'course'; |
| 1026 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1027 | - if ( $count == count( $course ) ) { $class .= ' last'; } |
|
| 1028 | - if ( $count % 2 != 0 ) { |
|
| 1026 | + if ($count == 1) { $class .= ' first'; } |
|
| 1027 | + if ($count == count($course)) { $class .= ' last'; } |
|
| 1028 | + if ($count % 2 != 0) { |
|
| 1029 | 1029 | $class .= ' alternate'; |
| 1030 | 1030 | } |
| 1031 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n"; |
|
| 1031 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n"; |
|
| 1032 | 1032 | } |
| 1033 | - $html .= '</ul>' . "\n"; |
|
| 1033 | + $html .= '</ul>'."\n"; |
|
| 1034 | 1034 | |
| 1035 | - $html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; |
|
| 1036 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n"; |
|
| 1035 | + $html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n"; |
|
| 1036 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n"; |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | echo $html; |
@@ -1042,25 +1042,25 @@ discard block |
||
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | public function get_course_order() { |
| 1045 | - return get_option( 'sensei_course_order', '' ); |
|
| 1045 | + return get_option('sensei_course_order', ''); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - public function save_course_order( $order_string = '' ) { |
|
| 1049 | - $order = explode( ',', $order_string ); |
|
| 1048 | + public function save_course_order($order_string = '') { |
|
| 1049 | + $order = explode(',', $order_string); |
|
| 1050 | 1050 | |
| 1051 | - update_option( 'sensei_course_order', $order_string ); |
|
| 1051 | + update_option('sensei_course_order', $order_string); |
|
| 1052 | 1052 | |
| 1053 | 1053 | $i = 1; |
| 1054 | - foreach( $order as $course_id ) { |
|
| 1054 | + foreach ($order as $course_id) { |
|
| 1055 | 1055 | |
| 1056 | - if( $course_id ) { |
|
| 1056 | + if ($course_id) { |
|
| 1057 | 1057 | |
| 1058 | 1058 | $update_args = array( |
| 1059 | 1059 | 'ID' => $course_id, |
| 1060 | 1060 | 'menu_order' => $i, |
| 1061 | 1061 | ); |
| 1062 | 1062 | |
| 1063 | - wp_update_post( $update_args ); |
|
| 1063 | + wp_update_post($update_args); |
|
| 1064 | 1064 | |
| 1065 | 1065 | ++$i; |
| 1066 | 1066 | } |
@@ -1075,22 +1075,22 @@ discard block |
||
| 1075 | 1075 | */ |
| 1076 | 1076 | public function lesson_order_screen() { |
| 1077 | 1077 | |
| 1078 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1079 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); |
|
| 1078 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1079 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); |
|
| 1080 | 1080 | |
| 1081 | 1081 | ?><div id="lesson-order" class="wrap lesson-order"> |
| 1082 | - <h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php |
|
| 1082 | + <h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php |
|
| 1083 | 1083 | |
| 1084 | 1084 | $html = ''; |
| 1085 | 1085 | |
| 1086 | - if( isset( $_POST['lesson-order'] ) ) { |
|
| 1086 | + if (isset($_POST['lesson-order'])) { |
|
| 1087 | 1087 | |
| 1088 | - $ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) ); |
|
| 1088 | + $ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id'])); |
|
| 1089 | 1089 | |
| 1090 | - if( $ordered ) { |
|
| 1091 | - $html .= '<div class="updated fade">' . "\n"; |
|
| 1092 | - $html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
| 1093 | - $html .= '</div>' . "\n"; |
|
| 1090 | + if ($ordered) { |
|
| 1091 | + $html .= '<div class="updated fade">'."\n"; |
|
| 1092 | + $html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n"; |
|
| 1093 | + $html .= '</div>'."\n"; |
|
| 1094 | 1094 | } |
| 1095 | 1095 | } |
| 1096 | 1096 | |
@@ -1101,43 +1101,43 @@ discard block |
||
| 1101 | 1101 | 'orderby' => 'name', |
| 1102 | 1102 | 'order' => 'ASC', |
| 1103 | 1103 | ); |
| 1104 | - $courses = get_posts( $args ); |
|
| 1104 | + $courses = get_posts($args); |
|
| 1105 | 1105 | |
| 1106 | - $html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n"; |
|
| 1107 | - $html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n"; |
|
| 1108 | - $html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n"; |
|
| 1109 | - $html .= '<select id="lesson-order-course" name="course_id">' . "\n"; |
|
| 1110 | - $html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
| 1106 | + $html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n"; |
|
| 1107 | + $html .= '<input type="hidden" name="post_type" value="lesson" />'."\n"; |
|
| 1108 | + $html .= '<input type="hidden" name="page" value="lesson-order" />'."\n"; |
|
| 1109 | + $html .= '<select id="lesson-order-course" name="course_id">'."\n"; |
|
| 1110 | + $html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n"; |
|
| 1111 | 1111 | |
| 1112 | - foreach( $courses as $course ) { |
|
| 1112 | + foreach ($courses as $course) { |
|
| 1113 | 1113 | $course_id = ''; |
| 1114 | - if( isset( $_GET['course_id'] ) ) { |
|
| 1115 | - $course_id = intval( $_GET['course_id'] ); |
|
| 1114 | + if (isset($_GET['course_id'])) { |
|
| 1115 | + $course_id = intval($_GET['course_id']); |
|
| 1116 | 1116 | } |
| 1117 | - $html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n"; |
|
| 1117 | + $html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n"; |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - $html .= '</select>' . "\n"; |
|
| 1121 | - $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n"; |
|
| 1122 | - $html .= '</form>' . "\n"; |
|
| 1120 | + $html .= '</select>'."\n"; |
|
| 1121 | + $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n"; |
|
| 1122 | + $html .= '</form>'."\n"; |
|
| 1123 | 1123 | |
| 1124 | - $html .= '<script type="text/javascript">' . "\n"; |
|
| 1125 | - $html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n"; |
|
| 1126 | - $html .= '</script>' . "\n"; |
|
| 1124 | + $html .= '<script type="text/javascript">'."\n"; |
|
| 1125 | + $html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n"; |
|
| 1126 | + $html .= '</script>'."\n"; |
|
| 1127 | 1127 | |
| 1128 | - if( isset( $_GET['course_id'] ) ) { |
|
| 1129 | - $course_id = intval( $_GET['course_id'] ); |
|
| 1130 | - if( $course_id > 0 ) { |
|
| 1128 | + if (isset($_GET['course_id'])) { |
|
| 1129 | + $course_id = intval($_GET['course_id']); |
|
| 1130 | + if ($course_id > 0) { |
|
| 1131 | 1131 | |
| 1132 | - $order_string = $this->get_lesson_order( $course_id ); |
|
| 1132 | + $order_string = $this->get_lesson_order($course_id); |
|
| 1133 | 1133 | |
| 1134 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
| 1134 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
| 1135 | 1135 | |
| 1136 | 1136 | $displayed_lessons = array(); |
| 1137 | 1137 | |
| 1138 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1138 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); |
|
| 1139 | 1139 | |
| 1140 | - foreach( $modules as $module ) { |
|
| 1140 | + foreach ($modules as $module) { |
|
| 1141 | 1141 | |
| 1142 | 1142 | $args = array( |
| 1143 | 1143 | 'post_type' => 'lesson', |
@@ -1146,7 +1146,7 @@ discard block |
||
| 1146 | 1146 | 'meta_query' => array( |
| 1147 | 1147 | array( |
| 1148 | 1148 | 'key' => '_lesson_course', |
| 1149 | - 'value' => intval( $course_id ), |
|
| 1149 | + 'value' => intval($course_id), |
|
| 1150 | 1150 | 'compare' => '=' |
| 1151 | 1151 | ) |
| 1152 | 1152 | ), |
@@ -1154,66 +1154,66 @@ discard block |
||
| 1154 | 1154 | array( |
| 1155 | 1155 | 'taxonomy' => Sensei()->modules->taxonomy, |
| 1156 | 1156 | 'field' => 'id', |
| 1157 | - 'terms' => intval( $module->term_id ) |
|
| 1157 | + 'terms' => intval($module->term_id) |
|
| 1158 | 1158 | ) |
| 1159 | 1159 | ), |
| 1160 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
| 1160 | + 'meta_key' => '_order_module_'.$module->term_id, |
|
| 1161 | 1161 | 'orderby' => 'meta_value_num date', |
| 1162 | 1162 | 'order' => 'ASC', |
| 1163 | 1163 | 'suppress_filters' => 0 |
| 1164 | 1164 | ); |
| 1165 | 1165 | |
| 1166 | - $lessons = get_posts( $args ); |
|
| 1166 | + $lessons = get_posts($args); |
|
| 1167 | 1167 | |
| 1168 | - if( count( $lessons ) > 0 ) { |
|
| 1169 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
| 1170 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
| 1168 | + if (count($lessons) > 0) { |
|
| 1169 | + $html .= '<h3>'.$module->name.'</h3>'."\n"; |
|
| 1170 | + $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n"; |
|
| 1171 | 1171 | |
| 1172 | 1172 | $count = 0; |
| 1173 | - foreach( $lessons as $lesson ) { |
|
| 1173 | + foreach ($lessons as $lesson) { |
|
| 1174 | 1174 | $count++; |
| 1175 | 1175 | $class = 'lesson'; |
| 1176 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1177 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
| 1178 | - if ( $count % 2 != 0 ) { |
|
| 1176 | + if ($count == 1) { $class .= ' first'; } |
|
| 1177 | + if ($count == count($lesson)) { $class .= ' last'; } |
|
| 1178 | + if ($count % 2 != 0) { |
|
| 1179 | 1179 | $class .= ' alternate'; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
| 1182 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; |
|
| 1183 | 1183 | |
| 1184 | 1184 | $displayed_lessons[] = $lesson->ID; |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - $html .= '</ul>' . "\n"; |
|
| 1187 | + $html .= '</ul>'."\n"; |
|
| 1188 | 1188 | |
| 1189 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
| 1189 | + $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n"; |
|
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | 1193 | |
| 1194 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
| 1194 | + $lessons = Sensei()->course->course_lessons($course_id); |
|
| 1195 | 1195 | |
| 1196 | - if( 0 < count( $lessons ) ) { |
|
| 1196 | + if (0 < count($lessons)) { |
|
| 1197 | 1197 | |
| 1198 | 1198 | //get module term ids, will be used to exclude lessons |
| 1199 | 1199 | $module_items_ids = array(); |
| 1200 | - if( ! empty( $modules ) ) { |
|
| 1200 | + if ( ! empty($modules)) { |
|
| 1201 | 1201 | foreach ($modules as $module) { |
| 1202 | 1202 | $module_items_ids[] = $module->term_id; |
| 1203 | 1203 | } |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | - if( 0 < count( $displayed_lessons ) ) { |
|
| 1207 | - $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; |
|
| 1206 | + if (0 < count($displayed_lessons)) { |
|
| 1207 | + $html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n"; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - $html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n"; |
|
| 1210 | + $html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n"; |
|
| 1211 | 1211 | $count = 0; |
| 1212 | - foreach ( $lessons as $lesson ) { |
|
| 1212 | + foreach ($lessons as $lesson) { |
|
| 1213 | 1213 | |
| 1214 | 1214 | // if lesson belongs to one fo the course modules then exclude it here |
| 1215 | 1215 | // as it is listed above |
| 1216 | - if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
| 1216 | + if (has_term($module_items_ids, 'module', $lesson->ID)) { |
|
| 1217 | 1217 | |
| 1218 | 1218 | continue; |
| 1219 | 1219 | |
@@ -1221,28 +1221,28 @@ discard block |
||
| 1221 | 1221 | |
| 1222 | 1222 | $count++; |
| 1223 | 1223 | $class = 'lesson'; |
| 1224 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1225 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
| 1226 | - if ( $count % 2 != 0 ) { |
|
| 1224 | + if ($count == 1) { $class .= ' first'; } |
|
| 1225 | + if ($count == count($lesson)) { $class .= ' last'; } |
|
| 1226 | + if ($count % 2 != 0) { |
|
| 1227 | 1227 | |
| 1228 | 1228 | $class .= ' alternate'; |
| 1229 | 1229 | |
| 1230 | 1230 | } |
| 1231 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
| 1231 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; |
|
| 1232 | 1232 | |
| 1233 | 1233 | $displayed_lessons[] = $lesson->ID; |
| 1234 | 1234 | } |
| 1235 | - $html .= '</ul>' . "\n"; |
|
| 1235 | + $html .= '</ul>'."\n"; |
|
| 1236 | 1236 | } else { |
| 1237 | - if( 0 == count( $displayed_lessons ) ) { |
|
| 1238 | - $html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>'; |
|
| 1237 | + if (0 == count($displayed_lessons)) { |
|
| 1238 | + $html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>'; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | - if( 0 < count( $displayed_lessons ) ) { |
|
| 1243 | - $html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; |
|
| 1244 | - $html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n"; |
|
| 1245 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n"; |
|
| 1242 | + if (0 < count($displayed_lessons)) { |
|
| 1243 | + $html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n"; |
|
| 1244 | + $html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n"; |
|
| 1245 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n"; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | } |
| 1248 | 1248 | } |
@@ -1252,29 +1252,29 @@ discard block |
||
| 1252 | 1252 | ?></div><?php |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | - public function get_lesson_order( $course_id = 0 ) { |
|
| 1256 | - $order_string = get_post_meta( $course_id, '_lesson_order', true ); |
|
| 1255 | + public function get_lesson_order($course_id = 0) { |
|
| 1256 | + $order_string = get_post_meta($course_id, '_lesson_order', true); |
|
| 1257 | 1257 | return $order_string; |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | - public function save_lesson_order( $order_string = '', $course_id = 0 ) { |
|
| 1260 | + public function save_lesson_order($order_string = '', $course_id = 0) { |
|
| 1261 | 1261 | |
| 1262 | - if( $course_id ) { |
|
| 1262 | + if ($course_id) { |
|
| 1263 | 1263 | |
| 1264 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1264 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); |
|
| 1265 | 1265 | |
| 1266 | - foreach( $modules as $module ) { |
|
| 1266 | + foreach ($modules as $module) { |
|
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | - if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) |
|
| 1270 | - && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { |
|
| 1269 | + if (isset($_POST['lesson-order-module-'.$module->term_id]) |
|
| 1270 | + && $_POST['lesson-order-module-'.$module->term_id]) { |
|
| 1271 | 1271 | |
| 1272 | - $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); |
|
| 1272 | + $order = explode(',', $_POST['lesson-order-module-'.$module->term_id]); |
|
| 1273 | 1273 | $i = 1; |
| 1274 | - foreach( $order as $lesson_id ) { |
|
| 1274 | + foreach ($order as $lesson_id) { |
|
| 1275 | 1275 | |
| 1276 | - if( $lesson_id ) { |
|
| 1277 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
| 1276 | + if ($lesson_id) { |
|
| 1277 | + update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i); |
|
| 1278 | 1278 | ++$i; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
@@ -1285,15 +1285,15 @@ discard block |
||
| 1285 | 1285 | } // end for each modules |
| 1286 | 1286 | |
| 1287 | 1287 | |
| 1288 | - if( $order_string ) { |
|
| 1289 | - update_post_meta( $course_id, '_lesson_order', $order_string ); |
|
| 1288 | + if ($order_string) { |
|
| 1289 | + update_post_meta($course_id, '_lesson_order', $order_string); |
|
| 1290 | 1290 | |
| 1291 | - $order = explode( ',', $order_string ); |
|
| 1291 | + $order = explode(',', $order_string); |
|
| 1292 | 1292 | |
| 1293 | 1293 | $i = 1; |
| 1294 | - foreach( $order as $lesson_id ) { |
|
| 1295 | - if( $lesson_id ) { |
|
| 1296 | - update_post_meta( $lesson_id, '_order_' . $course_id, $i ); |
|
| 1294 | + foreach ($order as $lesson_id) { |
|
| 1295 | + if ($lesson_id) { |
|
| 1296 | + update_post_meta($lesson_id, '_order_'.$course_id, $i); |
|
| 1297 | 1297 | ++$i; |
| 1298 | 1298 | } |
| 1299 | 1299 | } |
@@ -1308,54 +1308,54 @@ discard block |
||
| 1308 | 1308 | function sensei_add_custom_menu_items() { |
| 1309 | 1309 | global $pagenow; |
| 1310 | 1310 | |
| 1311 | - if( 'nav-menus.php' == $pagenow ) { |
|
| 1312 | - add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' ); |
|
| 1311 | + if ('nav-menus.php' == $pagenow) { |
|
| 1312 | + add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low'); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | - function wp_nav_menu_item_sensei_links_meta_box( $object ) { |
|
| 1316 | + function wp_nav_menu_item_sensei_links_meta_box($object) { |
|
| 1317 | 1317 | global $nav_menu_selected_id; |
| 1318 | 1318 | |
| 1319 | 1319 | $menu_items = array( |
| 1320 | - '#senseicourses' => __( 'Courses', 'woothemes-sensei' ), |
|
| 1321 | - '#senseilessons' => __( 'Lessons', 'woothemes-sensei' ), |
|
| 1322 | - '#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ), |
|
| 1323 | - '#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ), |
|
| 1324 | - '#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ), |
|
| 1325 | - '#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' ) |
|
| 1320 | + '#senseicourses' => __('Courses', 'woothemes-sensei'), |
|
| 1321 | + '#senseilessons' => __('Lessons', 'woothemes-sensei'), |
|
| 1322 | + '#senseimycourses' => __('My Courses', 'woothemes-sensei'), |
|
| 1323 | + '#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'), |
|
| 1324 | + '#senseimymessages' => __('My Messages', 'woothemes-sensei'), |
|
| 1325 | + '#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei') |
|
| 1326 | 1326 | ); |
| 1327 | 1327 | |
| 1328 | 1328 | $menu_items_obj = array(); |
| 1329 | - foreach ( $menu_items as $value => $title ) { |
|
| 1329 | + foreach ($menu_items as $value => $title) { |
|
| 1330 | 1330 | $menu_items_obj[$title] = new stdClass; |
| 1331 | - $menu_items_obj[$title]->object_id = esc_attr( $value ); |
|
| 1332 | - $menu_items_obj[$title]->title = esc_attr( $title ); |
|
| 1333 | - $menu_items_obj[$title]->url = esc_attr( $value ); |
|
| 1334 | - $menu_items_obj[$title]->description = 'description'; |
|
| 1331 | + $menu_items_obj[$title]->object_id = esc_attr($value); |
|
| 1332 | + $menu_items_obj[$title]->title = esc_attr($title); |
|
| 1333 | + $menu_items_obj[$title]->url = esc_attr($value); |
|
| 1334 | + $menu_items_obj[$title]->description = 'description'; |
|
| 1335 | 1335 | $menu_items_obj[$title]->db_id = 0; |
| 1336 | 1336 | $menu_items_obj[$title]->object = 'sensei'; |
| 1337 | - $menu_items_obj[$title]->menu_item_parent = 0; |
|
| 1338 | - $menu_items_obj[$title]->type = 'custom'; |
|
| 1337 | + $menu_items_obj[$title]->menu_item_parent = 0; |
|
| 1338 | + $menu_items_obj[$title]->type = 'custom'; |
|
| 1339 | 1339 | $menu_items_obj[$title]->target = ''; |
| 1340 | - $menu_items_obj[$title]->attr_title = ''; |
|
| 1341 | - $menu_items_obj[$title]->classes = array(); |
|
| 1342 | - $menu_items_obj[$title]->xfn = ''; |
|
| 1340 | + $menu_items_obj[$title]->attr_title = ''; |
|
| 1341 | + $menu_items_obj[$title]->classes = array(); |
|
| 1342 | + $menu_items_obj[$title]->xfn = ''; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
| 1345 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
| 1346 | 1346 | ?> |
| 1347 | 1347 | |
| 1348 | 1348 | <div id="sensei-links" class="senseidiv taxonomydiv"> |
| 1349 | 1349 | <div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active"> |
| 1350 | 1350 | |
| 1351 | 1351 | <ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear"> |
| 1352 | - <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?> |
|
| 1352 | + <?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?> |
|
| 1353 | 1353 | </ul> |
| 1354 | 1354 | |
| 1355 | 1355 | </div> |
| 1356 | 1356 | <p class="button-controls"> |
| 1357 | 1357 | <span class="add-to-menu"> |
| 1358 | - <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'woothemes-sensei' ); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" /> |
|
| 1358 | + <input type="submit"<?php disabled($nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu', 'woothemes-sensei'); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" /> |
|
| 1359 | 1359 | <span class="spinner"></span> |
| 1360 | 1360 | </span> |
| 1361 | 1361 | </p> |
@@ -1371,17 +1371,17 @@ discard block |
||
| 1371 | 1371 | */ |
| 1372 | 1372 | public function theme_compatibility_notices() { |
| 1373 | 1373 | |
| 1374 | - if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
| 1375 | - switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
| 1376 | - case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; |
|
| 1377 | - case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; |
|
| 1374 | + if (isset($_GET['sensei_hide_notice'])) { |
|
| 1375 | + switch (esc_attr($_GET['sensei_hide_notice'])) { |
|
| 1376 | + case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break; |
|
| 1377 | + case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break; |
|
| 1378 | 1378 | } |
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | // white list templates that are already support by default and do not show notice for them |
| 1382 | - $template = get_option( 'template' ); |
|
| 1382 | + $template = get_option('template'); |
|
| 1383 | 1383 | |
| 1384 | - $white_list = array( 'twentyeleven', |
|
| 1384 | + $white_list = array('twentyeleven', |
|
| 1385 | 1385 | 'twentytwelve', |
| 1386 | 1386 | 'twentyfourteen', |
| 1387 | 1387 | 'twentyfifteen', |
@@ -1389,43 +1389,43 @@ discard block |
||
| 1389 | 1389 | 'storefront', |
| 1390 | 1390 | ); |
| 1391 | 1391 | |
| 1392 | - if ( in_array( $template, $white_list ) ) { |
|
| 1392 | + if (in_array($template, $white_list)) { |
|
| 1393 | 1393 | |
| 1394 | 1394 | return; |
| 1395 | 1395 | |
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | // don't show the notice if the user chose to hide it |
| 1399 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
| 1400 | - if( $hide_theme_check_notice ) { |
|
| 1399 | + $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); |
|
| 1400 | + if ($hide_theme_check_notice) { |
|
| 1401 | 1401 | |
| 1402 | 1402 | return; |
| 1403 | 1403 | |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | // show the notice for themes not supporting sensei |
| 1407 | - if ( ! current_theme_supports( 'sensei' ) ) { |
|
| 1407 | + if ( ! current_theme_supports('sensei')) { |
|
| 1408 | 1408 | ?> |
| 1409 | 1409 | |
| 1410 | 1410 | <div id="message" class="error sensei-message sensei-connect"> |
| 1411 | 1411 | <p> |
| 1412 | 1412 | <strong> |
| 1413 | 1413 | |
| 1414 | - <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?> |
|
| 1414 | + <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?> |
|
| 1415 | 1415 | |
| 1416 | 1416 | </strong> – |
| 1417 | 1417 | |
| 1418 | - <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?> |
|
| 1418 | + <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?> |
|
| 1419 | 1419 | |
| 1420 | - <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a> |
|
| 1420 | + <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e('Sensei theme', 'woothemes-sensei') ?> </a> |
|
| 1421 | 1421 | |
| 1422 | 1422 | :) |
| 1423 | 1423 | |
| 1424 | 1424 | </p> |
| 1425 | 1425 | <p class="submit"> |
| 1426 | - <a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility' ) ); ?>" class="button-primary"> |
|
| 1426 | + <a href="<?php echo esc_url(apply_filters('sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility')); ?>" class="button-primary"> |
|
| 1427 | 1427 | |
| 1428 | - <?php _e( 'Theme Integration Guide', 'woothemes-sensei' ); ?></a> <a class="skip button" href="<?php echo esc_url( add_query_arg( 'sensei_hide_notice', 'theme_check' ) ); ?>"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?> |
|
| 1428 | + <?php _e('Theme Integration Guide', 'woothemes-sensei'); ?></a> <a class="skip button" href="<?php echo esc_url(add_query_arg('sensei_hide_notice', 'theme_check')); ?>"><?php _e('Hide this notice', 'woothemes-sensei'); ?> |
|
| 1429 | 1429 | |
| 1430 | 1430 | </a> |
| 1431 | 1431 | </p> |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | wp_get_current_user(); |
| 1444 | 1444 | $user_id = $current_user->ID; |
| 1445 | 1445 | |
| 1446 | - delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); |
|
| 1446 | + delete_user_meta($user_id, 'sensei_hide_theme_check_notice'); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1453,8 +1453,8 @@ discard block |
||
| 1453 | 1453 | * @param bool $prevent_access |
| 1454 | 1454 | * @return bool |
| 1455 | 1455 | */ |
| 1456 | - public function admin_access( $prevent_access ) { |
|
| 1457 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 1456 | + public function admin_access($prevent_access) { |
|
| 1457 | + if (current_user_can('manage_sensei_grades')) { |
|
| 1458 | 1458 | return false; |
| 1459 | 1459 | } |
| 1460 | 1460 | |
@@ -1469,12 +1469,12 @@ discard block |
||
| 1469 | 1469 | * |
| 1470 | 1470 | * @since 1.8.7 |
| 1471 | 1471 | */ |
| 1472 | - public static function install_pages(){ |
|
| 1472 | + public static function install_pages() { |
|
| 1473 | 1473 | |
| 1474 | 1474 | // only fire on the settings page |
| 1475 | - if( ! isset( $_GET['page'] ) |
|
| 1475 | + if ( ! isset($_GET['page']) |
|
| 1476 | 1476 | || 'woothemes-sensei-settings' != $_GET['page'] |
| 1477 | - || 1 == get_option('skip_install_sensei_pages') ){ |
|
| 1477 | + || 1 == get_option('skip_install_sensei_pages')) { |
|
| 1478 | 1478 | |
| 1479 | 1479 | return; |
| 1480 | 1480 | |
@@ -1511,8 +1511,8 @@ discard block |
||
| 1511 | 1511 | // Set installed option |
| 1512 | 1512 | update_option('sensei_installed', 0); |
| 1513 | 1513 | |
| 1514 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
| 1515 | - wp_redirect( $complete_url ); |
|
| 1514 | + $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url); |
|
| 1515 | + wp_redirect($complete_url); |
|
| 1516 | 1516 | |
| 1517 | 1517 | } |
| 1518 | 1518 | |
@@ -1526,4 +1526,4 @@ discard block |
||
| 1526 | 1526 | * @since 1.9.0 |
| 1527 | 1527 | * @ignore |
| 1528 | 1528 | */ |
| 1529 | -class WooThemes_Sensei_Admin extends Sensei_Admin{ } |
|
| 1529 | +class WooThemes_Sensei_Admin extends Sensei_Admin { } |
|
@@ -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 | * A settings API (wrapping the WordPress Settings API). |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @access public |
| 32 | 32 | * @since 1.0.0 |
| 33 | 33 | */ |
| 34 | - public function __construct () { |
|
| 34 | + public function __construct() { |
|
| 35 | 35 | |
| 36 | 36 | $this->token = 'woothemes-sensei-settings'; |
| 37 | 37 | $this->page_slug = 'woothemes-sensei-settings-api'; |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function register_hook_listener() { |
| 59 | 59 | |
| 60 | - add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 61 | - add_action( 'admin_init', array( $this, 'settings_fields' ) ); |
|
| 62 | - add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 60 | + add_action('admin_menu', array($this, 'register_settings_screen'), 60); |
|
| 61 | + add_action('admin_init', array($this, 'settings_fields')); |
|
| 62 | + add_action('init', array($this, 'general_init'), 5); |
|
| 63 | 63 | |
| 64 | 64 | } // End setup_settings() |
| 65 | 65 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $this->init_sections(); |
| 74 | 74 | $this->init_fields(); |
| 75 | 75 | $this->get_settings(); |
| 76 | - if ( $this->has_tabs == true ) { |
|
| 76 | + if ($this->has_tabs == true) { |
|
| 77 | 77 | $this->create_tabs(); |
| 78 | 78 | } // End If Statement |
| 79 | 79 | } // End general_init() |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | * @since 1.0.0 |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | - public function init_sections () { |
|
| 87 | + public function init_sections() { |
|
| 88 | 88 | // Override this function in your class and assign the array of sections to $this->sections. |
| 89 | - _e( 'Override init_sections() in your class.', 'woothemes-sensei' ); |
|
| 89 | + _e('Override init_sections() in your class.', 'woothemes-sensei'); |
|
| 90 | 90 | } // End init_sections() |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @since 1.0.0 |
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | - public function init_fields () { |
|
| 98 | + public function init_fields() { |
|
| 99 | 99 | // Override this function in your class and assign the array of sections to $this->fields. |
| 100 | - _e( 'Override init_fields() in your class.', 'woothemes-sensei' ); |
|
| 100 | + _e('Override init_fields() in your class.', 'woothemes-sensei'); |
|
| 101 | 101 | } // End init_fields() |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -106,34 +106,34 @@ discard block |
||
| 106 | 106 | * @since 1.1.0 |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function settings_tabs () { |
|
| 109 | + public function settings_tabs() { |
|
| 110 | 110 | |
| 111 | - if ( ! $this->has_tabs ) { return; } |
|
| 111 | + if ( ! $this->has_tabs) { return; } |
|
| 112 | 112 | |
| 113 | - if ( count( $this->tabs ) > 0 ) { |
|
| 113 | + if (count($this->tabs) > 0) { |
|
| 114 | 114 | $html = ''; |
| 115 | 115 | |
| 116 | - $html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n"; |
|
| 116 | + $html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">'."\n"; |
|
| 117 | 117 | |
| 118 | 118 | $sections = array( |
| 119 | - 'all' => array( 'href' => '#all', 'name' => __( 'All', 'woothemes-sensei' ), 'class' => 'current all tab' ) |
|
| 119 | + 'all' => array('href' => '#all', 'name' => __('All', 'woothemes-sensei'), 'class' => 'current all tab') |
|
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | - foreach ( $this->tabs as $k => $v ) { |
|
| 123 | - $sections[$k] = array( 'href' => '#' . esc_attr( $k ), 'name' => esc_attr( $v['name'] ), 'class' => 'tab' ); |
|
| 122 | + foreach ($this->tabs as $k => $v) { |
|
| 123 | + $sections[$k] = array('href' => '#'.esc_attr($k), 'name' => esc_attr($v['name']), 'class' => 'tab'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $count = 1; |
| 127 | - foreach ( $sections as $k => $v ) { |
|
| 127 | + foreach ($sections as $k => $v) { |
|
| 128 | 128 | $count++; |
| 129 | - $html .= '<li><a href="' . $v['href'] . '"'; |
|
| 130 | - if ( isset( $v['class'] ) && ( $v['class'] != '' ) ) { $html .= ' class="' . esc_attr( $v['class'] ) . '"'; } |
|
| 131 | - $html .= '>' . esc_attr( $v['name'] ) . '</a>'; |
|
| 132 | - if ( $count <= count( $sections ) ) { $html .= ' | '; } |
|
| 133 | - $html .= '</li>' . "\n"; |
|
| 129 | + $html .= '<li><a href="'.$v['href'].'"'; |
|
| 130 | + if (isset($v['class']) && ($v['class'] != '')) { $html .= ' class="'.esc_attr($v['class']).'"'; } |
|
| 131 | + $html .= '>'.esc_attr($v['name']).'</a>'; |
|
| 132 | + if ($count <= count($sections)) { $html .= ' | '; } |
|
| 133 | + $html .= '</li>'."\n"; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $html .= '</ul><div class="clear"></div>' . "\n"; |
|
| 136 | + $html .= '</ul><div class="clear"></div>'."\n"; |
|
| 137 | 137 | |
| 138 | 138 | echo $html; |
| 139 | 139 | } |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | * @since 1.1.0 |
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | - private function create_tabs () { |
|
| 149 | - if ( count( $this->sections ) > 0 ) { |
|
| 148 | + private function create_tabs() { |
|
| 149 | + if (count($this->sections) > 0) { |
|
| 150 | 150 | $tabs = array(); |
| 151 | - foreach ( $this->sections as $k => $v ) { |
|
| 151 | + foreach ($this->sections as $k => $v) { |
|
| 152 | 152 | $tabs[$k] = $v; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * @since 1.0.0 |
| 163 | 163 | * @return void |
| 164 | 164 | */ |
| 165 | - public function create_sections () { |
|
| 166 | - if ( count( $this->sections ) > 0 ) { |
|
| 167 | - foreach ( $this->sections as $k => $v ) { |
|
| 168 | - add_settings_section( $k, $v['name'], array( $this, 'section_description' ), $this->token ); |
|
| 165 | + public function create_sections() { |
|
| 166 | + if (count($this->sections) > 0) { |
|
| 167 | + foreach ($this->sections as $k => $v) { |
|
| 168 | + add_settings_section($k, $v['name'], array($this, 'section_description'), $this->token); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } // End create_sections() |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | * @since 1.0.0 |
| 177 | 177 | * @return void |
| 178 | 178 | */ |
| 179 | - public function create_fields () { |
|
| 180 | - if ( count( $this->sections ) > 0 ) { |
|
| 179 | + public function create_fields() { |
|
| 180 | + if (count($this->sections) > 0) { |
|
| 181 | 181 | // $this->parse_fields( $this->fields ); |
| 182 | 182 | |
| 183 | - foreach ( $this->fields as $k => $v ) { |
|
| 184 | - $method = $this->determine_method( $v, 'form' ); |
|
| 183 | + foreach ($this->fields as $k => $v) { |
|
| 184 | + $method = $this->determine_method($v, 'form'); |
|
| 185 | 185 | $name = $v['name']; |
| 186 | - if ( $v['type'] == 'info' ) { $name = ''; } |
|
| 187 | - add_settings_field( $k, $name, $method, $this->token, $v['section'], array( 'key' => $k, 'data' => $v ) ); |
|
| 186 | + if ($v['type'] == 'info') { $name = ''; } |
|
| 187 | + add_settings_field($k, $name, $method, $this->token, $v['section'], array('key' => $k, 'data' => $v)); |
|
| 188 | 188 | |
| 189 | 189 | // Let the API know that we have a colourpicker field. |
| 190 | - if ( $v['type'] == 'range' && $this->has_range == false ) { $this->has_range = true; } |
|
| 190 | + if ($v['type'] == 'range' && $this->has_range == false) { $this->has_range = true; } |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | } // End create_fields() |
@@ -199,43 +199,43 @@ discard block |
||
| 199 | 199 | * @param array $data |
| 200 | 200 | * @return callable, array or string |
| 201 | 201 | */ |
| 202 | - protected function determine_method ( $data, $type = 'form' ) { |
|
| 202 | + protected function determine_method($data, $type = 'form') { |
|
| 203 | 203 | $method = ''; |
| 204 | 204 | |
| 205 | - if ( ! in_array( $type, array( 'form', 'validate', 'check' ) ) ) { return; } |
|
| 205 | + if ( ! in_array($type, array('form', 'validate', 'check'))) { return; } |
|
| 206 | 206 | |
| 207 | 207 | // Check for custom functions. |
| 208 | - if ( isset( $data[$type] ) ) { |
|
| 209 | - if ( function_exists( $data[$type] ) ) { |
|
| 208 | + if (isset($data[$type])) { |
|
| 209 | + if (function_exists($data[$type])) { |
|
| 210 | 210 | $method = $data[$type]; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( $method == '' && method_exists( $this, $data[$type] ) ) { |
|
| 214 | - if ( $type == 'form' ) { |
|
| 215 | - $method = array( $this, $data[$type] ); |
|
| 213 | + if ($method == '' && method_exists($this, $data[$type])) { |
|
| 214 | + if ($type == 'form') { |
|
| 215 | + $method = array($this, $data[$type]); |
|
| 216 | 216 | } else { |
| 217 | 217 | $method = $data[$type]; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if ( $method == '' && method_exists ( $this, $type . '_field_' . $data['type'] ) ) { |
|
| 223 | - if ( $type == 'form' ) { |
|
| 224 | - $method = array( $this, $type . '_field_' . $data['type'] ); |
|
| 222 | + if ($method == '' && method_exists($this, $type.'_field_'.$data['type'])) { |
|
| 223 | + if ($type == 'form') { |
|
| 224 | + $method = array($this, $type.'_field_'.$data['type']); |
|
| 225 | 225 | } else { |
| 226 | - $method = $type . '_field_' . $data['type']; |
|
| 226 | + $method = $type.'_field_'.$data['type']; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( $method == '' && function_exists ( $this->token . '_' . $type . '_field_' . $data['type'] ) ) { |
|
| 231 | - $method = $this->token . '_' . $type . '_field_' . $data['type']; |
|
| 230 | + if ($method == '' && function_exists($this->token.'_'.$type.'_field_'.$data['type'])) { |
|
| 231 | + $method = $this->token.'_'.$type.'_field_'.$data['type']; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( $method == '' ) { |
|
| 235 | - if ( $type == 'form' ) { |
|
| 236 | - $method = array( $this, $type . '_field_text' ); |
|
| 234 | + if ($method == '') { |
|
| 235 | + if ($type == 'form') { |
|
| 236 | + $method = array($this, $type.'_field_text'); |
|
| 237 | 237 | } else { |
| 238 | - $method = $type . '_field_text'; |
|
| 238 | + $method = $type.'_field_text'; |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | * @param array $fields |
| 250 | 250 | * @return void |
| 251 | 251 | */ |
| 252 | - public function parse_fields ( $fields ) { |
|
| 253 | - foreach ( $fields as $k => $v ) { |
|
| 254 | - if ( isset( $v['section'] ) && ( $v['section'] != '' ) && ( isset( $this->sections[$v['section']] ) ) ) { |
|
| 255 | - if ( ! isset( $this->sections[$v['section']]['fields'] ) ) { |
|
| 252 | + public function parse_fields($fields) { |
|
| 253 | + foreach ($fields as $k => $v) { |
|
| 254 | + if (isset($v['section']) && ($v['section'] != '') && (isset($this->sections[$v['section']]))) { |
|
| 255 | + if ( ! isset($this->sections[$v['section']]['fields'])) { |
|
| 256 | 256 | $this->sections[$v['section']]['fields'] = array(); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -269,19 +269,19 @@ discard block |
||
| 269 | 269 | * @since 1.0.0 |
| 270 | 270 | * @return void |
| 271 | 271 | */ |
| 272 | - public function register_settings_screen () { |
|
| 272 | + public function register_settings_screen() { |
|
| 273 | 273 | |
| 274 | - if ( current_user_can( 'manage_sensei' ) ) { |
|
| 275 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
|
| 274 | + if (current_user_can('manage_sensei')) { |
|
| 275 | + $hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); |
|
| 276 | 276 | |
| 277 | 277 | $this->hook = $hook; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 280 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 281 | 281 | |
| 282 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
|
| 283 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 284 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 282 | + add_action('admin_notices', array($this, 'settings_errors')); |
|
| 283 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 284 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 285 | 285 | |
| 286 | 286 | } |
| 287 | 287 | } // End register_settings_screen() |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | * @since 1.0.0 |
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | - public function settings_screen () |
|
| 295 | + public function settings_screen() |
|
| 296 | 296 | { |
| 297 | 297 | |
| 298 | 298 | ?> |
| 299 | 299 | <div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>"> |
| 300 | 300 | <?php screen_icon('woothemes-sensei'); ?> |
| 301 | 301 | <h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) { |
| 302 | - echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 302 | + echo ' <span class="version">'.$this->settings_version.'</span>'; |
|
| 303 | 303 | } ?></h2> |
| 304 | 304 | <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" |
| 305 | 305 | title="WooThemes"><img |
@@ -313,13 +313,13 @@ discard block |
||
| 313 | 313 | $page = 'woothemes-sensei-settings'; |
| 314 | 314 | foreach ($this->sections as $section_id => $section) { |
| 315 | 315 | |
| 316 | - echo '<section id="' . $section_id . '">'; |
|
| 316 | + echo '<section id="'.$section_id.'">'; |
|
| 317 | 317 | |
| 318 | 318 | if ($section['name']) |
| 319 | 319 | echo "<h2>{$section['name']}</h2>\n"; |
| 320 | 320 | |
| 321 | 321 | echo '<table class="form-table">'; |
| 322 | - do_settings_fields($page, $section_id ); |
|
| 322 | + do_settings_fields($page, $section_id); |
|
| 323 | 323 | echo '</table>'; |
| 324 | 324 | |
| 325 | 325 | echo '</section>'; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | submit_button(); |
| 330 | 330 | ?> |
| 331 | 331 | </form> |
| 332 | - <?php do_action( 'settings_after_form' ); ?> |
|
| 332 | + <?php do_action('settings_after_form'); ?> |
|
| 333 | 333 | </div><!--/#woothemes-sensei--> |
| 334 | 334 | <?php |
| 335 | 335 | } // End settings_screen() |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | * @since 1.0.0 |
| 341 | 341 | * @return array |
| 342 | 342 | */ |
| 343 | - public function get_settings () { |
|
| 343 | + public function get_settings() { |
|
| 344 | 344 | |
| 345 | - $this->settings = get_option( $this->token, array() ); |
|
| 345 | + $this->settings = get_option($this->token, array()); |
|
| 346 | 346 | |
| 347 | - foreach ( $this->fields as $k => $v ) { |
|
| 348 | - if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) { |
|
| 347 | + foreach ($this->fields as $k => $v) { |
|
| 348 | + if ( ! isset($this->settings[$k]) && isset($v['default'])) { |
|
| 349 | 349 | $this->settings[$k] = $v['default']; |
| 350 | 350 | } |
| 351 | - if ( $v['type'] == 'checkbox' && $this->settings[$k] != true ) { |
|
| 351 | + if ($v['type'] == 'checkbox' && $this->settings[$k] != true) { |
|
| 352 | 352 | $this->settings[$k] = 0; |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | * @since 1.0.0 |
| 363 | 363 | * @return void |
| 364 | 364 | */ |
| 365 | - public function settings_fields () { |
|
| 366 | - register_setting( $this->token, $this->token, array( $this, 'validate_fields' ) ); |
|
| 365 | + public function settings_fields() { |
|
| 366 | + register_setting($this->token, $this->token, array($this, 'validate_fields')); |
|
| 367 | 367 | $this->create_sections(); |
| 368 | 368 | $this->create_fields(); |
| 369 | 369 | } // End settings_fields() |
@@ -374,8 +374,8 @@ discard block |
||
| 374 | 374 | * @since 1.0.0 |
| 375 | 375 | * @return void |
| 376 | 376 | */ |
| 377 | - public function settings_errors () { |
|
| 378 | - settings_errors( $this->token . '-errors' ); |
|
| 377 | + public function settings_errors() { |
|
| 378 | + settings_errors($this->token.'-errors'); |
|
| 379 | 379 | } // End settings_errors() |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -384,9 +384,9 @@ discard block |
||
| 384 | 384 | * @since 1.0.0 |
| 385 | 385 | * @return void |
| 386 | 386 | */ |
| 387 | - public function section_description ( $section ) { |
|
| 388 | - if ( isset( $this->sections[$section['id']]['description'] ) ) { |
|
| 389 | - echo wpautop( $this->sections[$section['id']]['description'] ); |
|
| 387 | + public function section_description($section) { |
|
| 388 | + if (isset($this->sections[$section['id']]['description'])) { |
|
| 389 | + echo wpautop($this->sections[$section['id']]['description']); |
|
| 390 | 390 | } |
| 391 | 391 | } // End section_description_main() |
| 392 | 392 | |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | * @param array $args |
| 398 | 398 | * @return void |
| 399 | 399 | */ |
| 400 | - public function form_field_text ( $args ) { |
|
| 400 | + public function form_field_text($args) { |
|
| 401 | 401 | $options = $this->get_settings(); |
| 402 | 402 | |
| 403 | - echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n"; |
|
| 404 | - if ( isset( $args['data']['description'] ) ) { |
|
| 405 | - echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n"; |
|
| 403 | + echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" value="'.esc_attr($options[$args['key']]).'" />'."\n"; |
|
| 404 | + if (isset($args['data']['description'])) { |
|
| 405 | + echo '<span class="description">'.$args['data']['description'].'</span>'."\n"; |
|
| 406 | 406 | } |
| 407 | 407 | } // End form_field_text() |
| 408 | 408 | |
@@ -413,13 +413,13 @@ discard block |
||
| 413 | 413 | * @param array $args |
| 414 | 414 | * @return void |
| 415 | 415 | */ |
| 416 | - public function form_field_color ( $args ) { |
|
| 416 | + public function form_field_color($args) { |
|
| 417 | 417 | $options = $this->get_settings(); |
| 418 | 418 | |
| 419 | - echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" class="color" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n"; |
|
| 419 | + echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" class="color" value="'.esc_attr($options[$args['key']]).'" />'."\n"; |
|
| 420 | 420 | echo '<div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div>'; |
| 421 | - if ( isset( $args['data']['description'] ) ) { |
|
| 422 | - echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n"; |
|
| 421 | + if (isset($args['data']['description'])) { |
|
| 422 | + echo '<span class="description">'.$args['data']['description'].'</span>'."\n"; |
|
| 423 | 423 | } |
| 424 | 424 | } // End form_field_text() |
| 425 | 425 | |
@@ -430,22 +430,22 @@ discard block |
||
| 430 | 430 | * @param array $args |
| 431 | 431 | * @return void |
| 432 | 432 | */ |
| 433 | - public function form_field_checkbox ( $args ) { |
|
| 433 | + public function form_field_checkbox($args) { |
|
| 434 | 434 | $options = $this->get_settings(); |
| 435 | 435 | |
| 436 | 436 | $has_description = false; |
| 437 | - if ( isset( $args['data']['description'] ) ) { |
|
| 437 | + if (isset($args['data']['description'])) { |
|
| 438 | 438 | $has_description = true; |
| 439 | - echo '<label for="' . esc_attr( $args['key'] ) . '">' . "\n"; |
|
| 439 | + echo '<label for="'.esc_attr($args['key']).'">'."\n"; |
|
| 440 | 440 | } |
| 441 | - echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n"; |
|
| 442 | - if ( $has_description ) { |
|
| 443 | - echo wp_kses( $args['data']['description'], array( 'a' => array( |
|
| 441 | + echo '<input id="'.$args['key'].'" name="'.$this->token.'['.esc_attr($args['key']).']" type="checkbox" value="1"'.checked(esc_attr($options[$args['key']]), '1', false).' />'."\n"; |
|
| 442 | + if ($has_description) { |
|
| 443 | + echo wp_kses($args['data']['description'], array('a' => array( |
|
| 444 | 444 | 'href' => array(), |
| 445 | 445 | 'title' => array() |
| 446 | 446 | ) |
| 447 | 447 | ) |
| 448 | - ) . '</label>' . "\n"; |
|
| 448 | + ).'</label>'."\n"; |
|
| 449 | 449 | } |
| 450 | 450 | } // End form_field_checkbox() |
| 451 | 451 | |
@@ -456,12 +456,12 @@ discard block |
||
| 456 | 456 | * @param array $args |
| 457 | 457 | * @return void |
| 458 | 458 | */ |
| 459 | - public function form_field_textarea ( $args ) { |
|
| 459 | + public function form_field_textarea($args) { |
|
| 460 | 460 | $options = $this->get_settings(); |
| 461 | 461 | |
| 462 | - echo '<textarea id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" cols="42" rows="5">' . esc_html( $options[$args['key']] ) . '</textarea>' . "\n"; |
|
| 463 | - if ( isset( $args['data']['description'] ) ) { |
|
| 464 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 462 | + echo '<textarea id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" cols="42" rows="5">'.esc_html($options[$args['key']]).'</textarea>'."\n"; |
|
| 463 | + if (isset($args['data']['description'])) { |
|
| 464 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 465 | 465 | } |
| 466 | 466 | } // End form_field_textarea() |
| 467 | 467 | |
@@ -472,20 +472,20 @@ discard block |
||
| 472 | 472 | * @param array $args |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function form_field_select ( $args ) { |
|
| 475 | + public function form_field_select($args) { |
|
| 476 | 476 | $options = $this->get_settings(); |
| 477 | 477 | |
| 478 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 478 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 479 | 479 | $html = ''; |
| 480 | - $html .= '<select class="" id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']">' . "\n"; |
|
| 481 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 482 | - $html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n"; |
|
| 480 | + $html .= '<select class="" id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']">'."\n"; |
|
| 481 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 482 | + $html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n"; |
|
| 483 | 483 | } |
| 484 | - $html .= '</select>' . "\n"; |
|
| 484 | + $html .= '</select>'."\n"; |
|
| 485 | 485 | echo $html; |
| 486 | 486 | |
| 487 | - if ( isset( $args['data']['description'] ) ) { |
|
| 488 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 487 | + if (isset($args['data']['description'])) { |
|
| 488 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | } // End form_field_select() |
@@ -497,18 +497,18 @@ discard block |
||
| 497 | 497 | * @param array $args |
| 498 | 498 | * @return void |
| 499 | 499 | */ |
| 500 | - public function form_field_radio ( $args ) { |
|
| 500 | + public function form_field_radio($args) { |
|
| 501 | 501 | $options = $this->get_settings(); |
| 502 | 502 | |
| 503 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 503 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 504 | 504 | $html = ''; |
| 505 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 506 | - $html .= '<input type="radio" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n"; |
|
| 505 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 506 | + $html .= '<input type="radio" name="'.$this->token.'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n"; |
|
| 507 | 507 | } |
| 508 | 508 | echo $html; |
| 509 | 509 | |
| 510 | - if ( isset( $args['data']['description'] ) ) { |
|
| 511 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 510 | + if (isset($args['data']['description'])) { |
|
| 511 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | } // End form_field_radio() |
@@ -520,28 +520,28 @@ discard block |
||
| 520 | 520 | * @param array $args |
| 521 | 521 | * @return void |
| 522 | 522 | */ |
| 523 | - public function form_field_multicheck ( $args ) { |
|
| 523 | + public function form_field_multicheck($args) { |
|
| 524 | 524 | $options = $this->get_settings(); |
| 525 | 525 | |
| 526 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 527 | - $html = '<div class="multicheck-container" style="margin-bottom:10px;">' . "\n"; |
|
| 528 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 526 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 527 | + $html = '<div class="multicheck-container" style="margin-bottom:10px;">'."\n"; |
|
| 528 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 529 | 529 | $checked = ''; |
| 530 | 530 | |
| 531 | - if( isset( $options[ $args['key'] ] ) ) { |
|
| 532 | - if ( in_array( $k, (array)$options[ $args['key'] ] ) ) { $checked = ' checked="checked"'; } |
|
| 531 | + if (isset($options[$args['key']])) { |
|
| 532 | + if (in_array($k, (array) $options[$args['key']])) { $checked = ' checked="checked"'; } |
|
| 533 | 533 | } else { |
| 534 | - if ( in_array( $k, $args['data']['defaults'] ) ) { $checked = ' checked="checked"'; } |
|
| 534 | + if (in_array($k, $args['data']['defaults'])) { $checked = ' checked="checked"'; } |
|
| 535 | 535 | } |
| 536 | - $html .= '<label for="checkbox-' . esc_attr( $k ) . '">' . "\n"; |
|
| 537 | - $html .= '<input type="checkbox" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . '][]" class="multicheck multicheck-' . esc_attr( $args['key'] ) . '" value="' . esc_attr( $k ) . '" id="checkbox-' . esc_attr( $k ) . '" ' . $checked . ' /> ' . $v . "\n"; |
|
| 538 | - $html .= '</label><br />' . "\n"; |
|
| 536 | + $html .= '<label for="checkbox-'.esc_attr($k).'">'."\n"; |
|
| 537 | + $html .= '<input type="checkbox" name="'.esc_attr($this->token).'['.esc_attr($args['key']).'][]" class="multicheck multicheck-'.esc_attr($args['key']).'" value="'.esc_attr($k).'" id="checkbox-'.esc_attr($k).'" '.$checked.' /> '.$v."\n"; |
|
| 538 | + $html .= '</label><br />'."\n"; |
|
| 539 | 539 | } |
| 540 | - $html .= '</div>' . "\n"; |
|
| 540 | + $html .= '</div>'."\n"; |
|
| 541 | 541 | echo $html; |
| 542 | 542 | |
| 543 | - if ( isset( $args['data']['description'] ) ) { |
|
| 544 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 543 | + if (isset($args['data']['description'])) { |
|
| 544 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } // End form_field_multicheck() |
@@ -553,20 +553,20 @@ discard block |
||
| 553 | 553 | * @param array $args |
| 554 | 554 | * @return void |
| 555 | 555 | */ |
| 556 | - public function form_field_range ( $args ) { |
|
| 556 | + public function form_field_range($args) { |
|
| 557 | 557 | $options = $this->get_settings(); |
| 558 | 558 | |
| 559 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 559 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 560 | 560 | $html = ''; |
| 561 | - $html .= '<select id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" class="range-input">' . "\n"; |
|
| 562 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 563 | - $html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n"; |
|
| 561 | + $html .= '<select id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" class="range-input">'."\n"; |
|
| 562 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 563 | + $html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n"; |
|
| 564 | 564 | } |
| 565 | - $html .= '</select>' . "\n"; |
|
| 565 | + $html .= '</select>'."\n"; |
|
| 566 | 566 | echo $html; |
| 567 | 567 | |
| 568 | - if ( isset( $args['data']['description'] ) ) { |
|
| 569 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 568 | + if (isset($args['data']['description'])) { |
|
| 569 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | } // End form_field_range() |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | * @param array $args |
| 579 | 579 | * @return void |
| 580 | 580 | */ |
| 581 | - public function form_field_images ( $args ) { |
|
| 581 | + public function form_field_images($args) { |
|
| 582 | 582 | $options = $this->get_settings(); |
| 583 | 583 | |
| 584 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 584 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 585 | 585 | $html = ''; |
| 586 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 587 | - $html .= '<input type="radio" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n"; |
|
| 586 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 587 | + $html .= '<input type="radio" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n"; |
|
| 588 | 588 | } |
| 589 | 589 | echo $html; |
| 590 | 590 | |
| 591 | - if ( isset( $args['data']['description'] ) ) { |
|
| 592 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 591 | + if (isset($args['data']['description'])) { |
|
| 592 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | } // End form_field_images() |
@@ -601,19 +601,19 @@ discard block |
||
| 601 | 601 | * @param array $args |
| 602 | 602 | * @return void |
| 603 | 603 | */ |
| 604 | - public function form_field_info ( $args ) { |
|
| 604 | + public function form_field_info($args) { |
|
| 605 | 605 | $class = ''; |
| 606 | - if ( isset( $args['data']['class'] ) ) { |
|
| 607 | - $class = ' ' . esc_attr( $args['data']['class'] ); |
|
| 606 | + if (isset($args['data']['class'])) { |
|
| 607 | + $class = ' '.esc_attr($args['data']['class']); |
|
| 608 | 608 | } |
| 609 | - $html = '<div id="' . $args['key'] . '" class="info-box' . $class . '">' . "\n"; |
|
| 610 | - if ( isset( $args['data']['name'] ) && ( $args['data']['name'] != '' ) ) { |
|
| 611 | - $html .= '<h3 class="title">' . esc_html( $args['data']['name'] ) . '</h3>' . "\n"; |
|
| 609 | + $html = '<div id="'.$args['key'].'" class="info-box'.$class.'">'."\n"; |
|
| 610 | + if (isset($args['data']['name']) && ($args['data']['name'] != '')) { |
|
| 611 | + $html .= '<h3 class="title">'.esc_html($args['data']['name']).'</h3>'."\n"; |
|
| 612 | 612 | } |
| 613 | - if ( isset( $args['data']['description'] ) && ( $args['data']['description'] != '' ) ) { |
|
| 614 | - $html .= '<p>' . esc_html( $args['data']['description'] ) . '</p>' . "\n"; |
|
| 613 | + if (isset($args['data']['description']) && ($args['data']['description'] != '')) { |
|
| 614 | + $html .= '<p>'.esc_html($args['data']['description']).'</p>'."\n"; |
|
| 615 | 615 | } |
| 616 | - $html .= '</div>' . "\n"; |
|
| 616 | + $html .= '</div>'."\n"; |
|
| 617 | 617 | |
| 618 | 618 | echo $html; |
| 619 | 619 | } // End form_field_info() |
@@ -625,14 +625,14 @@ discard block |
||
| 625 | 625 | * @since 1.9.0 |
| 626 | 626 | * @param array $args |
| 627 | 627 | */ |
| 628 | - public function form_field_button( $args ) { |
|
| 628 | + public function form_field_button($args) { |
|
| 629 | 629 | $options = $this->get_settings(); |
| 630 | 630 | |
| 631 | - if ( isset( $args['data']['target'] ) && isset( $args['data']['label'] ) ) { |
|
| 632 | - printf( '<a href="%s" class="button button-secondary">%s</a> ', esc_url( $args['data']['target'] ), esc_html( $args['data']['label'] ) ); |
|
| 631 | + if (isset($args['data']['target']) && isset($args['data']['label'])) { |
|
| 632 | + printf('<a href="%s" class="button button-secondary">%s</a> ', esc_url($args['data']['target']), esc_html($args['data']['label'])); |
|
| 633 | 633 | |
| 634 | - if ( isset( $args['data']['description'] ) ) { |
|
| 635 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 634 | + if (isset($args['data']['description'])) { |
|
| 635 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } // End form_field_button() |
@@ -646,23 +646,23 @@ discard block |
||
| 646 | 646 | * @uses $this->parse_errors() |
| 647 | 647 | * @return array $options |
| 648 | 648 | */ |
| 649 | - public function validate_fields ( $input ) { |
|
| 649 | + public function validate_fields($input) { |
|
| 650 | 650 | $options = $this->get_settings(); |
| 651 | 651 | |
| 652 | - foreach ( $this->fields as $k => $v ) { |
|
| 652 | + foreach ($this->fields as $k => $v) { |
|
| 653 | 653 | // Make sure checkboxes are present even when false. |
| 654 | - if ( $v['type'] == 'checkbox' && ! isset( $input[$k] ) ) { $input[$k] = false; } |
|
| 655 | - if ( $v['type'] == 'multicheck' && ! isset( $input[$k] ) ) { $input[$k] = false; } |
|
| 654 | + if ($v['type'] == 'checkbox' && ! isset($input[$k])) { $input[$k] = false; } |
|
| 655 | + if ($v['type'] == 'multicheck' && ! isset($input[$k])) { $input[$k] = false; } |
|
| 656 | 656 | |
| 657 | - if ( isset( $input[$k] ) ) { |
|
| 657 | + if (isset($input[$k])) { |
|
| 658 | 658 | // Perform checks on required fields. |
| 659 | - if ( isset( $v['required'] ) && ( $v['required'] == true ) ) { |
|
| 660 | - if ( in_array( $v['type'], $this->get_array_field_types() ) && ( count( (array) $input[$k] ) <= 0 ) ) { |
|
| 661 | - $this->add_error( $k, $v ); |
|
| 659 | + if (isset($v['required']) && ($v['required'] == true)) { |
|
| 660 | + if (in_array($v['type'], $this->get_array_field_types()) && (count((array) $input[$k]) <= 0)) { |
|
| 661 | + $this->add_error($k, $v); |
|
| 662 | 662 | continue; |
| 663 | 663 | } else { |
| 664 | - if ( $input[$k] == '' ) { |
|
| 665 | - $this->add_error( $k, $v ); |
|
| 664 | + if ($input[$k] == '') { |
|
| 665 | + $this->add_error($k, $v); |
|
| 666 | 666 | continue; |
| 667 | 667 | } |
| 668 | 668 | } |
@@ -671,28 +671,28 @@ discard block |
||
| 671 | 671 | $value = $input[$k]; |
| 672 | 672 | |
| 673 | 673 | // Check if the field is valid. |
| 674 | - $method = $this->determine_method( $v, 'check' ); |
|
| 674 | + $method = $this->determine_method($v, 'check'); |
|
| 675 | 675 | |
| 676 | - if ( function_exists ( $method ) ) { |
|
| 677 | - $is_valid = $method( $value ); |
|
| 676 | + if (function_exists($method)) { |
|
| 677 | + $is_valid = $method($value); |
|
| 678 | 678 | } else { |
| 679 | - if ( method_exists( $this, $method ) ) { |
|
| 680 | - $is_valid = $this->$method( $value ); |
|
| 679 | + if (method_exists($this, $method)) { |
|
| 680 | + $is_valid = $this->$method($value); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if ( ! $is_valid ) { |
|
| 685 | - $this->add_error( $k, $v ); |
|
| 684 | + if ( ! $is_valid) { |
|
| 685 | + $this->add_error($k, $v); |
|
| 686 | 686 | continue; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - $method = $this->determine_method( $v, 'validate' ); |
|
| 689 | + $method = $this->determine_method($v, 'validate'); |
|
| 690 | 690 | |
| 691 | - if ( function_exists ( $method ) ) { |
|
| 692 | - $options[$k] = $method( $value ); |
|
| 691 | + if (function_exists($method)) { |
|
| 692 | + $options[$k] = $method($value); |
|
| 693 | 693 | } else { |
| 694 | - if ( method_exists( $this, $method ) ) { |
|
| 695 | - $options[$k] = $this->$method( $value ); |
|
| 694 | + if (method_exists($this, $method)) { |
|
| 695 | + $options[$k] = $this->$method($value); |
|
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | * @param string $input |
| 711 | 711 | * @return string |
| 712 | 712 | */ |
| 713 | - public function validate_field_text ( $input ) { |
|
| 714 | - return trim( esc_attr( $input ) ); |
|
| 713 | + public function validate_field_text($input) { |
|
| 714 | + return trim(esc_attr($input)); |
|
| 715 | 715 | } // End validate_field_text() |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -721,11 +721,11 @@ discard block |
||
| 721 | 721 | * @param string $input |
| 722 | 722 | * @return string |
| 723 | 723 | */ |
| 724 | - public function validate_field_checkbox ( $input ) { |
|
| 725 | - if ( ! isset( $input ) ) { |
|
| 724 | + public function validate_field_checkbox($input) { |
|
| 725 | + if ( ! isset($input)) { |
|
| 726 | 726 | return 0; |
| 727 | 727 | } else { |
| 728 | - return (bool)$input; |
|
| 728 | + return (bool) $input; |
|
| 729 | 729 | } |
| 730 | 730 | } // End validate_field_checkbox() |
| 731 | 731 | |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | * @param string $input |
| 737 | 737 | * @return string |
| 738 | 738 | */ |
| 739 | - public function validate_field_multicheck ( $input ) { |
|
| 739 | + public function validate_field_multicheck($input) { |
|
| 740 | 740 | $input = (array) $input; |
| 741 | 741 | |
| 742 | - $input = array_map( 'esc_attr', $input ); |
|
| 742 | + $input = array_map('esc_attr', $input); |
|
| 743 | 743 | |
| 744 | 744 | return $input; |
| 745 | 745 | } // End validate_field_multicheck() |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | * @param string $input |
| 752 | 752 | * @return string |
| 753 | 753 | */ |
| 754 | - public function validate_field_range ( $input ) { |
|
| 755 | - $input = number_format( floatval( $input ), 0 ); |
|
| 754 | + public function validate_field_range($input) { |
|
| 755 | + $input = number_format(floatval($input), 0); |
|
| 756 | 756 | |
| 757 | 757 | return $input; |
| 758 | 758 | } // End validate_field_range() |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param string $input |
| 765 | 765 | * @return string |
| 766 | 766 | */ |
| 767 | - public function validate_field_url ( $input ) { |
|
| 768 | - return trim( esc_url( $input ) ); |
|
| 767 | + public function validate_field_url($input) { |
|
| 768 | + return trim(esc_url($input)); |
|
| 769 | 769 | } // End validate_field_url() |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @since 1.1.0 |
| 775 | 775 | * @return boolean Is the value valid? |
| 776 | 776 | */ |
| 777 | - public function check_field_text ( $input ) { |
|
| 777 | + public function check_field_text($input) { |
|
| 778 | 778 | $is_valid = true; |
| 779 | 779 | |
| 780 | 780 | return $is_valid; |
@@ -788,11 +788,11 @@ discard block |
||
| 788 | 788 | * @param array $data |
| 789 | 789 | * @return void |
| 790 | 790 | */ |
| 791 | - protected function add_error ( $key, $data ) { |
|
| 792 | - if ( isset( $data['error_message'] ) ) { |
|
| 791 | + protected function add_error($key, $data) { |
|
| 792 | + if (isset($data['error_message'])) { |
|
| 793 | 793 | $message = $data['error_message']; |
| 794 | 794 | } else { |
| 795 | - $message = sprintf( __( '%s is a required field', 'woothemes-sensei' ), $data['name'] ); |
|
| 795 | + $message = sprintf(__('%s is a required field', 'woothemes-sensei'), $data['name']); |
|
| 796 | 796 | } |
| 797 | 797 | $this->errors[$key] = $message; |
| 798 | 798 | } // End add_error() |
@@ -803,14 +803,14 @@ discard block |
||
| 803 | 803 | * @since 1.0.0 |
| 804 | 804 | * @return void |
| 805 | 805 | */ |
| 806 | - protected function parse_errors () { |
|
| 807 | - if ( count ( $this->errors ) > 0 ) { |
|
| 808 | - foreach ( $this->errors as $k => $v ) { |
|
| 809 | - add_settings_error( $this->token . '-errors', $k, $v, 'error' ); |
|
| 806 | + protected function parse_errors() { |
|
| 807 | + if (count($this->errors) > 0) { |
|
| 808 | + foreach ($this->errors as $k => $v) { |
|
| 809 | + add_settings_error($this->token.'-errors', $k, $v, 'error'); |
|
| 810 | 810 | } |
| 811 | 811 | } else { |
| 812 | - $message = sprintf( __( '%s updated', 'woothemes-sensei' ), $this->name ); |
|
| 813 | - add_settings_error( $this->token . '-errors', $this->token, $message, 'updated' ); |
|
| 812 | + $message = sprintf(__('%s updated', 'woothemes-sensei'), $this->name); |
|
| 813 | + add_settings_error($this->token.'-errors', $this->token, $message, 'updated'); |
|
| 814 | 814 | } |
| 815 | 815 | } // End parse_errors() |
| 816 | 816 | |
@@ -820,8 +820,8 @@ discard block |
||
| 820 | 820 | * @since 1.0.0 |
| 821 | 821 | * @return array |
| 822 | 822 | */ |
| 823 | - protected function get_array_field_types () { |
|
| 824 | - return array( 'multicheck' ); |
|
| 823 | + protected function get_array_field_types() { |
|
| 824 | + return array('multicheck'); |
|
| 825 | 825 | } // End get_array_field_types() |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -830,21 +830,21 @@ discard block |
||
| 830 | 830 | * @since 1.0.0 |
| 831 | 831 | * @return void |
| 832 | 832 | */ |
| 833 | - public function enqueue_scripts () { |
|
| 833 | + public function enqueue_scripts() { |
|
| 834 | 834 | |
| 835 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 835 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 836 | 836 | |
| 837 | - wp_enqueue_script( 'farbtastic' ); |
|
| 838 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version ); |
|
| 837 | + wp_enqueue_script('farbtastic'); |
|
| 838 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'farbtastic'), Sensei()->version); |
|
| 839 | 839 | |
| 840 | - if ( $this->has_range ) { |
|
| 841 | - wp_enqueue_script( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/js/ranges' . $suffix . '.js' ), array( 'jquery-ui-slider' ), Sensei()->version ); |
|
| 840 | + if ($this->has_range) { |
|
| 841 | + wp_enqueue_script('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/js/ranges'.$suffix.'.js'), array('jquery-ui-slider'), Sensei()->version); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - wp_register_script( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/js/image-selectors' . $suffix . '.js' ), array( 'jquery' ), Sensei()->version ); |
|
| 844 | + wp_register_script('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/js/image-selectors'.$suffix.'.js'), array('jquery'), Sensei()->version); |
|
| 845 | 845 | |
| 846 | - if ( $this->has_imageselector ) { |
|
| 847 | - wp_enqueue_script( 'woothemes-sensei-settings-imageselectors' ); |
|
| 846 | + if ($this->has_imageselector) { |
|
| 847 | + wp_enqueue_script('woothemes-sensei-settings-imageselectors'); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | } // End enqueue_scripts() |
@@ -855,12 +855,12 @@ discard block |
||
| 855 | 855 | * @since 1.0.0 |
| 856 | 856 | * @return void |
| 857 | 857 | */ |
| 858 | - public function enqueue_styles () { |
|
| 858 | + public function enqueue_styles() { |
|
| 859 | 859 | |
| 860 | - wp_enqueue_style( $this->token . '-admin' ); |
|
| 860 | + wp_enqueue_style($this->token.'-admin'); |
|
| 861 | 861 | |
| 862 | - wp_enqueue_style( 'farbtastic' ); |
|
| 863 | - wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), array( 'farbtastic' ), Sensei()->version ); |
|
| 862 | + wp_enqueue_style('farbtastic'); |
|
| 863 | + wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), array('farbtastic'), Sensei()->version); |
|
| 864 | 864 | |
| 865 | 865 | $this->enqueue_field_styles(); |
| 866 | 866 | } // End enqueue_styles() |
@@ -871,16 +871,16 @@ discard block |
||
| 871 | 871 | * @since 1.0.0 |
| 872 | 872 | * @return void |
| 873 | 873 | */ |
| 874 | - public function enqueue_field_styles () { |
|
| 874 | + public function enqueue_field_styles() { |
|
| 875 | 875 | |
| 876 | - if ( $this->has_range ) { |
|
| 877 | - wp_enqueue_style( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/css/ranges.css' ), '', Sensei()->version ); |
|
| 876 | + if ($this->has_range) { |
|
| 877 | + wp_enqueue_style('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/css/ranges.css'), '', Sensei()->version); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - wp_register_style( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/css/image-selectors.css' ), '', Sensei()->version ); |
|
| 880 | + wp_register_style('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/css/image-selectors.css'), '', Sensei()->version); |
|
| 881 | 881 | |
| 882 | - if ( $this->has_imageselector ) { |
|
| 883 | - wp_enqueue_style( 'woothemes-sensei-settings-imageselectors' ); |
|
| 882 | + if ($this->has_imageselector) { |
|
| 883 | + wp_enqueue_style('woothemes-sensei-settings-imageselectors'); |
|
| 884 | 884 | } |
| 885 | 885 | } // End enqueue_field_styles() |
| 886 | 886 | } // End Class |
@@ -890,4 +890,4 @@ discard block |
||
| 890 | 890 | * @ignore only for backward compatibility |
| 891 | 891 | * @since 1.9.0 |
| 892 | 892 | */ |
| 893 | -class WooThemes_Sensei_Settings_API extends Sensei_Settings_API{} |
|
| 893 | +class WooThemes_Sensei_Settings_API extends Sensei_Settings_API {} |
|
@@ -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 | * Analysis Overview Data Table. |
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | * @since 1.2.0 |
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | - public function __construct ( $type = 'users' ) { |
|
| 22 | - $this->type = in_array( $type, array( 'courses', 'lessons', 'users' ) ) ? $type : 'users'; |
|
| 21 | + public function __construct($type = 'users') { |
|
| 22 | + $this->type = in_array($type, array('courses', 'lessons', 'users')) ? $type : 'users'; |
|
| 23 | 23 | |
| 24 | 24 | // Load Parent token into constructor |
| 25 | - parent::__construct( 'analysis_overview' ); |
|
| 25 | + parent::__construct('analysis_overview'); |
|
| 26 | 26 | |
| 27 | 27 | // Actions |
| 28 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 29 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 28 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 29 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 30 | 30 | |
| 31 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 31 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 32 | 32 | } // End __construct() |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -38,41 +38,41 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function get_columns() { |
| 40 | 40 | |
| 41 | - switch( $this->type ) { |
|
| 41 | + switch ($this->type) { |
|
| 42 | 42 | case 'courses': |
| 43 | 43 | $columns = array( |
| 44 | - 'title' => __( 'Course', 'woothemes-sensei' ), |
|
| 45 | - 'students' => __( 'Learners', 'woothemes-sensei' ), |
|
| 46 | - 'lessons' => __( 'Lessons', 'woothemes-sensei' ), |
|
| 47 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
| 48 | - 'average_percent' => __( 'Average Percentage', 'woothemes-sensei' ), |
|
| 44 | + 'title' => __('Course', 'woothemes-sensei'), |
|
| 45 | + 'students' => __('Learners', 'woothemes-sensei'), |
|
| 46 | + 'lessons' => __('Lessons', 'woothemes-sensei'), |
|
| 47 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
| 48 | + 'average_percent' => __('Average Percentage', 'woothemes-sensei'), |
|
| 49 | 49 | ); |
| 50 | 50 | break; |
| 51 | 51 | |
| 52 | 52 | case 'lessons': |
| 53 | 53 | $columns = array( |
| 54 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 55 | - 'course' => __( 'Course', 'woothemes-sensei' ), |
|
| 56 | - 'students' => __( 'Learners', 'woothemes-sensei' ), |
|
| 57 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
| 58 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
| 54 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 55 | + 'course' => __('Course', 'woothemes-sensei'), |
|
| 56 | + 'students' => __('Learners', 'woothemes-sensei'), |
|
| 57 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
| 58 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
| 59 | 59 | ); |
| 60 | 60 | break; |
| 61 | 61 | |
| 62 | 62 | case 'users': |
| 63 | 63 | default: |
| 64 | 64 | $columns = array( |
| 65 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 66 | - 'registered' => __( 'Date Registered', 'woothemes-sensei' ), |
|
| 67 | - 'active_courses' => __( 'Active Courses', 'woothemes-sensei' ), |
|
| 68 | - 'completed_courses' => __( 'Completed Courses', 'woothemes-sensei' ), |
|
| 69 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
| 65 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 66 | + 'registered' => __('Date Registered', 'woothemes-sensei'), |
|
| 67 | + 'active_courses' => __('Active Courses', 'woothemes-sensei'), |
|
| 68 | + 'completed_courses' => __('Completed Courses', 'woothemes-sensei'), |
|
| 69 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
| 70 | 70 | ); |
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | // Backwards compatible filter name, moving forward should have single filter name |
| 74 | - $columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns', $columns, $this ); |
|
| 75 | - $columns = apply_filters( 'sensei_analysis_overview_columns', $columns, $this ); |
|
| 74 | + $columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns', $columns, $this); |
|
| 75 | + $columns = apply_filters('sensei_analysis_overview_columns', $columns, $this); |
|
| 76 | 76 | return $columns; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -83,41 +83,41 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function get_sortable_columns() { |
| 85 | 85 | |
| 86 | - switch( $this->type ) { |
|
| 86 | + switch ($this->type) { |
|
| 87 | 87 | case 'courses': |
| 88 | 88 | $columns = array( |
| 89 | - 'title' => array( 'title', false ), |
|
| 90 | - 'students' => array( 'students', false ), |
|
| 91 | - 'lessons' => array( 'lessons', false ), |
|
| 92 | - 'completions' => array( 'completions', false ), |
|
| 93 | - 'average_percent' => array( 'average_percent', false ), |
|
| 89 | + 'title' => array('title', false), |
|
| 90 | + 'students' => array('students', false), |
|
| 91 | + 'lessons' => array('lessons', false), |
|
| 92 | + 'completions' => array('completions', false), |
|
| 93 | + 'average_percent' => array('average_percent', false), |
|
| 94 | 94 | ); |
| 95 | 95 | break; |
| 96 | 96 | |
| 97 | 97 | case 'lessons': |
| 98 | 98 | $columns = array( |
| 99 | - 'title' => array( 'title', false ), |
|
| 100 | - 'course' => array( 'course', false ), |
|
| 101 | - 'students' => array( 'students', false ), |
|
| 102 | - 'completions' => array( 'completions', false ), |
|
| 103 | - 'average_grade' => array( 'average_grade', false ), |
|
| 99 | + 'title' => array('title', false), |
|
| 100 | + 'course' => array('course', false), |
|
| 101 | + 'students' => array('students', false), |
|
| 102 | + 'completions' => array('completions', false), |
|
| 103 | + 'average_grade' => array('average_grade', false), |
|
| 104 | 104 | ); |
| 105 | 105 | break; |
| 106 | 106 | |
| 107 | 107 | case 'users': |
| 108 | 108 | default: |
| 109 | 109 | $columns = array( |
| 110 | - 'title' => array( 'user_login', false ), |
|
| 111 | - 'registered' => array( 'registered', false ), |
|
| 112 | - 'active_courses' => array( 'active_courses', false ), |
|
| 113 | - 'completed_courses' => array( 'completed_courses', false ), |
|
| 114 | - 'average_grade' => array( 'average_grade', false ) |
|
| 110 | + 'title' => array('user_login', false), |
|
| 111 | + 'registered' => array('registered', false), |
|
| 112 | + 'active_courses' => array('active_courses', false), |
|
| 113 | + 'completed_courses' => array('completed_courses', false), |
|
| 114 | + 'average_grade' => array('average_grade', false) |
|
| 115 | 115 | ); |
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | // Backwards compatible filter name, moving forward should have single filter name |
| 119 | - $columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns_sortable', $columns, $this ); |
|
| 120 | - $columns = apply_filters( 'sensei_analysis_overview_columns_sortable', $columns, $this ); |
|
| 119 | + $columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns_sortable', $columns, $this); |
|
| 120 | + $columns = apply_filters('sensei_analysis_overview_columns_sortable', $columns, $this); |
|
| 121 | 121 | return $columns; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -131,25 +131,25 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Handle orderby |
| 133 | 133 | $orderby = ''; |
| 134 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 135 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 136 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 134 | + if ( ! empty($_GET['orderby'])) { |
|
| 135 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 136 | + $orderby = esc_html($_GET['orderby']); |
|
| 137 | 137 | } // End If Statement |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Handle order |
| 141 | 141 | $order = 'ASC'; |
| 142 | - if ( !empty( $_GET['order'] ) ) { |
|
| 143 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 142 | + if ( ! empty($_GET['order'])) { |
|
| 143 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 147 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 146 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 147 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 148 | 148 | |
| 149 | 149 | $paged = $this->get_pagenum(); |
| 150 | 150 | $offset = 0; |
| 151 | - if ( !empty($paged) ) { |
|
| 152 | - $offset = $per_page * ( $paged - 1 ); |
|
| 151 | + if ( ! empty($paged)) { |
|
| 152 | + $offset = $per_page * ($paged - 1); |
|
| 153 | 153 | } // End If Statement |
| 154 | 154 | |
| 155 | 155 | $args = array( |
@@ -160,32 +160,32 @@ discard block |
||
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | // Handle search |
| 163 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 164 | - $args['search'] = esc_html( $_GET['s'] ); |
|
| 163 | + if (isset($_GET['s']) && ! empty($_GET['s'])) { |
|
| 164 | + $args['search'] = esc_html($_GET['s']); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - switch ( $this->type ) { |
|
| 167 | + switch ($this->type) { |
|
| 168 | 168 | case 'courses': |
| 169 | - $this->items = $this->get_courses( $args ); |
|
| 169 | + $this->items = $this->get_courses($args); |
|
| 170 | 170 | break; |
| 171 | 171 | |
| 172 | 172 | case 'lessons': |
| 173 | - $this->items = $this->get_lessons( $args ); |
|
| 173 | + $this->items = $this->get_lessons($args); |
|
| 174 | 174 | break; |
| 175 | 175 | |
| 176 | 176 | case 'users': |
| 177 | 177 | default : |
| 178 | - $this->items = $this->get_learners( $args ); |
|
| 178 | + $this->items = $this->get_learners($args); |
|
| 179 | 179 | break; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $total_items = $this->total_items; |
| 183 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 184 | - $this->set_pagination_args( array( |
|
| 183 | + $total_pages = ceil($total_items / $per_page); |
|
| 184 | + $this->set_pagination_args(array( |
|
| 185 | 185 | 'total_items' => $total_items, |
| 186 | 186 | 'total_pages' => $total_pages, |
| 187 | 187 | 'per_page' => $per_page |
| 188 | - ) ); |
|
| 188 | + )); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @since 1.7.0 |
| 194 | 194 | * @return data |
| 195 | 195 | */ |
| 196 | - public function generate_report( $report ) { |
|
| 196 | + public function generate_report($report) { |
|
| 197 | 197 | |
| 198 | 198 | $data = array(); |
| 199 | 199 | |
@@ -201,16 +201,16 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | // Handle orderby |
| 203 | 203 | $orderby = ''; |
| 204 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 205 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 206 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 204 | + if ( ! empty($_GET['orderby'])) { |
|
| 205 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 206 | + $orderby = esc_html($_GET['orderby']); |
|
| 207 | 207 | } // End If Statement |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Handle order |
| 211 | 211 | $order = 'ASC'; |
| 212 | - if ( !empty( $_GET['order'] ) ) { |
|
| 213 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 212 | + if ( ! empty($_GET['order'])) { |
|
| 213 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $args = array( |
@@ -220,37 +220,37 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | |
| 222 | 222 | // Handle search |
| 223 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 224 | - $args['search'] = esc_html( $_GET['s'] ); |
|
| 223 | + if (isset($_GET['s']) && ! empty($_GET['s'])) { |
|
| 224 | + $args['search'] = esc_html($_GET['s']); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
| 228 | 228 | // Start the csv with the column headings |
| 229 | 229 | $column_headers = array(); |
| 230 | 230 | $columns = $this->get_columns(); |
| 231 | - foreach( $columns AS $key => $title ) { |
|
| 231 | + foreach ($columns AS $key => $title) { |
|
| 232 | 232 | $column_headers[] = $title; |
| 233 | 233 | } |
| 234 | 234 | $data[] = $column_headers; |
| 235 | 235 | |
| 236 | - switch ( $this->type ) { |
|
| 236 | + switch ($this->type) { |
|
| 237 | 237 | case 'courses': |
| 238 | - $this->items = $this->get_courses( $args ); |
|
| 238 | + $this->items = $this->get_courses($args); |
|
| 239 | 239 | break; |
| 240 | 240 | |
| 241 | 241 | case 'lessons': |
| 242 | - $this->items = $this->get_lessons( $args ); |
|
| 242 | + $this->items = $this->get_lessons($args); |
|
| 243 | 243 | break; |
| 244 | 244 | |
| 245 | 245 | case 'users': |
| 246 | 246 | default : |
| 247 | - $this->items = $this->get_learners( $args ); |
|
| 247 | + $this->items = $this->get_learners($args); |
|
| 248 | 248 | break; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // Process each row |
| 252 | - foreach( $this->items AS $item) { |
|
| 253 | - $data[] = $this->get_row_data( $item ); |
|
| 252 | + foreach ($this->items AS $item) { |
|
| 253 | + $data[] = $this->get_row_data($item); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | return $data; |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | * @param object $item The current item |
| 263 | 263 | * @return array $column_data; |
| 264 | 264 | */ |
| 265 | - protected function get_row_data( $item ) { |
|
| 265 | + protected function get_row_data($item) { |
|
| 266 | 266 | |
| 267 | - switch( $this->type ) { |
|
| 267 | + switch ($this->type) { |
|
| 268 | 268 | case 'courses' : |
| 269 | 269 | // Get Learners (i.e. those who have started) |
| 270 | 270 | $course_args = array( |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | 'type' => 'sensei_course_status', |
| 273 | 273 | 'status' => 'any', |
| 274 | 274 | ); |
| 275 | - $course_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_learners', $course_args, $item ) ); |
|
| 275 | + $course_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_learners', $course_args, $item)); |
|
| 276 | 276 | |
| 277 | 277 | // Get Course Completions |
| 278 | 278 | $course_args = array( |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | 'type' => 'sensei_course_status', |
| 281 | 281 | 'status' => 'complete', |
| 282 | 282 | ); |
| 283 | - $course_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_completions', $course_args, $item ) ); |
|
| 283 | + $course_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_completions', $course_args, $item)); |
|
| 284 | 284 | |
| 285 | 285 | // Course Lessons |
| 286 | - $course_lessons = Sensei()->lesson->lesson_count( array('publish', 'private'), $item->ID ); |
|
| 286 | + $course_lessons = Sensei()->lesson->lesson_count(array('publish', 'private'), $item->ID); |
|
| 287 | 287 | |
| 288 | 288 | // Get Percent Complete |
| 289 | 289 | $grade_args = array( |
@@ -293,31 +293,31 @@ discard block |
||
| 293 | 293 | 'meta_key' => 'percent', |
| 294 | 294 | ); |
| 295 | 295 | |
| 296 | - $percent_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_percentage', $grade_args, $item ), true ) ); |
|
| 297 | - $percent_total = Sensei_Grading::get_course_users_grades_sum( $item->ID ); |
|
| 296 | + $percent_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_percentage', $grade_args, $item), true)); |
|
| 297 | + $percent_total = Sensei_Grading::get_course_users_grades_sum($item->ID); |
|
| 298 | 298 | |
| 299 | 299 | $course_average_percent = 0; |
| 300 | - if( $percent_count > 0 && $percent_total > 0 ){ |
|
| 301 | - $course_average_percent = abs( round( doubleval( $percent_total / $percent_count ), 2 ) ); |
|
| 300 | + if ($percent_count > 0 && $percent_total > 0) { |
|
| 301 | + $course_average_percent = abs(round(doubleval($percent_total / $percent_count), 2)); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | // Output course data |
| 306 | - if ( $this->csv_output ) { |
|
| 307 | - $course_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 306 | + if ($this->csv_output) { |
|
| 307 | + $course_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 308 | 308 | } |
| 309 | 309 | else { |
| 310 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 310 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID), admin_url('admin.php')); |
|
| 311 | 311 | |
| 312 | - $course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 312 | + $course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 313 | 313 | $course_average_percent .= '%'; |
| 314 | 314 | } // End If Statement |
| 315 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $course_title, |
|
| 315 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $course_title, |
|
| 316 | 316 | 'students' => $course_students, |
| 317 | 317 | 'lessons' => $course_lessons, |
| 318 | 318 | 'completions' => $course_completions, |
| 319 | 319 | 'average_percent' => $course_average_percent, |
| 320 | - ), $item, $this ); |
|
| 320 | + ), $item, $this); |
|
| 321 | 321 | break; |
| 322 | 322 | |
| 323 | 323 | case 'lessons' : |
@@ -327,65 +327,65 @@ discard block |
||
| 327 | 327 | 'type' => 'sensei_lesson_status', |
| 328 | 328 | 'status' => 'any', |
| 329 | 329 | ); |
| 330 | - $lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) ); |
|
| 330 | + $lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item)); |
|
| 331 | 331 | |
| 332 | 332 | // Get Course Completions |
| 333 | 333 | $lesson_args = array( |
| 334 | 334 | 'post_id' => $item->ID, |
| 335 | 335 | 'type' => 'sensei_lesson_status', |
| 336 | - 'status' => array( 'complete', 'graded', 'passed', 'failed' ), |
|
| 336 | + 'status' => array('complete', 'graded', 'passed', 'failed'), |
|
| 337 | 337 | 'count' => true, |
| 338 | 338 | ); |
| 339 | - $lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) ); |
|
| 339 | + $lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item)); |
|
| 340 | 340 | |
| 341 | 341 | // Course |
| 342 | - $course_id = get_post_meta( $item->ID, '_lesson_course', true ); |
|
| 343 | - $course_title = $course_id ? get_the_title( $course_id ) : ''; |
|
| 342 | + $course_id = get_post_meta($item->ID, '_lesson_course', true); |
|
| 343 | + $course_title = $course_id ? get_the_title($course_id) : ''; |
|
| 344 | 344 | |
| 345 | 345 | $lesson_average_grade = __('n/a', 'woothemes-sensei'); |
| 346 | - if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) { |
|
| 346 | + if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
| 347 | 347 | // Get Percent Complete |
| 348 | 348 | $grade_args = array( |
| 349 | 349 | 'post_id' => $item->ID, |
| 350 | 350 | 'type' => 'sensei_lesson_status', |
| 351 | - 'status' => array( 'graded', 'passed', 'failed' ), |
|
| 351 | + 'status' => array('graded', 'passed', 'failed'), |
|
| 352 | 352 | 'meta_key' => 'grade', |
| 353 | 353 | ); |
| 354 | 354 | |
| 355 | - $grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true )); |
|
| 356 | - $grade_total = Sensei_Grading::get_lessons_users_grades_sum( $item->ID ); |
|
| 355 | + $grade_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true)); |
|
| 356 | + $grade_total = Sensei_Grading::get_lessons_users_grades_sum($item->ID); |
|
| 357 | 357 | |
| 358 | 358 | $lesson_average_grade = 0; |
| 359 | - if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 360 | - $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 359 | + if ($grade_total > 0 && $grade_count > 0) { |
|
| 360 | + $lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | // Output lesson data |
| 365 | - if ( $this->csv_output ) { |
|
| 366 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 365 | + if ($this->csv_output) { |
|
| 366 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 367 | 367 | } |
| 368 | 368 | else { |
| 369 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 370 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 369 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
| 370 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 371 | 371 | |
| 372 | - if ( $course_id ) { |
|
| 373 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 374 | - $course_title = '<a href="' . esc_url( $url ) . '">' . $course_title . '</a>'; |
|
| 372 | + if ($course_id) { |
|
| 373 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 374 | + $course_title = '<a href="'.esc_url($url).'">'.$course_title.'</a>'; |
|
| 375 | 375 | } |
| 376 | 376 | else { |
| 377 | 377 | $course_title = __('n/a', 'woothemes-sensei'); |
| 378 | 378 | } |
| 379 | - if ( is_numeric( $lesson_average_grade ) ) { |
|
| 379 | + if (is_numeric($lesson_average_grade)) { |
|
| 380 | 380 | $lesson_average_grade .= '%'; |
| 381 | 381 | } |
| 382 | 382 | } // End If Statement |
| 383 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $lesson_title, |
|
| 383 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $lesson_title, |
|
| 384 | 384 | 'course' => $course_title, |
| 385 | 385 | 'students' => $lesson_students, |
| 386 | 386 | 'completions' => $lesson_completions, |
| 387 | 387 | 'average_grade' => $lesson_average_grade, |
| 388 | - ), $item, $this ); |
|
| 388 | + ), $item, $this); |
|
| 389 | 389 | break; |
| 390 | 390 | |
| 391 | 391 | case 'users' : |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | 'type' => 'sensei_course_status', |
| 397 | 397 | 'status' => 'any', |
| 398 | 398 | ); |
| 399 | - $user_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_started', $course_args, $item ) ); |
|
| 399 | + $user_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_started', $course_args, $item)); |
|
| 400 | 400 | |
| 401 | 401 | // Get Completed Courses |
| 402 | 402 | $course_args = array( |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | 'type' => 'sensei_course_status', |
| 405 | 405 | 'status' => 'complete', |
| 406 | 406 | ); |
| 407 | - $user_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_ended', $course_args, $item ) ); |
|
| 407 | + $user_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_ended', $course_args, $item)); |
|
| 408 | 408 | |
| 409 | 409 | // Get Quiz Grades |
| 410 | 410 | $grade_args = array( |
@@ -414,29 +414,29 @@ discard block |
||
| 414 | 414 | 'meta_key' => 'grade', |
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | - $grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_lesson_grades', $grade_args, $item ), true )); |
|
| 418 | - $grade_total = Sensei_Grading::get_user_graded_lessons_sum( $item->ID ); |
|
| 417 | + $grade_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_lesson_grades', $grade_args, $item), true)); |
|
| 418 | + $grade_total = Sensei_Grading::get_user_graded_lessons_sum($item->ID); |
|
| 419 | 419 | |
| 420 | 420 | $user_average_grade = 0; |
| 421 | - if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 422 | - $user_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 421 | + if ($grade_total > 0 && $grade_count > 0) { |
|
| 422 | + $user_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Output the users data |
| 426 | - if ( $this->csv_output ) { |
|
| 427 | - $user_name = Sensei_Learner::get_full_name( $item->ID ); |
|
| 426 | + if ($this->csv_output) { |
|
| 427 | + $user_name = Sensei_Learner::get_full_name($item->ID); |
|
| 428 | 428 | } |
| 429 | 429 | else { |
| 430 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 431 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $item->display_name . '</a></strong>'; |
|
| 430 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->ID), admin_url('admin.php')); |
|
| 431 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$item->display_name.'</a></strong>'; |
|
| 432 | 432 | $user_average_grade .= '%'; |
| 433 | 433 | } // End If Statement |
| 434 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $user_name, |
|
| 434 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $user_name, |
|
| 435 | 435 | 'registered' => $item->user_registered, |
| 436 | - 'active_courses' => ( $user_courses_started - $user_courses_ended ), |
|
| 436 | + 'active_courses' => ($user_courses_started - $user_courses_ended), |
|
| 437 | 437 | 'completed_courses' => $user_courses_ended, |
| 438 | 438 | 'average_grade' => $user_average_grade, |
| 439 | - ), $item, $this ); |
|
| 439 | + ), $item, $this); |
|
| 440 | 440 | break; |
| 441 | 441 | } // end switch |
| 442 | 442 | return $column_data; |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @since 1.7.0 |
| 448 | 448 | * @return array courses |
| 449 | 449 | */ |
| 450 | - private function get_courses( $args ) { |
|
| 450 | + private function get_courses($args) { |
|
| 451 | 451 | $course_args = array( |
| 452 | 452 | 'post_type' => 'course', |
| 453 | 453 | 'post_status' => array('publish', 'private'), |
@@ -458,16 +458,16 @@ discard block |
||
| 458 | 458 | 'suppress_filters' => 0, |
| 459 | 459 | ); |
| 460 | 460 | |
| 461 | - if ( $this->csv_output ) { |
|
| 461 | + if ($this->csv_output) { |
|
| 462 | 462 | $course_args['posts_per_page'] = '-1'; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if( isset( $args['search'] ) ) { |
|
| 465 | + if (isset($args['search'])) { |
|
| 466 | 466 | $course_args['s'] = $args['search']; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
| 470 | - $courses_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_courses', $course_args ) ); |
|
| 470 | + $courses_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_courses', $course_args)); |
|
| 471 | 471 | $this->total_items = $courses_query->found_posts; |
| 472 | 472 | return $courses_query->posts; |
| 473 | 473 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @since 1.7.0 |
| 479 | 479 | * @return array lessons |
| 480 | 480 | */ |
| 481 | - private function get_lessons( $args ) { |
|
| 481 | + private function get_lessons($args) { |
|
| 482 | 482 | $lessons_args = array( |
| 483 | 483 | 'post_type' => 'lesson', |
| 484 | 484 | 'post_status' => array('publish', 'private'), |
@@ -489,16 +489,16 @@ discard block |
||
| 489 | 489 | 'suppress_filters' => 0, |
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - if ( $this->csv_output ) { |
|
| 492 | + if ($this->csv_output) { |
|
| 493 | 493 | $lessons_args['posts_per_page'] = '-1'; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if( isset( $args['search'] ) ) { |
|
| 496 | + if (isset($args['search'])) { |
|
| 497 | 497 | $lessons_args['s'] = $args['search']; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
| 501 | - $lessons_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_lessons', $lessons_args ) ); |
|
| 501 | + $lessons_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_lessons', $lessons_args)); |
|
| 502 | 502 | $this->total_items = $lessons_query->found_posts; |
| 503 | 503 | return $lessons_query->posts; |
| 504 | 504 | } // End get_lessons() |
@@ -508,24 +508,24 @@ discard block |
||
| 508 | 508 | * @since 1.7.0 |
| 509 | 509 | * @return array learners |
| 510 | 510 | */ |
| 511 | - private function get_learners( $args ) { |
|
| 511 | + private function get_learners($args) { |
|
| 512 | 512 | |
| 513 | - if ( !empty($args['search']) ) { |
|
| 513 | + if ( ! empty($args['search'])) { |
|
| 514 | 514 | $args = array( |
| 515 | - 'search' => '*' . trim( $args['search'], '*' ) . '*', |
|
| 515 | + 'search' => '*'.trim($args['search'], '*').'*', |
|
| 516 | 516 | ); |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | // This stops the full meta data of each user being loaded |
| 520 | - $args['fields'] = array( 'ID', 'user_login', 'user_email', 'user_registered', 'display_name' ); |
|
| 520 | + $args['fields'] = array('ID', 'user_login', 'user_email', 'user_registered', 'display_name'); |
|
| 521 | 521 | |
| 522 | 522 | /** |
| 523 | 523 | * Filter the WP_User_Query arguments |
| 524 | 524 | * @since 1.6.0 |
| 525 | 525 | * @param $args |
| 526 | 526 | */ |
| 527 | - $args = apply_filters( 'sensei_analysis_overview_filter_users', $args ); |
|
| 528 | - $wp_user_search = new WP_User_Query( $args ); |
|
| 527 | + $args = apply_filters('sensei_analysis_overview_filter_users', $args); |
|
| 528 | + $wp_user_search = new WP_User_Query($args); |
|
| 529 | 529 | $learners = $wp_user_search->get_results(); |
| 530 | 530 | $this->total_items = $wp_user_search->get_total(); |
| 531 | 531 | |
@@ -538,18 +538,18 @@ discard block |
||
| 538 | 538 | * @since 1.2.0 |
| 539 | 539 | * @return array $stats_to_render of stats boxes and values |
| 540 | 540 | */ |
| 541 | - public function stats_boxes () { |
|
| 541 | + public function stats_boxes() { |
|
| 542 | 542 | |
| 543 | 543 | // Get the data required |
| 544 | 544 | $user_count = count_users(); |
| 545 | - $user_count = apply_filters( 'sensei_analysis_total_users', $user_count['total_users'], $user_count ); |
|
| 546 | - $total_courses = Sensei()->course->course_count( array('publish', 'private') ); |
|
| 547 | - $total_lessons = Sensei()->lesson->lesson_count( array('publish', 'private') ); |
|
| 545 | + $user_count = apply_filters('sensei_analysis_total_users', $user_count['total_users'], $user_count); |
|
| 546 | + $total_courses = Sensei()->course->course_count(array('publish', 'private')); |
|
| 547 | + $total_lessons = Sensei()->lesson->lesson_count(array('publish', 'private')); |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * filter the analysis tot grades query args |
| 551 | 551 | */ |
| 552 | - $grade_args = apply_filters( 'sensei_analysis_total_quiz_grades', array( |
|
| 552 | + $grade_args = apply_filters('sensei_analysis_total_quiz_grades', array( |
|
| 553 | 553 | 'type' => 'sensei_lesson_status', |
| 554 | 554 | 'status' => 'any', |
| 555 | 555 | |
@@ -559,8 +559,8 @@ discard block |
||
| 559 | 559 | $total_grade_count = Sensei_Grading::get_graded_lessons_count(); |
| 560 | 560 | $total_grade_total = Sensei_Grading::get_graded_lessons_sum(); |
| 561 | 561 | $total_average_grade = 0; |
| 562 | - if( $total_grade_total > 0 && $total_grade_count >0 ){ |
|
| 563 | - $total_average_grade = abs( round( doubleval( $total_grade_total / $total_grade_count ), 2 ) ); |
|
| 562 | + if ($total_grade_total > 0 && $total_grade_count > 0) { |
|
| 563 | + $total_average_grade = abs(round(doubleval($total_grade_total / $total_grade_count), 2)); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | |
@@ -568,24 +568,24 @@ discard block |
||
| 568 | 568 | 'type' => 'sensei_course_status', |
| 569 | 569 | 'status' => 'any', |
| 570 | 570 | ); |
| 571 | - $total_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_started', $course_args ) ); |
|
| 571 | + $total_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_started', $course_args)); |
|
| 572 | 572 | $course_args = array( |
| 573 | 573 | 'type' => 'sensei_course_status', |
| 574 | 574 | 'status' => 'complete', |
| 575 | 575 | ); |
| 576 | - $total_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_ended', $course_args ) ); |
|
| 577 | - $average_courses_per_learner = abs( round( doubleval( $total_courses_started / $user_count ), 2 ) ); |
|
| 576 | + $total_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_ended', $course_args)); |
|
| 577 | + $average_courses_per_learner = abs(round(doubleval($total_courses_started / $user_count), 2)); |
|
| 578 | 578 | |
| 579 | 579 | // Setup the boxes to render |
| 580 | 580 | $stats_to_render = array( |
| 581 | - __( 'Total Courses', 'woothemes-sensei' ) => $total_courses, |
|
| 582 | - __( 'Total Lessons', 'woothemes-sensei' ) => $total_lessons, |
|
| 583 | - __( 'Total Learners', 'woothemes-sensei' ) => $user_count, |
|
| 584 | - __( 'Average Courses per Learner', 'woothemes-sensei' ) => $average_courses_per_learner, |
|
| 585 | - __( 'Average Grade', 'woothemes-sensei' ) => $total_average_grade . '%', |
|
| 586 | - __( 'Total Completed Courses', 'woothemes-sensei' ) => $total_courses_ended, |
|
| 581 | + __('Total Courses', 'woothemes-sensei') => $total_courses, |
|
| 582 | + __('Total Lessons', 'woothemes-sensei') => $total_lessons, |
|
| 583 | + __('Total Learners', 'woothemes-sensei') => $user_count, |
|
| 584 | + __('Average Courses per Learner', 'woothemes-sensei') => $average_courses_per_learner, |
|
| 585 | + __('Average Grade', 'woothemes-sensei') => $total_average_grade.'%', |
|
| 586 | + __('Total Completed Courses', 'woothemes-sensei') => $total_courses_ended, |
|
| 587 | 587 | ); |
| 588 | - return apply_filters( 'sensei_analysis_stats_boxes', $stats_to_render ); |
|
| 588 | + return apply_filters('sensei_analysis_stats_boxes', $stats_to_render); |
|
| 589 | 589 | } // End stats_boxes() |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -595,12 +595,12 @@ discard block |
||
| 595 | 595 | * @return void |
| 596 | 596 | */ |
| 597 | 597 | public function no_items() { |
| 598 | - if( ! $this->view || 'users' == $this->view ) { |
|
| 598 | + if ( ! $this->view || 'users' == $this->view) { |
|
| 599 | 599 | $type = 'learners'; |
| 600 | 600 | } else { |
| 601 | 601 | $type = $this->view; |
| 602 | 602 | } |
| 603 | - echo sprintf( __( '%1$sNo %2$s found%3$s', 'woothemes-sensei' ), '<em>', $type, '</em>' ); |
|
| 603 | + echo sprintf(__('%1$sNo %2$s found%3$s', 'woothemes-sensei'), '<em>', $type, '</em>'); |
|
| 604 | 604 | } // End no_items() |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | 'page' => $this->page_slug, |
| 616 | 616 | ); |
| 617 | 617 | $learners_class = $courses_class = $lessons_class = ''; |
| 618 | - switch( $this->type ) { |
|
| 618 | + switch ($this->type) { |
|
| 619 | 619 | case 'courses': |
| 620 | 620 | $courses_class = 'current'; |
| 621 | 621 | break; |
@@ -633,18 +633,18 @@ discard block |
||
| 633 | 633 | $lesson_args['view'] = 'lessons'; |
| 634 | 634 | $courses_args['view'] = 'courses'; |
| 635 | 635 | |
| 636 | - $menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ). '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>'; |
|
| 637 | - $menu['courses'] = '<a class="' . $courses_class . '" href="' . esc_url ( add_query_arg( $courses_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Courses', 'woothemes-sensei' ) . '</a>'; |
|
| 638 | - $menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>'; |
|
| 636 | + $menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>'; |
|
| 637 | + $menu['courses'] = '<a class="'.$courses_class.'" href="'.esc_url(add_query_arg($courses_args, admin_url('admin.php'))).'">'.__('Courses', 'woothemes-sensei').'</a>'; |
|
| 638 | + $menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>'; |
|
| 639 | 639 | |
| 640 | - $menu = apply_filters( 'sensei_analysis_overview_sub_menu', $menu ); |
|
| 641 | - if ( !empty($menu) ) { |
|
| 642 | - echo '<ul class="subsubsub">' . "\n"; |
|
| 643 | - foreach ( $menu as $class => $item ) { |
|
| 644 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
| 640 | + $menu = apply_filters('sensei_analysis_overview_sub_menu', $menu); |
|
| 641 | + if ( ! empty($menu)) { |
|
| 642 | + echo '<ul class="subsubsub">'."\n"; |
|
| 643 | + foreach ($menu as $class => $item) { |
|
| 644 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
| 645 | 645 | } |
| 646 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
| 647 | - echo '</ul>' . "\n"; |
|
| 646 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
| 647 | + echo '</ul>'."\n"; |
|
| 648 | 648 | } |
| 649 | 649 | } // End data_table_header() |
| 650 | 650 | |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | * @return void |
| 655 | 655 | */ |
| 656 | 656 | public function data_table_footer() { |
| 657 | - switch ( $this->type ) { |
|
| 657 | + switch ($this->type) { |
|
| 658 | 658 | case 'courses': |
| 659 | 659 | $report = 'courses-overview'; |
| 660 | 660 | break; |
@@ -668,8 +668,8 @@ discard block |
||
| 668 | 668 | $report = 'user-overview'; |
| 669 | 669 | break; |
| 670 | 670 | } // End Switch Statement |
| 671 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
| 672 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
| 671 | + $url = add_query_arg(array('page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
| 672 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
| 673 | 673 | } // End data_table_footer() |
| 674 | 674 | |
| 675 | 675 | /** |
@@ -677,19 +677,19 @@ discard block |
||
| 677 | 677 | * @since 1.7.0 |
| 678 | 678 | * @return string $text |
| 679 | 679 | */ |
| 680 | - public function search_button( $text = '' ) { |
|
| 681 | - switch( $this->type ) { |
|
| 680 | + public function search_button($text = '') { |
|
| 681 | + switch ($this->type) { |
|
| 682 | 682 | case 'courses': |
| 683 | - $text = __( 'Search Courses', 'woothemes-sensei' ); |
|
| 683 | + $text = __('Search Courses', 'woothemes-sensei'); |
|
| 684 | 684 | break; |
| 685 | 685 | |
| 686 | 686 | case 'lessons': |
| 687 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
| 687 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
| 688 | 688 | break; |
| 689 | 689 | |
| 690 | 690 | case 'users': |
| 691 | 691 | default: |
| 692 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
| 692 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
| 693 | 693 | break; |
| 694 | 694 | } // End Switch Statement |
| 695 | 695 | |
@@ -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 Post Types Class |
@@ -40,43 +40,43 @@ discard block |
||
| 40 | 40 | * Constructor |
| 41 | 41 | * @since 1.0.0 |
| 42 | 42 | */ |
| 43 | - public function __construct () { |
|
| 43 | + public function __construct() { |
|
| 44 | 44 | |
| 45 | 45 | // Setup Post Types |
| 46 | 46 | $this->labels = array(); |
| 47 | 47 | $this->token = 'woothemes-sensei-posttypes'; |
| 48 | 48 | |
| 49 | 49 | $this->setup_post_type_labels_base(); |
| 50 | - add_action( 'init', array( $this, 'setup_course_post_type' ), 100 ); |
|
| 51 | - add_action( 'init', array( $this, 'setup_lesson_post_type' ), 100 ); |
|
| 52 | - add_action( 'init', array( $this, 'setup_quiz_post_type' ), 100 ); |
|
| 53 | - add_action( 'init', array( $this, 'setup_question_post_type' ), 100 ); |
|
| 54 | - add_action( 'init', array( $this, 'setup_multiple_question_post_type' ), 100 ); |
|
| 55 | - add_action( 'init', array( $this, 'setup_sensei_message_post_type' ), 100 ); |
|
| 50 | + add_action('init', array($this, 'setup_course_post_type'), 100); |
|
| 51 | + add_action('init', array($this, 'setup_lesson_post_type'), 100); |
|
| 52 | + add_action('init', array($this, 'setup_quiz_post_type'), 100); |
|
| 53 | + add_action('init', array($this, 'setup_question_post_type'), 100); |
|
| 54 | + add_action('init', array($this, 'setup_multiple_question_post_type'), 100); |
|
| 55 | + add_action('init', array($this, 'setup_sensei_message_post_type'), 100); |
|
| 56 | 56 | |
| 57 | 57 | // Setup Taxonomies |
| 58 | - add_action( 'init', array( $this, 'setup_course_category_taxonomy' ), 100 ); |
|
| 59 | - add_action( 'init', array( $this, 'setup_quiz_type_taxonomy' ), 100 ); |
|
| 60 | - add_action( 'init', array( $this, 'setup_question_type_taxonomy' ), 100 ); |
|
| 61 | - add_action( 'init', array( $this, 'setup_question_category_taxonomy' ), 100 ); |
|
| 62 | - add_action( 'init', array( $this, 'setup_lesson_tag_taxonomy' ), 100 ); |
|
| 58 | + add_action('init', array($this, 'setup_course_category_taxonomy'), 100); |
|
| 59 | + add_action('init', array($this, 'setup_quiz_type_taxonomy'), 100); |
|
| 60 | + add_action('init', array($this, 'setup_question_type_taxonomy'), 100); |
|
| 61 | + add_action('init', array($this, 'setup_question_category_taxonomy'), 100); |
|
| 62 | + add_action('init', array($this, 'setup_lesson_tag_taxonomy'), 100); |
|
| 63 | 63 | |
| 64 | 64 | // Load Post Type Objects |
| 65 | - $default_post_types = array( 'course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages' ) ; |
|
| 66 | - $this->load_posttype_objects( $default_post_types ); |
|
| 65 | + $default_post_types = array('course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages'); |
|
| 66 | + $this->load_posttype_objects($default_post_types); |
|
| 67 | 67 | |
| 68 | 68 | // Admin functions |
| 69 | - if ( is_admin() ) { |
|
| 70 | - $this->set_role_cap_defaults( $default_post_types ); |
|
| 69 | + if (is_admin()) { |
|
| 70 | + $this->set_role_cap_defaults($default_post_types); |
|
| 71 | 71 | global $pagenow; |
| 72 | - if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) ) { |
|
| 73 | - add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 10 ); |
|
| 74 | - add_filter( 'post_updated_messages', array( $this, 'setup_post_type_messages' ) ); |
|
| 72 | + if (($pagenow == 'post.php' || $pagenow == 'post-new.php')) { |
|
| 73 | + add_filter('enter_title_here', array($this, 'enter_title_here'), 10); |
|
| 74 | + add_filter('post_updated_messages', array($this, 'setup_post_type_messages')); |
|
| 75 | 75 | } // End If Statement |
| 76 | 76 | } // End If Statement |
| 77 | 77 | |
| 78 | 78 | // Add 'Edit Quiz' link to admin bar |
| 79 | - add_action( 'admin_bar_menu', array( $this, 'quiz_admin_bar_menu' ), 81 ); |
|
| 79 | + add_action('admin_bar_menu', array($this, 'quiz_admin_bar_menu'), 81); |
|
| 80 | 80 | |
| 81 | 81 | } // End __construct() |
| 82 | 82 | |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | * @param array $posttypes (default: array()) |
| 88 | 88 | * @return void |
| 89 | 89 | */ |
| 90 | - public function load_posttype_objects( $posttypes = array() ) { |
|
| 90 | + public function load_posttype_objects($posttypes = array()) { |
|
| 91 | 91 | |
| 92 | - foreach ( $posttypes as $posttype_token => $posttype_name ) { |
|
| 92 | + foreach ($posttypes as $posttype_token => $posttype_name) { |
|
| 93 | 93 | |
| 94 | 94 | // Load the files |
| 95 | - $class_name = 'WooThemes_Sensei_' . $posttype_name; |
|
| 95 | + $class_name = 'WooThemes_Sensei_'.$posttype_name; |
|
| 96 | 96 | $this->$posttype_token = new $class_name(); |
| 97 | 97 | $this->$posttype_token->token = $posttype_token; |
| 98 | 98 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | * @uses Sensei() |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function setup_course_post_type () { |
|
| 109 | + public function setup_course_post_type() { |
|
| 110 | 110 | |
| 111 | 111 | $args = array( |
| 112 | - 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ), |
|
| 112 | + 'labels' => $this->create_post_type_labels($this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu']), |
|
| 113 | 113 | 'public' => true, |
| 114 | 114 | 'publicly_queryable' => true, |
| 115 | 115 | 'show_ui' => true, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | 'show_in_admin_bar' => true, |
| 118 | 118 | 'query_var' => true, |
| 119 | 119 | 'rewrite' => array( |
| 120 | - 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) , |
|
| 120 | + 'slug' => esc_attr(apply_filters('sensei_course_slug', _x('course', 'post type single url base', 'woothemes-sensei'))), |
|
| 121 | 121 | 'with_front' => true, |
| 122 | 122 | 'feeds' => true, |
| 123 | 123 | 'pages' => true |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | 'has_archive' => $this->get_course_post_type_archive_slug(), |
| 128 | 128 | 'hierarchical' => false, |
| 129 | 129 | 'menu_position' => 51, |
| 130 | - 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) |
|
| 130 | + 'supports' => array('title', 'editor', 'excerpt', 'thumbnail') |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @since 1.9.0 |
| 137 | 137 | * @param array $args |
| 138 | 138 | */ |
| 139 | - register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) ); |
|
| 139 | + register_post_type('course', apply_filters('sensei_register_post_type_course', $args)); |
|
| 140 | 140 | |
| 141 | 141 | } // End setup_course_post_type() |
| 142 | 142 | |
@@ -155,17 +155,17 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return false|string |
| 157 | 157 | */ |
| 158 | - public function get_course_post_type_archive_slug(){ |
|
| 158 | + public function get_course_post_type_archive_slug() { |
|
| 159 | 159 | |
| 160 | - $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) ); |
|
| 160 | + $settings_course_page = get_post(Sensei()->settings->get('course_page')); |
|
| 161 | 161 | |
| 162 | 162 | // for a valid post that doesn't have any of the old short codes set the archive the same |
| 163 | 163 | // as the page URI |
| 164 | - if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){ |
|
| 164 | + if (is_a($settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes($settings_course_page->post_content)) { |
|
| 165 | 165 | |
| 166 | - return get_page_uri( $settings_course_page->ID ); |
|
| 166 | + return get_page_uri($settings_course_page->ID); |
|
| 167 | 167 | |
| 168 | - }else{ |
|
| 168 | + } else { |
|
| 169 | 169 | |
| 170 | 170 | return 'courses'; |
| 171 | 171 | |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | - public function has_old_shortcodes( $content ){ |
|
| 186 | + public function has_old_shortcodes($content) { |
|
| 187 | 187 | |
| 188 | - return ( has_shortcode( $content, 'newcourses') |
|
| 189 | - || has_shortcode( $content, 'featuredcourses') |
|
| 190 | - || has_shortcode( $content, 'freecourses') |
|
| 191 | - || has_shortcode( $content, 'paidcourses') ); |
|
| 188 | + return (has_shortcode($content, 'newcourses') |
|
| 189 | + || has_shortcode($content, 'featuredcourses') |
|
| 190 | + || has_shortcode($content, 'freecourses') |
|
| 191 | + || has_shortcode($content, 'paidcourses')); |
|
| 192 | 192 | |
| 193 | 193 | }// end has old shortcodes |
| 194 | 194 | |
@@ -199,26 +199,26 @@ discard block |
||
| 199 | 199 | * @uses Sensei() |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - public function setup_lesson_post_type () { |
|
| 202 | + public function setup_lesson_post_type() { |
|
| 203 | 203 | |
| 204 | - $supports_array = array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ); |
|
| 204 | + $supports_array = array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes'); |
|
| 205 | 205 | $allow_comments = false; |
| 206 | - if ( isset( Sensei()->settings->settings[ 'lesson_comments' ] ) ) { |
|
| 207 | - $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ]; |
|
| 206 | + if (isset(Sensei()->settings->settings['lesson_comments'])) { |
|
| 207 | + $allow_comments = Sensei()->settings->settings['lesson_comments']; |
|
| 208 | 208 | } // End If Statement |
| 209 | - if ( $allow_comments ) { |
|
| 210 | - array_push( $supports_array, 'comments' ); |
|
| 209 | + if ($allow_comments) { |
|
| 210 | + array_push($supports_array, 'comments'); |
|
| 211 | 211 | } // End If Statement |
| 212 | 212 | |
| 213 | 213 | $args = array( |
| 214 | - 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ), |
|
| 214 | + 'labels' => $this->create_post_type_labels($this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu']), |
|
| 215 | 215 | 'public' => true, |
| 216 | 216 | 'publicly_queryable' => true, |
| 217 | 217 | 'show_ui' => true, |
| 218 | 218 | 'show_in_menu' => true, |
| 219 | 219 | 'query_var' => true, |
| 220 | 220 | 'rewrite' => array( |
| 221 | - 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 221 | + 'slug' => esc_attr(apply_filters('sensei_lesson_slug', _x('lesson', 'post type single slug', 'woothemes-sensei'))), |
|
| 222 | 222 | 'with_front' => true, |
| 223 | 223 | 'feeds' => true, |
| 224 | 224 | 'pages' => true |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @since 1.9.0 |
| 238 | 238 | * @param array $args |
| 239 | 239 | */ |
| 240 | - register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) ); |
|
| 240 | + register_post_type('lesson', apply_filters('sensei_register_post_type_lesson', $args)); |
|
| 241 | 241 | |
| 242 | 242 | } // End setup_lesson_post_type() |
| 243 | 243 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @uses Sensei() |
| 248 | 248 | * @return void |
| 249 | 249 | */ |
| 250 | - public function setup_quiz_post_type () { |
|
| 250 | + public function setup_quiz_post_type() { |
|
| 251 | 251 | |
| 252 | 252 | $args = array( |
| 253 | 253 | 'labels' => $this->create_post_type_labels( |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | 'query_var' => true, |
| 264 | 264 | 'exclude_from_search' => true, |
| 265 | 265 | 'rewrite' => array( |
| 266 | - 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 266 | + 'slug' => esc_attr(apply_filters('sensei_quiz_slug', _x('quiz', 'post type single slug', 'woothemes-sensei'))), |
|
| 267 | 267 | 'with_front' => true, |
| 268 | 268 | 'feeds' => true, |
| 269 | 269 | 'pages' => true |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | 'has_archive' => false, |
| 274 | 274 | 'hierarchical' => false, |
| 275 | 275 | 'menu_position' => 20, // Below "Pages" |
| 276 | - 'supports' => array( '' ) |
|
| 276 | + 'supports' => array('') |
|
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @since 1.9.0 |
| 283 | 283 | * @param array $args |
| 284 | 284 | */ |
| 285 | - register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) ); |
|
| 285 | + register_post_type('quiz', apply_filters('sensei_register_post_type_quiz', $args)); |
|
| 286 | 286 | |
| 287 | 287 | } // End setup_quiz_post_type() |
| 288 | 288 | |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | * @since 1.0.0 |
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | - public function setup_question_post_type () { |
|
| 295 | + public function setup_question_post_type() { |
|
| 296 | 296 | |
| 297 | 297 | $args = array( |
| 298 | - 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ), |
|
| 298 | + 'labels' => $this->create_post_type_labels($this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu']), |
|
| 299 | 299 | 'public' => false, |
| 300 | 300 | 'publicly_queryable' => true, |
| 301 | 301 | 'show_ui' => true, |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | 'query_var' => true, |
| 305 | 305 | 'exclude_from_search' => true, |
| 306 | 306 | 'rewrite' => array( |
| 307 | - 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 307 | + 'slug' => esc_attr(apply_filters('sensei_question_slug', _x('question', 'post type single slug', 'woothemes-sensei'))), |
|
| 308 | 308 | 'with_front' => true, |
| 309 | 309 | 'feeds' => true, |
| 310 | 310 | 'pages' => true |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | 'has_archive' => true, |
| 315 | 315 | 'hierarchical' => false, |
| 316 | 316 | 'menu_position' => 51, |
| 317 | - 'supports' => array( 'title' ) |
|
| 317 | + 'supports' => array('title') |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @since 1.9.0 |
| 324 | 324 | * @param array $args |
| 325 | 325 | */ |
| 326 | - register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) ); |
|
| 326 | + register_post_type('question', apply_filters('sensei_register_post_type_question', $args)); |
|
| 327 | 327 | |
| 328 | 328 | } // End setup_question_post_type() |
| 329 | 329 | |
@@ -332,10 +332,10 @@ discard block |
||
| 332 | 332 | * @since 1.6.0 |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | - public function setup_multiple_question_post_type () { |
|
| 335 | + public function setup_multiple_question_post_type() { |
|
| 336 | 336 | |
| 337 | 337 | $args = array( |
| 338 | - 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ), |
|
| 338 | + 'labels' => $this->create_post_type_labels($this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu']), |
|
| 339 | 339 | 'public' => false, |
| 340 | 340 | 'publicly_queryable' => false, |
| 341 | 341 | 'show_ui' => false, |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | 'query_var' => false, |
| 345 | 345 | 'exclude_from_search' => true, |
| 346 | 346 | 'rewrite' => array( |
| 347 | - 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 347 | + 'slug' => esc_attr(apply_filters('sensei_multiple_question_slug', _x('multiple_question', 'post type single slug', 'woothemes-sensei'))), |
|
| 348 | 348 | 'with_front' => false, |
| 349 | 349 | 'feeds' => false, |
| 350 | 350 | 'pages' => false |
@@ -354,10 +354,10 @@ discard block |
||
| 354 | 354 | 'has_archive' => false, |
| 355 | 355 | 'hierarchical' => false, |
| 356 | 356 | 'menu_position' => 51, |
| 357 | - 'supports' => array( 'title', 'custom-fields' ) |
|
| 357 | + 'supports' => array('title', 'custom-fields') |
|
| 358 | 358 | ); |
| 359 | 359 | |
| 360 | - register_post_type( 'multiple_question', $args ); |
|
| 360 | + register_post_type('multiple_question', $args); |
|
| 361 | 361 | } // End setup_multiple_question_post_type() |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -365,12 +365,12 @@ discard block |
||
| 365 | 365 | * @since 1.6.0 |
| 366 | 366 | * @return void |
| 367 | 367 | */ |
| 368 | - public function setup_sensei_message_post_type () { |
|
| 368 | + public function setup_sensei_message_post_type() { |
|
| 369 | 369 | |
| 370 | - if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) { |
|
| 370 | + if ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable']) { |
|
| 371 | 371 | |
| 372 | 372 | $args = array( |
| 373 | - 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ), |
|
| 373 | + 'labels' => $this->create_post_type_labels($this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu']), |
|
| 374 | 374 | 'public' => true, |
| 375 | 375 | 'publicly_queryable' => true, |
| 376 | 376 | 'show_ui' => true, |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | 'query_var' => true, |
| 380 | 380 | 'exclude_from_search' => true, |
| 381 | 381 | 'rewrite' => array( |
| 382 | - 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 382 | + 'slug' => esc_attr(apply_filters('sensei_messages_slug', _x('messages', 'post type single slug', 'woothemes-sensei'))), |
|
| 383 | 383 | 'with_front' => false, |
| 384 | 384 | 'feeds' => false, |
| 385 | 385 | 'pages' => true |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | 'has_archive' => true, |
| 390 | 390 | 'hierarchical' => false, |
| 391 | 391 | 'menu_position' => 50, |
| 392 | - 'supports' => array( 'title', 'editor', 'comments' ), |
|
| 392 | + 'supports' => array('title', 'editor', 'comments'), |
|
| 393 | 393 | ); |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @since 1.9.0 |
| 399 | 399 | * @param array $args |
| 400 | 400 | */ |
| 401 | - register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args ) ); |
|
| 401 | + register_post_type('sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args)); |
|
| 402 | 402 | } |
| 403 | 403 | } // End setup_sensei_message_post_type() |
| 404 | 404 | |
@@ -407,20 +407,20 @@ discard block |
||
| 407 | 407 | * @since 1.1.0 |
| 408 | 408 | * @return void |
| 409 | 409 | */ |
| 410 | - public function setup_course_category_taxonomy () { |
|
| 410 | + public function setup_course_category_taxonomy() { |
|
| 411 | 411 | // "Course Categories" Custom Taxonomy |
| 412 | 412 | $labels = array( |
| 413 | - 'name' => _x( 'Course Categories', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 414 | - 'singular_name' => _x( 'Course Category', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 415 | - 'search_items' => __( 'Search Course Categories', 'woothemes-sensei' ), |
|
| 416 | - 'all_items' => __( 'All Course Categories', 'woothemes-sensei' ), |
|
| 417 | - 'parent_item' => __( 'Parent Course Category', 'woothemes-sensei' ), |
|
| 418 | - 'parent_item_colon' => __( 'Parent Course Category:', 'woothemes-sensei' ), |
|
| 419 | - 'edit_item' => __( 'Edit Course Category', 'woothemes-sensei' ), |
|
| 420 | - 'update_item' => __( 'Update Course Category', 'woothemes-sensei' ), |
|
| 421 | - 'add_new_item' => __( 'Add New Course Category', 'woothemes-sensei' ), |
|
| 422 | - 'new_item_name' => __( 'New Course Category Name', 'woothemes-sensei' ), |
|
| 423 | - 'menu_name' => __( 'Course Categories', 'woothemes-sensei' ), |
|
| 413 | + 'name' => _x('Course Categories', 'taxonomy general name', 'woothemes-sensei'), |
|
| 414 | + 'singular_name' => _x('Course Category', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 415 | + 'search_items' => __('Search Course Categories', 'woothemes-sensei'), |
|
| 416 | + 'all_items' => __('All Course Categories', 'woothemes-sensei'), |
|
| 417 | + 'parent_item' => __('Parent Course Category', 'woothemes-sensei'), |
|
| 418 | + 'parent_item_colon' => __('Parent Course Category:', 'woothemes-sensei'), |
|
| 419 | + 'edit_item' => __('Edit Course Category', 'woothemes-sensei'), |
|
| 420 | + 'update_item' => __('Update Course Category', 'woothemes-sensei'), |
|
| 421 | + 'add_new_item' => __('Add New Course Category', 'woothemes-sensei'), |
|
| 422 | + 'new_item_name' => __('New Course Category Name', 'woothemes-sensei'), |
|
| 423 | + 'menu_name' => __('Course Categories', 'woothemes-sensei'), |
|
| 424 | 424 | 'popular_items' => null // Hides the "Popular" section above the "add" form in the admin. |
| 425 | 425 | ); |
| 426 | 426 | |
@@ -435,10 +435,10 @@ discard block |
||
| 435 | 435 | 'edit_terms' => 'edit_courses', |
| 436 | 436 | 'delete_terms' => 'manage_categories', |
| 437 | 437 | 'assign_terms' => 'edit_courses',), |
| 438 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 438 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_course_category_slug', _x('course-category', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 439 | 439 | ); |
| 440 | 440 | |
| 441 | - register_taxonomy( 'course-category', array( 'course' ), $args ); |
|
| 441 | + register_taxonomy('course-category', array('course'), $args); |
|
| 442 | 442 | |
| 443 | 443 | } // End setup_course_category_taxonomy() |
| 444 | 444 | |
@@ -447,21 +447,21 @@ discard block |
||
| 447 | 447 | * @since 1.0.0 |
| 448 | 448 | * @return void |
| 449 | 449 | */ |
| 450 | - public function setup_quiz_type_taxonomy () { |
|
| 450 | + public function setup_quiz_type_taxonomy() { |
|
| 451 | 451 | |
| 452 | 452 | // "Quiz Types" Custom Taxonomy |
| 453 | 453 | $labels = array( |
| 454 | - 'name' => _x( 'Quiz Types', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 455 | - 'singular_name' => _x( 'Quiz Type', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 456 | - 'search_items' => __( 'Search Quiz Types', 'woothemes-sensei' ), |
|
| 457 | - 'all_items' => __( 'All Quiz Types', 'woothemes-sensei' ), |
|
| 458 | - 'parent_item' => __( 'Parent Quiz Type', 'woothemes-sensei' ), |
|
| 459 | - 'parent_item_colon' => __( 'Parent Quiz Type:', 'woothemes-sensei' ), |
|
| 460 | - 'edit_item' => __( 'Edit Quiz Type', 'woothemes-sensei' ), |
|
| 461 | - 'update_item' => __( 'Update Quiz Type', 'woothemes-sensei' ), |
|
| 462 | - 'add_new_item' => __( 'Add New Quiz Type', 'woothemes-sensei' ), |
|
| 463 | - 'new_item_name' => __( 'New Quiz Type Name', 'woothemes-sensei' ), |
|
| 464 | - 'menu_name' => __( 'Quiz Types', 'woothemes-sensei' ), |
|
| 454 | + 'name' => _x('Quiz Types', 'taxonomy general name', 'woothemes-sensei'), |
|
| 455 | + 'singular_name' => _x('Quiz Type', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 456 | + 'search_items' => __('Search Quiz Types', 'woothemes-sensei'), |
|
| 457 | + 'all_items' => __('All Quiz Types', 'woothemes-sensei'), |
|
| 458 | + 'parent_item' => __('Parent Quiz Type', 'woothemes-sensei'), |
|
| 459 | + 'parent_item_colon' => __('Parent Quiz Type:', 'woothemes-sensei'), |
|
| 460 | + 'edit_item' => __('Edit Quiz Type', 'woothemes-sensei'), |
|
| 461 | + 'update_item' => __('Update Quiz Type', 'woothemes-sensei'), |
|
| 462 | + 'add_new_item' => __('Add New Quiz Type', 'woothemes-sensei'), |
|
| 463 | + 'new_item_name' => __('New Quiz Type Name', 'woothemes-sensei'), |
|
| 464 | + 'menu_name' => __('Quiz Types', 'woothemes-sensei'), |
|
| 465 | 465 | 'popular_items' => null // Hides the "Popular" section above the "add" form in the admin. |
| 466 | 466 | ); |
| 467 | 467 | |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | 'query_var' => true, |
| 473 | 473 | 'show_in_nav_menus' => false, |
| 474 | 474 | 'public' => false, |
| 475 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 475 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_quiz_type_slug', _x('quiz-type', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 476 | 476 | ); |
| 477 | 477 | |
| 478 | - register_taxonomy( 'quiz-type', array( 'quiz' ), $args ); |
|
| 478 | + register_taxonomy('quiz-type', array('quiz'), $args); |
|
| 479 | 479 | } // End setup_quiz_type_taxonomy() |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -483,21 +483,21 @@ discard block |
||
| 483 | 483 | * @since 1.3.0 |
| 484 | 484 | * @return void |
| 485 | 485 | */ |
| 486 | - public function setup_question_type_taxonomy () { |
|
| 486 | + public function setup_question_type_taxonomy() { |
|
| 487 | 487 | |
| 488 | 488 | // "Question Types" Custom Taxonomy |
| 489 | 489 | $labels = array( |
| 490 | - 'name' => _x( 'Question Types', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 491 | - 'singular_name' => _x( 'Question Type', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 492 | - 'search_items' => __( 'Search Question Types', 'woothemes-sensei' ), |
|
| 493 | - 'all_items' => __( 'All Question Types', 'woothemes-sensei' ), |
|
| 494 | - 'parent_item' => __( 'Parent Question Type', 'woothemes-sensei' ), |
|
| 495 | - 'parent_item_colon' => __( 'Parent Question Type:', 'woothemes-sensei' ), |
|
| 496 | - 'edit_item' => __( 'Edit Question Type', 'woothemes-sensei' ), |
|
| 497 | - 'update_item' => __( 'Update Question Type', 'woothemes-sensei' ), |
|
| 498 | - 'add_new_item' => __( 'Add New Question Type', 'woothemes-sensei' ), |
|
| 499 | - 'new_item_name' => __( 'New Question Type Name', 'woothemes-sensei' ), |
|
| 500 | - 'menu_name' => __( 'Question Types', 'woothemes-sensei' ), |
|
| 490 | + 'name' => _x('Question Types', 'taxonomy general name', 'woothemes-sensei'), |
|
| 491 | + 'singular_name' => _x('Question Type', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 492 | + 'search_items' => __('Search Question Types', 'woothemes-sensei'), |
|
| 493 | + 'all_items' => __('All Question Types', 'woothemes-sensei'), |
|
| 494 | + 'parent_item' => __('Parent Question Type', 'woothemes-sensei'), |
|
| 495 | + 'parent_item_colon' => __('Parent Question Type:', 'woothemes-sensei'), |
|
| 496 | + 'edit_item' => __('Edit Question Type', 'woothemes-sensei'), |
|
| 497 | + 'update_item' => __('Update Question Type', 'woothemes-sensei'), |
|
| 498 | + 'add_new_item' => __('Add New Question Type', 'woothemes-sensei'), |
|
| 499 | + 'new_item_name' => __('New Question Type Name', 'woothemes-sensei'), |
|
| 500 | + 'menu_name' => __('Question Types', 'woothemes-sensei'), |
|
| 501 | 501 | 'popular_items' => null // Hides the "Popular" section above the "add" form in the admin. |
| 502 | 502 | ); |
| 503 | 503 | |
@@ -509,10 +509,10 @@ discard block |
||
| 509 | 509 | 'query_var' => false, |
| 510 | 510 | 'show_in_nav_menus' => false, |
| 511 | 511 | 'show_admin_column' => true, |
| 512 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_type_slug', _x( 'question-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 512 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_type_slug', _x('question-type', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | - register_taxonomy( 'question-type', array( 'question' ), $args ); |
|
| 515 | + register_taxonomy('question-type', array('question'), $args); |
|
| 516 | 516 | } // End setup_question_type_taxonomy() |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -520,20 +520,20 @@ discard block |
||
| 520 | 520 | * @since 1.3.0 |
| 521 | 521 | * @return void |
| 522 | 522 | */ |
| 523 | - public function setup_question_category_taxonomy () { |
|
| 523 | + public function setup_question_category_taxonomy() { |
|
| 524 | 524 | // "Question Categories" Custom Taxonomy |
| 525 | 525 | $labels = array( |
| 526 | - 'name' => _x( 'Question Categories', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 527 | - 'singular_name' => _x( 'Question Category', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 528 | - 'search_items' => __( 'Search Question Categories', 'woothemes-sensei' ), |
|
| 529 | - 'all_items' => __( 'All Question Categories', 'woothemes-sensei' ), |
|
| 530 | - 'parent_item' => __( 'Parent Question Category', 'woothemes-sensei' ), |
|
| 531 | - 'parent_item_colon' => __( 'Parent Question Category:', 'woothemes-sensei' ), |
|
| 532 | - 'edit_item' => __( 'Edit Question Category', 'woothemes-sensei' ), |
|
| 533 | - 'update_item' => __( 'Update Question Category', 'woothemes-sensei' ), |
|
| 534 | - 'add_new_item' => __( 'Add New Question Category', 'woothemes-sensei' ), |
|
| 535 | - 'new_item_name' => __( 'New Question Category Name', 'woothemes-sensei' ), |
|
| 536 | - 'menu_name' => __( 'Categories', 'woothemes-sensei' ), |
|
| 526 | + 'name' => _x('Question Categories', 'taxonomy general name', 'woothemes-sensei'), |
|
| 527 | + 'singular_name' => _x('Question Category', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 528 | + 'search_items' => __('Search Question Categories', 'woothemes-sensei'), |
|
| 529 | + 'all_items' => __('All Question Categories', 'woothemes-sensei'), |
|
| 530 | + 'parent_item' => __('Parent Question Category', 'woothemes-sensei'), |
|
| 531 | + 'parent_item_colon' => __('Parent Question Category:', 'woothemes-sensei'), |
|
| 532 | + 'edit_item' => __('Edit Question Category', 'woothemes-sensei'), |
|
| 533 | + 'update_item' => __('Update Question Category', 'woothemes-sensei'), |
|
| 534 | + 'add_new_item' => __('Add New Question Category', 'woothemes-sensei'), |
|
| 535 | + 'new_item_name' => __('New Question Category Name', 'woothemes-sensei'), |
|
| 536 | + 'menu_name' => __('Categories', 'woothemes-sensei'), |
|
| 537 | 537 | ); |
| 538 | 538 | |
| 539 | 539 | $args = array( |
@@ -549,10 +549,10 @@ discard block |
||
| 549 | 549 | 'edit_terms' => 'edit_questions', |
| 550 | 550 | 'delete_terms' => 'manage_categories', |
| 551 | 551 | 'assign_terms' => 'edit_questions',), |
| 552 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 552 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_category_slug', _x('question-category', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 553 | 553 | ); |
| 554 | 554 | |
| 555 | - register_taxonomy( 'question-category', array( 'question' ), $args ); |
|
| 555 | + register_taxonomy('question-category', array('question'), $args); |
|
| 556 | 556 | } // End setup_question_type_taxonomy() |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -560,20 +560,20 @@ discard block |
||
| 560 | 560 | * @since 1.5.0 |
| 561 | 561 | * @return void |
| 562 | 562 | */ |
| 563 | - public function setup_lesson_tag_taxonomy () { |
|
| 563 | + public function setup_lesson_tag_taxonomy() { |
|
| 564 | 564 | // "Lesson Tags" Custom Taxonomy |
| 565 | 565 | $labels = array( |
| 566 | - 'name' => _x( 'Lesson Tags', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 567 | - 'singular_name' => _x( 'Lesson Tag', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 568 | - 'search_items' => __( 'Search Lesson Tags', 'woothemes-sensei' ), |
|
| 569 | - 'all_items' => __( 'All Lesson Tags', 'woothemes-sensei' ), |
|
| 570 | - 'parent_item' => __( 'Parent Tag', 'woothemes-sensei' ), |
|
| 571 | - 'parent_item_colon' => __( 'Parent Tag:', 'woothemes-sensei' ), |
|
| 572 | - 'edit_item' => __( 'Edit Lesson Tag', 'woothemes-sensei' ), |
|
| 573 | - 'update_item' => __( 'Update Lesson Tag', 'woothemes-sensei' ), |
|
| 574 | - 'add_new_item' => __( 'Add New Lesson Tag', 'woothemes-sensei' ), |
|
| 575 | - 'new_item_name' => __( 'New Tag Name', 'woothemes-sensei' ), |
|
| 576 | - 'menu_name' => __( 'Lesson Tags', 'woothemes-sensei' ) |
|
| 566 | + 'name' => _x('Lesson Tags', 'taxonomy general name', 'woothemes-sensei'), |
|
| 567 | + 'singular_name' => _x('Lesson Tag', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 568 | + 'search_items' => __('Search Lesson Tags', 'woothemes-sensei'), |
|
| 569 | + 'all_items' => __('All Lesson Tags', 'woothemes-sensei'), |
|
| 570 | + 'parent_item' => __('Parent Tag', 'woothemes-sensei'), |
|
| 571 | + 'parent_item_colon' => __('Parent Tag:', 'woothemes-sensei'), |
|
| 572 | + 'edit_item' => __('Edit Lesson Tag', 'woothemes-sensei'), |
|
| 573 | + 'update_item' => __('Update Lesson Tag', 'woothemes-sensei'), |
|
| 574 | + 'add_new_item' => __('Add New Lesson Tag', 'woothemes-sensei'), |
|
| 575 | + 'new_item_name' => __('New Tag Name', 'woothemes-sensei'), |
|
| 576 | + 'menu_name' => __('Lesson Tags', 'woothemes-sensei') |
|
| 577 | 577 | ); |
| 578 | 578 | |
| 579 | 579 | $args = array( |
@@ -587,10 +587,10 @@ discard block |
||
| 587 | 587 | 'edit_terms' => 'edit_lessons', |
| 588 | 588 | 'delete_terms' => 'manage_categories', |
| 589 | 589 | 'assign_terms' => 'edit_lessons',), |
| 590 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 590 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_lesson_tag_slug', _x('lesson-tag', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 591 | 591 | ); |
| 592 | 592 | |
| 593 | - register_taxonomy( 'lesson-tag', array( 'lesson' ), $args ); |
|
| 593 | + register_taxonomy('lesson-tag', array('lesson'), $args); |
|
| 594 | 594 | } // End setup_lesson_tag_taxonomy() |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -598,15 +598,15 @@ discard block |
||
| 598 | 598 | * @since 1.0.0 |
| 599 | 599 | * @return void |
| 600 | 600 | */ |
| 601 | - private function setup_post_type_labels_base () { |
|
| 602 | - $this->labels = array( 'course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array() ); |
|
| 601 | + private function setup_post_type_labels_base() { |
|
| 602 | + $this->labels = array('course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array()); |
|
| 603 | 603 | |
| 604 | - $this->labels['course'] = array( 'singular' => __( 'Course', 'woothemes-sensei' ), 'plural' => __( 'Courses', 'woothemes-sensei' ), 'menu' => __( 'Courses', 'woothemes-sensei' ) ); |
|
| 605 | - $this->labels['lesson'] = array( 'singular' => __( 'Lesson', 'woothemes-sensei' ), 'plural' => __( 'Lessons', 'woothemes-sensei' ), 'menu' => __( 'Lessons', 'woothemes-sensei' ) ); |
|
| 606 | - $this->labels['quiz'] = array( 'singular' => __( 'Quiz', 'woothemes-sensei' ), 'plural' => __( 'Quizzes', 'woothemes-sensei' ), 'menu' => __( 'Quizzes', 'woothemes-sensei' ) ); |
|
| 607 | - $this->labels['question'] = array( 'singular' => __( 'Question', 'woothemes-sensei' ), 'plural' => __( 'Questions', 'woothemes-sensei' ), 'menu' => __( 'Questions', 'woothemes-sensei' ) ); |
|
| 608 | - $this->labels['multiple_question'] = array( 'singular' => __( 'Multiple Question', 'woothemes-sensei' ), 'plural' => __( 'Multiple Questions', 'woothemes-sensei' ), 'menu' => __( 'Multiple Questions', 'woothemes-sensei' ) ); |
|
| 609 | - $this->labels['sensei_message'] = array( 'singular' => __( 'Message', 'woothemes-sensei' ), 'plural' => __( 'Messages', 'woothemes-sensei' ), 'menu' => __( 'Messages', 'woothemes-sensei' ) ); |
|
| 604 | + $this->labels['course'] = array('singular' => __('Course', 'woothemes-sensei'), 'plural' => __('Courses', 'woothemes-sensei'), 'menu' => __('Courses', 'woothemes-sensei')); |
|
| 605 | + $this->labels['lesson'] = array('singular' => __('Lesson', 'woothemes-sensei'), 'plural' => __('Lessons', 'woothemes-sensei'), 'menu' => __('Lessons', 'woothemes-sensei')); |
|
| 606 | + $this->labels['quiz'] = array('singular' => __('Quiz', 'woothemes-sensei'), 'plural' => __('Quizzes', 'woothemes-sensei'), 'menu' => __('Quizzes', 'woothemes-sensei')); |
|
| 607 | + $this->labels['question'] = array('singular' => __('Question', 'woothemes-sensei'), 'plural' => __('Questions', 'woothemes-sensei'), 'menu' => __('Questions', 'woothemes-sensei')); |
|
| 608 | + $this->labels['multiple_question'] = array('singular' => __('Multiple Question', 'woothemes-sensei'), 'plural' => __('Multiple Questions', 'woothemes-sensei'), 'menu' => __('Multiple Questions', 'woothemes-sensei')); |
|
| 609 | + $this->labels['sensei_message'] = array('singular' => __('Message', 'woothemes-sensei'), 'plural' => __('Messages', 'woothemes-sensei'), 'menu' => __('Messages', 'woothemes-sensei')); |
|
| 610 | 610 | |
| 611 | 611 | } // End setup_post_type_labels_base() |
| 612 | 612 | |
@@ -618,24 +618,24 @@ discard block |
||
| 618 | 618 | * @param string $menu The menu item label |
| 619 | 619 | * @return array An array of the labels to be used |
| 620 | 620 | */ |
| 621 | - private function create_post_type_labels ( $singular, $plural, $menu ) { |
|
| 621 | + private function create_post_type_labels($singular, $plural, $menu) { |
|
| 622 | 622 | |
| 623 | - $lower_case_plural = function_exists( 'mb_strtolower' ) ? mb_strtolower( $plural, 'UTF-8') : strtolower( $plural ); |
|
| 623 | + $lower_case_plural = function_exists('mb_strtolower') ? mb_strtolower($plural, 'UTF-8') : strtolower($plural); |
|
| 624 | 624 | |
| 625 | 625 | $labels = array( |
| 626 | - 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ), |
|
| 627 | - 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ), |
|
| 628 | - 'add_new' => __( 'Add New', 'woothemes-sensei' ), |
|
| 629 | - 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ), |
|
| 630 | - 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ), |
|
| 631 | - 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ), |
|
| 632 | - 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ), |
|
| 633 | - 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ), |
|
| 634 | - 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ), |
|
| 635 | - 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), $lower_case_plural ) , |
|
| 636 | - 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), $lower_case_plural ), |
|
| 626 | + 'name' => sprintf(_x('%s', 'post type general name', 'woothemes-sensei'), $plural), |
|
| 627 | + 'singular_name' => sprintf(_x('%s', 'post type singular name', 'woothemes-sensei'), $singular), |
|
| 628 | + 'add_new' => __('Add New', 'woothemes-sensei'), |
|
| 629 | + 'add_new_item' => sprintf(__('Add New %s', 'woothemes-sensei'), $singular), |
|
| 630 | + 'edit_item' => sprintf(__('Edit %s', 'woothemes-sensei'), $singular), |
|
| 631 | + 'new_item' => sprintf(__('New %s', 'woothemes-sensei'), $singular), |
|
| 632 | + 'all_items' => sprintf(__('All %s', 'woothemes-sensei'), $plural), |
|
| 633 | + 'view_item' => sprintf(__('View %s', 'woothemes-sensei'), $singular), |
|
| 634 | + 'search_items' => sprintf(__('Search %s', 'woothemes-sensei'), $plural), |
|
| 635 | + 'not_found' => sprintf(__('No %s found', 'woothemes-sensei'), $lower_case_plural), |
|
| 636 | + 'not_found_in_trash' => sprintf(__('No %s found in Trash', 'woothemes-sensei'), $lower_case_plural), |
|
| 637 | 637 | 'parent_item_colon' => '', |
| 638 | - 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu ) |
|
| 638 | + 'menu_name' => sprintf(__('%s', 'woothemes-sensei'), $menu) |
|
| 639 | 639 | ); |
| 640 | 640 | |
| 641 | 641 | return $labels; |
@@ -647,14 +647,14 @@ discard block |
||
| 647 | 647 | * @param array $messages The existing array of messages for post types. |
| 648 | 648 | * @return array The modified array of messages for post types. |
| 649 | 649 | */ |
| 650 | - public function setup_post_type_messages ( $messages ) { |
|
| 650 | + public function setup_post_type_messages($messages) { |
|
| 651 | 651 | global $post, $post_ID; |
| 652 | 652 | |
| 653 | - $messages['course'] = $this->create_post_type_messages( 'course' ); |
|
| 654 | - $messages['lesson'] = $this->create_post_type_messages( 'lesson' ); |
|
| 655 | - $messages['quiz'] = $this->create_post_type_messages( 'quiz' ); |
|
| 656 | - $messages['question'] = $this->create_post_type_messages( 'question' ); |
|
| 657 | - $messages['multiple_question'] = $this->create_post_type_messages( 'multiple_question' ); |
|
| 653 | + $messages['course'] = $this->create_post_type_messages('course'); |
|
| 654 | + $messages['lesson'] = $this->create_post_type_messages('lesson'); |
|
| 655 | + $messages['quiz'] = $this->create_post_type_messages('quiz'); |
|
| 656 | + $messages['question'] = $this->create_post_type_messages('question'); |
|
| 657 | + $messages['multiple_question'] = $this->create_post_type_messages('multiple_question'); |
|
| 658 | 658 | |
| 659 | 659 | return $messages; |
| 660 | 660 | } // End setup_post_type_messages() |
@@ -665,23 +665,23 @@ discard block |
||
| 665 | 665 | * @param string $post_type The post type for which to create messages. |
| 666 | 666 | * @return array An array of messages (empty array if the post type isn't one we're looking to work with). |
| 667 | 667 | */ |
| 668 | - private function create_post_type_messages ( $post_type ) { |
|
| 668 | + private function create_post_type_messages($post_type) { |
|
| 669 | 669 | global $post, $post_ID; |
| 670 | 670 | |
| 671 | - if ( ! isset( $this->labels[$post_type] ) ) { return array(); } |
|
| 671 | + if ( ! isset($this->labels[$post_type])) { return array(); } |
|
| 672 | 672 | |
| 673 | 673 | $messages = array( |
| 674 | 674 | 0 => '', |
| 675 | - 1 => sprintf( __( '%1$s updated. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ), |
|
| 676 | - 2 => __( 'Custom field updated.' , 'woothemes-sensei' ), |
|
| 677 | - 3 => __( 'Custom field deleted.' , 'woothemes-sensei' ), |
|
| 678 | - 4 => sprintf( __( '%1$s updated.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ), |
|
| 679 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 680 | - 6 => sprintf( __( '%1$s published. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ), |
|
| 681 | - 7 => sprintf( __( '%1$s saved.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ), |
|
| 682 | - 8 => sprintf( __( '%1$s submitted. %2$sPreview %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', '</a>' ), |
|
| 683 | - 9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<strong>' . date_i18n( __( 'M j, Y @ G:i' , 'woothemes-sensei' ), strtotime( $post->post_date ) ) . '</strong>', '<a target="_blank" href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ), |
|
| 684 | - 10 => sprintf( __( '%1$s draft updated. %2$sPreview %3$s%4$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ), |
|
| 675 | + 1 => sprintf(__('%1$s updated. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'), |
|
| 676 | + 2 => __('Custom field updated.', 'woothemes-sensei'), |
|
| 677 | + 3 => __('Custom field deleted.', 'woothemes-sensei'), |
|
| 678 | + 4 => sprintf(__('%1$s updated.', 'woothemes-sensei'), $this->labels[$post_type]['singular']), |
|
| 679 | + 5 => isset($_GET['revision']) ? sprintf(__('%1$s restored to revision from %2$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 680 | + 6 => sprintf(__('%1$s published. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'), |
|
| 681 | + 7 => sprintf(__('%1$s saved.', 'woothemes-sensei'), $this->labels[$post_type]['singular']), |
|
| 682 | + 8 => sprintf(__('%1$s submitted. %2$sPreview %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', '</a>'), |
|
| 683 | + 9 => sprintf(__('%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<strong>'.date_i18n(__('M j, Y @ G:i', 'woothemes-sensei'), strtotime($post->post_date)).'</strong>', '<a target="_blank" href="'.esc_url(get_permalink($post_ID)).'">', $this->labels[$post_type]['singular'], '</a>'), |
|
| 684 | + 10 => sprintf(__('%1$s draft updated. %2$sPreview %3$s%4$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', $this->labels[$post_type]['singular'], '</a>'), |
|
| 685 | 685 | ); |
| 686 | 686 | |
| 687 | 687 | return $messages; |
@@ -694,11 +694,11 @@ discard block |
||
| 694 | 694 | * @param string $title |
| 695 | 695 | * @return string $title |
| 696 | 696 | */ |
| 697 | - public function enter_title_here ( $title ) { |
|
| 698 | - if ( get_post_type() == 'course' ) { |
|
| 699 | - $title = __( 'Enter a title for this course here', 'woothemes-sensei' ); |
|
| 700 | - } elseif ( get_post_type() == 'lesson' ) { |
|
| 701 | - $title = __( 'Enter a title for this lesson here', 'woothemes-sensei' ); |
|
| 697 | + public function enter_title_here($title) { |
|
| 698 | + if (get_post_type() == 'course') { |
|
| 699 | + $title = __('Enter a title for this course here', 'woothemes-sensei'); |
|
| 700 | + } elseif (get_post_type() == 'lesson') { |
|
| 701 | + $title = __('Enter a title for this lesson here', 'woothemes-sensei'); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return $title; |
@@ -712,60 +712,60 @@ discard block |
||
| 712 | 712 | * @param array $post_types |
| 713 | 713 | * @return void |
| 714 | 714 | */ |
| 715 | - public function set_role_cap_defaults( $post_types = array() ) { |
|
| 715 | + public function set_role_cap_defaults($post_types = array()) { |
|
| 716 | 716 | |
| 717 | - foreach ( $post_types as $post_type_item => $post_type_name ) { |
|
| 717 | + foreach ($post_types as $post_type_item => $post_type_name) { |
|
| 718 | 718 | // Super Admin |
| 719 | - $this->role_caps[] = array( 'administrator' => array( 'edit_' . $post_type_item, |
|
| 720 | - 'read_' . $post_type_item, |
|
| 721 | - 'delete_' . $post_type_item, |
|
| 722 | - 'create_' . $post_type_item . 's', |
|
| 723 | - 'edit_' . $post_type_item . 's', |
|
| 724 | - 'edit_others_' . $post_type_item . 's', |
|
| 725 | - 'publish_' . $post_type_item . 's', |
|
| 726 | - 'read_private_' . $post_type_item . 's', |
|
| 719 | + $this->role_caps[] = array('administrator' => array('edit_'.$post_type_item, |
|
| 720 | + 'read_'.$post_type_item, |
|
| 721 | + 'delete_'.$post_type_item, |
|
| 722 | + 'create_'.$post_type_item.'s', |
|
| 723 | + 'edit_'.$post_type_item.'s', |
|
| 724 | + 'edit_others_'.$post_type_item.'s', |
|
| 725 | + 'publish_'.$post_type_item.'s', |
|
| 726 | + 'read_private_'.$post_type_item.'s', |
|
| 727 | 727 | 'read', |
| 728 | - 'delete_' . $post_type_item . 's', |
|
| 729 | - 'delete_private_' . $post_type_item . 's', |
|
| 730 | - 'delete_published_' . $post_type_item . 's', |
|
| 731 | - 'delete_others_' . $post_type_item . 's', |
|
| 732 | - 'edit_private_' . $post_type_item . 's', |
|
| 733 | - 'edit_published_' . $post_type_item . 's', |
|
| 728 | + 'delete_'.$post_type_item.'s', |
|
| 729 | + 'delete_private_'.$post_type_item.'s', |
|
| 730 | + 'delete_published_'.$post_type_item.'s', |
|
| 731 | + 'delete_others_'.$post_type_item.'s', |
|
| 732 | + 'edit_private_'.$post_type_item.'s', |
|
| 733 | + 'edit_published_'.$post_type_item.'s', |
|
| 734 | 734 | 'manage_sensei', |
| 735 | - 'manage_sensei_grades' ), |
|
| 736 | - 'editor' => array( 'edit_' . $post_type_item, |
|
| 737 | - 'read_' . $post_type_item, |
|
| 738 | - 'delete_' . $post_type_item, |
|
| 739 | - 'create_' . $post_type_item . 's', |
|
| 740 | - 'edit_' . $post_type_item . 's', |
|
| 741 | - 'edit_others_' . $post_type_item . 's', |
|
| 742 | - 'publish_' . $post_type_item . 's', |
|
| 743 | - 'read_private_' . $post_type_item . 's', |
|
| 735 | + 'manage_sensei_grades'), |
|
| 736 | + 'editor' => array('edit_'.$post_type_item, |
|
| 737 | + 'read_'.$post_type_item, |
|
| 738 | + 'delete_'.$post_type_item, |
|
| 739 | + 'create_'.$post_type_item.'s', |
|
| 740 | + 'edit_'.$post_type_item.'s', |
|
| 741 | + 'edit_others_'.$post_type_item.'s', |
|
| 742 | + 'publish_'.$post_type_item.'s', |
|
| 743 | + 'read_private_'.$post_type_item.'s', |
|
| 744 | 744 | 'read', |
| 745 | - 'delete_' . $post_type_item . 's', |
|
| 746 | - 'delete_private_' . $post_type_item . 's', |
|
| 747 | - 'delete_published_' . $post_type_item . 's', |
|
| 748 | - 'delete_others_' . $post_type_item . 's', |
|
| 749 | - 'edit_private_' . $post_type_item . 's', |
|
| 750 | - 'edit_published_' . $post_type_item . 's' ), |
|
| 751 | - 'author' => array( 'edit_' . $post_type_item, |
|
| 752 | - 'read_' . $post_type_item, |
|
| 753 | - 'delete_' . $post_type_item, |
|
| 754 | - 'create_' . $post_type_item . 's', |
|
| 755 | - 'edit_' . $post_type_item . 's', |
|
| 756 | - 'publish_' . $post_type_item . 's', |
|
| 745 | + 'delete_'.$post_type_item.'s', |
|
| 746 | + 'delete_private_'.$post_type_item.'s', |
|
| 747 | + 'delete_published_'.$post_type_item.'s', |
|
| 748 | + 'delete_others_'.$post_type_item.'s', |
|
| 749 | + 'edit_private_'.$post_type_item.'s', |
|
| 750 | + 'edit_published_'.$post_type_item.'s'), |
|
| 751 | + 'author' => array('edit_'.$post_type_item, |
|
| 752 | + 'read_'.$post_type_item, |
|
| 753 | + 'delete_'.$post_type_item, |
|
| 754 | + 'create_'.$post_type_item.'s', |
|
| 755 | + 'edit_'.$post_type_item.'s', |
|
| 756 | + 'publish_'.$post_type_item.'s', |
|
| 757 | 757 | 'read', |
| 758 | - 'delete_' . $post_type_item . 's', |
|
| 759 | - 'delete_published_' . $post_type_item . 's', |
|
| 760 | - 'edit_published_' . $post_type_item . 's' ), |
|
| 761 | - 'contributor' => array( 'edit_' . $post_type_item, |
|
| 762 | - 'read_' . $post_type_item, |
|
| 763 | - 'delete_' . $post_type_item, |
|
| 764 | - 'create_' . $post_type_item . 's', |
|
| 765 | - 'edit_' . $post_type_item . 's', |
|
| 758 | + 'delete_'.$post_type_item.'s', |
|
| 759 | + 'delete_published_'.$post_type_item.'s', |
|
| 760 | + 'edit_published_'.$post_type_item.'s'), |
|
| 761 | + 'contributor' => array('edit_'.$post_type_item, |
|
| 762 | + 'read_'.$post_type_item, |
|
| 763 | + 'delete_'.$post_type_item, |
|
| 764 | + 'create_'.$post_type_item.'s', |
|
| 765 | + 'edit_'.$post_type_item.'s', |
|
| 766 | 766 | 'read', |
| 767 | - 'delete_' . $post_type_item . 's' ), |
|
| 768 | - 'subscriber' => array( 'read' ) |
|
| 767 | + 'delete_'.$post_type_item.'s'), |
|
| 768 | + 'subscriber' => array('read') |
|
| 769 | 769 | |
| 770 | 770 | ); |
| 771 | 771 | } // End For Loop |
@@ -779,16 +779,16 @@ discard block |
||
| 779 | 779 | * @param WP_Admin_Bar $bar |
| 780 | 780 | * @return void |
| 781 | 781 | */ |
| 782 | - public function quiz_admin_bar_menu( $bar ) { |
|
| 783 | - if ( is_single() && 'quiz' == get_queried_object()->post_type ) { |
|
| 784 | - $lesson_id = get_post_meta( get_queried_object()->ID, '_quiz_lesson', true ); |
|
| 785 | - if ( $lesson_id ) { |
|
| 782 | + public function quiz_admin_bar_menu($bar) { |
|
| 783 | + if (is_single() && 'quiz' == get_queried_object()->post_type) { |
|
| 784 | + $lesson_id = get_post_meta(get_queried_object()->ID, '_quiz_lesson', true); |
|
| 785 | + if ($lesson_id) { |
|
| 786 | 786 | $object_type = get_post_type_object('quiz'); |
| 787 | - $bar->add_menu( array( |
|
| 787 | + $bar->add_menu(array( |
|
| 788 | 788 | 'id' => 'edit', |
| 789 | 789 | 'title' => $object_type->labels->edit_item, |
| 790 | - 'href' => get_edit_post_link( $lesson_id ), |
|
| 791 | - ) ); |
|
| 790 | + 'href' => get_edit_post_link($lesson_id), |
|
| 791 | + )); |
|
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | } |
@@ -800,4 +800,4 @@ discard block |
||
| 800 | 800 | * @ignore only for backward compatibility |
| 801 | 801 | * @since 1.9.0 |
| 802 | 802 | */ |
| 803 | -class WooThemes_Sensei_PostTypes extends Sensei_PostTypes{} |
|
| 803 | +class WooThemes_Sensei_PostTypes extends Sensei_PostTypes {} |
|
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Grading Class |
@@ -23,30 +23,30 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param $file |
| 25 | 25 | */ |
| 26 | - public function __construct ( $file ) { |
|
| 27 | - $this->name = __( 'Grading', 'woothemes-sensei' ); |
|
| 26 | + public function __construct($file) { |
|
| 27 | + $this->name = __('Grading', 'woothemes-sensei'); |
|
| 28 | 28 | $this->file = $file; |
| 29 | 29 | $this->page_slug = 'sensei_grading'; |
| 30 | 30 | |
| 31 | 31 | // Admin functions |
| 32 | - if ( is_admin() ) { |
|
| 33 | - add_action( 'admin_menu', array( $this, 'grading_admin_menu' ), 20); |
|
| 34 | - add_action( 'grading_wrapper_container', array( $this, 'wrapper_container' ) ); |
|
| 35 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 36 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 37 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 32 | + if (is_admin()) { |
|
| 33 | + add_action('admin_menu', array($this, 'grading_admin_menu'), 20); |
|
| 34 | + add_action('grading_wrapper_container', array($this, 'wrapper_container')); |
|
| 35 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 36 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 37 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - add_action( 'admin_init', array( $this, 'admin_process_grading_submission' ) ); |
|
| 40 | + add_action('admin_init', array($this, 'admin_process_grading_submission')); |
|
| 41 | 41 | |
| 42 | - add_action( 'admin_notices', array( $this, 'add_grading_notices' ) ); |
|
| 42 | + add_action('admin_notices', array($this, 'add_grading_notices')); |
|
| 43 | 43 | // add_action( 'sensei_grading_notices', array( $this, 'sensei_grading_notices' ) ); |
| 44 | 44 | } // End If Statement |
| 45 | 45 | |
| 46 | 46 | // Ajax functions |
| 47 | - if ( is_admin() ) { |
|
| 48 | - add_action( 'wp_ajax_get_lessons_dropdown', array( $this, 'get_lessons_dropdown' ) ); |
|
| 49 | - add_action( 'wp_ajax_get_redirect_url', array( $this, 'get_redirect_url' ) ); |
|
| 47 | + if (is_admin()) { |
|
| 48 | + add_action('wp_ajax_get_lessons_dropdown', array($this, 'get_lessons_dropdown')); |
|
| 49 | + add_action('wp_ajax_get_redirect_url', array($this, 'get_redirect_url')); |
|
| 50 | 50 | } // End If Statement |
| 51 | 51 | } // End __construct() |
| 52 | 52 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | public function grading_admin_menu() { |
| 60 | 60 | global $menu; |
| 61 | 61 | |
| 62 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 63 | - $grading_page = add_submenu_page('sensei', __('Grading', 'woothemes-sensei'), __('Grading', 'woothemes-sensei') , 'manage_sensei_grades', $this->page_slug, array( $this, 'grading_page' ) ); |
|
| 62 | + if (current_user_can('manage_sensei_grades')) { |
|
| 63 | + $grading_page = add_submenu_page('sensei', __('Grading', 'woothemes-sensei'), __('Grading', 'woothemes-sensei'), 'manage_sensei_grades', $this->page_slug, array($this, 'grading_page')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | } // End grading_admin_menu() |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * @since 1.3.0 |
| 74 | 74 | * @return void |
| 75 | 75 | */ |
| 76 | - public function enqueue_scripts () { |
|
| 76 | + public function enqueue_scripts() { |
|
| 77 | 77 | |
| 78 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 78 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 79 | 79 | |
| 80 | 80 | // Load Grading JS |
| 81 | - wp_enqueue_script( 'sensei-grading-general', Sensei()->plugin_url . 'assets/js/grading-general' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
| 81 | + wp_enqueue_script('sensei-grading-general', Sensei()->plugin_url.'assets/js/grading-general'.$suffix.'.js', array('jquery'), Sensei()->version); |
|
| 82 | 82 | |
| 83 | 83 | } // End enqueue_scripts() |
| 84 | 84 | |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | * @since 1.0.0 |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | - public function enqueue_styles () { |
|
| 93 | + public function enqueue_styles() { |
|
| 94 | 94 | |
| 95 | - wp_enqueue_style( Sensei()->token . '-admin' ); |
|
| 95 | + wp_enqueue_style(Sensei()->token.'-admin'); |
|
| 96 | 96 | |
| 97 | - wp_enqueue_style( 'woothemes-sensei-settings-api', Sensei()->plugin_url . 'assets/css/settings.css', '', Sensei()->version ); |
|
| 97 | + wp_enqueue_style('woothemes-sensei-settings-api', Sensei()->plugin_url.'assets/css/settings.css', '', Sensei()->version); |
|
| 98 | 98 | |
| 99 | 99 | } // End enqueue_styles() |
| 100 | 100 | |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | public function load_data_table_files() { |
| 107 | 107 | |
| 108 | 108 | // Load Grading Classes |
| 109 | - $classes_to_load = array( 'list-table', |
|
| 109 | + $classes_to_load = array('list-table', |
|
| 110 | 110 | 'grading-main', |
| 111 | 111 | 'grading-user-quiz' |
| 112 | 112 | ); |
| 113 | - foreach ( $classes_to_load as $class_file ) { |
|
| 114 | - Sensei()->load_class( $class_file ); |
|
| 113 | + foreach ($classes_to_load as $class_file) { |
|
| 114 | + Sensei()->load_class($class_file); |
|
| 115 | 115 | } // End For Loop |
| 116 | 116 | } // End load_data_table_files() |
| 117 | 117 | |
@@ -123,16 +123,16 @@ discard block |
||
| 123 | 123 | * @param undefined $optional_data optional constructor arguments |
| 124 | 124 | * @return object class instance object |
| 125 | 125 | */ |
| 126 | - public function load_data_object( $name = '', $data = 0, $optional_data = null ) { |
|
| 126 | + public function load_data_object($name = '', $data = 0, $optional_data = null) { |
|
| 127 | 127 | // Load Analysis data |
| 128 | - $object_name = 'WooThemes_Sensei_Grading_' . $name; |
|
| 129 | - if ( is_null($optional_data) ) { |
|
| 130 | - $sensei_grading_object = new $object_name( $data ); |
|
| 128 | + $object_name = 'WooThemes_Sensei_Grading_'.$name; |
|
| 129 | + if (is_null($optional_data)) { |
|
| 130 | + $sensei_grading_object = new $object_name($data); |
|
| 131 | 131 | } |
| 132 | 132 | else { |
| 133 | - $sensei_grading_object = new $object_name( $data, $optional_data ); |
|
| 133 | + $sensei_grading_object = new $object_name($data, $optional_data); |
|
| 134 | 134 | } // End If Statement |
| 135 | - if ( 'Main' == $name ) { |
|
| 135 | + if ('Main' == $name) { |
|
| 136 | 136 | $sensei_grading_object->prepare_items(); |
| 137 | 137 | } // End If Statement |
| 138 | 138 | return $sensei_grading_object; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function grading_page() { |
| 148 | 148 | |
| 149 | - if ( isset( $_GET['quiz_id'] ) && 0 < intval( $_GET['quiz_id'] ) && isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) { |
|
| 149 | + if (isset($_GET['quiz_id']) && 0 < intval($_GET['quiz_id']) && isset($_GET['user']) && 0 < intval($_GET['user'])) { |
|
| 150 | 150 | $this->grading_user_quiz_view(); |
| 151 | 151 | } |
| 152 | 152 | else { |
@@ -162,23 +162,23 @@ discard block |
||
| 162 | 162 | public function grading_default_view() { |
| 163 | 163 | |
| 164 | 164 | // Load Grading data |
| 165 | - if( !empty( $_GET['course_id'] ) ) { |
|
| 166 | - $course_id = intval( $_GET['course_id'] ); |
|
| 165 | + if ( ! empty($_GET['course_id'])) { |
|
| 166 | + $course_id = intval($_GET['course_id']); |
|
| 167 | 167 | } |
| 168 | - if( !empty( $_GET['lesson_id'] ) ) { |
|
| 169 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 168 | + if ( ! empty($_GET['lesson_id'])) { |
|
| 169 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 170 | 170 | } |
| 171 | - if( !empty( $_GET['user_id'] ) ) { |
|
| 172 | - $user_id = intval( $_GET['user_id'] ); |
|
| 171 | + if ( ! empty($_GET['user_id'])) { |
|
| 172 | + $user_id = intval($_GET['user_id']); |
|
| 173 | 173 | } |
| 174 | - if( !empty( $_GET['view'] ) ) { |
|
| 175 | - $view = esc_html( $_GET['view'] ); |
|
| 174 | + if ( ! empty($_GET['view'])) { |
|
| 175 | + $view = esc_html($_GET['view']); |
|
| 176 | 176 | } |
| 177 | - $sensei_grading_overview = $this->load_data_object( 'Main', compact( 'course_id', 'lesson_id', 'user_id', 'view' ) ); |
|
| 177 | + $sensei_grading_overview = $this->load_data_object('Main', compact('course_id', 'lesson_id', 'user_id', 'view')); |
|
| 178 | 178 | |
| 179 | 179 | // Wrappers |
| 180 | - do_action( 'grading_before_container' ); |
|
| 181 | - do_action( 'grading_wrapper_container', 'top' ); |
|
| 180 | + do_action('grading_before_container'); |
|
| 181 | + do_action('grading_wrapper_container', 'top'); |
|
| 182 | 182 | $this->grading_headers(); |
| 183 | 183 | ?> |
| 184 | 184 | <div id="poststuff" class="sensei-grading-wrap"> |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | <?php $sensei_grading_overview->display(); ?> |
| 187 | 187 | </div> |
| 188 | 188 | <div class="sensei-grading-extra"> |
| 189 | - <?php do_action( 'sensei_grading_extra' ); ?> |
|
| 189 | + <?php do_action('sensei_grading_extra'); ?> |
|
| 190 | 190 | </div> |
| 191 | 191 | </div> |
| 192 | 192 | <?php |
| 193 | - do_action( 'grading_wrapper_container', 'bottom' ); |
|
| 194 | - do_action( 'grading_after_container' ); |
|
| 193 | + do_action('grading_wrapper_container', 'bottom'); |
|
| 194 | + do_action('grading_after_container'); |
|
| 195 | 195 | } // End grading_default_view() |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -204,17 +204,17 @@ discard block |
||
| 204 | 204 | // Load Grading data |
| 205 | 205 | $user_id = 0; |
| 206 | 206 | $quiz_id = 0; |
| 207 | - if( isset( $_GET['user'] ) ) { |
|
| 208 | - $user_id = intval( $_GET['user'] ); |
|
| 207 | + if (isset($_GET['user'])) { |
|
| 208 | + $user_id = intval($_GET['user']); |
|
| 209 | 209 | } |
| 210 | - if( isset( $_GET['quiz_id'] ) ) { |
|
| 211 | - $quiz_id = intval( $_GET['quiz_id'] ); |
|
| 210 | + if (isset($_GET['quiz_id'])) { |
|
| 211 | + $quiz_id = intval($_GET['quiz_id']); |
|
| 212 | 212 | } |
| 213 | - $sensei_grading_user_profile = $this->load_data_object( 'User_Quiz', $user_id, $quiz_id ); |
|
| 213 | + $sensei_grading_user_profile = $this->load_data_object('User_Quiz', $user_id, $quiz_id); |
|
| 214 | 214 | // Wrappers |
| 215 | - do_action( 'grading_before_container' ); |
|
| 216 | - do_action( 'grading_wrapper_container', 'top' ); |
|
| 217 | - $this->grading_headers( array( 'nav' => 'user_quiz' ) ); |
|
| 215 | + do_action('grading_before_container'); |
|
| 216 | + do_action('grading_wrapper_container', 'top'); |
|
| 217 | + $this->grading_headers(array('nav' => 'user_quiz')); |
|
| 218 | 218 | ?> |
| 219 | 219 | <div id="poststuff" class="sensei-grading-wrap user-profile"> |
| 220 | 220 | <div class="sensei-grading-main"> |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | </div> |
| 224 | 224 | </div> |
| 225 | 225 | <?php |
| 226 | - do_action( 'grading_wrapper_container', 'bottom' ); |
|
| 227 | - do_action( 'grading_after_container' ); |
|
| 226 | + do_action('grading_wrapper_container', 'bottom'); |
|
| 227 | + do_action('grading_after_container'); |
|
| 228 | 228 | } // End grading_user_quiz_view() |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | * @param array $args |
| 234 | 234 | * @return void |
| 235 | 235 | */ |
| 236 | - public function grading_headers( $args = array( 'nav' => 'default' ) ) { |
|
| 236 | + public function grading_headers($args = array('nav' => 'default')) { |
|
| 237 | 237 | |
| 238 | - $function = 'grading_' . $args['nav'] . '_nav'; |
|
| 238 | + $function = 'grading_'.$args['nav'].'_nav'; |
|
| 239 | 239 | $this->$function(); |
| 240 | 240 | ?> |
| 241 | - <p class="powered-by-woo"><?php _e( 'Powered by', 'woothemes-sensei' ); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p> |
|
| 241 | + <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p> |
|
| 242 | 242 | <?php |
| 243 | - do_action( 'sensei_grading_after_headers' ); |
|
| 243 | + do_action('sensei_grading_after_headers'); |
|
| 244 | 244 | } // End grading_headers() |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | * @param $which string |
| 250 | 250 | * @return void |
| 251 | 251 | */ |
| 252 | - public function wrapper_container( $which ) { |
|
| 253 | - if ( 'top' == $which ) { |
|
| 252 | + public function wrapper_container($which) { |
|
| 253 | + if ('top' == $which) { |
|
| 254 | 254 | ?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php |
| 255 | - } elseif ( 'bottom' == $which ) { |
|
| 255 | + } elseif ('bottom' == $which) { |
|
| 256 | 256 | ?></div><!--/#woothemes-sensei--><?php |
| 257 | 257 | } // End If Statement |
| 258 | 258 | } // End wrapper_container() |
@@ -265,29 +265,29 @@ discard block |
||
| 265 | 265 | public function grading_default_nav() { |
| 266 | 266 | global $wp_version; |
| 267 | 267 | |
| 268 | - $title = sprintf( '<a href="%s">%s</a>', esc_url(add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ) ), esc_html( $this->name ) ); |
|
| 269 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 270 | - $course_id = intval( $_GET['course_id'] ); |
|
| 271 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
| 272 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 273 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 268 | + $title = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('page' => $this->page_slug), admin_url('admin.php'))), esc_html($this->name)); |
|
| 269 | + if (isset($_GET['course_id'])) { |
|
| 270 | + $course_id = intval($_GET['course_id']); |
|
| 271 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
| 272 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 273 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 274 | 274 | } |
| 275 | 275 | else { |
| 276 | - $title .= sprintf( ' <span class="course-title">> %s</span>', get_the_title( $course_id ) ); |
|
| 276 | + $title .= sprintf(' <span class="course-title">> %s</span>', get_the_title($course_id)); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | - if ( isset( $_GET['lesson_id'] ) ) { |
|
| 280 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
| 281 | - $title .= ' <span class="lesson-title">> ' . get_the_title( intval( $lesson_id ) ) . '</span>'; |
|
| 279 | + if (isset($_GET['lesson_id'])) { |
|
| 280 | + $lesson_id = intval($_GET['lesson_id']); |
|
| 281 | + $title .= ' <span class="lesson-title">> '.get_the_title(intval($lesson_id)).'</span>'; |
|
| 282 | 282 | } |
| 283 | - if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) { |
|
| 283 | + if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) { |
|
| 284 | 284 | |
| 285 | - $user_name = Sensei_Learner::get_full_name( $_GET['user_id'] ); |
|
| 286 | - $title .= ' <span class="user-title">> ' . $user_name . '</span>'; |
|
| 285 | + $user_name = Sensei_Learner::get_full_name($_GET['user_id']); |
|
| 286 | + $title .= ' <span class="user-title">> '.$user_name.'</span>'; |
|
| 287 | 287 | |
| 288 | 288 | } // End If Statement |
| 289 | 289 | ?> |
| 290 | - <h2><?php echo apply_filters( 'sensei_grading_nav_title', $title ); ?></h2> |
|
| 290 | + <h2><?php echo apply_filters('sensei_grading_nav_title', $title); ?></h2> |
|
| 291 | 291 | <?php |
| 292 | 292 | } // End grading_default_nav() |
| 293 | 293 | |
@@ -299,29 +299,29 @@ discard block |
||
| 299 | 299 | public function grading_user_quiz_nav() { |
| 300 | 300 | global $wp_version; |
| 301 | 301 | |
| 302 | - $title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) ); |
|
| 303 | - if ( isset( $_GET['quiz_id'] ) ) { |
|
| 304 | - $quiz_id = intval( $_GET['quiz_id'] ); |
|
| 305 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 306 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 307 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
| 308 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 309 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
| 302 | + $title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name)); |
|
| 303 | + if (isset($_GET['quiz_id'])) { |
|
| 304 | + $quiz_id = intval($_GET['quiz_id']); |
|
| 305 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 306 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 307 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
| 308 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 309 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
| 310 | 310 | } |
| 311 | 311 | else { |
| 312 | - $title .= sprintf( ' <span class="course-title">> %s</span>', get_the_title( $course_id ) ); |
|
| 312 | + $title .= sprintf(' <span class="course-title">> %s</span>', get_the_title($course_id)); |
|
| 313 | 313 | } |
| 314 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id ), admin_url( 'admin.php' ) ); |
|
| 315 | - $title .= sprintf( ' <span class="lesson-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $lesson_id ) ); |
|
| 314 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id), admin_url('admin.php')); |
|
| 315 | + $title .= sprintf(' <span class="lesson-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($lesson_id)); |
|
| 316 | 316 | } |
| 317 | - if ( isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) { |
|
| 317 | + if (isset($_GET['user']) && 0 < intval($_GET['user'])) { |
|
| 318 | 318 | |
| 319 | - $user_name = Sensei_Learner::get_full_name( $_GET['user'] ); |
|
| 320 | - $title .= ' <span class="user-title">> ' . $user_name . '</span>'; |
|
| 319 | + $user_name = Sensei_Learner::get_full_name($_GET['user']); |
|
| 320 | + $title .= ' <span class="user-title">> '.$user_name.'</span>'; |
|
| 321 | 321 | |
| 322 | 322 | } // End If Statement |
| 323 | 323 | ?> |
| 324 | - <h2><?php echo apply_filters( 'sensei_grading_nav_title', $title ); ?></h2> |
|
| 324 | + <h2><?php echo apply_filters('sensei_grading_nav_title', $title); ?></h2> |
|
| 325 | 325 | <?php |
| 326 | 326 | } // End grading_user_quiz_nav() |
| 327 | 327 | |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | * @since 1.7.0 |
| 331 | 331 | * @return array |
| 332 | 332 | */ |
| 333 | - public function get_stati( $type ) { |
|
| 333 | + public function get_stati($type) { |
|
| 334 | 334 | $statuses = array(); |
| 335 | - switch( $type ) { |
|
| 335 | + switch ($type) { |
|
| 336 | 336 | case 'course' : |
| 337 | 337 | $statuses = array( |
| 338 | 338 | 'in-progress', |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @param array $args (default: array()) |
| 363 | 363 | * @return object |
| 364 | 364 | */ |
| 365 | - public function count_statuses( $args = array() ) { |
|
| 365 | + public function count_statuses($args = array()) { |
|
| 366 | 366 | global $wpdb; |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -373,71 +373,71 @@ discard block |
||
| 373 | 373 | * @since 1.8.0 |
| 374 | 374 | * @param array $args |
| 375 | 375 | */ |
| 376 | - $args = apply_filters( 'sensei_count_statuses_args', $args ); |
|
| 376 | + $args = apply_filters('sensei_count_statuses_args', $args); |
|
| 377 | 377 | |
| 378 | - if ( 'course' == $args['type'] ) { |
|
| 378 | + if ('course' == $args['type']) { |
|
| 379 | 379 | $type = 'sensei_course_status'; |
| 380 | 380 | } |
| 381 | 381 | else { |
| 382 | 382 | $type = 'sensei_lesson_status'; |
| 383 | 383 | } |
| 384 | - $cache_key = 'sensei-' . $args['type'] . '-statuses'; |
|
| 384 | + $cache_key = 'sensei-'.$args['type'].'-statuses'; |
|
| 385 | 385 | |
| 386 | 386 | $query = "SELECT comment_approved, COUNT( * ) AS total FROM {$wpdb->comments} WHERE comment_type = %s "; |
| 387 | 387 | |
| 388 | 388 | // Restrict to specific posts |
| 389 | - if ( isset( $args['post__in'] ) && !empty( $args['post__in'] ) && is_array( $args['post__in'] ) ) { |
|
| 390 | - $query .= ' AND comment_post_ID IN (' . implode( ',', array_map( 'absint', $args['post__in'] ) ) . ')'; |
|
| 389 | + if (isset($args['post__in']) && ! empty($args['post__in']) && is_array($args['post__in'])) { |
|
| 390 | + $query .= ' AND comment_post_ID IN ('.implode(',', array_map('absint', $args['post__in'])).')'; |
|
| 391 | 391 | } |
| 392 | - elseif ( !empty( $args['post_id'] ) ) { |
|
| 393 | - $query .= $wpdb->prepare( ' AND comment_post_ID = %d', $args['post_id'] ); |
|
| 392 | + elseif ( ! empty($args['post_id'])) { |
|
| 393 | + $query .= $wpdb->prepare(' AND comment_post_ID = %d', $args['post_id']); |
|
| 394 | 394 | } |
| 395 | 395 | // Restrict to specific users |
| 396 | - if ( isset( $args['user_id'] ) && is_array( $args['user_id'] ) ) { |
|
| 397 | - $query .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $args['user_id'] ) ) . ')'; |
|
| 396 | + if (isset($args['user_id']) && is_array($args['user_id'])) { |
|
| 397 | + $query .= ' AND user_id IN ('.implode(',', array_map('absint', $args['user_id'])).')'; |
|
| 398 | 398 | } |
| 399 | - elseif ( !empty( $args['user_id'] ) ) { |
|
| 400 | - $query .= $wpdb->prepare( ' AND user_id = %d', $args['user_id'] ); |
|
| 399 | + elseif ( ! empty($args['user_id'])) { |
|
| 400 | + $query .= $wpdb->prepare(' AND user_id = %d', $args['user_id']); |
|
| 401 | 401 | } |
| 402 | 402 | $query .= ' GROUP BY comment_approved'; |
| 403 | 403 | |
| 404 | - $counts = wp_cache_get( $cache_key, 'counts' ); |
|
| 405 | - if ( false === $counts ) { |
|
| 406 | - $sql = $wpdb->prepare( $query, $type ); |
|
| 407 | - $results = (array) $wpdb->get_results( $sql, ARRAY_A ); |
|
| 408 | - $counts = array_fill_keys( $this->get_stati( $type ), 0 ); |
|
| 404 | + $counts = wp_cache_get($cache_key, 'counts'); |
|
| 405 | + if (false === $counts) { |
|
| 406 | + $sql = $wpdb->prepare($query, $type); |
|
| 407 | + $results = (array) $wpdb->get_results($sql, ARRAY_A); |
|
| 408 | + $counts = array_fill_keys($this->get_stati($type), 0); |
|
| 409 | 409 | |
| 410 | - foreach ( $results as $row ) { |
|
| 411 | - $counts[ $row['comment_approved'] ] = $row['total']; |
|
| 410 | + foreach ($results as $row) { |
|
| 411 | + $counts[$row['comment_approved']] = $row['total']; |
|
| 412 | 412 | } |
| 413 | - wp_cache_set( $cache_key, $counts, 'counts' ); |
|
| 413 | + wp_cache_set($cache_key, $counts, 'counts'); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if( ! isset( $counts['graded'] ) ) { |
|
| 416 | + if ( ! isset($counts['graded'])) { |
|
| 417 | 417 | $counts['graded'] = 0; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if( ! isset( $counts['ungraded'] ) ) { |
|
| 420 | + if ( ! isset($counts['ungraded'])) { |
|
| 421 | 421 | $counts['ungraded'] = 0; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if( ! isset( $counts['passed'] ) ) { |
|
| 424 | + if ( ! isset($counts['passed'])) { |
|
| 425 | 425 | $counts['passed'] = 0; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if( ! isset( $counts['failed'] ) ) { |
|
| 428 | + if ( ! isset($counts['failed'])) { |
|
| 429 | 429 | $counts['failed'] = 0; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if( ! isset( $counts['in-progress'] ) ) { |
|
| 432 | + if ( ! isset($counts['in-progress'])) { |
|
| 433 | 433 | $counts['in-progress'] = 0; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if( ! isset( $counts['complete'] ) ) { |
|
| 436 | + if ( ! isset($counts['complete'])) { |
|
| 437 | 437 | $counts['complete'] = 0; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - return apply_filters( 'sensei_count_statuses', $counts, $type ); |
|
| 440 | + return apply_filters('sensei_count_statuses', $counts, $type); |
|
| 441 | 441 | } // End sensei_count_statuses() |
| 442 | 442 | |
| 443 | 443 | /** |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | * @since 1.7.0 |
| 446 | 446 | * @return string |
| 447 | 447 | */ |
| 448 | - public function courses_drop_down_html( $selected_course_id = 0 ) { |
|
| 448 | + public function courses_drop_down_html($selected_course_id = 0) { |
|
| 449 | 449 | |
| 450 | 450 | $html = ''; |
| 451 | 451 | |
| 452 | - $course_args = array( 'post_type' => 'course', |
|
| 452 | + $course_args = array('post_type' => 'course', |
|
| 453 | 453 | 'posts_per_page' => -1, |
| 454 | 454 | 'orderby' => 'title', |
| 455 | 455 | 'order' => 'ASC', |
@@ -457,12 +457,12 @@ discard block |
||
| 457 | 457 | 'suppress_filters' => 0, |
| 458 | 458 | 'fields' => 'ids', |
| 459 | 459 | ); |
| 460 | - $courses = get_posts( apply_filters( 'sensei_grading_filter_courses', $course_args ) ); |
|
| 460 | + $courses = get_posts(apply_filters('sensei_grading_filter_courses', $course_args)); |
|
| 461 | 461 | |
| 462 | - $html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>'; |
|
| 463 | - if ( count( $courses ) > 0 ) { |
|
| 464 | - foreach ($courses as $course_id){ |
|
| 465 | - $html .= '<option value="' . esc_attr( absint( $course_id ) ) . '" ' . selected( $course_id, $selected_course_id, false ) . '>' . esc_html( get_the_title( $course_id ) ) . '</option>' . "\n"; |
|
| 462 | + $html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'; |
|
| 463 | + if (count($courses) > 0) { |
|
| 464 | + foreach ($courses as $course_id) { |
|
| 465 | + $html .= '<option value="'.esc_attr(absint($course_id)).'" '.selected($course_id, $selected_course_id, false).'>'.esc_html(get_the_title($course_id)).'</option>'."\n"; |
|
| 466 | 466 | } // End For Loop |
| 467 | 467 | } // End If Statement |
| 468 | 468 | |
@@ -483,20 +483,20 @@ discard block |
||
| 483 | 483 | $course_data = array(); |
| 484 | 484 | parse_str($data, $course_data); |
| 485 | 485 | |
| 486 | - $course_id = intval( $course_data['course_id'] ); |
|
| 486 | + $course_id = intval($course_data['course_id']); |
|
| 487 | 487 | |
| 488 | - $html = $this->lessons_drop_down_html( $course_id ); |
|
| 488 | + $html = $this->lessons_drop_down_html($course_id); |
|
| 489 | 489 | |
| 490 | 490 | echo $html; |
| 491 | 491 | die(); // WordPress may print out a spurious zero without this can be particularly bad if using JSON |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - public function lessons_drop_down_html( $course_id = 0, $selected_lesson_id = 0 ) { |
|
| 494 | + public function lessons_drop_down_html($course_id = 0, $selected_lesson_id = 0) { |
|
| 495 | 495 | |
| 496 | 496 | $html = ''; |
| 497 | - if ( 0 < intval( $course_id ) ) { |
|
| 497 | + if (0 < intval($course_id)) { |
|
| 498 | 498 | |
| 499 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 499 | + $lesson_args = array('post_type' => 'lesson', |
|
| 500 | 500 | 'posts_per_page' => -1, |
| 501 | 501 | 'orderby' => 'title', |
| 502 | 502 | 'order' => 'ASC', |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | 'suppress_filters' => 0, |
| 507 | 507 | 'fields' => 'ids', |
| 508 | 508 | ); |
| 509 | - $lessons = get_posts( apply_filters( 'sensei_grading_filter_lessons', $lesson_args ) ); |
|
| 509 | + $lessons = get_posts(apply_filters('sensei_grading_filter_lessons', $lesson_args)); |
|
| 510 | 510 | |
| 511 | - $html .= '<option value="">' . __( 'Select a lesson', 'woothemes-sensei' ) . '</option>'; |
|
| 512 | - if ( count( $lessons ) > 0 ) { |
|
| 513 | - foreach ( $lessons as $lesson_id ){ |
|
| 514 | - $html .= '<option value="' . esc_attr( absint( $lesson_id ) ) . '" ' . selected( $lesson_id, $selected_lesson_id, false ) . '>' . esc_html( get_the_title( $lesson_id ) ) . '</option>' . "\n"; |
|
| 511 | + $html .= '<option value="">'.__('Select a lesson', 'woothemes-sensei').'</option>'; |
|
| 512 | + if (count($lessons) > 0) { |
|
| 513 | + foreach ($lessons as $lesson_id) { |
|
| 514 | + $html .= '<option value="'.esc_attr(absint($lesson_id)).'" '.selected($lesson_id, $selected_lesson_id, false).'>'.esc_html(get_the_title($lesson_id)).'</option>'."\n"; |
|
| 515 | 515 | } // End For Loop |
| 516 | 516 | } // End If Statement |
| 517 | 517 | |
@@ -532,10 +532,10 @@ discard block |
||
| 532 | 532 | public function admin_process_grading_submission() { |
| 533 | 533 | |
| 534 | 534 | // NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry |
| 535 | - if( ! isset( $_POST['sensei_manual_grade'] ) |
|
| 536 | - || ! wp_verify_nonce( $_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading' ) |
|
| 537 | - || ! isset( $_GET['quiz_id'] ) |
|
| 538 | - || $_GET['quiz_id'] != $_POST['sensei_manual_grade'] ) { |
|
| 535 | + if ( ! isset($_POST['sensei_manual_grade']) |
|
| 536 | + || ! wp_verify_nonce($_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading') |
|
| 537 | + || ! isset($_GET['quiz_id']) |
|
| 538 | + || $_GET['quiz_id'] != $_POST['sensei_manual_grade']) { |
|
| 539 | 539 | |
| 540 | 540 | return false; //exit and do not grade |
| 541 | 541 | |
@@ -545,30 +545,30 @@ discard block |
||
| 545 | 545 | $user_id = $_GET['user']; |
| 546 | 546 | |
| 547 | 547 | |
| 548 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); |
|
| 549 | - $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 548 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); |
|
| 549 | + $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id); |
|
| 550 | 550 | $quiz_grade = 0; |
| 551 | 551 | $count = 0; |
| 552 | 552 | $quiz_grade_total = $_POST['quiz_grade_total']; |
| 553 | 553 | $all_question_grades = array(); |
| 554 | 554 | $all_answers_feedback = array(); |
| 555 | 555 | |
| 556 | - foreach( $questions as $question ) { |
|
| 556 | + foreach ($questions as $question) { |
|
| 557 | 557 | |
| 558 | 558 | ++$count; |
| 559 | 559 | $question_id = $question->ID; |
| 560 | 560 | |
| 561 | - if( isset( $_POST[ 'question_' . $question_id ] ) ) { |
|
| 561 | + if (isset($_POST['question_'.$question_id])) { |
|
| 562 | 562 | |
| 563 | 563 | $question_grade = 0; |
| 564 | - if( $_POST[ 'question_' . $question_id ] == 'right' ) { |
|
| 564 | + if ($_POST['question_'.$question_id] == 'right') { |
|
| 565 | 565 | |
| 566 | - $question_grade = $_POST[ 'question_' . $question_id . '_grade' ]; |
|
| 566 | + $question_grade = $_POST['question_'.$question_id.'_grade']; |
|
| 567 | 567 | |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // add data to the array that will, after the loop, be stored on the lesson status |
| 571 | - $all_question_grades[ $question_id ] = $question_grade; |
|
| 571 | + $all_question_grades[$question_id] = $question_grade; |
|
| 572 | 572 | |
| 573 | 573 | // tally up the total quiz grade |
| 574 | 574 | $quiz_grade += $question_grade; |
@@ -577,41 +577,41 @@ discard block |
||
| 577 | 577 | |
| 578 | 578 | // Question answer feedback / notes |
| 579 | 579 | $question_feedback = ''; |
| 580 | - if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){ |
|
| 580 | + if (isset($_POST['questions_feedback'][$question_id])) { |
|
| 581 | 581 | |
| 582 | - $question_feedback = wp_unslash( $_POST[ 'questions_feedback' ][ $question_id ] ); |
|
| 582 | + $question_feedback = wp_unslash($_POST['questions_feedback'][$question_id]); |
|
| 583 | 583 | |
| 584 | 584 | } |
| 585 | - $all_answers_feedback[ $question_id ] = $question_feedback; |
|
| 585 | + $all_answers_feedback[$question_id] = $question_feedback; |
|
| 586 | 586 | |
| 587 | 587 | } // end for each $questions |
| 588 | 588 | |
| 589 | 589 | //store all question grades on the lesson status |
| 590 | - Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id ); |
|
| 590 | + Sensei()->quiz->set_user_grades($all_question_grades, $quiz_lesson_id, $user_id); |
|
| 591 | 591 | |
| 592 | 592 | //store the feedback from grading |
| 593 | - Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id ); |
|
| 593 | + Sensei()->quiz->save_user_answers_feedback($all_answers_feedback, $quiz_lesson_id, $user_id); |
|
| 594 | 594 | |
| 595 | 595 | // $_POST['all_questions_graded'] is set when all questions have been graded |
| 596 | 596 | // in the class sensei grading user quiz -> display() |
| 597 | - if( $_POST['all_questions_graded'] == 'yes' ) { |
|
| 597 | + if ($_POST['all_questions_graded'] == 'yes') { |
|
| 598 | 598 | |
| 599 | 599 | // set the users total quiz grade |
| 600 | - if ( 0 < intval( $quiz_grade_total ) ) { |
|
| 601 | - $grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) ); |
|
| 600 | + if (0 < intval($quiz_grade_total)) { |
|
| 601 | + $grade = abs(round((doubleval($quiz_grade) * 100) / ($quiz_grade_total), 2)); |
|
| 602 | 602 | } |
| 603 | 603 | else { |
| 604 | 604 | $grade = 0; |
| 605 | 605 | } |
| 606 | - Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id ); |
|
| 606 | + Sensei_Utils::sensei_grade_quiz($quiz_id, $grade, $user_id); |
|
| 607 | 607 | |
| 608 | 608 | // Duplicating what Frontend->sensei_complete_quiz() does |
| 609 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
| 610 | - $quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) ); |
|
| 609 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
| 610 | + $quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2)); |
|
| 611 | 611 | $lesson_metadata = array(); |
| 612 | - if ( $pass_required ) { |
|
| 612 | + if ($pass_required) { |
|
| 613 | 613 | // Student has reached the pass mark and lesson is complete |
| 614 | - if ( $quiz_passmark <= $grade ) { |
|
| 614 | + if ($quiz_passmark <= $grade) { |
|
| 615 | 615 | $lesson_status = 'passed'; |
| 616 | 616 | } |
| 617 | 617 | else { |
@@ -624,9 +624,9 @@ discard block |
||
| 624 | 624 | } |
| 625 | 625 | $lesson_metadata['grade'] = $grade; // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above |
| 626 | 626 | |
| 627 | - Sensei_Utils::update_lesson_status( $user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata ); |
|
| 627 | + Sensei_Utils::update_lesson_status($user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata); |
|
| 628 | 628 | |
| 629 | - if( in_array( $lesson_status, array( 'passed', 'graded' ) ) ) { |
|
| 629 | + if (in_array($lesson_status, array('passed', 'graded'))) { |
|
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | 632 | * Summary. |
@@ -638,27 +638,27 @@ discard block |
||
| 638 | 638 | * @param int $user_id |
| 639 | 639 | * @param int $quiz_lesson_id |
| 640 | 640 | */ |
| 641 | - do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id ); |
|
| 641 | + do_action('sensei_user_lesson_end', $user_id, $quiz_lesson_id); |
|
| 642 | 642 | |
| 643 | 643 | } // end if in_array |
| 644 | 644 | |
| 645 | 645 | }// end if $_POST['all_que... |
| 646 | 646 | |
| 647 | - if( isset( $_POST['sensei_grade_next_learner'] ) && strlen( $_POST['sensei_grade_next_learner'] ) > 0 ) { |
|
| 647 | + if (isset($_POST['sensei_grade_next_learner']) && strlen($_POST['sensei_grade_next_learner']) > 0) { |
|
| 648 | 648 | |
| 649 | - $load_url = add_query_arg( array( 'message' => 'graded' ) ); |
|
| 649 | + $load_url = add_query_arg(array('message' => 'graded')); |
|
| 650 | 650 | |
| 651 | - } elseif ( isset( $_POST['_wp_http_referer'] ) ) { |
|
| 651 | + } elseif (isset($_POST['_wp_http_referer'])) { |
|
| 652 | 652 | |
| 653 | - $load_url = add_query_arg( array( 'message' => 'graded' ), $_POST['_wp_http_referer'] ); |
|
| 653 | + $load_url = add_query_arg(array('message' => 'graded'), $_POST['_wp_http_referer']); |
|
| 654 | 654 | |
| 655 | 655 | } else { |
| 656 | 656 | |
| 657 | - $load_url = add_query_arg( array( 'message' => 'graded' ) ); |
|
| 657 | + $load_url = add_query_arg(array('message' => 'graded')); |
|
| 658 | 658 | |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - wp_safe_redirect( esc_url_raw( $load_url ) ); |
|
| 661 | + wp_safe_redirect(esc_url_raw($load_url)); |
|
| 662 | 662 | exit; |
| 663 | 663 | |
| 664 | 664 | } // end admin_process_grading_submission |
@@ -669,13 +669,13 @@ discard block |
||
| 669 | 669 | $lesson_data = array(); |
| 670 | 670 | parse_str($data, $lesson_data); |
| 671 | 671 | |
| 672 | - $lesson_id = intval( $lesson_data['lesson_id'] ); |
|
| 673 | - $course_id = intval( $lesson_data['course_id'] ); |
|
| 674 | - $grading_view = sanitize_text_field( $lesson_data['view'] ); |
|
| 672 | + $lesson_id = intval($lesson_data['lesson_id']); |
|
| 673 | + $course_id = intval($lesson_data['course_id']); |
|
| 674 | + $grading_view = sanitize_text_field($lesson_data['view']); |
|
| 675 | 675 | |
| 676 | 676 | $redirect_url = ''; |
| 677 | - if ( 0 < $lesson_id && 0 < $course_id ) { |
|
| 678 | - $redirect_url = esc_url_raw( apply_filters( 'sensei_ajax_redirect_url', add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id, 'course_id' => $course_id, 'view' => $grading_view ), admin_url( 'admin.php' ) ) ) ); |
|
| 677 | + if (0 < $lesson_id && 0 < $course_id) { |
|
| 678 | + $redirect_url = esc_url_raw(apply_filters('sensei_ajax_redirect_url', add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id, 'course_id' => $course_id, 'view' => $grading_view), admin_url('admin.php')))); |
|
| 679 | 679 | } // End If Statement |
| 680 | 680 | |
| 681 | 681 | echo $redirect_url; |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | public function add_grading_notices() { |
| 686 | - if( isset( $_GET['page'] ) && $this->page_slug == $_GET['page'] && isset( $_GET['message'] ) && $_GET['message'] ) { |
|
| 687 | - if( 'graded' == $_GET['message'] ) { |
|
| 686 | + if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) { |
|
| 687 | + if ('graded' == $_GET['message']) { |
|
| 688 | 688 | $msg = array( |
| 689 | 689 | 'updated', |
| 690 | - __( 'Quiz Graded Successfully!', 'woothemes-sensei' ), |
|
| 690 | + __('Quiz Graded Successfully!', 'woothemes-sensei'), |
|
| 691 | 691 | ); |
| 692 | 692 | } |
| 693 | 693 | ?> |
@@ -699,9 +699,9 @@ discard block |
||
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | public function sensei_grading_notices() { |
| 702 | - if ( isset( $_GET['action'] ) && 'graded' == $_GET['action'] ) { |
|
| 702 | + if (isset($_GET['action']) && 'graded' == $_GET['action']) { |
|
| 703 | 703 | echo '<div class="grading-notice updated">'; |
| 704 | - echo '<p>' . __( 'Quiz Graded Successfully!', 'woothemes-sensei' ) . '</p>'; |
|
| 704 | + echo '<p>'.__('Quiz Graded Successfully!', 'woothemes-sensei').'</p>'; |
|
| 705 | 705 | echo '</div>'; |
| 706 | 706 | } // End If Statement |
| 707 | 707 | } // End sensei_grading_notices() |
@@ -724,16 +724,16 @@ discard block |
||
| 724 | 724 | * |
| 725 | 725 | * @return int $quiz_grade total sum of all question grades |
| 726 | 726 | */ |
| 727 | - public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) { |
|
| 727 | + public static function grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') { |
|
| 728 | 728 | |
| 729 | - if( ! ( intval( $quiz_id ) > 0 ) || ! $submitted |
|
| 730 | - || $quiz_grade_type != 'auto' ) { |
|
| 729 | + if ( ! (intval($quiz_id) > 0) || ! $submitted |
|
| 730 | + || $quiz_grade_type != 'auto') { |
|
| 731 | 731 | return false; // exit early |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | |
| 735 | 735 | $user_id = get_current_user_id(); |
| 736 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ) ; |
|
| 736 | + $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id); |
|
| 737 | 737 | $quiz_autogradable = true; |
| 738 | 738 | |
| 739 | 739 | /** |
@@ -747,23 +747,23 @@ discard block |
||
| 747 | 747 | * 'gap-fill'. |
| 748 | 748 | * } |
| 749 | 749 | */ |
| 750 | - $autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) ); |
|
| 750 | + $autogradable_question_types = apply_filters('sensei_autogradable_question_types', array('multiple-choice', 'boolean', 'gap-fill')); |
|
| 751 | 751 | |
| 752 | 752 | $grade_total = 0; |
| 753 | 753 | $all_question_grades = array(); |
| 754 | - foreach( $submitted as $question_id => $answer ) { |
|
| 754 | + foreach ($submitted as $question_id => $answer) { |
|
| 755 | 755 | |
| 756 | 756 | // check if the question is autogradable, either by type, or because the grade is 0 |
| 757 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 758 | - $achievable_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 757 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 758 | + $achievable_grade = Sensei()->question->get_question_grade($question_id); |
|
| 759 | 759 | // Question has a zero grade, so skip grading |
| 760 | - if ( 0 == $achievable_grade ) { |
|
| 761 | - $all_question_grades[ $question_id ] = $achievable_grade; |
|
| 760 | + if (0 == $achievable_grade) { |
|
| 761 | + $all_question_grades[$question_id] = $achievable_grade; |
|
| 762 | 762 | } |
| 763 | - elseif ( in_array( $question_type, $autogradable_question_types ) ) { |
|
| 763 | + elseif (in_array($question_type, $autogradable_question_types)) { |
|
| 764 | 764 | // Get user question grade |
| 765 | - $question_grade = Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id ); |
|
| 766 | - $all_question_grades[ $question_id ] = $question_grade; |
|
| 765 | + $question_grade = Sensei_Utils::sensei_grade_question_auto($question_id, $question_type, $answer, $user_id); |
|
| 766 | + $all_question_grades[$question_id] = $question_grade; |
|
| 767 | 767 | $grade_total += $question_grade; |
| 768 | 768 | |
| 769 | 769 | } else { |
@@ -776,27 +776,27 @@ discard block |
||
| 776 | 776 | }// end for each question |
| 777 | 777 | |
| 778 | 778 | // Only if the whole quiz was autogradable do we set a grade |
| 779 | - if ( $quiz_autogradable ) { |
|
| 779 | + if ($quiz_autogradable) { |
|
| 780 | 780 | |
| 781 | - $quiz_total = Sensei_Utils::sensei_get_quiz_total( $quiz_id ); |
|
| 781 | + $quiz_total = Sensei_Utils::sensei_get_quiz_total($quiz_id); |
|
| 782 | 782 | // Check for zero total from grades |
| 783 | - if ( 0 < $quiz_total ) { |
|
| 784 | - $grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) ); |
|
| 783 | + if (0 < $quiz_total) { |
|
| 784 | + $grade = abs(round((doubleval($grade_total) * 100) / ($quiz_total), 2)); |
|
| 785 | 785 | } |
| 786 | 786 | else { |
| 787 | 787 | $grade = 0; |
| 788 | 788 | } |
| 789 | - Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type ); |
|
| 789 | + Sensei_Utils::sensei_grade_quiz($quiz_id, $grade, $user_id, $quiz_grade_type); |
|
| 790 | 790 | |
| 791 | 791 | } else { |
| 792 | 792 | |
| 793 | - $grade = new WP_Error( 'autograde', __( 'This quiz is not able to be automatically graded.', 'woothemes-sensei' ) ); |
|
| 793 | + $grade = new WP_Error('autograde', __('This quiz is not able to be automatically graded.', 'woothemes-sensei')); |
|
| 794 | 794 | |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | // store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default |
| 798 | 798 | // when doing manual grading. |
| 799 | - Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id ); |
|
| 799 | + Sensei()->quiz-> set_user_grades($all_question_grades, $lesson_id, $user_id); |
|
| 800 | 800 | |
| 801 | 801 | return $grade; |
| 802 | 802 | |
@@ -816,22 +816,22 @@ discard block |
||
| 816 | 816 | * |
| 817 | 817 | * @return int $question_grade |
| 818 | 818 | */ |
| 819 | - public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) { |
|
| 819 | + public static function grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) { |
|
| 820 | 820 | |
| 821 | - if( intval( $user_id ) == 0 ) { |
|
| 821 | + if (intval($user_id) == 0) { |
|
| 822 | 822 | |
| 823 | 823 | $user_id = get_current_user_id(); |
| 824 | 824 | |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - if( ! ( intval( $question_id ) > 0 ) ) { |
|
| 827 | + if ( ! (intval($question_id) > 0)) { |
|
| 828 | 828 | |
| 829 | 829 | return false; |
| 830 | 830 | |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | |
| 834 | - Sensei()->question->get_question_type( $question_id ); |
|
| 834 | + Sensei()->question->get_question_type($question_id); |
|
| 835 | 835 | |
| 836 | 836 | /** |
| 837 | 837 | * Applying a grade before the auto grading takes place. |
@@ -845,42 +845,42 @@ discard block |
||
| 845 | 845 | * @param string $question_type one of the Sensei question type. |
| 846 | 846 | * @param string $answer user supplied question answer |
| 847 | 847 | */ |
| 848 | - $question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer ); |
|
| 848 | + $question_grade = apply_filters('sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer); |
|
| 849 | 849 | |
| 850 | - if ( false !== $question_grade ) { |
|
| 850 | + if (false !== $question_grade) { |
|
| 851 | 851 | |
| 852 | 852 | return $question_grade; |
| 853 | 853 | |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | // auto grading core |
| 857 | - if( in_array( $question_type , array( 'multiple-choice' , 'boolean' ) ) ){ |
|
| 857 | + if (in_array($question_type, array('multiple-choice', 'boolean'))) { |
|
| 858 | 858 | |
| 859 | - $right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true ); |
|
| 859 | + $right_answer = (array) get_post_meta($question_id, '_question_right_answer', true); |
|
| 860 | 860 | |
| 861 | - if( 0 == get_magic_quotes_gpc() ) { |
|
| 862 | - $answer = wp_unslash( $answer ); |
|
| 861 | + if (0 == get_magic_quotes_gpc()) { |
|
| 862 | + $answer = wp_unslash($answer); |
|
| 863 | 863 | } |
| 864 | 864 | $answer = (array) $answer; |
| 865 | - if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) { |
|
| 865 | + if (is_array($right_answer) && count($right_answer) == count($answer)) { |
|
| 866 | 866 | // Loop through all answers ensure none are 'missing' |
| 867 | 867 | $all_correct = true; |
| 868 | - foreach ( $answer as $check_answer ) { |
|
| 869 | - if ( !in_array( $check_answer, $right_answer ) ) { |
|
| 868 | + foreach ($answer as $check_answer) { |
|
| 869 | + if ( ! in_array($check_answer, $right_answer)) { |
|
| 870 | 870 | $all_correct = false; |
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | // If all correct then grade |
| 874 | - if ( $all_correct ) { |
|
| 875 | - $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 874 | + if ($all_correct) { |
|
| 875 | + $question_grade = Sensei()->question->get_question_grade($question_id); |
|
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - } elseif( 'gap-fill' == $question_type ){ |
|
| 879 | + } elseif ('gap-fill' == $question_type) { |
|
| 880 | 880 | |
| 881 | - $question_grade = self::grade_gap_fill_question( $question_id ,$answer ); |
|
| 881 | + $question_grade = self::grade_gap_fill_question($question_id, $answer); |
|
| 882 | 882 | |
| 883 | - } else{ |
|
| 883 | + } else { |
|
| 884 | 884 | |
| 885 | 885 | /** |
| 886 | 886 | * Grading questions that are not auto gradable. |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | * @param string $question_type one of the Sensei question type. |
| 894 | 894 | * @param string $answer user supplied question answer |
| 895 | 895 | */ |
| 896 | - $question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer ); |
|
| 896 | + $question_grade = (int) apply_filters('sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer); |
|
| 897 | 897 | |
| 898 | 898 | } // end if $question_type |
| 899 | 899 | |
@@ -909,13 +909,13 @@ discard block |
||
| 909 | 909 | * |
| 910 | 910 | * @return bool | int false or the grade given to the user answer |
| 911 | 911 | */ |
| 912 | - public static function grade_gap_fill_question( $question_id, $user_answer ){ |
|
| 912 | + public static function grade_gap_fill_question($question_id, $user_answer) { |
|
| 913 | 913 | |
| 914 | - $right_answer = get_post_meta( $question_id, '_question_right_answer', true ); |
|
| 915 | - $gapfill_array = explode( '||', $right_answer ); |
|
| 914 | + $right_answer = get_post_meta($question_id, '_question_right_answer', true); |
|
| 915 | + $gapfill_array = explode('||', $right_answer); |
|
| 916 | 916 | |
| 917 | - if( 0 == get_magic_quotes_gpc() ) { // deprecated from PHP 5.4 but we still support PHP 5.2 |
|
| 918 | - $user_answer = wp_unslash( $user_answer ); |
|
| 917 | + if (0 == get_magic_quotes_gpc()) { // deprecated from PHP 5.4 but we still support PHP 5.2 |
|
| 918 | + $user_answer = wp_unslash($user_answer); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -928,53 +928,53 @@ discard block |
||
| 928 | 928 | * |
| 929 | 929 | * @since 1.9.0 |
| 930 | 930 | */ |
| 931 | - $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false ); |
|
| 931 | + $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false); |
|
| 932 | 932 | |
| 933 | - if( $do_case_sensitive_comparison ){ |
|
| 933 | + if ($do_case_sensitive_comparison) { |
|
| 934 | 934 | |
| 935 | 935 | // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer |
| 936 | - if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) { |
|
| 936 | + if (trim(($gapfill_array[1])) == trim($user_answer)) { |
|
| 937 | 937 | |
| 938 | - return Sensei()->question->get_question_grade( $question_id ); |
|
| 938 | + return Sensei()->question->get_question_grade($question_id); |
|
| 939 | 939 | |
| 940 | - } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) { |
|
| 940 | + } else if (@preg_match('/'.$gapfill_array[1].'/i', null) !== FALSE) { |
|
| 941 | 941 | |
| 942 | - if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) { |
|
| 942 | + if (preg_match('/'.$gapfill_array[1].'/i', $user_answer)) { |
|
| 943 | 943 | |
| 944 | 944 | return Sensei()->question->get_question_grade($question_id); |
| 945 | 945 | |
| 946 | - }else{ |
|
| 946 | + } else { |
|
| 947 | 947 | |
| 948 | 948 | return false; |
| 949 | 949 | |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - }else{ |
|
| 952 | + } else { |
|
| 953 | 953 | |
| 954 | 954 | return false; |
| 955 | 955 | |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - }else{ |
|
| 958 | + } else { |
|
| 959 | 959 | |
| 960 | 960 | // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer |
| 961 | - if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) { |
|
| 961 | + if (trim(strtolower($gapfill_array[1])) == trim(strtolower($user_answer))) { |
|
| 962 | 962 | |
| 963 | - return Sensei()->question->get_question_grade( $question_id ); |
|
| 963 | + return Sensei()->question->get_question_grade($question_id); |
|
| 964 | 964 | |
| 965 | - } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) { |
|
| 965 | + } else if (@preg_match('/'.$gapfill_array[1].'/i', null) !== FALSE) { |
|
| 966 | 966 | |
| 967 | - if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) { |
|
| 967 | + if (preg_match('/'.$gapfill_array[1].'/i', $user_answer)) { |
|
| 968 | 968 | |
| 969 | - return Sensei()->question->get_question_grade( $question_id ); |
|
| 969 | + return Sensei()->question->get_question_grade($question_id); |
|
| 970 | 970 | |
| 971 | - }else{ |
|
| 971 | + } else { |
|
| 972 | 972 | |
| 973 | 973 | return false; |
| 974 | 974 | |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | - }else{ |
|
| 977 | + } else { |
|
| 978 | 978 | |
| 979 | 979 | return false; |
| 980 | 980 | |
@@ -990,17 +990,17 @@ discard block |
||
| 990 | 990 | * @since 1.9.0 |
| 991 | 991 | * @return int $number_of_graded_lessons |
| 992 | 992 | */ |
| 993 | - public static function get_graded_lessons_count(){ |
|
| 993 | + public static function get_graded_lessons_count() { |
|
| 994 | 994 | |
| 995 | 995 | global $wpdb; |
| 996 | 996 | |
| 997 | - $comment_query_piece[ 'select'] = "SELECT COUNT(*) AS total"; |
|
| 998 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 999 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1000 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 997 | + $comment_query_piece['select'] = "SELECT COUNT(*) AS total"; |
|
| 998 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 999 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1000 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1001 | 1001 | |
| 1002 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1003 | - $number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1002 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1003 | + $number_of_graded_lessons = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1004 | 1004 | |
| 1005 | 1005 | return $number_of_graded_lessons; |
| 1006 | 1006 | } |
@@ -1011,17 +1011,17 @@ discard block |
||
| 1011 | 1011 | * @since 1.9.0 |
| 1012 | 1012 | * @return double $sum_of_all_grades |
| 1013 | 1013 | */ |
| 1014 | - public static function get_graded_lessons_sum(){ |
|
| 1014 | + public static function get_graded_lessons_sum() { |
|
| 1015 | 1015 | |
| 1016 | 1016 | global $wpdb; |
| 1017 | 1017 | |
| 1018 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1019 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1020 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1021 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1018 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1019 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1020 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')"; |
|
| 1021 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1022 | 1022 | |
| 1023 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1024 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1023 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1024 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1025 | 1025 | |
| 1026 | 1026 | return $sum_of_all_grades; |
| 1027 | 1027 | |
@@ -1034,17 +1034,17 @@ discard block |
||
| 1034 | 1034 | * @param $user_id |
| 1035 | 1035 | * @return double |
| 1036 | 1036 | */ |
| 1037 | - public static function get_user_graded_lessons_sum( $user_id ){ |
|
| 1037 | + public static function get_user_graded_lessons_sum($user_id) { |
|
| 1038 | 1038 | global $wpdb; |
| 1039 | 1039 | |
| 1040 | - $clean_user_id = esc_sql( $user_id); |
|
| 1041 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1042 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1043 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} "; |
|
| 1044 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1040 | + $clean_user_id = esc_sql($user_id); |
|
| 1041 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1042 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1043 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} "; |
|
| 1044 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1045 | 1045 | |
| 1046 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1047 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1046 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1047 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1048 | 1048 | |
| 1049 | 1049 | return $sum_of_all_grades; |
| 1050 | 1050 | } |
@@ -1057,18 +1057,18 @@ discard block |
||
| 1057 | 1057 | * @param int lesson_id |
| 1058 | 1058 | * @return double |
| 1059 | 1059 | */ |
| 1060 | - public static function get_lessons_users_grades_sum( $lesson_id ){ |
|
| 1060 | + public static function get_lessons_users_grades_sum($lesson_id) { |
|
| 1061 | 1061 | |
| 1062 | 1062 | global $wpdb; |
| 1063 | 1063 | |
| 1064 | - $clean_lesson_id = esc_sql( $lesson_id); |
|
| 1065 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1066 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1067 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} "; |
|
| 1068 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1064 | + $clean_lesson_id = esc_sql($lesson_id); |
|
| 1065 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1066 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1067 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} "; |
|
| 1068 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1069 | 1069 | |
| 1070 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1071 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1070 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1071 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1072 | 1072 | |
| 1073 | 1073 | return $sum_of_all_grades; |
| 1074 | 1074 | |
@@ -1082,18 +1082,18 @@ discard block |
||
| 1082 | 1082 | * @param int $course_id |
| 1083 | 1083 | * @return double |
| 1084 | 1084 | */ |
| 1085 | - public static function get_course_users_grades_sum( $course_id ){ |
|
| 1085 | + public static function get_course_users_grades_sum($course_id) { |
|
| 1086 | 1086 | |
| 1087 | 1087 | global $wpdb; |
| 1088 | 1088 | |
| 1089 | - $clean_course_id = esc_sql( $course_id); |
|
| 1090 | - $comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1091 | - $comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1092 | - $comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} "; |
|
| 1093 | - $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1089 | + $clean_course_id = esc_sql($course_id); |
|
| 1090 | + $comment_query_piece['select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
|
| 1091 | + $comment_query_piece['from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
|
| 1092 | + $comment_query_piece['where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} "; |
|
| 1093 | + $comment_query_piece['orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
|
| 1094 | 1094 | |
| 1095 | - $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
|
| 1096 | - $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
|
| 1095 | + $comment_query = $comment_query_piece['select'].$comment_query_piece['from'].$comment_query_piece['where'].$comment_query_piece['orderby']; |
|
| 1096 | + $sum_of_all_grades = intval($wpdb->get_var($comment_query, 0, 0)); |
|
| 1097 | 1097 | |
| 1098 | 1098 | return $sum_of_all_grades; |
| 1099 | 1099 | |
@@ -1106,4 +1106,4 @@ discard block |
||
| 1106 | 1106 | * @ignore only for backward compatibility |
| 1107 | 1107 | * @since 1.9.0 |
| 1108 | 1108 | */ |
| 1109 | -class WooThemes_Sensei_Grading extends Sensei_Grading{} |
|
| 1109 | +class WooThemes_Sensei_Grading extends Sensei_Grading {} |
|