| @@ -1,32 +1,32 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; | 
| 3 | 3 | /** | 
| 4 | - * List the Course Modules and Lesson in these modules | |
| 5 | - * | |
| 6 | - * Template is hooked into Single Course sensei_single_main_content. It will | |
| 7 | - * only be shown if the course contains modules. | |
| 8 | - * | |
| 9 | - * All lessons shown here will not be included in the list of other lessons. | |
| 10 | - * | |
| 11 | - * @author Automattic | |
| 12 | - * @package Sensei | |
| 13 | - * @category Templates | |
| 14 | - * @version 1.9.0 | |
| 15 | - */ | |
| 4 | + * List the Course Modules and Lesson in these modules | |
| 5 | + * | |
| 6 | + * Template is hooked into Single Course sensei_single_main_content. It will | |
| 7 | + * only be shown if the course contains modules. | |
| 8 | + * | |
| 9 | + * All lessons shown here will not be included in the list of other lessons. | |
| 10 | + * | |
| 11 | + * @author Automattic | |
| 12 | + * @package Sensei | |
| 13 | + * @category Templates | |
| 14 | + * @version 1.9.0 | |
| 15 | + */ | |
| 16 | 16 | ?> | 
| 17 | 17 | |
| 18 | 18 | <?php | 
| 19 | 19 | |
| 20 | - /** | |
| 21 | - * Hook runs inside single-course/course-modules.php | |
| 22 | - * | |
| 23 | - * It runs before the modules are shown. This hook fires on the single course page. It will show | |
| 24 | - * irrespective of irrespective the course has any modules or not. | |
| 25 | - * | |
| 26 | - * @since 1.8.0 | |
| 27 | - * | |
| 28 | - */ | |
| 29 | -    do_action('sensei_single_course_modules_before'); | |
| 20 | + /** | |
| 21 | + * Hook runs inside single-course/course-modules.php | |
| 22 | + * | |
| 23 | + * It runs before the modules are shown. This hook fires on the single course page. It will show | |
| 24 | + * irrespective of irrespective the course has any modules or not. | |
| 25 | + * | |
| 26 | + * @since 1.8.0 | |
| 27 | + * | |
| 28 | + */ | |
| 29 | +	do_action('sensei_single_course_modules_before'); | |
| 30 | 30 | |
| 31 | 31 | ?> | 
| 32 | 32 | |
| @@ -39,19 +39,19 @@ discard block | ||
| 39 | 39 | |
| 40 | 40 | <?php | 
| 41 | 41 | |
| 42 | - /** | |
| 43 | - * Hook runs inside single-course/course-modules.php | |
| 44 | - * | |
| 45 | - * It runs inside the if statement after the article tag opens just before the modules are shown. This hook will NOT fire if there | |
| 46 | - * are no modules to show. | |
| 47 | - * | |
| 48 | - * @since 1.9.0 | |
| 49 | - * | |
| 50 | - * @hooked Sensei()->modules->course_modules_title - 20 | |
| 51 | - */ | |
| 52 | -                do_action('sensei_single_course_modules_inside_before'); | |
| 42 | + /** | |
| 43 | + * Hook runs inside single-course/course-modules.php | |
| 44 | + * | |
| 45 | + * It runs inside the if statement after the article tag opens just before the modules are shown. This hook will NOT fire if there | |
| 46 | + * are no modules to show. | |
| 47 | + * | |
| 48 | + * @since 1.9.0 | |
| 49 | + * | |
| 50 | + * @hooked Sensei()->modules->course_modules_title - 20 | |
| 51 | + */ | |
| 52 | +				do_action('sensei_single_course_modules_inside_before'); | |
| 53 | 53 | |
| 54 | - ?> | |
| 54 | + ?> | |
| 55 | 55 | |
| 56 | 56 | <header> | 
| 57 | 57 | |
| @@ -101,18 +101,18 @@ discard block | ||
| 101 | 101 | |
| 102 | 102 | <?php | 
| 103 | 103 | |
| 104 | - /** | |
| 105 | - * Hook runs inside single-course/course-modules.php | |
| 106 | - * | |
| 107 | - * It runs inside the if statement before the closing article tag directly after the modules were shown. | |
| 108 | - * This hook will not trigger if there are no modules to show. | |
| 109 | - * | |
| 110 | - * @since 1.9.0 | |
| 111 | - * | |
| 112 | - */ | |
| 113 | -                do_action('sensei_single_course_modules_inside_after'); | |
| 114 | - | |
| 115 | - ?> | |
| 104 | + /** | |
| 105 | + * Hook runs inside single-course/course-modules.php | |
| 106 | + * | |
| 107 | + * It runs inside the if statement before the closing article tag directly after the modules were shown. | |
| 108 | + * This hook will not trigger if there are no modules to show. | |
| 109 | + * | |
| 110 | + * @since 1.9.0 | |
| 111 | + * | |
| 112 | + */ | |
| 113 | +				do_action('sensei_single_course_modules_inside_after'); | |
| 114 | + | |
| 115 | + ?> | |
| 116 | 116 | |
| 117 | 117 | </article> | 
| 118 | 118 | |
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; | |
| 2 | +if ( ! defined('ABSPATH')) exit; | |
| 3 | 3 | /** | 
| 4 | 4 | * List the Course Modules and Lesson in these modules | 
| 5 | 5 | * | 
| @@ -30,10 +30,10 @@ discard block | ||
| 30 | 30 | |
| 31 | 31 | ?> | 
| 32 | 32 | |
| 33 | -<?php if( sensei_have_modules() ): ?> | |
| 33 | +<?php if (sensei_have_modules()): ?> | |
| 34 | 34 | |
| 35 | - <?php while ( sensei_have_modules() ): sensei_setup_module(); ?> | |
| 36 | - <?php if( sensei_module_has_lessons() ): ?> | |
| 35 | + <?php while (sensei_have_modules()): sensei_setup_module(); ?> | |
| 36 | + <?php if (sensei_module_has_lessons()): ?> | |
| 37 | 37 | |
| 38 | 38 | <article class="module"> | 
| 39 | 39 | |
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | |
| 58 | 58 | <h2> | 
| 59 | 59 | |
| 60 | - <a href="<?php sensei_the_module_permalink(); ?>" title="<?php sensei_the_module_title_attribute();?>"> | |
| 60 | + <a href="<?php sensei_the_module_permalink(); ?>" title="<?php sensei_the_module_title_attribute(); ?>"> | |
| 61 | 61 | |
| 62 | 62 | <?php sensei_the_module_title(); ?> | 
| 63 | 63 | |
| @@ -81,9 +81,9 @@ discard block | ||
| 81 | 81 | |
| 82 | 82 | <ul class="lessons-list" > | 
| 83 | 83 | |
| 84 | - <?php while( sensei_module_has_lessons() ): the_post(); ?> | |
| 84 | + <?php while (sensei_module_has_lessons()): the_post(); ?> | |
| 85 | 85 | |
| 86 | - <li class="<?php sensei_the_lesson_status_class();?>"> | |
| 86 | + <li class="<?php sensei_the_lesson_status_class(); ?>"> | |
| 87 | 87 | |
| 88 | 88 | <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute() ?>" > | 
| 89 | 89 | |
| @@ -192,7 +192,6 @@ discard block | ||
| 192 | 192 | * | 
| 193 | 193 | * @access public | 
| 194 | 194 | * @param mixed $slug | 
| 195 | - * @param mixed $option | |
| 196 | 195 | * @param string $page_title (default: '') | 
| 197 | 196 | * @param string $page_content (default: '') | 
| 198 | 197 | * @param int $post_parent (default: 0) | 
| @@ -1037,6 +1036,9 @@ discard block | ||
| 1037 | 1036 | ?></div><?php | 
| 1038 | 1037 | } | 
| 1039 | 1038 | |
| 1039 | + /** | |
| 1040 | + * @return string | |
| 1041 | + */ | |
| 1040 | 1042 |  	public function get_course_order() { | 
| 1041 | 1043 | return get_option( 'sensei_course_order', '' ); | 
| 1042 | 1044 | } | 
| @@ -16,11 +16,11 @@ discard block | ||
| 16 | 16 | */ | 
| 17 | 17 |  	public function __construct () { | 
| 18 | 18 | |
| 19 | - //register admin styles | |
| 19 | + //register admin styles | |
| 20 | 20 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) ); | 
| 21 | 21 | |
| 22 | - //register admin scripts | |
| 23 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); | |
| 22 | + //register admin scripts | |
| 23 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); | |
| 24 | 24 | |
| 25 | 25 | add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) ); | 
| 26 | 26 | add_action( 'settings_before_form', array( $this, 'install_pages_output' ) ); | 
| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) ); | 
| 30 | 30 | add_action( 'admin_init', array( $this, 'page_redirect' ) ); | 
| 31 | 31 | add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) ); | 
| 32 | - add_action( 'admin_init', array( __CLASS__, 'install_pages' )); | |
| 32 | + add_action( 'admin_init', array( __CLASS__, 'install_pages' )); | |
| 33 | 33 | |
| 34 | 34 | // Duplicate lesson & courses | 
| 35 | 35 | add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 ); | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | |
| 81 | 81 |  		if( $menu_cap ) { | 
| 82 | 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' ); | |
| 83 | + add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' ); | |
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | 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' ) ); | 
| @@ -137,14 +137,14 @@ discard block | ||
| 137 | 137 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; | 
| 138 | 138 | $parent_file = 'edit.php?post_type=course'; | 
| 139 | 139 | |
| 140 | -        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { | |
| 140 | +		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { | |
| 141 | 141 | |
| 142 | - $submenu_file = 'edit-tags.php?taxonomy=module'; | |
| 143 | - $parent_file = 'edit.php?post_type=course'; | |
| 142 | + $submenu_file = 'edit-tags.php?taxonomy=module'; | |
| 143 | + $parent_file = 'edit.php?post_type=course'; | |
| 144 | 144 | |
| 145 | 145 |  		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { | 
| 146 | 146 | |
| 147 | - $submenu_file = 'edit.php?post_type=sensei_message'; | |
| 147 | + $submenu_file = 'edit.php?post_type=sensei_message'; | |
| 148 | 148 | $parent_file = 'sensei'; | 
| 149 | 149 | |
| 150 | 150 | } | 
| @@ -172,9 +172,9 @@ discard block | ||
| 172 | 172 | */ | 
| 173 | 173 |  	function install_pages_output() { | 
| 174 | 174 | |
| 175 | -        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { | |
| 175 | +		if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { | |
| 176 | 176 | |
| 177 | - ?> | |
| 177 | + ?> | |
| 178 | 178 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 179 | 179 | <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> | 
| 180 | 180 | <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> | 
| @@ -182,7 +182,7 @@ discard block | ||
| 182 | 182 | </div> | 
| 183 | 183 | <?php | 
| 184 | 184 | |
| 185 | - } | |
| 185 | + } | |
| 186 | 186 | |
| 187 | 187 | } // End install_pages_output() | 
| 188 | 188 | |
| @@ -201,25 +201,25 @@ discard block | ||
| 201 | 201 |  	function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) { | 
| 202 | 202 | global $wpdb; | 
| 203 | 203 | |
| 204 | - $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); | |
| 204 | + $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); | |
| 205 | 205 | if ( $page_id ) : | 
| 206 | 206 | return $page_id; | 
| 207 | 207 | endif; | 
| 208 | 208 | |
| 209 | 209 | $page_data = array( | 
| 210 | - 'post_status' => 'publish', | |
| 211 | - 'post_type' => 'page', | |
| 212 | - 'post_author' => 1, | |
| 213 | - 'post_name' => $slug, | |
| 214 | - 'post_title' => $page_title, | |
| 215 | - 'post_content' => $page_content, | |
| 216 | - 'post_parent' => $post_parent, | |
| 217 | - 'comment_status' => 'closed' | |
| 218 | - ); | |
| 210 | + 'post_status' => 'publish', | |
| 211 | + 'post_type' => 'page', | |
| 212 | + 'post_author' => 1, | |
| 213 | + 'post_name' => $slug, | |
| 214 | + 'post_title' => $page_title, | |
| 215 | + 'post_content' => $page_content, | |
| 216 | + 'post_parent' => $post_parent, | |
| 217 | + 'comment_status' => 'closed' | |
| 218 | + ); | |
| 219 | 219 | |
| 220 | - $page_id = wp_insert_post( $page_data ); | |
| 220 | + $page_id = wp_insert_post( $page_data ); | |
| 221 | 221 | |
| 222 | - return $page_id; | |
| 222 | + return $page_id; | |
| 223 | 223 | |
| 224 | 224 | } // End create_page() | 
| 225 | 225 | |
| @@ -233,12 +233,12 @@ discard block | ||
| 233 | 233 |  	function create_pages() { | 
| 234 | 234 | |
| 235 | 235 | // Courses page | 
| 236 | -	    $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ),  __('Courses', 'woothemes-sensei'), '' ); | |
| 237 | - Sensei()->settings->set( 'course_page', $new_course_page_id ); | |
| 236 | +		$new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ),  __('Courses', 'woothemes-sensei'), '' ); | |
| 237 | + Sensei()->settings->set( 'course_page', $new_course_page_id ); | |
| 238 | 238 | |
| 239 | - // User Dashboard page | |
| 240 | -	    $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); | |
| 241 | - Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); | |
| 239 | + // User Dashboard page | |
| 240 | +		$new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); | |
| 241 | + Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); | |
| 242 | 242 | |
| 243 | 243 | } // End create_pages() | 
| 244 | 244 | |
| @@ -259,8 +259,8 @@ discard block | ||
| 259 | 259 | wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); | 
| 260 | 260 | wp_enqueue_style( 'woothemes-sensei-global' ); | 
| 261 | 261 | |
| 262 | - // Select 2 styles | |
| 263 | - wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); | |
| 262 | + // Select 2 styles | |
| 263 | + wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); | |
| 264 | 264 | |
| 265 | 265 | // Test for Write Panel Pages | 
| 266 | 266 |  		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 ) ) ) { | 
| @@ -273,32 +273,32 @@ discard block | ||
| 273 | 273 | } // End admin_styles_global() | 
| 274 | 274 | |
| 275 | 275 | |
| 276 | - /** | |
| 277 | - * Globally register all scripts needed in admin. | |
| 278 | - * | |
| 279 | - * The script users should enqueue the script when needed. | |
| 280 | - * | |
| 281 | - * @since 1.8.2 | |
| 282 | - * @access public | |
| 283 | - */ | |
| 284 | -    public function register_scripts( $hook ){ | |
| 276 | + /** | |
| 277 | + * Globally register all scripts needed in admin. | |
| 278 | + * | |
| 279 | + * The script users should enqueue the script when needed. | |
| 280 | + * | |
| 281 | + * @since 1.8.2 | |
| 282 | + * @access public | |
| 283 | + */ | |
| 284 | +	public function register_scripts( $hook ){ | |
| 285 | 285 | |
| 286 | - $screen = get_current_screen(); | |
| 286 | + $screen = get_current_screen(); | |
| 287 | 287 | |
| 288 | - // Allow developers to load non-minified versions of scripts | |
| 289 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 288 | + // Allow developers to load non-minified versions of scripts | |
| 289 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 290 | 290 | |
| 291 | - // Select2 script used to enhance all select boxes | |
| 292 | - wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); | |
| 291 | + // Select2 script used to enhance all select boxes | |
| 292 | + wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); | |
| 293 | 293 | |
| 294 | - // load edit module scripts | |
| 295 | -        if( 'edit-module' ==  $screen->id ){ | |
| 294 | + // load edit module scripts | |
| 295 | +		if( 'edit-module' ==  $screen->id ){ | |
| 296 | 296 | |
| 297 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); | |
| 297 | + wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); | |
| 298 | 298 | |
| 299 | - } | |
| 299 | + } | |
| 300 | 300 | |
| 301 | - } | |
| 301 | + } | |
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | /** | 
| @@ -308,7 +308,7 @@ discard block | ||
| 308 | 308 | * @return void | 
| 309 | 309 | */ | 
| 310 | 310 |  	function admin_install_notice() { | 
| 311 | - ?> | |
| 311 | + ?> | |
| 312 | 312 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 313 | 313 | |
| 314 | 314 | <p> | 
| @@ -343,7 +343,7 @@ discard block | ||
| 343 | 343 | * @return void | 
| 344 | 344 | */ | 
| 345 | 345 |  	function admin_installed_notice() { | 
| 346 | - ?> | |
| 346 | + ?> | |
| 347 | 347 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 348 | 348 | |
| 349 | 349 | <p> | 
| @@ -371,8 +371,8 @@ discard block | ||
| 371 | 371 | </div> | 
| 372 | 372 | <?php | 
| 373 | 373 | |
| 374 | - // Set installed option | |
| 375 | -	    update_option('sensei_installed', 0); | |
| 374 | + // Set installed option | |
| 375 | +		update_option('sensei_installed', 0); | |
| 376 | 376 | } // End admin_installed_notice() | 
| 377 | 377 | |
| 378 | 378 | |
| @@ -404,21 +404,21 @@ discard block | ||
| 404 | 404 |  	function admin_notices_styles() { | 
| 405 | 405 | |
| 406 | 406 | // Installed notices | 
| 407 | -	    if ( 1 == get_option( 'sensei_installed' ) ) { | |
| 407 | +		if ( 1 == get_option( 'sensei_installed' ) ) { | |
| 408 | 408 | |
| 409 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); | |
| 409 | + wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); | |
| 410 | 410 | |
| 411 | -	    	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'])) { | |
| 412 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); | |
| 413 | -	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { | |
| 414 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); | |
| 415 | - } // End If Statement | |
| 411 | +			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'])) { | |
| 412 | + add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); | |
| 413 | +			} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { | |
| 414 | + add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); | |
| 415 | + } // End If Statement | |
| 416 | 416 | |
| 417 | - } // End If Statement | |
| 417 | + } // End If Statement | |
| 418 | 418 | |
| 419 | -	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { | |
| 420 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); | |
| 421 | - } | |
| 419 | +		if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { | |
| 420 | + add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); | |
| 421 | + } | |
| 422 | 422 | |
| 423 | 423 | } // End admin_notices_styles() | 
| 424 | 424 | |
| @@ -534,30 +534,30 @@ discard block | ||
| 534 | 534 | */ | 
| 535 | 535 |  	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { | 
| 536 | 536 | |
| 537 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); | |
| 538 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); | |
| 537 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); | |
| 538 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); | |
| 539 | 539 | |
| 540 | - // duplicate the generic wp post information | |
| 540 | + // duplicate the generic wp post information | |
| 541 | 541 | $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); | 
| 542 | 542 | |
| 543 | 543 | //update the new lesson data | 
| 544 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); | |
| 544 | + add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); | |
| 545 | 545 | |
| 546 | 546 | //update the new quiz data | 
| 547 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); | |
| 548 | - wp_update_post( | |
| 549 | - array( | |
| 550 | - 'ID' => $new_quiz->ID, | |
| 551 | - 'post_parent' => $new_lesson_id | |
| 552 | - ) | |
| 553 | - ); | |
| 547 | + add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); | |
| 548 | + wp_update_post( | |
| 549 | + array( | |
| 550 | + 'ID' => $new_quiz->ID, | |
| 551 | + 'post_parent' => $new_lesson_id | |
| 552 | + ) | |
| 553 | + ); | |
| 554 | 554 | |
| 555 | 555 |  		foreach( $old_quiz_questions as $question ) { | 
| 556 | 556 | |
| 557 | 557 | // copy the question order over to the new quiz | 
| 558 | 558 | $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); | 
| 559 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); | |
| 560 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); | |
| 559 | + $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); | |
| 560 | + add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); | |
| 561 | 561 | |
| 562 | 562 | // Add question to quiz | 
| 563 | 563 | add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); | 
| @@ -879,21 +879,21 @@ discard block | ||
| 879 | 879 | break; | 
| 880 | 880 | |
| 881 | 881 | case 'checkbox': | 
| 882 | - //backwards compatibility | |
| 883 | -                                    if( empty( $data ) || 'on' == $data ){ | |
| 884 | - $checked_value = 'on'; | |
| 885 | -                                    }elseif( 'yes' == $data  ) { | |
| 882 | + //backwards compatibility | |
| 883 | +									if( empty( $data ) || 'on' == $data ){ | |
| 884 | + $checked_value = 'on'; | |
| 885 | +									}elseif( 'yes' == $data  ) { | |
| 886 | 886 | |
| 887 | - $checked_value = 'yes'; | |
| 887 | + $checked_value = 'yes'; | |
| 888 | 888 | |
| 889 | -                                    }elseif( 'auto' == $data  ) { | |
| 889 | +									}elseif( 'auto' == $data  ) { | |
| 890 | 890 | |
| 891 | - $checked_value = 'auto'; | |
| 891 | + $checked_value = 'auto'; | |
| 892 | 892 | |
| 893 | -                                    } else { | |
| 894 | - $checked_value = 1; | |
| 895 | - $data = intval( $data ); | |
| 896 | - } | |
| 893 | +									} else { | |
| 894 | + $checked_value = 1; | |
| 895 | + $data = intval( $data ); | |
| 896 | + } | |
| 897 | 897 | $checked = checked( $checked_value, $data, false ); | 
| 898 | 898 | $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; | 
| 899 | 899 | break; | 
| @@ -997,26 +997,26 @@ discard block | ||
| 997 | 997 | |
| 998 | 998 |  		if( 0 < count( $courses ) ) { | 
| 999 | 999 | |
| 1000 | - // order the courses as set by the users | |
| 1001 | - $all_course_ids = array(); | |
| 1002 | -            foreach( $courses as $course ){ | |
| 1000 | + // order the courses as set by the users | |
| 1001 | + $all_course_ids = array(); | |
| 1002 | +			foreach( $courses as $course ){ | |
| 1003 | 1003 | |
| 1004 | - $all_course_ids[] = (string)$course->ID; | |
| 1004 | + $all_course_ids[] = (string)$course->ID; | |
| 1005 | 1005 | |
| 1006 | - } | |
| 1007 | - $order_string = $this->get_course_order(); | |
| 1006 | + } | |
| 1007 | + $order_string = $this->get_course_order(); | |
| 1008 | 1008 | |
| 1009 | -            if( !empty( $order_string ) ){ | |
| 1010 | -                $ordered_course_ids = explode(',' , $order_string ); | |
| 1011 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); | |
| 1012 | - } | |
| 1009 | +			if( !empty( $order_string ) ){ | |
| 1010 | +				$ordered_course_ids = explode(',' , $order_string ); | |
| 1011 | + $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); | |
| 1012 | + } | |
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | 1015 | $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; | 
| 1016 | 1016 | $html .= '<ul class="sortable-course-list">' . "\n"; | 
| 1017 | 1017 | $count = 0; | 
| 1018 | 1018 |  			foreach ( $all_course_ids as $course_id ) { | 
| 1019 | - $course = get_post( $course_id ); | |
| 1019 | + $course = get_post( $course_id ); | |
| 1020 | 1020 | $count++; | 
| 1021 | 1021 | $class = 'course'; | 
| 1022 | 1022 |  				if ( $count == 1 ) { $class .= ' first'; } | 
| @@ -1131,73 +1131,73 @@ discard block | ||
| 1131 | 1131 | |
| 1132 | 1132 | $displayed_lessons = array(); | 
| 1133 | 1133 | |
| 1134 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); | |
| 1135 | - | |
| 1136 | -                foreach( $modules as $module ) { | |
| 1137 | - | |
| 1138 | - $args = array( | |
| 1139 | - 'post_type' => 'lesson', | |
| 1140 | - 'post_status' => 'publish', | |
| 1141 | - 'posts_per_page' => -1, | |
| 1142 | - 'meta_query' => array( | |
| 1143 | - array( | |
| 1144 | - 'key' => '_lesson_course', | |
| 1145 | - 'value' => intval( $course_id ), | |
| 1146 | - 'compare' => '=' | |
| 1147 | - ) | |
| 1148 | - ), | |
| 1149 | - 'tax_query' => array( | |
| 1150 | - array( | |
| 1151 | - 'taxonomy' => Sensei()->modules->taxonomy, | |
| 1152 | - 'field' => 'id', | |
| 1153 | - 'terms' => intval( $module->term_id ) | |
| 1154 | - ) | |
| 1155 | - ), | |
| 1156 | - 'meta_key' => '_order_module_' . $module->term_id, | |
| 1157 | - 'orderby' => 'meta_value_num date', | |
| 1158 | - 'order' => 'ASC', | |
| 1159 | - 'suppress_filters' => 0 | |
| 1160 | - ); | |
| 1161 | - | |
| 1162 | - $lessons = get_posts( $args ); | |
| 1163 | - | |
| 1164 | -                    if( count( $lessons ) > 0 ) { | |
| 1165 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; | |
| 1166 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; | |
| 1167 | - | |
| 1168 | - $count = 0; | |
| 1169 | -                        foreach( $lessons as $lesson ) { | |
| 1170 | - $count++; | |
| 1171 | - $class = 'lesson'; | |
| 1172 | -                            if ( $count == 1 ) { $class .= ' first'; } | |
| 1173 | -                            if ( $count == count( $lesson ) ) { $class .= ' last'; } | |
| 1174 | -                            if ( $count % 2 != 0 ) { | |
| 1175 | - $class .= ' alternate'; | |
| 1176 | - } | |
| 1177 | - | |
| 1178 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; | |
| 1179 | - | |
| 1180 | - $displayed_lessons[] = $lesson->ID; | |
| 1181 | - } | |
| 1182 | - | |
| 1183 | - $html .= '</ul>' . "\n"; | |
| 1184 | - | |
| 1185 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; | |
| 1186 | - } | |
| 1187 | - } | |
| 1188 | - | |
| 1189 | - | |
| 1190 | - $lessons = Sensei()->course->course_lessons( $course_id ); | |
| 1134 | + $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); | |
| 1135 | + | |
| 1136 | +				foreach( $modules as $module ) { | |
| 1137 | + | |
| 1138 | + $args = array( | |
| 1139 | + 'post_type' => 'lesson', | |
| 1140 | + 'post_status' => 'publish', | |
| 1141 | + 'posts_per_page' => -1, | |
| 1142 | + 'meta_query' => array( | |
| 1143 | + array( | |
| 1144 | + 'key' => '_lesson_course', | |
| 1145 | + 'value' => intval( $course_id ), | |
| 1146 | + 'compare' => '=' | |
| 1147 | + ) | |
| 1148 | + ), | |
| 1149 | + 'tax_query' => array( | |
| 1150 | + array( | |
| 1151 | + 'taxonomy' => Sensei()->modules->taxonomy, | |
| 1152 | + 'field' => 'id', | |
| 1153 | + 'terms' => intval( $module->term_id ) | |
| 1154 | + ) | |
| 1155 | + ), | |
| 1156 | + 'meta_key' => '_order_module_' . $module->term_id, | |
| 1157 | + 'orderby' => 'meta_value_num date', | |
| 1158 | + 'order' => 'ASC', | |
| 1159 | + 'suppress_filters' => 0 | |
| 1160 | + ); | |
| 1161 | + | |
| 1162 | + $lessons = get_posts( $args ); | |
| 1163 | + | |
| 1164 | +					if( count( $lessons ) > 0 ) { | |
| 1165 | + $html .= '<h3>' . $module->name . '</h3>' . "\n"; | |
| 1166 | + $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; | |
| 1167 | + | |
| 1168 | + $count = 0; | |
| 1169 | +						foreach( $lessons as $lesson ) { | |
| 1170 | + $count++; | |
| 1171 | + $class = 'lesson'; | |
| 1172 | +							if ( $count == 1 ) { $class .= ' first'; } | |
| 1173 | +							if ( $count == count( $lesson ) ) { $class .= ' last'; } | |
| 1174 | +							if ( $count % 2 != 0 ) { | |
| 1175 | + $class .= ' alternate'; | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; | |
| 1179 | + | |
| 1180 | + $displayed_lessons[] = $lesson->ID; | |
| 1181 | + } | |
| 1182 | + | |
| 1183 | + $html .= '</ul>' . "\n"; | |
| 1184 | + | |
| 1185 | + $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; | |
| 1186 | + } | |
| 1187 | + } | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + $lessons = Sensei()->course->course_lessons( $course_id ); | |
| 1191 | 1191 | |
| 1192 | 1192 |  				if( 0 < count( $lessons ) ) { | 
| 1193 | 1193 | |
| 1194 | - //get module term ids, will be used to exclude lessons | |
| 1195 | - $module_items_ids = array(); | |
| 1196 | -                    if( ! empty( $modules ) ) { | |
| 1197 | -                        foreach ($modules as $module) { | |
| 1198 | - $module_items_ids[] = $module->term_id; | |
| 1199 | - } | |
| 1200 | - } | |
| 1194 | + //get module term ids, will be used to exclude lessons | |
| 1195 | + $module_items_ids = array(); | |
| 1196 | +					if( ! empty( $modules ) ) { | |
| 1197 | +						foreach ($modules as $module) { | |
| 1198 | + $module_items_ids[] = $module->term_id; | |
| 1199 | + } | |
| 1200 | + } | |
| 1201 | 1201 | |
| 1202 | 1202 |  					if( 0 < count( $displayed_lessons ) ) { | 
| 1203 | 1203 | $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; | 
| @@ -1207,13 +1207,13 @@ discard block | ||
| 1207 | 1207 | $count = 0; | 
| 1208 | 1208 |  					foreach ( $lessons as $lesson ) { | 
| 1209 | 1209 | |
| 1210 | - // if lesson belongs to one fo the course modules then exclude it here | |
| 1211 | - // as it is listed above | |
| 1212 | -                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){ | |
| 1210 | + // if lesson belongs to one fo the course modules then exclude it here | |
| 1211 | + // as it is listed above | |
| 1212 | +						if( has_term( $module_items_ids, 'module', $lesson->ID )  ){ | |
| 1213 | 1213 | |
| 1214 | - continue; | |
| 1214 | + continue; | |
| 1215 | 1215 | |
| 1216 | - } | |
| 1216 | + } | |
| 1217 | 1217 | |
| 1218 | 1218 | $count++; | 
| 1219 | 1219 | $class = 'lesson'; | 
| @@ -1257,28 +1257,28 @@ discard block | ||
| 1257 | 1257 | |
| 1258 | 1258 |  		if( $course_id ) { | 
| 1259 | 1259 | |
| 1260 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); | |
| 1260 | + $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); | |
| 1261 | 1261 | |
| 1262 | -            foreach( $modules as $module ) { | |
| 1262 | +			foreach( $modules as $module ) { | |
| 1263 | 1263 | |
| 1264 | 1264 | |
| 1265 | - if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) | |
| 1266 | -                    && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { | |
| 1265 | + if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) | |
| 1266 | +					&& $_POST[ 'lesson-order-module-' . $module->term_id ] ) { | |
| 1267 | 1267 | |
| 1268 | - $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); | |
| 1269 | - $i = 1; | |
| 1270 | -                    foreach( $order as $lesson_id ) { | |
| 1268 | + $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); | |
| 1269 | + $i = 1; | |
| 1270 | +					foreach( $order as $lesson_id ) { | |
| 1271 | 1271 | |
| 1272 | -                        if( $lesson_id ) { | |
| 1273 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); | |
| 1274 | - ++$i; | |
| 1275 | - } | |
| 1272 | +						if( $lesson_id ) { | |
| 1273 | + update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); | |
| 1274 | + ++$i; | |
| 1275 | + } | |
| 1276 | 1276 | |
| 1277 | - }// end for each order | |
| 1277 | + }// end for each order | |
| 1278 | 1278 | |
| 1279 | - }// end if | |
| 1279 | + }// end if | |
| 1280 | 1280 | |
| 1281 | - } // end for each modules | |
| 1281 | + } // end for each modules | |
| 1282 | 1282 | |
| 1283 | 1283 | |
| 1284 | 1284 |  			if( $order_string ) { | 
| @@ -1361,47 +1361,47 @@ discard block | ||
| 1361 | 1361 | |
| 1362 | 1362 | /** | 
| 1363 | 1363 | * Adding admin notice if the current | 
| 1364 | - * installed theme is not compatible | |
| 1365 | - * | |
| 1364 | + * installed theme is not compatible | |
| 1365 | + * | |
| 1366 | 1366 | * @return void | 
| 1367 | 1367 | */ | 
| 1368 | 1368 |  	public function theme_compatibility_notices() { | 
| 1369 | 1369 | |
| 1370 | -        if( isset( $_GET['sensei_hide_notice'] ) ) { | |
| 1371 | -        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { | |
| 1370 | +		if( isset( $_GET['sensei_hide_notice'] ) ) { | |
| 1371 | +			switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { | |
| 1372 | 1372 | case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; | 
| 1373 | 1373 | case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; | 
| 1374 | 1374 | } | 
| 1375 | - } | |
| 1375 | + } | |
| 1376 | 1376 | |
| 1377 | - // white list templates that are already support by default and do not show notice for them | |
| 1378 | - $template = get_option( 'template' ); | |
| 1377 | + // white list templates that are already support by default and do not show notice for them | |
| 1378 | + $template = get_option( 'template' ); | |
| 1379 | 1379 | |
| 1380 | - $white_list = array( 'twentyeleven', | |
| 1381 | - 'twentytwelve', | |
| 1382 | - 'twentyfourteen', | |
| 1383 | - 'twentyfifteen', | |
| 1384 | - 'twentysixteen', | |
| 1385 | - 'storefront', | |
| 1386 | - ); | |
| 1380 | + $white_list = array( 'twentyeleven', | |
| 1381 | + 'twentytwelve', | |
| 1382 | + 'twentyfourteen', | |
| 1383 | + 'twentyfifteen', | |
| 1384 | + 'twentysixteen', | |
| 1385 | + 'storefront', | |
| 1386 | + ); | |
| 1387 | 1387 | |
| 1388 | -        if ( in_array( $template, $white_list ) ) { | |
| 1388 | +		if ( in_array( $template, $white_list ) ) { | |
| 1389 | 1389 | |
| 1390 | - return; | |
| 1390 | + return; | |
| 1391 | 1391 | |
| 1392 | - } | |
| 1392 | + } | |
| 1393 | 1393 | |
| 1394 | - // don't show the notice if the user chose to hide it | |
| 1395 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); | |
| 1396 | -        if(  $hide_theme_check_notice ) { | |
| 1394 | + // don't show the notice if the user chose to hide it | |
| 1395 | + $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); | |
| 1396 | +		if(  $hide_theme_check_notice ) { | |
| 1397 | 1397 | |
| 1398 | - return; | |
| 1398 | + return; | |
| 1399 | 1399 | |
| 1400 | - } | |
| 1400 | + } | |
| 1401 | 1401 | |
| 1402 | - // show the notice for themes not supporting sensei | |
| 1403 | -	    if ( ! current_theme_supports( 'sensei' ) ) { | |
| 1404 | - ?> | |
| 1402 | + // show the notice for themes not supporting sensei | |
| 1403 | +		if ( ! current_theme_supports( 'sensei' ) ) { | |
| 1404 | + ?> | |
| 1405 | 1405 | |
| 1406 | 1406 | <div id="message" class="error sensei-message sensei-connect"> | 
| 1407 | 1407 | <p> | 
| @@ -1437,7 +1437,7 @@ discard block | ||
| 1437 | 1437 |  	public function reset_theme_check_notices() { | 
| 1438 | 1438 | global $current_user; | 
| 1439 | 1439 | wp_get_current_user(); | 
| 1440 | - $user_id = $current_user->ID; | |
| 1440 | + $user_id = $current_user->ID; | |
| 1441 | 1441 | |
| 1442 | 1442 | delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); | 
| 1443 | 1443 | } | 
| @@ -1457,62 +1457,62 @@ discard block | ||
| 1457 | 1457 | return $prevent_access; | 
| 1458 | 1458 | } | 
| 1459 | 1459 | |
| 1460 | - /** | |
| 1461 | - * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args | |
| 1462 | - * on the sensei settings page. | |
| 1463 | - * | |
| 1464 | - * The function | |
| 1465 | - * | |
| 1466 | - * @since 1.8.7 | |
| 1467 | - */ | |
| 1468 | -    public  static function install_pages(){ | |
| 1460 | + /** | |
| 1461 | + * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args | |
| 1462 | + * on the sensei settings page. | |
| 1463 | + * | |
| 1464 | + * The function | |
| 1465 | + * | |
| 1466 | + * @since 1.8.7 | |
| 1467 | + */ | |
| 1468 | +	public  static function install_pages(){ | |
| 1469 | 1469 | |
| 1470 | - // only fire on the settings page | |
| 1471 | - if( ! isset( $_GET['page'] ) | |
| 1472 | - || 'woothemes-sensei-settings' != $_GET['page'] | |
| 1473 | -            || 1 == get_option('skip_install_sensei_pages') ){ | |
| 1470 | + // only fire on the settings page | |
| 1471 | + if( ! isset( $_GET['page'] ) | |
| 1472 | + || 'woothemes-sensei-settings' != $_GET['page'] | |
| 1473 | +			|| 1 == get_option('skip_install_sensei_pages') ){ | |
| 1474 | 1474 | |
| 1475 | - return; | |
| 1475 | + return; | |
| 1476 | 1476 | |
| 1477 | - } | |
| 1477 | + } | |
| 1478 | 1478 | |
| 1479 | - // Install/page installer | |
| 1480 | - $install_complete = false; | |
| 1479 | + // Install/page installer | |
| 1480 | + $install_complete = false; | |
| 1481 | 1481 | |
| 1482 | - // Add pages button | |
| 1483 | - $settings_url = ''; | |
| 1484 | -        if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) { | |
| 1482 | + // Add pages button | |
| 1483 | + $settings_url = ''; | |
| 1484 | +		if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) { | |
| 1485 | 1485 | |
| 1486 | - Sensei()->admin->create_pages(); | |
| 1486 | + Sensei()->admin->create_pages(); | |
| 1487 | 1487 | |
| 1488 | -            update_option('skip_install_sensei_pages', 1); | |
| 1488 | +			update_option('skip_install_sensei_pages', 1); | |
| 1489 | 1489 | |
| 1490 | - $install_complete = true; | |
| 1491 | -            $settings_url = remove_query_arg('install_sensei_pages'); | |
| 1490 | + $install_complete = true; | |
| 1491 | +			$settings_url = remove_query_arg('install_sensei_pages'); | |
| 1492 | 1492 | |
| 1493 | - // Skip button | |
| 1494 | -        } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) { | |
| 1493 | + // Skip button | |
| 1494 | +		} elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) { | |
| 1495 | 1495 | |
| 1496 | -            update_option('skip_install_sensei_pages', 1); | |
| 1497 | - $install_complete = true; | |
| 1498 | -            $settings_url = remove_query_arg('skip_install_sensei_pages'); | |
| 1496 | +			update_option('skip_install_sensei_pages', 1); | |
| 1497 | + $install_complete = true; | |
| 1498 | +			$settings_url = remove_query_arg('skip_install_sensei_pages'); | |
| 1499 | 1499 | |
| 1500 | - } | |
| 1500 | + } | |
| 1501 | 1501 | |
| 1502 | -        if ($install_complete) { | |
| 1502 | +		if ($install_complete) { | |
| 1503 | 1503 | |
| 1504 | - // refresh the rewrite rules on init | |
| 1505 | -            update_option('sensei_flush_rewrite_rules', '1'); | |
| 1504 | + // refresh the rewrite rules on init | |
| 1505 | +			update_option('sensei_flush_rewrite_rules', '1'); | |
| 1506 | 1506 | |
| 1507 | - // Set installed option | |
| 1508 | -            update_option('sensei_installed', 0); | |
| 1507 | + // Set installed option | |
| 1508 | +			update_option('sensei_installed', 0); | |
| 1509 | 1509 | |
| 1510 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); | |
| 1511 | - wp_redirect( $complete_url ); | |
| 1510 | + $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); | |
| 1511 | + wp_redirect( $complete_url ); | |
| 1512 | 1512 | |
| 1513 | - } | |
| 1513 | + } | |
| 1514 | 1514 | |
| 1515 | - }// end install_pages | |
| 1515 | + }// end install_pages | |
| 1516 | 1516 | |
| 1517 | 1517 | } // End Class | 
| 1518 | 1518 | |
| @@ -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,24 +128,24 @@ discard block | ||
| 128 | 128 | |
| 129 | 129 | $screen = get_current_screen(); | 
| 130 | 130 | |
| 131 | -		if ( $screen->base == 'post' && $post_type == 'course' ) { | |
| 131 | +		if ($screen->base == 'post' && $post_type == 'course') { | |
| 132 | 132 | |
| 133 | - $parent_file = 'edit.php?post_type=course'; | |
| 133 | + $parent_file = 'edit.php?post_type=course'; | |
| 134 | 134 | |
| 135 | -		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) { | |
| 135 | +		} elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') { | |
| 136 | 136 | |
| 137 | 137 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; | 
| 138 | 138 | $parent_file = 'edit.php?post_type=course'; | 
| 139 | 139 | |
| 140 | -        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { | |
| 140 | +        } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') { | |
| 141 | 141 | |
| 142 | 142 | $submenu_file = 'edit-tags.php?taxonomy=module'; | 
| 143 | 143 | $parent_file = 'edit.php?post_type=course'; | 
| 144 | 144 | |
| 145 | -		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { | |
| 145 | +		} elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) { | |
| 146 | 146 | |
| 147 | 147 | $submenu_file = 'edit.php?post_type=sensei_message'; | 
| 148 | - $parent_file = 'sensei'; | |
| 148 | + $parent_file = 'sensei'; | |
| 149 | 149 | |
| 150 | 150 | } | 
| 151 | 151 | } | 
| @@ -156,8 +156,8 @@ discard block | ||
| 156 | 156 | * @return void | 
| 157 | 157 | */ | 
| 158 | 158 |  	public function page_redirect() { | 
| 159 | -		if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) { | |
| 160 | - wp_safe_redirect( 'admin.php?page=sensei_analysis' ); | |
| 159 | +		if (isset($_GET['page']) && $_GET['page'] == 'sensei') { | |
| 160 | +			wp_safe_redirect('admin.php?page=sensei_analysis'); | |
| 161 | 161 | exit; | 
| 162 | 162 | } | 
| 163 | 163 | } | 
| @@ -172,11 +172,11 @@ discard block | ||
| 172 | 172 | */ | 
| 173 | 173 |  	function install_pages_output() { | 
| 174 | 174 | |
| 175 | -        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { | |
| 175 | +        if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { | |
| 176 | 176 | |
| 177 | 177 | ?> | 
| 178 | 178 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 179 | - <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> | |
| 179 | +                <p><?php _e('<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei'); ?></p> | |
| 180 | 180 | <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> | 
| 181 | 181 |                  <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> | 
| 182 | 182 | </div> | 
| @@ -198,11 +198,11 @@ discard block | ||
| 198 | 198 | * @param int $post_parent (default: 0) | 
| 199 | 199 | * @return integer $page_id | 
| 200 | 200 | */ | 
| 201 | -	function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) { | |
| 201 | +	function create_page($slug, $page_title = '', $page_content = '', $post_parent = 0) { | |
| 202 | 202 | global $wpdb; | 
| 203 | 203 | |
| 204 | - $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); | |
| 205 | - if ( $page_id ) : | |
| 204 | +        $page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug)); | |
| 205 | + if ($page_id) : | |
| 206 | 206 | return $page_id; | 
| 207 | 207 | endif; | 
| 208 | 208 | |
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | 'comment_status' => 'closed' | 
| 218 | 218 | ); | 
| 219 | 219 | |
| 220 | - $page_id = wp_insert_post( $page_data ); | |
| 220 | + $page_id = wp_insert_post($page_data); | |
| 221 | 221 | |
| 222 | 222 | return $page_id; | 
| 223 | 223 | |
| @@ -233,12 +233,12 @@ discard block | ||
| 233 | 233 |  	function create_pages() { | 
| 234 | 234 | |
| 235 | 235 | // Courses page | 
| 236 | -	    $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ),  __('Courses', 'woothemes-sensei'), '' ); | |
| 237 | - Sensei()->settings->set( 'course_page', $new_course_page_id ); | |
| 236 | +	    $new_course_page_id = $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), __('Courses', 'woothemes-sensei'), ''); | |
| 237 | +        Sensei()->settings->set('course_page', $new_course_page_id); | |
| 238 | 238 | |
| 239 | 239 | // User Dashboard page | 
| 240 | -	    $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); | |
| 241 | - Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); | |
| 240 | +	    $new_my_course_page_id = $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]'); | |
| 241 | +        Sensei()->settings->set('my_course_page', $new_my_course_page_id); | |
| 242 | 242 | |
| 243 | 243 | } // End create_pages() | 
| 244 | 244 | |
| @@ -248,25 +248,25 @@ discard block | ||
| 248 | 248 | * @since 1.0.0 | 
| 249 | 249 | * @return void | 
| 250 | 250 | */ | 
| 251 | -	public function admin_styles_global ( $hook ) { | |
| 251 | +	public function admin_styles_global($hook) { | |
| 252 | 252 | global $post_type; | 
| 253 | 253 | |
| 254 | - $allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) ); | |
| 255 | - $allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) ); | |
| 256 | - $allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) ); | |
| 254 | +		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question')); | |
| 255 | +		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php')); | |
| 256 | +		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order')); | |
| 257 | 257 | |
| 258 | 258 | // Global Styles for icons and menu items | 
| 259 | - wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); | |
| 260 | - wp_enqueue_style( 'woothemes-sensei-global' ); | |
| 259 | +		wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen'); | |
| 260 | +		wp_enqueue_style('woothemes-sensei-global'); | |
| 261 | 261 | |
| 262 | 262 | // Select 2 styles | 
| 263 | - wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); | |
| 263 | +        wp_enqueue_style('sensei-core-select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen'); | |
| 264 | 264 | |
| 265 | 265 | // Test for Write Panel Pages | 
| 266 | -		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 ) ) ) { | |
| 266 | +		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))) { | |
| 267 | 267 | |
| 268 | - wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' ); | |
| 269 | - wp_enqueue_style( 'woothemes-sensei-admin-custom' ); | |
| 268 | +			wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen'); | |
| 269 | +			wp_enqueue_style('woothemes-sensei-admin-custom'); | |
| 270 | 270 | |
| 271 | 271 | } | 
| 272 | 272 | |
| @@ -281,20 +281,20 @@ discard block | ||
| 281 | 281 | * @since 1.8.2 | 
| 282 | 282 | * @access public | 
| 283 | 283 | */ | 
| 284 | -    public function register_scripts( $hook ){ | |
| 284 | +    public function register_scripts($hook) { | |
| 285 | 285 | |
| 286 | 286 | $screen = get_current_screen(); | 
| 287 | 287 | |
| 288 | 288 | // Allow developers to load non-minified versions of scripts | 
| 289 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 289 | +        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; | |
| 290 | 290 | |
| 291 | 291 | // Select2 script used to enhance all select boxes | 
| 292 | - wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); | |
| 292 | +        wp_register_script('sensei-core-select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version); | |
| 293 | 293 | |
| 294 | 294 | // load edit module scripts | 
| 295 | -        if( 'edit-module' ==  $screen->id ){ | |
| 295 | +        if ('edit-module' == $screen->id) { | |
| 296 | 296 | |
| 297 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); | |
| 297 | +            wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true); | |
| 298 | 298 | |
| 299 | 299 | } | 
| 300 | 300 | |
| @@ -312,19 +312,19 @@ discard block | ||
| 312 | 312 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 313 | 313 | |
| 314 | 314 | <p> | 
| 315 | - <?php _e( '<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?> | |
| 315 | +                <?php _e('<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei'); ?> | |
| 316 | 316 | </p> | 
| 317 | 317 | |
| 318 | 318 | <p class="submit"> | 
| 319 | 319 | |
| 320 | -                <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>" | |
| 320 | +                <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>" | |
| 321 | 321 | class="button-primary"> | 
| 322 | 322 | |
| 323 | - <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?> | |
| 323 | +                    <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?> | |
| 324 | 324 | |
| 325 | 325 | </a> | 
| 326 | 326 | |
| 327 | -                <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' ) ) ); ?>"> | |
| 327 | +                <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'))); ?>"> | |
| 328 | 328 | |
| 329 | 329 |                      <?php _e('Skip setup', 'woothemes-sensei'); ?> | 
| 330 | 330 | |
| @@ -347,11 +347,11 @@ discard block | ||
| 347 | 347 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 348 | 348 | |
| 349 | 349 | <p> | 
| 350 | - <?php _e( '<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei' ); ?> | |
| 350 | +                <?php _e('<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei'); ?> | |
| 351 | 351 | </p> | 
| 352 | 352 | |
| 353 | 353 | <p class="submit"> | 
| 354 | -                <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/"> | |
| 354 | +                <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/"> | |
| 355 | 355 |                      <?php _e('Documentation', 'woothemes-sensei'); ?> | 
| 356 | 356 | </a> | 
| 357 | 357 | </p> | 
| @@ -384,11 +384,11 @@ discard block | ||
| 384 | 384 |  	public function language_pack_install_notice() { | 
| 385 | 385 | ?> | 
| 386 | 386 | <div id="message" class="updated sensei-message sensei-connect"> | 
| 387 | - <p><?php _e( '<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei' ); ?><p> | |
| 387 | +				<p><?php _e('<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei'); ?><p> | |
| 388 | 388 | |
| 389 | 389 | <p class="submit"> | 
| 390 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a> | |
| 391 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a> | |
| 390 | +					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a> | |
| 391 | +					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a> | |
| 392 | 392 | </p> | 
| 393 | 393 | </div> | 
| 394 | 394 | <?php | 
| @@ -404,20 +404,20 @@ discard block | ||
| 404 | 404 |  	function admin_notices_styles() { | 
| 405 | 405 | |
| 406 | 406 | // Installed notices | 
| 407 | -	    if ( 1 == get_option( 'sensei_installed' ) ) { | |
| 407 | +	    if (1 == get_option('sensei_installed')) { | |
| 408 | 408 | |
| 409 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); | |
| 409 | +	    	wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version); | |
| 410 | 410 | |
| 411 | -	    	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'])) { | |
| 412 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); | |
| 413 | -	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { | |
| 414 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); | |
| 411 | +	    	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'])) { | |
| 412 | +	    		add_action('admin_notices', array($this, 'admin_install_notice')); | |
| 413 | +	    	} elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') { | |
| 414 | +	    		add_action('admin_notices', array($this, 'admin_installed_notice')); | |
| 415 | 415 | } // End If Statement | 
| 416 | 416 | |
| 417 | 417 | } // End If Statement | 
| 418 | 418 | |
| 419 | -	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { | |
| 420 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); | |
| 419 | +	    if (Sensei_Language_Pack_Manager::has_language_pack_available()) { | |
| 420 | +	    	add_action('admin_notices', array($this, 'language_pack_install_notice')); | |
| 421 | 421 | } | 
| 422 | 422 | |
| 423 | 423 | } // End admin_notices_styles() | 
| @@ -428,17 +428,17 @@ discard block | ||
| 428 | 428 | * @param object $post Current post | 
| 429 | 429 | * @return array Modified actions | 
| 430 | 430 | */ | 
| 431 | -	public function duplicate_action_link( $actions, $post ) { | |
| 432 | -		switch( $post->post_type ) { | |
| 431 | +	public function duplicate_action_link($actions, $post) { | |
| 432 | +		switch ($post->post_type) { | |
| 433 | 433 | case 'lesson': | 
| 434 | - $confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' ); | |
| 435 | -				$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>"; | |
| 434 | +				$confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei'); | |
| 435 | +				$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>"; | |
| 436 | 436 | break; | 
| 437 | 437 | |
| 438 | 438 | case 'course': | 
| 439 | - $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' ); | |
| 440 | -				$actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' .  __('Duplicate', 'woothemes-sensei' ) . '</a>'; | |
| 441 | -				$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>'; | |
| 439 | +				$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'); | |
| 440 | +				$actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>'; | |
| 441 | +				$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>'; | |
| 442 | 442 | break; | 
| 443 | 443 | } | 
| 444 | 444 | |
| @@ -451,17 +451,17 @@ discard block | ||
| 451 | 451 | * @param boolean $with_lessons Include lessons or not | 
| 452 | 452 | * @return string Duplication link | 
| 453 | 453 | */ | 
| 454 | -	private function get_duplicate_link( $post_id = 0, $with_lessons = false ) { | |
| 454 | +	private function get_duplicate_link($post_id = 0, $with_lessons = false) { | |
| 455 | 455 | |
| 456 | - $post = get_post( $post_id ); | |
| 456 | + $post = get_post($post_id); | |
| 457 | 457 | |
| 458 | - $action = 'duplicate_' . $post->post_type; | |
| 458 | + $action = 'duplicate_'.$post->post_type; | |
| 459 | 459 | |
| 460 | -		if( 'course' == $post->post_type && $with_lessons ) { | |
| 460 | +		if ('course' == $post->post_type && $with_lessons) { | |
| 461 | 461 | $action .= '_with_lessons'; | 
| 462 | 462 | } | 
| 463 | 463 | |
| 464 | - return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id ); | |
| 464 | +		return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id); | |
| 465 | 465 | } | 
| 466 | 466 | |
| 467 | 467 | /** | 
| @@ -469,7 +469,7 @@ discard block | ||
| 469 | 469 | * @return void | 
| 470 | 470 | */ | 
| 471 | 471 |  	public function duplicate_lesson_action() { | 
| 472 | - $this->duplicate_content( 'lesson' ); | |
| 472 | +		$this->duplicate_content('lesson'); | |
| 473 | 473 | } | 
| 474 | 474 | |
| 475 | 475 | /** | 
| @@ -477,7 +477,7 @@ discard block | ||
| 477 | 477 | * @return void | 
| 478 | 478 | */ | 
| 479 | 479 |  	public function duplicate_course_action() { | 
| 480 | - $this->duplicate_content( 'course' ); | |
| 480 | +		$this->duplicate_content('course'); | |
| 481 | 481 | } | 
| 482 | 482 | |
| 483 | 483 | /** | 
| @@ -485,7 +485,7 @@ discard block | ||
| 485 | 485 | * @return void | 
| 486 | 486 | */ | 
| 487 | 487 |  	public function duplicate_course_with_lessons_action() { | 
| 488 | - $this->duplicate_content( 'course', true ); | |
| 488 | +		$this->duplicate_content('course', true); | |
| 489 | 489 | } | 
| 490 | 490 | |
| 491 | 491 | /** | 
| @@ -494,34 +494,34 @@ discard block | ||
| 494 | 494 | * @param boolean $with_lessons Include lessons or not | 
| 495 | 495 | * @return void | 
| 496 | 496 | */ | 
| 497 | -	private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) { | |
| 498 | -		if ( ! isset( $_GET['post'] ) ) { | |
| 499 | - wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type ); | |
| 497 | +	private function duplicate_content($post_type = 'lesson', $with_lessons = false) { | |
| 498 | +		if ( ! isset($_GET['post'])) { | |
| 499 | +			wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type); | |
| 500 | 500 | } | 
| 501 | 501 | |
| 502 | 502 | $post_id = $_GET['post']; | 
| 503 | - $post = get_post( $post_id ); | |
| 503 | + $post = get_post($post_id); | |
| 504 | 504 | |
| 505 | -		if( ! is_wp_error( $post ) ) { | |
| 505 | +		if ( ! is_wp_error($post)) { | |
| 506 | 506 | |
| 507 | - $new_post = $this->duplicate_post( $post ); | |
| 507 | + $new_post = $this->duplicate_post($post); | |
| 508 | 508 | |
| 509 | -			if( $new_post && ! is_wp_error( $new_post ) ) { | |
| 509 | +			if ($new_post && ! is_wp_error($new_post)) { | |
| 510 | 510 | |
| 511 | -				if( 'lesson' == $new_post->post_type ) { | |
| 512 | - $this->duplicate_lesson_quizzes( $post_id, $new_post->ID ); | |
| 511 | +				if ('lesson' == $new_post->post_type) { | |
| 512 | + $this->duplicate_lesson_quizzes($post_id, $new_post->ID); | |
| 513 | 513 | } | 
| 514 | 514 | |
| 515 | -				if( 'course' == $new_post->post_type && $with_lessons ) { | |
| 516 | - $this->duplicate_course_lessons( $post_id, $new_post->ID ); | |
| 515 | +				if ('course' == $new_post->post_type && $with_lessons) { | |
| 516 | + $this->duplicate_course_lessons($post_id, $new_post->ID); | |
| 517 | 517 | } | 
| 518 | 518 | |
| 519 | - $redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' ); | |
| 519 | +				$redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit'); | |
| 520 | 520 |  			} else { | 
| 521 | - $redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' ); | |
| 521 | +				$redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed'); | |
| 522 | 522 | } | 
| 523 | 523 | |
| 524 | - wp_safe_redirect( esc_url_raw( $redirect_url ) ); | |
| 524 | + wp_safe_redirect(esc_url_raw($redirect_url)); | |
| 525 | 525 | exit; | 
| 526 | 526 | } | 
| 527 | 527 | } | 
| @@ -532,19 +532,19 @@ discard block | ||
| 532 | 532 | * @param integer $new_lesson_id ID of duplicate lesson | 
| 533 | 533 | * @return void | 
| 534 | 534 | */ | 
| 535 | -	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { | |
| 535 | +	private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) { | |
| 536 | 536 | |
| 537 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); | |
| 538 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); | |
| 537 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id); | |
| 538 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id); | |
| 539 | 539 | |
| 540 | 540 | // duplicate the generic wp post information | 
| 541 | - $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); | |
| 541 | + $new_quiz = $this->duplicate_post(get_post($old_quiz_id), ''); | |
| 542 | 542 | |
| 543 | 543 | //update the new lesson data | 
| 544 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); | |
| 544 | + add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID); | |
| 545 | 545 | |
| 546 | 546 | //update the new quiz data | 
| 547 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); | |
| 547 | + add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id); | |
| 548 | 548 | wp_update_post( | 
| 549 | 549 | array( | 
| 550 | 550 | 'ID' => $new_quiz->ID, | 
| @@ -552,15 +552,15 @@ discard block | ||
| 552 | 552 | ) | 
| 553 | 553 | ); | 
| 554 | 554 | |
| 555 | -		foreach( $old_quiz_questions as $question ) { | |
| 555 | +		foreach ($old_quiz_questions as $question) { | |
| 556 | 556 | |
| 557 | 557 | // copy the question order over to the new quiz | 
| 558 | - $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); | |
| 559 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); | |
| 560 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); | |
| 558 | + $old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true); | |
| 559 | + $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order); | |
| 560 | + add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order); | |
| 561 | 561 | |
| 562 | 562 | // Add question to quiz | 
| 563 | - add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); | |
| 563 | + add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false); | |
| 564 | 564 | |
| 565 | 565 | } | 
| 566 | 566 | } | 
| @@ -571,7 +571,7 @@ discard block | ||
| 571 | 571 | * @param integer $new_course_id ID of duplicated course | 
| 572 | 572 | * @return void | 
| 573 | 573 | */ | 
| 574 | -	private function duplicate_course_lessons( $old_course_id, $new_course_id ) { | |
| 574 | +	private function duplicate_course_lessons($old_course_id, $new_course_id) { | |
| 575 | 575 | $lesson_args = array( | 
| 576 | 576 | 'post_type' => 'lesson', | 
| 577 | 577 | 'posts_per_page' => -1, | 
| @@ -579,13 +579,13 @@ discard block | ||
| 579 | 579 | 'meta_value' => $old_course_id, | 
| 580 | 580 | 'suppress_filters' => 0 | 
| 581 | 581 | ); | 
| 582 | - $lessons = get_posts( $lesson_args ); | |
| 582 | + $lessons = get_posts($lesson_args); | |
| 583 | 583 | |
| 584 | -		foreach( $lessons as $lesson ) { | |
| 585 | - $new_lesson = $this->duplicate_post( $lesson, '', true ); | |
| 586 | - add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id ); | |
| 584 | +		foreach ($lessons as $lesson) { | |
| 585 | + $new_lesson = $this->duplicate_post($lesson, '', true); | |
| 586 | + add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id); | |
| 587 | 587 | |
| 588 | - $this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID ); | |
| 588 | + $this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID); | |
| 589 | 589 | } | 
| 590 | 590 | } | 
| 591 | 591 | |
| @@ -596,24 +596,24 @@ discard block | ||
| 596 | 596 | * @param boolean $ignore_course Ignore lesson course when dulicating | 
| 597 | 597 | * @return object Duplicate post object | 
| 598 | 598 | */ | 
| 599 | -	private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) { | |
| 599 | +	private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) { | |
| 600 | 600 | |
| 601 | 601 | $new_post = array(); | 
| 602 | 602 | |
| 603 | -		foreach( $post as $k => $v ) { | |
| 604 | -			if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) { | |
| 605 | - $new_post[ $k ] = $v; | |
| 603 | +		foreach ($post as $k => $v) { | |
| 604 | +			if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) { | |
| 605 | + $new_post[$k] = $v; | |
| 606 | 606 | } | 
| 607 | 607 | } | 
| 608 | 608 | |
| 609 | - $new_post['post_title'] .= __( $suffix, 'woothemes-sensei' ); | |
| 609 | + $new_post['post_title'] .= __($suffix, 'woothemes-sensei'); | |
| 610 | 610 | |
| 611 | - $new_post['post_date'] = current_time( 'mysql' ); | |
| 612 | - $new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] ); | |
| 611 | +		$new_post['post_date'] = current_time('mysql'); | |
| 612 | + $new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']); | |
| 613 | 613 | $new_post['post_modified'] = $new_post['post_date']; | 
| 614 | 614 | $new_post['post_modified_gmt'] = $new_post['post_date_gmt']; | 
| 615 | 615 | |
| 616 | -		switch( $post->post_type ) { | |
| 616 | +		switch ($post->post_type) { | |
| 617 | 617 | case 'course': $new_post['post_status'] = 'draft'; break; | 
| 618 | 618 | case 'lesson': $new_post['post_status'] = 'draft'; break; | 
| 619 | 619 | case 'quiz': $new_post['post_status'] = 'publish'; break; | 
| @@ -621,45 +621,45 @@ discard block | ||
| 621 | 621 | } | 
| 622 | 622 | |
| 623 | 623 | // As per wp_update_post() we need to escape the data from the db. | 
| 624 | - $new_post = wp_slash( $new_post ); | |
| 624 | + $new_post = wp_slash($new_post); | |
| 625 | 625 | |
| 626 | - $new_post_id = wp_insert_post( $new_post ); | |
| 626 | + $new_post_id = wp_insert_post($new_post); | |
| 627 | 627 | |
| 628 | -		if( ! is_wp_error( $new_post_id ) ) { | |
| 628 | +		if ( ! is_wp_error($new_post_id)) { | |
| 629 | 629 | |
| 630 | - $post_meta = get_post_custom( $post->ID ); | |
| 631 | -			if( $post_meta && count( $post_meta ) > 0 ) { | |
| 630 | + $post_meta = get_post_custom($post->ID); | |
| 631 | +			if ($post_meta && count($post_meta) > 0) { | |
| 632 | 632 | |
| 633 | - $ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' ); | |
| 633 | +				$ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz'); | |
| 634 | 634 | |
| 635 | -				if( $ignore_course ) { | |
| 635 | +				if ($ignore_course) { | |
| 636 | 636 | $ignore_meta[] = '_lesson_course'; | 
| 637 | 637 | } | 
| 638 | 638 | |
| 639 | -				foreach( $post_meta as $key => $meta ) { | |
| 640 | -					foreach( $meta as $value ) { | |
| 641 | - $value = maybe_unserialize( $value ); | |
| 642 | -						if( ! in_array( $key, $ignore_meta ) ) { | |
| 643 | - add_post_meta( $new_post_id, $key, $value ); | |
| 639 | +				foreach ($post_meta as $key => $meta) { | |
| 640 | +					foreach ($meta as $value) { | |
| 641 | + $value = maybe_unserialize($value); | |
| 642 | +						if ( ! in_array($key, $ignore_meta)) { | |
| 643 | + add_post_meta($new_post_id, $key, $value); | |
| 644 | 644 | } | 
| 645 | 645 | } | 
| 646 | 646 | } | 
| 647 | 647 | } | 
| 648 | 648 | |
| 649 | - add_post_meta( $new_post_id, '_duplicate', $post->ID ); | |
| 649 | + add_post_meta($new_post_id, '_duplicate', $post->ID); | |
| 650 | 650 | |
| 651 | - $taxonomies = get_object_taxonomies( $post->post_type, 'objects' ); | |
| 651 | + $taxonomies = get_object_taxonomies($post->post_type, 'objects'); | |
| 652 | 652 | |
| 653 | -			foreach ( $taxonomies as $slug => $tax ) { | |
| 654 | - $terms = get_the_terms( $post->ID, $slug ); | |
| 655 | -				if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) { | |
| 656 | -					foreach( $terms as $term ) { | |
| 657 | - wp_set_object_terms( $new_post_id, $term->term_id, $slug, true ); | |
| 653 | +			foreach ($taxonomies as $slug => $tax) { | |
| 654 | + $terms = get_the_terms($post->ID, $slug); | |
| 655 | +				if (isset($terms) && is_array($terms) && 0 < count($terms)) { | |
| 656 | +					foreach ($terms as $term) { | |
| 657 | + wp_set_object_terms($new_post_id, $term->term_id, $slug, true); | |
| 658 | 658 | } | 
| 659 | 659 | } | 
| 660 | 660 | } | 
| 661 | 661 | |
| 662 | - $new_post = get_post( $new_post_id ); | |
| 662 | + $new_post = get_post($new_post_id); | |
| 663 | 663 | |
| 664 | 664 | return $new_post; | 
| 665 | 665 | } | 
| @@ -674,7 +674,7 @@ discard block | ||
| 674 | 674 |  	public function lesson_filter_options() { | 
| 675 | 675 | global $typenow; | 
| 676 | 676 | |
| 677 | -		if( is_admin() && 'lesson' == $typenow ) { | |
| 677 | +		if (is_admin() && 'lesson' == $typenow) { | |
| 678 | 678 | |
| 679 | 679 | $args = array( | 
| 680 | 680 | 'post_type' => 'course', | 
| @@ -684,16 +684,16 @@ discard block | ||
| 684 | 684 | 'orderby' => 'menu_order date', | 
| 685 | 685 | 'order' => 'ASC', | 
| 686 | 686 | ); | 
| 687 | - $courses = get_posts( $args ); | |
| 687 | + $courses = get_posts($args); | |
| 688 | 688 | |
| 689 | - $selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; | |
| 689 | + $selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; | |
| 690 | 690 | $course_options = ''; | 
| 691 | -			foreach( $courses as $course ) { | |
| 692 | - $course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>'; | |
| 691 | +			foreach ($courses as $course) { | |
| 692 | + $course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>'; | |
| 693 | 693 | } | 
| 694 | 694 | |
| 695 | 695 | $output = '<select name="lesson_course" id="dropdown_lesson_course">'; | 
| 696 | - $output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>'; | |
| 696 | +			$output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>'; | |
| 697 | 697 | $output .= $course_options; | 
| 698 | 698 | $output .= '</select>'; | 
| 699 | 699 | |
| @@ -706,13 +706,13 @@ discard block | ||
| 706 | 706 | * @param array $request Current request | 
| 707 | 707 | * @return array Modified request | 
| 708 | 708 | */ | 
| 709 | -	public function lesson_filter_actions( $request ) { | |
| 709 | +	public function lesson_filter_actions($request) { | |
| 710 | 710 | global $typenow; | 
| 711 | 711 | |
| 712 | -		if( is_admin() && 'lesson' == $typenow ) { | |
| 713 | - $lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; | |
| 712 | +		if (is_admin() && 'lesson' == $typenow) { | |
| 713 | + $lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; | |
| 714 | 714 | |
| 715 | -			if( $lesson_course ) { | |
| 715 | +			if ($lesson_course) { | |
| 716 | 716 | $request['meta_key'] = '_lesson_course'; | 
| 717 | 717 | $request['meta_value'] = $lesson_course; | 
| 718 | 718 | $request['meta_compare'] = '='; | 
| @@ -727,27 +727,27 @@ discard block | ||
| 727 | 727 | * @param array $items Existing items | 
| 728 | 728 | * @return array Updated items | 
| 729 | 729 | */ | 
| 730 | -	public function glance_items( $items = array() ) { | |
| 730 | +	public function glance_items($items = array()) { | |
| 731 | 731 | |
| 732 | - $types = array( 'course', 'lesson', 'question' ); | |
| 732 | +		$types = array('course', 'lesson', 'question'); | |
| 733 | 733 | |
| 734 | -		foreach( $types as $type ) { | |
| 735 | - if( ! post_type_exists( $type ) ) continue; | |
| 734 | +		foreach ($types as $type) { | |
| 735 | + if ( ! post_type_exists($type)) continue; | |
| 736 | 736 | |
| 737 | - $num_posts = wp_count_posts( $type ); | |
| 737 | + $num_posts = wp_count_posts($type); | |
| 738 | 738 | |
| 739 | -			if( $num_posts ) { | |
| 739 | +			if ($num_posts) { | |
| 740 | 740 | |
| 741 | - $published = intval( $num_posts->publish ); | |
| 742 | - $post_type = get_post_type_object( $type ); | |
| 741 | + $published = intval($num_posts->publish); | |
| 742 | + $post_type = get_post_type_object($type); | |
| 743 | 743 | |
| 744 | - $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' ); | |
| 745 | - $text = sprintf( $text, number_format_i18n( $published ) ); | |
| 744 | +				$text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei'); | |
| 745 | + $text = sprintf($text, number_format_i18n($published)); | |
| 746 | 746 | |
| 747 | -				if ( current_user_can( $post_type->cap->edit_posts ) ) { | |
| 748 | - $items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n"; | |
| 747 | +				if (current_user_can($post_type->cap->edit_posts)) { | |
| 748 | +					$items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n"; | |
| 749 | 749 |  				} else { | 
| 750 | - $items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n"; | |
| 750 | +					$items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n"; | |
| 751 | 751 | } | 
| 752 | 752 | } | 
| 753 | 753 | } | 
| @@ -761,13 +761,13 @@ discard block | ||
| 761 | 761 | * @param object $post Post object | 
| 762 | 762 | * @return void | 
| 763 | 763 | */ | 
| 764 | -	public function delete_content( $post_id, $post ) { | |
| 764 | +	public function delete_content($post_id, $post) { | |
| 765 | 765 | |
| 766 | 766 | $type = $post->post_type; | 
| 767 | 767 | |
| 768 | -		if( in_array( $type, array( 'lesson', 'course' ) ) ) { | |
| 768 | +		if (in_array($type, array('lesson', 'course'))) { | |
| 769 | 769 | |
| 770 | - $meta_key = '_' . $type . '_prerequisite'; | |
| 770 | + $meta_key = '_'.$type.'_prerequisite'; | |
| 771 | 771 | |
| 772 | 772 | $args = array( | 
| 773 | 773 | 'post_type' => $type, | 
| @@ -777,10 +777,10 @@ discard block | ||
| 777 | 777 | 'meta_value' => $post_id | 
| 778 | 778 | ); | 
| 779 | 779 | |
| 780 | - $posts = get_posts( $args ); | |
| 780 | + $posts = get_posts($args); | |
| 781 | 781 | |
| 782 | -			foreach( $posts as $post ) { | |
| 783 | - delete_post_meta( $post->ID, $meta_key ); | |
| 782 | +			foreach ($posts as $post) { | |
| 783 | + delete_post_meta($post->ID, $meta_key); | |
| 784 | 784 | } | 
| 785 | 785 | } | 
| 786 | 786 | } | 
| @@ -790,181 +790,181 @@ discard block | ||
| 790 | 790 | * @param integer $user_id User ID | 
| 791 | 791 | * @return void | 
| 792 | 792 | */ | 
| 793 | -	public function delete_user_activity( $user_id = 0 ) { | |
| 794 | -		if( $user_id ) { | |
| 795 | - Sensei_Utils::delete_all_user_activity( $user_id ); | |
| 793 | +	public function delete_user_activity($user_id = 0) { | |
| 794 | +		if ($user_id) { | |
| 795 | + Sensei_Utils::delete_all_user_activity($user_id); | |
| 796 | 796 | } | 
| 797 | 797 | } | 
| 798 | 798 | |
| 799 | -	public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) { | |
| 799 | +	public function render_settings($settings = array(), $post_id = 0, $group_id = '') { | |
| 800 | 800 | |
| 801 | 801 | $html = ''; | 
| 802 | 802 | |
| 803 | - if( 0 == count( $settings ) ) return $html; | |
| 803 | + if (0 == count($settings)) return $html; | |
| 804 | 804 | |
| 805 | - $html .= '<div class="sensei-options-panel">' . "\n"; | |
| 805 | + $html .= '<div class="sensei-options-panel">'."\n"; | |
| 806 | 806 | |
| 807 | - $html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n"; | |
| 807 | + $html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n"; | |
| 808 | 808 | |
| 809 | -				foreach( $settings as $field ) { | |
| 809 | +				foreach ($settings as $field) { | |
| 810 | 810 | |
| 811 | 811 | $data = ''; | 
| 812 | 812 | |
| 813 | -					if( $post_id ) { | |
| 814 | - $data = get_post_meta( $post_id, '_' . $field['id'], true ); | |
| 815 | -						if( ! $data && isset( $field['default'] ) ) { | |
| 813 | +					if ($post_id) { | |
| 814 | + $data = get_post_meta($post_id, '_'.$field['id'], true); | |
| 815 | +						if ( ! $data && isset($field['default'])) { | |
| 816 | 816 | $data = $field['default']; | 
| 817 | 817 | } | 
| 818 | 818 |  					} else { | 
| 819 | - $option = get_option( $field['id'] ); | |
| 820 | -						if( isset( $field['default'] ) ) { | |
| 819 | + $option = get_option($field['id']); | |
| 820 | +						if (isset($field['default'])) { | |
| 821 | 821 | $data = $field['default']; | 
| 822 | -							if( $option ) { | |
| 822 | +							if ($option) { | |
| 823 | 823 | $data = $option; | 
| 824 | 824 | } | 
| 825 | 825 | } | 
| 826 | 826 | } | 
| 827 | 827 | |
| 828 | 828 | $disabled = ''; | 
| 829 | -					if( isset( $field['disabled'] ) && $field['disabled'] ) { | |
| 830 | - $disabled = disabled( $field['disabled'], true, false ); | |
| 829 | +					if (isset($field['disabled']) && $field['disabled']) { | |
| 830 | + $disabled = disabled($field['disabled'], true, false); | |
| 831 | 831 | } | 
| 832 | 832 | |
| 833 | -					if( 'hidden' != $field['type'] ) { | |
| 833 | +					if ('hidden' != $field['type']) { | |
| 834 | 834 | |
| 835 | 835 | $class_tail = ''; | 
| 836 | 836 | |
| 837 | -						if( isset( $field['class'] ) ) { | |
| 837 | +						if (isset($field['class'])) { | |
| 838 | 838 | $class_tail .= $field['class']; | 
| 839 | 839 | } | 
| 840 | 840 | |
| 841 | -						if( isset( $field['disabled'] ) && $field['disabled'] ) { | |
| 841 | +						if (isset($field['disabled']) && $field['disabled']) { | |
| 842 | 842 | $class_tail .= ' disabled'; | 
| 843 | 843 | } | 
| 844 | 844 | |
| 845 | - $html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n"; | |
| 845 | + $html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n"; | |
| 846 | 846 | } | 
| 847 | 847 | |
| 848 | -						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { | |
| 849 | - $html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n"; | |
| 848 | +						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { | |
| 849 | + $html .= '<label for="'.esc_attr($field['id']).'">'."\n"; | |
| 850 | 850 | } | 
| 851 | 851 | |
| 852 | -							if( $field['label'] ) { | |
| 853 | - $html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>'; | |
| 852 | +							if ($field['label']) { | |
| 853 | + $html .= '<span class="label">'.esc_html($field['label']).'</span>'; | |
| 854 | 854 | } | 
| 855 | 855 | |
| 856 | -							switch( $field['type'] ) { | |
| 856 | +							switch ($field['type']) { | |
| 857 | 857 | case 'text': | 
| 858 | 858 | case 'password': | 
| 859 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n"; | |
| 859 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n"; | |
| 860 | 860 | break; | 
| 861 | 861 | |
| 862 | 862 | case 'number': | 
| 863 | 863 | |
| 864 | 864 | $min = ''; | 
| 865 | -									if( isset( $field['min'] ) ) { | |
| 866 | - $min = 'min="' . esc_attr( $field['min'] ) . '"'; | |
| 865 | +									if (isset($field['min'])) { | |
| 866 | + $min = 'min="'.esc_attr($field['min']).'"'; | |
| 867 | 867 | } | 
| 868 | 868 | |
| 869 | 869 | $max = ''; | 
| 870 | -									if( isset( $field['max'] ) ) { | |
| 871 | - $max = 'max="' . esc_attr( $field['max'] ) . '"'; | |
| 870 | +									if (isset($field['max'])) { | |
| 871 | + $max = 'max="'.esc_attr($field['max']).'"'; | |
| 872 | 872 | } | 
| 873 | 873 | |
| 874 | - $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"; | |
| 874 | + $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"; | |
| 875 | 875 | break; | 
| 876 | 876 | |
| 877 | 877 | case 'textarea': | 
| 878 | - $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"; | |
| 878 | + $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"; | |
| 879 | 879 | break; | 
| 880 | 880 | |
| 881 | 881 | case 'checkbox': | 
| 882 | 882 | //backwards compatibility | 
| 883 | -                                    if( empty( $data ) || 'on' == $data ){ | |
| 883 | +                                    if (empty($data) || 'on' == $data) { | |
| 884 | 884 | $checked_value = 'on'; | 
| 885 | -                                    }elseif( 'yes' == $data  ) { | |
| 885 | +                                    }elseif ('yes' == $data) { | |
| 886 | 886 | |
| 887 | 887 | $checked_value = 'yes'; | 
| 888 | 888 | |
| 889 | -                                    }elseif( 'auto' == $data  ) { | |
| 889 | +                                    }elseif ('auto' == $data) { | |
| 890 | 890 | |
| 891 | 891 | $checked_value = 'auto'; | 
| 892 | 892 | |
| 893 | 893 |                                      } else { | 
| 894 | 894 | $checked_value = 1; | 
| 895 | - $data = intval( $data ); | |
| 895 | + $data = intval($data); | |
| 896 | 896 | } | 
| 897 | - $checked = checked( $checked_value, $data, false ); | |
| 898 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; | |
| 897 | + $checked = checked($checked_value, $data, false); | |
| 898 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n"; | |
| 899 | 899 | break; | 
| 900 | 900 | |
| 901 | 901 | case 'checkbox_multi': | 
| 902 | -									foreach( $field['options'] as $k => $v ) { | |
| 902 | +									foreach ($field['options'] as $k => $v) { | |
| 903 | 903 | $checked = false; | 
| 904 | -										if( in_array( $k, $data ) ) { | |
| 904 | +										if (in_array($k, $data)) { | |
| 905 | 905 | $checked = true; | 
| 906 | 906 | } | 
| 907 | - $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"; | |
| 907 | + $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"; | |
| 908 | 908 | } | 
| 909 | 909 | break; | 
| 910 | 910 | |
| 911 | 911 | case 'radio': | 
| 912 | -									foreach( $field['options'] as $k => $v ) { | |
| 912 | +									foreach ($field['options'] as $k => $v) { | |
| 913 | 913 | $checked = false; | 
| 914 | -										if( $k == $data ) { | |
| 914 | +										if ($k == $data) { | |
| 915 | 915 | $checked = true; | 
| 916 | 916 | } | 
| 917 | - $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"; | |
| 917 | + $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"; | |
| 918 | 918 | } | 
| 919 | 919 | break; | 
| 920 | 920 | |
| 921 | 921 | case 'select': | 
| 922 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n"; | |
| 923 | -									foreach( $field['options'] as $k => $v ) { | |
| 922 | + $html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n"; | |
| 923 | +									foreach ($field['options'] as $k => $v) { | |
| 924 | 924 | $selected = false; | 
| 925 | -										if( $k == $data ) { | |
| 925 | +										if ($k == $data) { | |
| 926 | 926 | $selected = true; | 
| 927 | 927 | } | 
| 928 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n"; | |
| 928 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n"; | |
| 929 | 929 | } | 
| 930 | - $html .= '</select><br/>' . "\n"; | |
| 930 | + $html .= '</select><br/>'."\n"; | |
| 931 | 931 | break; | 
| 932 | 932 | |
| 933 | 933 | case 'select_multi': | 
| 934 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n"; | |
| 935 | -									foreach( $field['options'] as $k => $v ) { | |
| 934 | + $html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n"; | |
| 935 | +									foreach ($field['options'] as $k => $v) { | |
| 936 | 936 | $selected = false; | 
| 937 | -										if( in_array( $k, $data ) ) { | |
| 937 | +										if (in_array($k, $data)) { | |
| 938 | 938 | $selected = true; | 
| 939 | 939 | } | 
| 940 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n"; | |
| 940 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n"; | |
| 941 | 941 | } | 
| 942 | 942 | $html .= '</select> . "\n"'; | 
| 943 | 943 | break; | 
| 944 | 944 | |
| 945 | 945 | case 'hidden': | 
| 946 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n"; | |
| 946 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n"; | |
| 947 | 947 | break; | 
| 948 | 948 | |
| 949 | 949 | } | 
| 950 | 950 | |
| 951 | -							if( $field['description'] ) { | |
| 952 | - $html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n"; | |
| 951 | +							if ($field['description']) { | |
| 952 | + $html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n"; | |
| 953 | 953 | } | 
| 954 | 954 | |
| 955 | -						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { | |
| 956 | - $html .= '</label>' . "\n"; | |
| 955 | +						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { | |
| 956 | + $html .= '</label>'."\n"; | |
| 957 | 957 | } | 
| 958 | 958 | |
| 959 | -					if( 'hidden' != $field['type'] ) { | |
| 960 | - $html .= '</p>' . "\n"; | |
| 959 | +					if ('hidden' != $field['type']) { | |
| 960 | + $html .= '</p>'."\n"; | |
| 961 | 961 | } | 
| 962 | 962 | |
| 963 | 963 | } | 
| 964 | 964 | |
| 965 | - $html .= '</div>' . "\n"; | |
| 965 | + $html .= '</div>'."\n"; | |
| 966 | 966 | |
| 967 | - $html .= '</div>' . "\n"; | |
| 967 | + $html .= '</div>'."\n"; | |
| 968 | 968 | |
| 969 | 969 | return $html; | 
| 970 | 970 | } | 
| @@ -975,61 +975,61 @@ discard block | ||
| 975 | 975 | */ | 
| 976 | 976 |  	public function course_order_screen() { | 
| 977 | 977 | |
| 978 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 979 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); | |
| 978 | +		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; | |
| 979 | +		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); | |
| 980 | 980 | |
| 981 | 981 | ?><div id="course-order" class="wrap course-order"> | 
| 982 | - <h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php | |
| 982 | +		<h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php | |
| 983 | 983 | |
| 984 | 984 | $html = ''; | 
| 985 | 985 | |
| 986 | -		if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) { | |
| 987 | - $ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) ); | |
| 986 | +		if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) { | |
| 987 | + $ordered = $this->save_course_order(esc_attr($_POST['course-order'])); | |
| 988 | 988 | |
| 989 | -			if( $ordered ) { | |
| 990 | - $html .= '<div class="updated fade">' . "\n"; | |
| 991 | - $html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; | |
| 992 | - $html .= '</div>' . "\n"; | |
| 989 | +			if ($ordered) { | |
| 990 | + $html .= '<div class="updated fade">'."\n"; | |
| 991 | +				$html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n"; | |
| 992 | + $html .= '</div>'."\n"; | |
| 993 | 993 | } | 
| 994 | 994 | } | 
| 995 | 995 | |
| 996 | 996 | $courses = Sensei()->course->get_all_courses(); | 
| 997 | 997 | |
| 998 | -		if( 0 < count( $courses ) ) { | |
| 998 | +		if (0 < count($courses)) { | |
| 999 | 999 | |
| 1000 | 1000 | // order the courses as set by the users | 
| 1001 | 1001 | $all_course_ids = array(); | 
| 1002 | -            foreach( $courses as $course ){ | |
| 1002 | +            foreach ($courses as $course) { | |
| 1003 | 1003 | |
| 1004 | - $all_course_ids[] = (string)$course->ID; | |
| 1004 | + $all_course_ids[] = (string) $course->ID; | |
| 1005 | 1005 | |
| 1006 | 1006 | } | 
| 1007 | 1007 | $order_string = $this->get_course_order(); | 
| 1008 | 1008 | |
| 1009 | -            if( !empty( $order_string ) ){ | |
| 1010 | -                $ordered_course_ids = explode(',' , $order_string ); | |
| 1011 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); | |
| 1009 | +            if ( ! empty($order_string)) { | |
| 1010 | +                $ordered_course_ids = explode(',', $order_string); | |
| 1011 | + $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids)); | |
| 1012 | 1012 | } | 
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; | |
| 1016 | - $html .= '<ul class="sortable-course-list">' . "\n"; | |
| 1015 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; | |
| 1016 | + $html .= '<ul class="sortable-course-list">'."\n"; | |
| 1017 | 1017 | $count = 0; | 
| 1018 | -			foreach ( $all_course_ids as $course_id ) { | |
| 1019 | - $course = get_post( $course_id ); | |
| 1018 | +			foreach ($all_course_ids as $course_id) { | |
| 1019 | + $course = get_post($course_id); | |
| 1020 | 1020 | $count++; | 
| 1021 | 1021 | $class = 'course'; | 
| 1022 | -				if ( $count == 1 ) { $class .= ' first'; } | |
| 1023 | -				if ( $count == count( $course ) ) { $class .= ' last'; } | |
| 1024 | -				if ( $count % 2 != 0 ) { | |
| 1022 | +				if ($count == 1) { $class .= ' first'; } | |
| 1023 | +				if ($count == count($course)) { $class .= ' last'; } | |
| 1024 | +				if ($count % 2 != 0) { | |
| 1025 | 1025 | $class .= ' alternate'; | 
| 1026 | 1026 | } | 
| 1027 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n"; | |
| 1027 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n"; | |
| 1028 | 1028 | } | 
| 1029 | - $html .= '</ul>' . "\n"; | |
| 1029 | + $html .= '</ul>'."\n"; | |
| 1030 | 1030 | |
| 1031 | - $html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; | |
| 1032 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n"; | |
| 1031 | + $html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n"; | |
| 1032 | +			$html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n"; | |
| 1033 | 1033 | } | 
| 1034 | 1034 | |
| 1035 | 1035 | echo $html; | 
| @@ -1038,25 +1038,25 @@ discard block | ||
| 1038 | 1038 | } | 
| 1039 | 1039 | |
| 1040 | 1040 |  	public function get_course_order() { | 
| 1041 | - return get_option( 'sensei_course_order', '' ); | |
| 1041 | +		return get_option('sensei_course_order', ''); | |
| 1042 | 1042 | } | 
| 1043 | 1043 | |
| 1044 | -	public function save_course_order( $order_string = '' ) { | |
| 1045 | - $order = explode( ',', $order_string ); | |
| 1044 | +	public function save_course_order($order_string = '') { | |
| 1045 | +		$order = explode(',', $order_string); | |
| 1046 | 1046 | |
| 1047 | - update_option( 'sensei_course_order', $order_string ); | |
| 1047 | +		update_option('sensei_course_order', $order_string); | |
| 1048 | 1048 | |
| 1049 | 1049 | $i = 1; | 
| 1050 | -		foreach( $order as $course_id ) { | |
| 1050 | +		foreach ($order as $course_id) { | |
| 1051 | 1051 | |
| 1052 | -			if( $course_id ) { | |
| 1052 | +			if ($course_id) { | |
| 1053 | 1053 | |
| 1054 | 1054 | $update_args = array( | 
| 1055 | 1055 | 'ID' => $course_id, | 
| 1056 | 1056 | 'menu_order' => $i, | 
| 1057 | 1057 | ); | 
| 1058 | 1058 | |
| 1059 | - wp_update_post( $update_args ); | |
| 1059 | + wp_update_post($update_args); | |
| 1060 | 1060 | |
| 1061 | 1061 | ++$i; | 
| 1062 | 1062 | } | 
| @@ -1071,22 +1071,22 @@ discard block | ||
| 1071 | 1071 | */ | 
| 1072 | 1072 |  	public function lesson_order_screen() { | 
| 1073 | 1073 | |
| 1074 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 1075 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); | |
| 1074 | +		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; | |
| 1075 | +		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); | |
| 1076 | 1076 | |
| 1077 | 1077 | ?><div id="lesson-order" class="wrap lesson-order"> | 
| 1078 | - <h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php | |
| 1078 | +		<h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php | |
| 1079 | 1079 | |
| 1080 | 1080 | $html = ''; | 
| 1081 | 1081 | |
| 1082 | -		if( isset( $_POST['lesson-order'] ) ) { | |
| 1082 | +		if (isset($_POST['lesson-order'])) { | |
| 1083 | 1083 | |
| 1084 | - $ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) ); | |
| 1084 | + $ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id'])); | |
| 1085 | 1085 | |
| 1086 | -			if( $ordered ) { | |
| 1087 | - $html .= '<div class="updated fade">' . "\n"; | |
| 1088 | - $html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; | |
| 1089 | - $html .= '</div>' . "\n"; | |
| 1086 | +			if ($ordered) { | |
| 1087 | + $html .= '<div class="updated fade">'."\n"; | |
| 1088 | +				$html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n"; | |
| 1089 | + $html .= '</div>'."\n"; | |
| 1090 | 1090 | } | 
| 1091 | 1091 | } | 
| 1092 | 1092 | |
| @@ -1097,43 +1097,43 @@ discard block | ||
| 1097 | 1097 | 'orderby' => 'name', | 
| 1098 | 1098 | 'order' => 'ASC', | 
| 1099 | 1099 | ); | 
| 1100 | - $courses = get_posts( $args ); | |
| 1100 | + $courses = get_posts($args); | |
| 1101 | 1101 | |
| 1102 | - $html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n"; | |
| 1103 | - $html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n"; | |
| 1104 | - $html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n"; | |
| 1105 | - $html .= '<select id="lesson-order-course" name="course_id">' . "\n"; | |
| 1106 | - $html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n"; | |
| 1102 | +		$html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n"; | |
| 1103 | + $html .= '<input type="hidden" name="post_type" value="lesson" />'."\n"; | |
| 1104 | + $html .= '<input type="hidden" name="page" value="lesson-order" />'."\n"; | |
| 1105 | + $html .= '<select id="lesson-order-course" name="course_id">'."\n"; | |
| 1106 | +		$html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n"; | |
| 1107 | 1107 | |
| 1108 | -		foreach( $courses as $course ) { | |
| 1108 | +		foreach ($courses as $course) { | |
| 1109 | 1109 | $course_id = ''; | 
| 1110 | -			if( isset( $_GET['course_id'] ) ) { | |
| 1111 | - $course_id = intval( $_GET['course_id'] ); | |
| 1110 | +			if (isset($_GET['course_id'])) { | |
| 1111 | + $course_id = intval($_GET['course_id']); | |
| 1112 | 1112 | } | 
| 1113 | - $html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n"; | |
| 1113 | + $html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n"; | |
| 1114 | 1114 | } | 
| 1115 | 1115 | |
| 1116 | - $html .= '</select>' . "\n"; | |
| 1117 | - $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n"; | |
| 1118 | - $html .= '</form>' . "\n"; | |
| 1116 | + $html .= '</select>'."\n"; | |
| 1117 | +		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n"; | |
| 1118 | + $html .= '</form>'."\n"; | |
| 1119 | 1119 | |
| 1120 | - $html .= '<script type="text/javascript">' . "\n"; | |
| 1121 | -		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n"; | |
| 1122 | - $html .= '</script>' . "\n"; | |
| 1120 | + $html .= '<script type="text/javascript">'."\n"; | |
| 1121 | +		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n"; | |
| 1122 | + $html .= '</script>'."\n"; | |
| 1123 | 1123 | |
| 1124 | -		if( isset( $_GET['course_id'] ) ) { | |
| 1125 | - $course_id = intval( $_GET['course_id'] ); | |
| 1126 | -			if( $course_id > 0 ) { | |
| 1124 | +		if (isset($_GET['course_id'])) { | |
| 1125 | + $course_id = intval($_GET['course_id']); | |
| 1126 | +			if ($course_id > 0) { | |
| 1127 | 1127 | |
| 1128 | - $order_string = $this->get_lesson_order( $course_id ); | |
| 1128 | + $order_string = $this->get_lesson_order($course_id); | |
| 1129 | 1129 | |
| 1130 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; | |
| 1130 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; | |
| 1131 | 1131 | |
| 1132 | 1132 | $displayed_lessons = array(); | 
| 1133 | 1133 | |
| 1134 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); | |
| 1134 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); | |
| 1135 | 1135 | |
| 1136 | -                foreach( $modules as $module ) { | |
| 1136 | +                foreach ($modules as $module) { | |
| 1137 | 1137 | |
| 1138 | 1138 | $args = array( | 
| 1139 | 1139 | 'post_type' => 'lesson', | 
| @@ -1142,7 +1142,7 @@ discard block | ||
| 1142 | 1142 | 'meta_query' => array( | 
| 1143 | 1143 | array( | 
| 1144 | 1144 | 'key' => '_lesson_course', | 
| 1145 | - 'value' => intval( $course_id ), | |
| 1145 | + 'value' => intval($course_id), | |
| 1146 | 1146 | 'compare' => '=' | 
| 1147 | 1147 | ) | 
| 1148 | 1148 | ), | 
| @@ -1150,66 +1150,66 @@ discard block | ||
| 1150 | 1150 | array( | 
| 1151 | 1151 | 'taxonomy' => Sensei()->modules->taxonomy, | 
| 1152 | 1152 | 'field' => 'id', | 
| 1153 | - 'terms' => intval( $module->term_id ) | |
| 1153 | + 'terms' => intval($module->term_id) | |
| 1154 | 1154 | ) | 
| 1155 | 1155 | ), | 
| 1156 | - 'meta_key' => '_order_module_' . $module->term_id, | |
| 1156 | + 'meta_key' => '_order_module_'.$module->term_id, | |
| 1157 | 1157 | 'orderby' => 'meta_value_num date', | 
| 1158 | 1158 | 'order' => 'ASC', | 
| 1159 | 1159 | 'suppress_filters' => 0 | 
| 1160 | 1160 | ); | 
| 1161 | 1161 | |
| 1162 | - $lessons = get_posts( $args ); | |
| 1162 | + $lessons = get_posts($args); | |
| 1163 | 1163 | |
| 1164 | -                    if( count( $lessons ) > 0 ) { | |
| 1165 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; | |
| 1166 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; | |
| 1164 | +                    if (count($lessons) > 0) { | |
| 1165 | + $html .= '<h3>'.$module->name.'</h3>'."\n"; | |
| 1166 | + $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n"; | |
| 1167 | 1167 | |
| 1168 | 1168 | $count = 0; | 
| 1169 | -                        foreach( $lessons as $lesson ) { | |
| 1169 | +                        foreach ($lessons as $lesson) { | |
| 1170 | 1170 | $count++; | 
| 1171 | 1171 | $class = 'lesson'; | 
| 1172 | -                            if ( $count == 1 ) { $class .= ' first'; } | |
| 1173 | -                            if ( $count == count( $lesson ) ) { $class .= ' last'; } | |
| 1174 | -                            if ( $count % 2 != 0 ) { | |
| 1172 | +                            if ($count == 1) { $class .= ' first'; } | |
| 1173 | +                            if ($count == count($lesson)) { $class .= ' last'; } | |
| 1174 | +                            if ($count % 2 != 0) { | |
| 1175 | 1175 | $class .= ' alternate'; | 
| 1176 | 1176 | } | 
| 1177 | 1177 | |
| 1178 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; | |
| 1178 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; | |
| 1179 | 1179 | |
| 1180 | 1180 | $displayed_lessons[] = $lesson->ID; | 
| 1181 | 1181 | } | 
| 1182 | 1182 | |
| 1183 | - $html .= '</ul>' . "\n"; | |
| 1183 | + $html .= '</ul>'."\n"; | |
| 1184 | 1184 | |
| 1185 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; | |
| 1185 | + $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n"; | |
| 1186 | 1186 | } | 
| 1187 | 1187 | } | 
| 1188 | 1188 | |
| 1189 | 1189 | |
| 1190 | - $lessons = Sensei()->course->course_lessons( $course_id ); | |
| 1190 | + $lessons = Sensei()->course->course_lessons($course_id); | |
| 1191 | 1191 | |
| 1192 | -				if( 0 < count( $lessons ) ) { | |
| 1192 | +				if (0 < count($lessons)) { | |
| 1193 | 1193 | |
| 1194 | 1194 | //get module term ids, will be used to exclude lessons | 
| 1195 | 1195 | $module_items_ids = array(); | 
| 1196 | -                    if( ! empty( $modules ) ) { | |
| 1196 | +                    if ( ! empty($modules)) { | |
| 1197 | 1197 |                          foreach ($modules as $module) { | 
| 1198 | 1198 | $module_items_ids[] = $module->term_id; | 
| 1199 | 1199 | } | 
| 1200 | 1200 | } | 
| 1201 | 1201 | |
| 1202 | -					if( 0 < count( $displayed_lessons ) ) { | |
| 1203 | - $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; | |
| 1202 | +					if (0 < count($displayed_lessons)) { | |
| 1203 | +						$html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n"; | |
| 1204 | 1204 | } | 
| 1205 | 1205 | |
| 1206 | - $html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n"; | |
| 1206 | + $html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n"; | |
| 1207 | 1207 | $count = 0; | 
| 1208 | -					foreach ( $lessons as $lesson ) { | |
| 1208 | +					foreach ($lessons as $lesson) { | |
| 1209 | 1209 | |
| 1210 | 1210 | // if lesson belongs to one fo the course modules then exclude it here | 
| 1211 | 1211 | // as it is listed above | 
| 1212 | -                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){ | |
| 1212 | +                        if (has_term($module_items_ids, 'module', $lesson->ID)) { | |
| 1213 | 1213 | |
| 1214 | 1214 | continue; | 
| 1215 | 1215 | |
| @@ -1217,28 +1217,28 @@ discard block | ||
| 1217 | 1217 | |
| 1218 | 1218 | $count++; | 
| 1219 | 1219 | $class = 'lesson'; | 
| 1220 | -						if ( $count == 1 ) { $class .= ' first'; } | |
| 1221 | -						if ( $count == count( $lesson ) ) { $class .= ' last'; } | |
| 1222 | -						if ( $count % 2 != 0 ) { | |
| 1220 | +						if ($count == 1) { $class .= ' first'; } | |
| 1221 | +						if ($count == count($lesson)) { $class .= ' last'; } | |
| 1222 | +						if ($count % 2 != 0) { | |
| 1223 | 1223 | |
| 1224 | 1224 | $class .= ' alternate'; | 
| 1225 | 1225 | |
| 1226 | 1226 | } | 
| 1227 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; | |
| 1227 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; | |
| 1228 | 1228 | |
| 1229 | 1229 | $displayed_lessons[] = $lesson->ID; | 
| 1230 | 1230 | } | 
| 1231 | - $html .= '</ul>' . "\n"; | |
| 1231 | + $html .= '</ul>'."\n"; | |
| 1232 | 1232 |  				} else { | 
| 1233 | -					if( 0 == count( $displayed_lessons ) ) { | |
| 1234 | - $html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>'; | |
| 1233 | +					if (0 == count($displayed_lessons)) { | |
| 1234 | +						$html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>'; | |
| 1235 | 1235 | } | 
| 1236 | 1236 | } | 
| 1237 | 1237 | |
| 1238 | -				if( 0 < count( $displayed_lessons ) ) { | |
| 1239 | - $html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; | |
| 1240 | - $html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n"; | |
| 1241 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n"; | |
| 1238 | +				if (0 < count($displayed_lessons)) { | |
| 1239 | + $html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n"; | |
| 1240 | + $html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n"; | |
| 1241 | +					$html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n"; | |
| 1242 | 1242 | } | 
| 1243 | 1243 | } | 
| 1244 | 1244 | } | 
| @@ -1248,29 +1248,29 @@ discard block | ||
| 1248 | 1248 | ?></div><?php | 
| 1249 | 1249 | } | 
| 1250 | 1250 | |
| 1251 | -	public function get_lesson_order( $course_id = 0 ) { | |
| 1252 | - $order_string = get_post_meta( $course_id, '_lesson_order', true ); | |
| 1251 | +	public function get_lesson_order($course_id = 0) { | |
| 1252 | + $order_string = get_post_meta($course_id, '_lesson_order', true); | |
| 1253 | 1253 | return $order_string; | 
| 1254 | 1254 | } | 
| 1255 | 1255 | |
| 1256 | -	public function save_lesson_order( $order_string = '', $course_id = 0 ) { | |
| 1256 | +	public function save_lesson_order($order_string = '', $course_id = 0) { | |
| 1257 | 1257 | |
| 1258 | -		if( $course_id ) { | |
| 1258 | +		if ($course_id) { | |
| 1259 | 1259 | |
| 1260 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); | |
| 1260 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); | |
| 1261 | 1261 | |
| 1262 | -            foreach( $modules as $module ) { | |
| 1262 | +            foreach ($modules as $module) { | |
| 1263 | 1263 | |
| 1264 | 1264 | |
| 1265 | - if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) | |
| 1266 | -                    && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { | |
| 1265 | + if (isset($_POST['lesson-order-module-'.$module->term_id]) | |
| 1266 | +                    && $_POST['lesson-order-module-'.$module->term_id]) { | |
| 1267 | 1267 | |
| 1268 | - $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); | |
| 1268 | +                    $order = explode(',', $_POST['lesson-order-module-'.$module->term_id]); | |
| 1269 | 1269 | $i = 1; | 
| 1270 | -                    foreach( $order as $lesson_id ) { | |
| 1270 | +                    foreach ($order as $lesson_id) { | |
| 1271 | 1271 | |
| 1272 | -                        if( $lesson_id ) { | |
| 1273 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); | |
| 1272 | +                        if ($lesson_id) { | |
| 1273 | + update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i); | |
| 1274 | 1274 | ++$i; | 
| 1275 | 1275 | } | 
| 1276 | 1276 | |
| @@ -1281,15 +1281,15 @@ discard block | ||
| 1281 | 1281 | } // end for each modules | 
| 1282 | 1282 | |
| 1283 | 1283 | |
| 1284 | -			if( $order_string ) { | |
| 1285 | - update_post_meta( $course_id, '_lesson_order', $order_string ); | |
| 1284 | +			if ($order_string) { | |
| 1285 | + update_post_meta($course_id, '_lesson_order', $order_string); | |
| 1286 | 1286 | |
| 1287 | - $order = explode( ',', $order_string ); | |
| 1287 | +				$order = explode(',', $order_string); | |
| 1288 | 1288 | |
| 1289 | 1289 | $i = 1; | 
| 1290 | -				foreach( $order as $lesson_id ) { | |
| 1291 | -					if( $lesson_id ) { | |
| 1292 | - update_post_meta( $lesson_id, '_order_' . $course_id, $i ); | |
| 1290 | +				foreach ($order as $lesson_id) { | |
| 1291 | +					if ($lesson_id) { | |
| 1292 | + update_post_meta($lesson_id, '_order_'.$course_id, $i); | |
| 1293 | 1293 | ++$i; | 
| 1294 | 1294 | } | 
| 1295 | 1295 | } | 
| @@ -1304,54 +1304,54 @@ discard block | ||
| 1304 | 1304 |  	function sensei_add_custom_menu_items() { | 
| 1305 | 1305 | global $pagenow; | 
| 1306 | 1306 | |
| 1307 | -		if( 'nav-menus.php' == $pagenow ) { | |
| 1308 | - add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' ); | |
| 1307 | +		if ('nav-menus.php' == $pagenow) { | |
| 1308 | +			add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low'); | |
| 1309 | 1309 | } | 
| 1310 | 1310 | } | 
| 1311 | 1311 | |
| 1312 | -	function wp_nav_menu_item_sensei_links_meta_box( $object ) { | |
| 1312 | +	function wp_nav_menu_item_sensei_links_meta_box($object) { | |
| 1313 | 1313 | global $nav_menu_selected_id; | 
| 1314 | 1314 | |
| 1315 | 1315 | $menu_items = array( | 
| 1316 | - '#senseicourses' => __( 'Courses', 'woothemes-sensei' ), | |
| 1317 | - '#senseilessons' => __( 'Lessons', 'woothemes-sensei' ), | |
| 1318 | - '#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ), | |
| 1319 | - '#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ), | |
| 1320 | - '#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ), | |
| 1321 | - '#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' ) | |
| 1316 | +			'#senseicourses' => __('Courses', 'woothemes-sensei'), | |
| 1317 | +			'#senseilessons' => __('Lessons', 'woothemes-sensei'), | |
| 1318 | +			'#senseimycourses' => __('My Courses', 'woothemes-sensei'), | |
| 1319 | +			'#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'), | |
| 1320 | +			'#senseimymessages' => __('My Messages', 'woothemes-sensei'), | |
| 1321 | +			'#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei') | |
| 1322 | 1322 | ); | 
| 1323 | 1323 | |
| 1324 | 1324 | $menu_items_obj = array(); | 
| 1325 | -		foreach ( $menu_items as $value => $title ) { | |
| 1325 | +		foreach ($menu_items as $value => $title) { | |
| 1326 | 1326 | $menu_items_obj[$title] = new stdClass; | 
| 1327 | - $menu_items_obj[$title]->object_id = esc_attr( $value ); | |
| 1328 | - $menu_items_obj[$title]->title = esc_attr( $title ); | |
| 1329 | - $menu_items_obj[$title]->url = esc_attr( $value ); | |
| 1330 | - $menu_items_obj[$title]->description = 'description'; | |
| 1327 | + $menu_items_obj[$title]->object_id = esc_attr($value); | |
| 1328 | + $menu_items_obj[$title]->title = esc_attr($title); | |
| 1329 | + $menu_items_obj[$title]->url = esc_attr($value); | |
| 1330 | + $menu_items_obj[$title]->description = 'description'; | |
| 1331 | 1331 | $menu_items_obj[$title]->db_id = 0; | 
| 1332 | 1332 | $menu_items_obj[$title]->object = 'sensei'; | 
| 1333 | - $menu_items_obj[$title]->menu_item_parent = 0; | |
| 1334 | - $menu_items_obj[$title]->type = 'custom'; | |
| 1333 | + $menu_items_obj[$title]->menu_item_parent = 0; | |
| 1334 | + $menu_items_obj[$title]->type = 'custom'; | |
| 1335 | 1335 | $menu_items_obj[$title]->target = ''; | 
| 1336 | - $menu_items_obj[$title]->attr_title = ''; | |
| 1337 | - $menu_items_obj[$title]->classes = array(); | |
| 1338 | - $menu_items_obj[$title]->xfn = ''; | |
| 1336 | + $menu_items_obj[$title]->attr_title = ''; | |
| 1337 | + $menu_items_obj[$title]->classes = array(); | |
| 1338 | + $menu_items_obj[$title]->xfn = ''; | |
| 1339 | 1339 | } | 
| 1340 | 1340 | |
| 1341 | - $walker = new Walker_Nav_Menu_Checklist( array() ); | |
| 1341 | + $walker = new Walker_Nav_Menu_Checklist(array()); | |
| 1342 | 1342 | ?> | 
| 1343 | 1343 | |
| 1344 | 1344 | <div id="sensei-links" class="senseidiv taxonomydiv"> | 
| 1345 | 1345 | <div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active"> | 
| 1346 | 1346 | |
| 1347 | 1347 | <ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear"> | 
| 1348 | - <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?> | |
| 1348 | +					<?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?> | |
| 1349 | 1349 | </ul> | 
| 1350 | 1350 | |
| 1351 | 1351 | </div> | 
| 1352 | 1352 | <p class="button-controls"> | 
| 1353 | 1353 | <span class="add-to-menu"> | 
| 1354 | - <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" /> | |
| 1354 | +					<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" /> | |
| 1355 | 1355 | <span class="spinner"></span> | 
| 1356 | 1356 | </span> | 
| 1357 | 1357 | </p> | 
| @@ -1367,17 +1367,17 @@ discard block | ||
| 1367 | 1367 | */ | 
| 1368 | 1368 |  	public function theme_compatibility_notices() { | 
| 1369 | 1369 | |
| 1370 | -        if( isset( $_GET['sensei_hide_notice'] ) ) { | |
| 1371 | -        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { | |
| 1372 | - case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; | |
| 1373 | - case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; | |
| 1370 | +        if (isset($_GET['sensei_hide_notice'])) { | |
| 1371 | +        	switch (esc_attr($_GET['sensei_hide_notice'])) { | |
| 1372 | + case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break; | |
| 1373 | + case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break; | |
| 1374 | 1374 | } | 
| 1375 | 1375 | } | 
| 1376 | 1376 | |
| 1377 | 1377 | // white list templates that are already support by default and do not show notice for them | 
| 1378 | - $template = get_option( 'template' ); | |
| 1378 | +        $template = get_option('template'); | |
| 1379 | 1379 | |
| 1380 | - $white_list = array( 'twentyeleven', | |
| 1380 | +        $white_list = array('twentyeleven', | |
| 1381 | 1381 | 'twentytwelve', | 
| 1382 | 1382 | 'twentyfourteen', | 
| 1383 | 1383 | 'twentyfifteen', | 
| @@ -1385,43 +1385,43 @@ discard block | ||
| 1385 | 1385 | 'storefront', | 
| 1386 | 1386 | ); | 
| 1387 | 1387 | |
| 1388 | -        if ( in_array( $template, $white_list ) ) { | |
| 1388 | +        if (in_array($template, $white_list)) { | |
| 1389 | 1389 | |
| 1390 | 1390 | return; | 
| 1391 | 1391 | |
| 1392 | 1392 | } | 
| 1393 | 1393 | |
| 1394 | 1394 | // don't show the notice if the user chose to hide it | 
| 1395 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); | |
| 1396 | -        if(  $hide_theme_check_notice ) { | |
| 1395 | + $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); | |
| 1396 | +        if ($hide_theme_check_notice) { | |
| 1397 | 1397 | |
| 1398 | 1398 | return; | 
| 1399 | 1399 | |
| 1400 | 1400 | } | 
| 1401 | 1401 | |
| 1402 | 1402 | // show the notice for themes not supporting sensei | 
| 1403 | -	    if ( ! current_theme_supports( 'sensei' ) ) { | |
| 1403 | +	    if ( ! current_theme_supports('sensei')) { | |
| 1404 | 1404 | ?> | 
| 1405 | 1405 | |
| 1406 | 1406 | <div id="message" class="error sensei-message sensei-connect"> | 
| 1407 | 1407 | <p> | 
| 1408 | 1408 | <strong> | 
| 1409 | 1409 | |
| 1410 | -                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?> | |
| 1410 | +                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?> | |
| 1411 | 1411 | |
| 1412 | 1412 | </strong> – | 
| 1413 | 1413 | |
| 1414 | - <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?> | |
| 1414 | +                        <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?> | |
| 1415 | 1415 | |
| 1416 | - <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a> | |
| 1416 | +                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e('Sensei theme', 'woothemes-sensei') ?> </a> | |
| 1417 | 1417 | |
| 1418 | 1418 | :) | 
| 1419 | 1419 | |
| 1420 | 1420 | </p> | 
| 1421 | 1421 | <p class="submit"> | 
| 1422 | - <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"> | |
| 1422 | +                        <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"> | |
| 1423 | 1423 | |
| 1424 | - <?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' ); ?> | |
| 1424 | +                            <?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'); ?> | |
| 1425 | 1425 | |
| 1426 | 1426 | </a> | 
| 1427 | 1427 | </p> | 
| @@ -1439,7 +1439,7 @@ discard block | ||
| 1439 | 1439 | wp_get_current_user(); | 
| 1440 | 1440 | $user_id = $current_user->ID; | 
| 1441 | 1441 | |
| 1442 | - delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); | |
| 1442 | + delete_user_meta($user_id, 'sensei_hide_theme_check_notice'); | |
| 1443 | 1443 | } | 
| 1444 | 1444 | |
| 1445 | 1445 | /** | 
| @@ -1449,8 +1449,8 @@ discard block | ||
| 1449 | 1449 | * @param bool $prevent_access | 
| 1450 | 1450 | * @return bool | 
| 1451 | 1451 | */ | 
| 1452 | -	public function admin_access( $prevent_access ) { | |
| 1453 | -		if ( current_user_can( 'manage_sensei_grades' ) ) { | |
| 1452 | +	public function admin_access($prevent_access) { | |
| 1453 | +		if (current_user_can('manage_sensei_grades')) { | |
| 1454 | 1454 | return false; | 
| 1455 | 1455 | } | 
| 1456 | 1456 | |
| @@ -1465,12 +1465,12 @@ discard block | ||
| 1465 | 1465 | * | 
| 1466 | 1466 | * @since 1.8.7 | 
| 1467 | 1467 | */ | 
| 1468 | -    public  static function install_pages(){ | |
| 1468 | +    public  static function install_pages() { | |
| 1469 | 1469 | |
| 1470 | 1470 | // only fire on the settings page | 
| 1471 | - if( ! isset( $_GET['page'] ) | |
| 1471 | + if ( ! isset($_GET['page']) | |
| 1472 | 1472 | || 'woothemes-sensei-settings' != $_GET['page'] | 
| 1473 | -            || 1 == get_option('skip_install_sensei_pages') ){ | |
| 1473 | +            || 1 == get_option('skip_install_sensei_pages')) { | |
| 1474 | 1474 | |
| 1475 | 1475 | return; | 
| 1476 | 1476 | |
| @@ -1507,8 +1507,8 @@ discard block | ||
| 1507 | 1507 | // Set installed option | 
| 1508 | 1508 |              update_option('sensei_installed', 0); | 
| 1509 | 1509 | |
| 1510 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); | |
| 1511 | - wp_redirect( $complete_url ); | |
| 1510 | +            $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url); | |
| 1511 | + wp_redirect($complete_url); | |
| 1512 | 1512 | |
| 1513 | 1513 | } | 
| 1514 | 1514 | |
| @@ -1522,4 +1522,4 @@ discard block | ||
| 1522 | 1522 | * @since 1.9.0 | 
| 1523 | 1523 | * @ignore | 
| 1524 | 1524 | */ | 
| 1525 | -class WooThemes_Sensei_Admin extends Sensei_Admin{ } | |
| 1525 | +class WooThemes_Sensei_Admin extends Sensei_Admin { } | |
| @@ -1,5 +1,8 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | + exit; | |
| 4 | +} | |
| 5 | +// Exit if accessed directly | |
| 3 | 6 | |
| 4 | 7 | /** | 
| 5 | 8 | * Handles all admin views, assets and navigation. | 
| @@ -732,7 +735,9 @@ discard block | ||
| 732 | 735 | $types = array( 'course', 'lesson', 'question' ); | 
| 733 | 736 | |
| 734 | 737 |  		foreach( $types as $type ) { | 
| 735 | - if( ! post_type_exists( $type ) ) continue; | |
| 738 | +			if( ! post_type_exists( $type ) ) { | |
| 739 | + continue; | |
| 740 | + } | |
| 736 | 741 | |
| 737 | 742 | $num_posts = wp_count_posts( $type ); | 
| 738 | 743 | |
| @@ -800,7 +805,9 @@ discard block | ||
| 800 | 805 | |
| 801 | 806 | $html = ''; | 
| 802 | 807 | |
| 803 | - if( 0 == count( $settings ) ) return $html; | |
| 808 | +		if( 0 == count( $settings ) ) { | |
| 809 | + return $html; | |
| 810 | + } | |
| 804 | 811 | |
| 805 | 812 | $html .= '<div class="sensei-options-panel">' . "\n"; | 
| 806 | 813 | |
| @@ -882,11 +889,11 @@ discard block | ||
| 882 | 889 | //backwards compatibility | 
| 883 | 890 |                                      if( empty( $data ) || 'on' == $data ){ | 
| 884 | 891 | $checked_value = 'on'; | 
| 885 | -                                    }elseif( 'yes' == $data  ) { | |
| 892 | +                                    } elseif( 'yes' == $data  ) { | |
| 886 | 893 | |
| 887 | 894 | $checked_value = 'yes'; | 
| 888 | 895 | |
| 889 | -                                    }elseif( 'auto' == $data  ) { | |
| 896 | +                                    } elseif( 'auto' == $data  ) { | |
| 890 | 897 | |
| 891 | 898 | $checked_value = 'auto'; | 
| 892 | 899 | |
| @@ -60,8 +60,8 @@ | ||
| 60 | 60 | /** | 
| 61 | 61 | * @since 1.9.0 | 
| 62 | 62 | * | 
| 63 | - * @param $setting | |
| 64 | - * @param $new_value | |
| 63 | + * @param string $setting | |
| 64 | + * @param integer $new_value | |
| 65 | 65 | */ | 
| 66 | 66 |      public function set( $setting, $new_value ){ | 
| 67 | 67 | |
| @@ -19,63 +19,63 @@ discard block | ||
| 19 | 19 | * @since 1.0.0 | 
| 20 | 20 | */ | 
| 21 | 21 |  	public function __construct () { | 
| 22 | - parent::__construct(); // Required in extended classes. | |
| 22 | + parent::__construct(); // Required in extended classes. | |
| 23 | 23 | |
| 24 | - $this->token = 'woothemes-sensei-settings'; | |
| 25 | -        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); | |
| 24 | + $this->token = 'woothemes-sensei-settings'; | |
| 25 | +		add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); | |
| 26 | 26 | |
| 27 | - // Setup Admin Settings data | |
| 28 | -        if ( is_admin() ) { | |
| 27 | + // Setup Admin Settings data | |
| 28 | +		if ( is_admin() ) { | |
| 29 | 29 | |
| 30 | - $this->has_tabs = true; | |
| 31 | - $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); | |
| 32 | - $this->menu_label = __( 'Settings', 'woothemes-sensei' ); | |
| 33 | - $this->page_slug = 'woothemes-sensei-settings'; | |
| 30 | + $this->has_tabs = true; | |
| 31 | + $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); | |
| 32 | + $this->menu_label = __( 'Settings', 'woothemes-sensei' ); | |
| 33 | + $this->page_slug = 'woothemes-sensei-settings'; | |
| 34 | 34 | |
| 35 | - } // End If Statement | |
| 35 | + } // End If Statement | |
| 36 | 36 | |
| 37 | - $this->register_hook_listener(); | |
| 38 | - $this->get_settings(); | |
| 37 | + $this->register_hook_listener(); | |
| 38 | + $this->get_settings(); | |
| 39 | 39 | |
| 40 | 40 | } // End __construct() | 
| 41 | 41 | |
| 42 | - /** | |
| 43 | - * Get settings value | |
| 44 | - * | |
| 45 | - * @since 1.9.0 | |
| 46 | - * @param string $setting_name | |
| 47 | - * @return mixed | |
| 48 | - */ | |
| 49 | -    public function get( $setting_name ){ | |
| 42 | + /** | |
| 43 | + * Get settings value | |
| 44 | + * | |
| 45 | + * @since 1.9.0 | |
| 46 | + * @param string $setting_name | |
| 47 | + * @return mixed | |
| 48 | + */ | |
| 49 | +	public function get( $setting_name ){ | |
| 50 | 50 | |
| 51 | -        if( isset( $this->settings[ $setting_name ] ) ){ | |
| 51 | +		if( isset( $this->settings[ $setting_name ] ) ){ | |
| 52 | 52 | |
| 53 | - return $this->settings[ $setting_name ]; | |
| 53 | + return $this->settings[ $setting_name ]; | |
| 54 | 54 | |
| 55 | - } | |
| 55 | + } | |
| 56 | 56 | |
| 57 | - return false; | |
| 58 | - } | |
| 57 | + return false; | |
| 58 | + } | |
| 59 | 59 | |
| 60 | - /** | |
| 61 | - * @since 1.9.0 | |
| 62 | - * | |
| 63 | - * @param $setting | |
| 64 | - * @param $new_value | |
| 65 | - */ | |
| 66 | -    public function set( $setting, $new_value ){ | |
| 60 | + /** | |
| 61 | + * @since 1.9.0 | |
| 62 | + * | |
| 63 | + * @param $setting | |
| 64 | + * @param $new_value | |
| 65 | + */ | |
| 66 | +	public function set( $setting, $new_value ){ | |
| 67 | 67 | |
| 68 | - $settings = get_option( $this->token, array() ); | |
| 68 | + $settings = get_option( $this->token, array() ); | |
| 69 | 69 | |
| 70 | -        if( isset(  $settings[ $setting ] ) ){ | |
| 70 | +		if( isset(  $settings[ $setting ] ) ){ | |
| 71 | 71 | |
| 72 | - $settings[ $setting ] = $new_value; | |
| 73 | - return update_option( $this->token,$settings ); | |
| 72 | + $settings[ $setting ] = $new_value; | |
| 73 | + return update_option( $this->token,$settings ); | |
| 74 | 74 | |
| 75 | - } | |
| 76 | - return false; | |
| 75 | + } | |
| 76 | + return false; | |
| 77 | 77 | |
| 78 | - } | |
| 78 | + } | |
| 79 | 79 | |
| 80 | 80 | /** | 
| 81 | 81 | * Register the settings screen within the WordPress admin. | 
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | $complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) ); | 
| 164 | 164 | $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); | 
| 165 | 165 | |
| 166 | - $fields = array(); | |
| 166 | + $fields = array(); | |
| 167 | 167 | |
| 168 | 168 | $fields['access_permission'] = array( | 
| 169 | 169 | 'name' => __( 'Access Permissions', 'woothemes-sensei' ), | 
| @@ -225,9 +225,9 @@ discard block | ||
| 225 | 225 | 'section' => 'default-settings' | 
| 226 | 226 | ); | 
| 227 | 227 | |
| 228 | - // Course Settings | |
| 228 | + // Course Settings | |
| 229 | 229 | |
| 230 | - $fields['course_completion'] = array( | |
| 230 | + $fields['course_completion'] = array( | |
| 231 | 231 | 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), | 
| 232 | 232 | 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), | 
| 233 | 233 | 'type' => 'select', | 
| @@ -237,7 +237,7 @@ discard block | ||
| 237 | 237 | 'options' => $complete_settings | 
| 238 | 238 | ); | 
| 239 | 239 | |
| 240 | - $fields['course_author'] = array( | |
| 240 | + $fields['course_author'] = array( | |
| 241 | 241 | 'name' => __( 'Display Course Author', 'woothemes-sensei' ), | 
| 242 | 242 | 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), | 
| 243 | 243 | 'type' => 'checkbox', | 
| @@ -465,10 +465,10 @@ discard block | ||
| 465 | 465 | ); | 
| 466 | 466 | |
| 467 | 467 | $teacher_email_options = array( | 
| 468 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), | |
| 469 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), | |
| 470 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), | |
| 471 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), | |
| 468 | + 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), | |
| 469 | + 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), | |
| 470 | + 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), | |
| 471 | + 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), | |
| 472 | 472 | 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), | 
| 473 | 473 | ); | 
| 474 | 474 | |
| @@ -577,7 +577,7 @@ discard block | ||
| 577 | 577 | |
| 578 | 578 |  		if ( Sensei_WC::is_woocommerce_present() ) { | 
| 579 | 579 | // WooCommerce Settings | 
| 580 | - $fields['woocommerce_enabled'] = array( | |
| 580 | + $fields['woocommerce_enabled'] = array( | |
| 581 | 581 | 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), | 
| 582 | 582 | 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), | 
| 583 | 583 | 'type' => 'checkbox', | 
| @@ -665,14 +665,14 @@ discard block | ||
| 665 | 665 | $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); | 
| 666 | 666 | |
| 667 | 667 |  		foreach ( $pages_split as $k => $v ) { | 
| 668 | - $id = ''; | |
| 669 | - // Get the ID value. | |
| 670 | - preg_match( '/value="(.*?)"/i', $v, $matches ); | |
| 671 | - | |
| 672 | -		    if ( isset( $matches[1] ) ) { | |
| 673 | - $id = $matches[1]; | |
| 674 | - $page_items[$id] = trim( strip_tags( $v ) ); | |
| 675 | - } // End If Statement | |
| 668 | + $id = ''; | |
| 669 | + // Get the ID value. | |
| 670 | + preg_match( '/value="(.*?)"/i', $v, $matches ); | |
| 671 | + | |
| 672 | +			if ( isset( $matches[1] ) ) { | |
| 673 | + $id = $matches[1]; | |
| 674 | + $page_items[$id] = trim( strip_tags( $v ) ); | |
| 675 | + } // End If Statement | |
| 676 | 676 | } // End For Loop | 
| 677 | 677 | |
| 678 | 678 | $pages_array = $page_items; | 
| @@ -689,22 +689,22 @@ discard block | ||
| 689 | 689 | Sensei_Language_Pack_Manager::messages(); | 
| 690 | 690 | } | 
| 691 | 691 | |
| 692 | - /** | |
| 693 | - * Flush the rewrite rules after the settings have been updated. | |
| 694 | - * This is to ensure that the | |
| 695 | - * | |
| 696 | - * @since 1.9.0 | |
| 697 | - */ | |
| 698 | -    public static function flush_rewrite_rules(){ | |
| 692 | + /** | |
| 693 | + * Flush the rewrite rules after the settings have been updated. | |
| 694 | + * This is to ensure that the | |
| 695 | + * | |
| 696 | + * @since 1.9.0 | |
| 697 | + */ | |
| 698 | +	public static function flush_rewrite_rules(){ | |
| 699 | 699 | |
| 700 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] | |
| 701 | -            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { | |
| 700 | + if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] | |
| 701 | +			&& isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { | |
| 702 | 702 | |
| 703 | - Sensei()->initiate_rewrite_rules_flush(); | |
| 703 | + Sensei()->initiate_rewrite_rules_flush(); | |
| 704 | 704 | |
| 705 | - } | |
| 705 | + } | |
| 706 | 706 | |
| 707 | - }//end flush_cache | |
| 707 | + }//end flush_cache | |
| 708 | 708 | } // End Class | 
| 709 | 709 | |
| 710 | 710 | /** | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly | |
| 3 | 3 | |
| 4 | 4 | /* | 
| 5 | 5 | * Sensei Settings Class | 
| @@ -18,18 +18,18 @@ discard block | ||
| 18 | 18 | * @access public | 
| 19 | 19 | * @since 1.0.0 | 
| 20 | 20 | */ | 
| 21 | -	public function __construct () { | |
| 21 | +	public function __construct() { | |
| 22 | 22 | parent::__construct(); // Required in extended classes. | 
| 23 | 23 | |
| 24 | 24 | $this->token = 'woothemes-sensei-settings'; | 
| 25 | -        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); | |
| 25 | +        add_action('init', array(__CLASS__, 'flush_rewrite_rules')); | |
| 26 | 26 | |
| 27 | 27 | // Setup Admin Settings data | 
| 28 | -        if ( is_admin() ) { | |
| 28 | +        if (is_admin()) { | |
| 29 | 29 | |
| 30 | 30 | $this->has_tabs = true; | 
| 31 | - $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); | |
| 32 | - $this->menu_label = __( 'Settings', 'woothemes-sensei' ); | |
| 31 | +            $this->name = __('Sensei Settings', 'woothemes-sensei'); | |
| 32 | +            $this->menu_label = __('Settings', 'woothemes-sensei'); | |
| 33 | 33 | $this->page_slug = 'woothemes-sensei-settings'; | 
| 34 | 34 | |
| 35 | 35 | } // End If Statement | 
| @@ -46,11 +46,11 @@ discard block | ||
| 46 | 46 | * @param string $setting_name | 
| 47 | 47 | * @return mixed | 
| 48 | 48 | */ | 
| 49 | -    public function get( $setting_name ){ | |
| 49 | +    public function get($setting_name) { | |
| 50 | 50 | |
| 51 | -        if( isset( $this->settings[ $setting_name ] ) ){ | |
| 51 | +        if (isset($this->settings[$setting_name])) { | |
| 52 | 52 | |
| 53 | - return $this->settings[ $setting_name ]; | |
| 53 | + return $this->settings[$setting_name]; | |
| 54 | 54 | |
| 55 | 55 | } | 
| 56 | 56 | |
| @@ -63,14 +63,14 @@ discard block | ||
| 63 | 63 | * @param $setting | 
| 64 | 64 | * @param $new_value | 
| 65 | 65 | */ | 
| 66 | -    public function set( $setting, $new_value ){ | |
| 66 | +    public function set($setting, $new_value) { | |
| 67 | 67 | |
| 68 | - $settings = get_option( $this->token, array() ); | |
| 68 | + $settings = get_option($this->token, array()); | |
| 69 | 69 | |
| 70 | -        if( isset(  $settings[ $setting ] ) ){ | |
| 70 | +        if (isset($settings[$setting])) { | |
| 71 | 71 | |
| 72 | - $settings[ $setting ] = $new_value; | |
| 73 | - return update_option( $this->token,$settings ); | |
| 72 | + $settings[$setting] = $new_value; | |
| 73 | + return update_option($this->token, $settings); | |
| 74 | 74 | |
| 75 | 75 | } | 
| 76 | 76 | return false; | 
| @@ -83,17 +83,17 @@ discard block | ||
| 83 | 83 | * @since 1.0.0 | 
| 84 | 84 | * @return void | 
| 85 | 85 | */ | 
| 86 | -	public function register_settings_screen () { | |
| 86 | +	public function register_settings_screen() { | |
| 87 | 87 | |
| 88 | 88 | $this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen. | 
| 89 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); | |
| 89 | +		$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); | |
| 90 | 90 | $this->hook = $hook; | 
| 91 | 91 | |
| 92 | -		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { | |
| 93 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); | |
| 94 | - add_action( 'admin_notices', array( $this, 'language_pack_notices' ) ); | |
| 95 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); | |
| 96 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); | |
| 92 | +		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { | |
| 93 | +			add_action('admin_notices', array($this, 'settings_errors')); | |
| 94 | +			add_action('admin_notices', array($this, 'language_pack_notices')); | |
| 95 | +			add_action('admin_print_scripts', array($this, 'enqueue_scripts')); | |
| 96 | +			add_action('admin_print_styles', array($this, 'enqueue_styles')); | |
| 97 | 97 | } | 
| 98 | 98 | } // End register_settings_screen() | 
| 99 | 99 | |
| @@ -103,49 +103,49 @@ discard block | ||
| 103 | 103 | * @since 1.0.0 | 
| 104 | 104 | * @return void | 
| 105 | 105 | */ | 
| 106 | -	public function init_sections () { | |
| 106 | +	public function init_sections() { | |
| 107 | 107 | $sections = array(); | 
| 108 | 108 | |
| 109 | 109 | $sections['default-settings'] = array( | 
| 110 | - 'name' => __( 'General', 'woothemes-sensei' ), | |
| 111 | - 'description' => __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' ) | |
| 110 | +			'name' 			=> __('General', 'woothemes-sensei'), | |
| 111 | +			'description'	=> __('Settings that apply to the entire plugin.', 'woothemes-sensei') | |
| 112 | 112 | ); | 
| 113 | 113 | |
| 114 | 114 | $sections['course-settings'] = array( | 
| 115 | - 'name' => __( 'Courses', 'woothemes-sensei' ), | |
| 116 | - 'description' => __( 'Settings that apply to all Courses.', 'woothemes-sensei' ) | |
| 115 | +			'name' 			=> __('Courses', 'woothemes-sensei'), | |
| 116 | +			'description'	=> __('Settings that apply to all Courses.', 'woothemes-sensei') | |
| 117 | 117 | ); | 
| 118 | 118 | |
| 119 | 119 | $sections['lesson-settings'] = array( | 
| 120 | - 'name' => __( 'Lessons', 'woothemes-sensei' ), | |
| 121 | - 'description' => __( 'Settings that apply to all Lessons.', 'woothemes-sensei' ) | |
| 120 | +			'name' 			=> __('Lessons', 'woothemes-sensei'), | |
| 121 | +			'description'	=> __('Settings that apply to all Lessons.', 'woothemes-sensei') | |
| 122 | 122 | ); | 
| 123 | 123 | |
| 124 | 124 | $sections['email-notification-settings'] = array( | 
| 125 | - 'name' => __( 'Email Notifications', 'woothemes-sensei' ), | |
| 126 | - 'description' => __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' ) | |
| 125 | +			'name' 			=> __('Email Notifications', 'woothemes-sensei'), | |
| 126 | +			'description'	=> __('Settings for email notifications sent from your site.', 'woothemes-sensei') | |
| 127 | 127 | ); | 
| 128 | 128 | |
| 129 | 129 | $sections['learner-profile-settings'] = array( | 
| 130 | - 'name' => __( 'Learner Profiles', 'woothemes-sensei' ), | |
| 131 | - 'description' => __( 'Settings for public Learner Profiles.', 'woothemes-sensei' ) | |
| 130 | +			'name' 			=> __('Learner Profiles', 'woothemes-sensei'), | |
| 131 | +			'description'	=> __('Settings for public Learner Profiles.', 'woothemes-sensei') | |
| 132 | 132 | ); | 
| 133 | 133 | |
| 134 | -		if ( Sensei_WC::is_woocommerce_present() ) { | |
| 134 | +		if (Sensei_WC::is_woocommerce_present()) { | |
| 135 | 135 | $sections['woocommerce-settings'] = array( | 
| 136 | - 'name' => __( 'WooCommerce', 'woothemes-sensei' ), | |
| 137 | - 'description' => __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' ) | |
| 136 | +				'name' 			=> __('WooCommerce', 'woothemes-sensei'), | |
| 137 | +				'description'	=> __('Optional settings for WooCommerce functions.', 'woothemes-sensei') | |
| 138 | 138 | ); | 
| 139 | 139 | } // End If Statement | 
| 140 | 140 | |
| 141 | -		if ( 'en_US' !== get_locale() ) { | |
| 141 | +		if ('en_US' !== get_locale()) { | |
| 142 | 142 | $sections['language-settings'] = array( | 
| 143 | - 'name' => __( 'Language', 'woothemes-sensei' ), | |
| 144 | - 'description' => __( 'Language options.', 'woothemes-sensei' ) | |
| 143 | +				'name' 			=> __('Language', 'woothemes-sensei'), | |
| 144 | +				'description'	=> __('Language options.', 'woothemes-sensei') | |
| 145 | 145 | ); | 
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | - $this->sections = apply_filters( 'sensei_settings_tabs', $sections ); | |
| 148 | +		$this->sections = apply_filters('sensei_settings_tabs', $sections); | |
| 149 | 149 | } // End init_sections() | 
| 150 | 150 | |
| 151 | 151 | /** | 
| @@ -155,71 +155,71 @@ discard block | ||
| 155 | 155 | * @uses Sensei_Utils::get_slider_types() | 
| 156 | 156 | * @return void | 
| 157 | 157 | */ | 
| 158 | -	public function init_fields () { | |
| 158 | +	public function init_fields() { | |
| 159 | 159 | global $pagenow; | 
| 160 | 160 | |
| 161 | 161 | $pages_array = $this->pages_array(); | 
| 162 | - $posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' ); | |
| 163 | - $complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) ); | |
| 164 | - $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); | |
| 162 | +		$posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20'); | |
| 163 | +		$complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei')); | |
| 164 | +		$course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei')); | |
| 165 | 165 | |
| 166 | 166 | $fields = array(); | 
| 167 | 167 | |
| 168 | 168 | $fields['access_permission'] = array( | 
| 169 | - 'name' => __( 'Access Permissions', 'woothemes-sensei' ), | |
| 170 | - 'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ), | |
| 169 | +								'name' => __('Access Permissions', 'woothemes-sensei'), | |
| 170 | +								'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'), | |
| 171 | 171 | 'type' => 'checkbox', | 
| 172 | 172 | 'default' => true, | 
| 173 | 173 | 'section' => 'default-settings' | 
| 174 | 174 | ); | 
| 175 | 175 | |
| 176 | 176 | $fields['messages_disable'] = array( | 
| 177 | - 'name' => __( 'Disable Private Messages', 'woothemes-sensei' ), | |
| 178 | - 'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ), | |
| 177 | +								'name' => __('Disable Private Messages', 'woothemes-sensei'), | |
| 178 | +								'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'), | |
| 179 | 179 | 'type' => 'checkbox', | 
| 180 | 180 | 'default' => false, | 
| 181 | 181 | 'section' => 'default-settings' | 
| 182 | 182 | ); | 
| 183 | 183 | |
| 184 | 184 | $fields['course_page'] = array( | 
| 185 | - 'name' => __( 'Course Archive Page', 'woothemes-sensei' ), | |
| 186 | - 'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ), | |
| 185 | +								'name' => __('Course Archive Page', 'woothemes-sensei'), | |
| 186 | +								'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'), | |
| 187 | 187 | 'type' => 'select', | 
| 188 | - 'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ), | |
| 188 | +								'default' => get_option('woothemes-sensei_courses_page_id', 0), | |
| 189 | 189 | 'section' => 'default-settings', | 
| 190 | 190 | 'required' => 0, | 
| 191 | 191 | 'options' => $pages_array | 
| 192 | 192 | ); | 
| 193 | 193 | |
| 194 | 194 | $fields['my_course_page'] = array( | 
| 195 | - 'name' => __( 'My Courses Page', 'woothemes-sensei' ), | |
| 196 | - 'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ), | |
| 195 | +								'name' => __('My Courses Page', 'woothemes-sensei'), | |
| 196 | +								'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'), | |
| 197 | 197 | 'type' => 'select', | 
| 198 | - 'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ), | |
| 198 | +								'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0), | |
| 199 | 199 | 'section' => 'default-settings', | 
| 200 | 200 | 'required' => 0, | 
| 201 | 201 | 'options' => $pages_array | 
| 202 | 202 | ); | 
| 203 | 203 | |
| 204 | 204 | $fields['placeholder_images_enable'] = array( | 
| 205 | - 'name' => __( 'Use placeholder images', 'woothemes-sensei' ), | |
| 206 | - 'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ), | |
| 205 | +								'name' => __('Use placeholder images', 'woothemes-sensei'), | |
| 206 | +								'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'), | |
| 207 | 207 | 'type' => 'checkbox', | 
| 208 | 208 | 'default' => false, | 
| 209 | 209 | 'section' => 'default-settings' | 
| 210 | 210 | ); | 
| 211 | 211 | |
| 212 | 212 | $fields['styles_disable'] = array( | 
| 213 | - 'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ), | |
| 214 | - 'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ), | |
| 213 | +								'name' => __('Disable Sensei Styles', 'woothemes-sensei'), | |
| 214 | +								'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'), | |
| 215 | 215 | 'type' => 'checkbox', | 
| 216 | 216 | 'default' => false, | 
| 217 | 217 | 'section' => 'default-settings' | 
| 218 | 218 | ); | 
| 219 | 219 | |
| 220 | 220 | $fields['js_disable'] = array( | 
| 221 | - 'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ), | |
| 222 | - 'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ), | |
| 221 | +								'name' => __('Disable Sensei Javascript', 'woothemes-sensei'), | |
| 222 | +								'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'), | |
| 223 | 223 | 'type' => 'checkbox', | 
| 224 | 224 | 'default' => false, | 
| 225 | 225 | 'section' => 'default-settings' | 
| @@ -228,8 +228,8 @@ discard block | ||
| 228 | 228 | // Course Settings | 
| 229 | 229 | |
| 230 | 230 | $fields['course_completion'] = array( | 
| 231 | - 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), | |
| 232 | - 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), | |
| 231 | +								'name' => __('Courses are complete:', 'woothemes-sensei'), | |
| 232 | +								'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'), | |
| 233 | 233 | 'type' => 'select', | 
| 234 | 234 | 'default' => 'passed', | 
| 235 | 235 | 'section' => 'course-settings', | 
| @@ -238,16 +238,16 @@ discard block | ||
| 238 | 238 | ); | 
| 239 | 239 | |
| 240 | 240 | $fields['course_author'] = array( | 
| 241 | - 'name' => __( 'Display Course Author', 'woothemes-sensei' ), | |
| 242 | - 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), | |
| 241 | +								'name' => __('Display Course Author', 'woothemes-sensei'), | |
| 242 | +								'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'), | |
| 243 | 243 | 'type' => 'checkbox', | 
| 244 | 244 | 'default' => true, | 
| 245 | 245 | 'section' => 'course-settings' | 
| 246 | 246 | ); | 
| 247 | 247 | |
| 248 | 248 | $fields['my_course_amount'] = array( | 
| 249 | - 'name' => __( 'My Courses Pagination', 'woothemes-sensei' ), | |
| 250 | - 'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ), | |
| 249 | +								'name' => __('My Courses Pagination', 'woothemes-sensei'), | |
| 250 | +								'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'), | |
| 251 | 251 | 'type' => 'range', | 
| 252 | 252 | 'default' => '0', | 
| 253 | 253 | 'section' => 'course-settings', | 
| @@ -256,16 +256,16 @@ discard block | ||
| 256 | 256 | ); | 
| 257 | 257 | |
| 258 | 258 | $fields['course_archive_image_enable'] = array( | 
| 259 | - 'name' => __( 'Course Archive Image', 'woothemes-sensei' ), | |
| 260 | - 'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ), | |
| 259 | +								'name' => __('Course Archive Image', 'woothemes-sensei'), | |
| 260 | +								'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'), | |
| 261 | 261 | 'type' => 'checkbox', | 
| 262 | 262 | 'default' => true, | 
| 263 | 263 | 'section' => 'course-settings' | 
| 264 | 264 | ); | 
| 265 | 265 | |
| 266 | 266 | $fields['course_archive_image_width'] = array( | 
| 267 | - 'name' => __( 'Image Width - Archive', 'woothemes-sensei' ), | |
| 268 | - 'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), | |
| 267 | +								'name' => __('Image Width - Archive', 'woothemes-sensei'), | |
| 268 | +								'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), | |
| 269 | 269 | 'type' => 'text', | 
| 270 | 270 | 'default' => '100', | 
| 271 | 271 | 'section' => 'course-settings', | 
| @@ -273,8 +273,8 @@ discard block | ||
| 273 | 273 | ); | 
| 274 | 274 | |
| 275 | 275 | $fields['course_archive_image_height'] = array( | 
| 276 | - 'name' => __( 'Image Height - Archive', 'woothemes-sensei' ), | |
| 277 | - 'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), | |
| 276 | +								'name' => __('Image Height - Archive', 'woothemes-sensei'), | |
| 277 | +								'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), | |
| 278 | 278 | 'type' => 'text', | 
| 279 | 279 | 'default' => '100', | 
| 280 | 280 | 'section' => 'course-settings', | 
| @@ -282,24 +282,24 @@ discard block | ||
| 282 | 282 | ); | 
| 283 | 283 | |
| 284 | 284 | $fields['course_archive_image_hard_crop'] = array( | 
| 285 | - 'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ), | |
| 286 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), | |
| 285 | +								'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'), | |
| 286 | +								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), | |
| 287 | 287 | 'type' => 'checkbox', | 
| 288 | 288 | 'default' => false, | 
| 289 | 289 | 'section' => 'course-settings' | 
| 290 | 290 | ); | 
| 291 | 291 | |
| 292 | 292 | $fields['course_single_image_enable'] = array( | 
| 293 | - 'name' => __( 'Single Course Image', 'woothemes-sensei' ), | |
| 294 | - 'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ), | |
| 293 | +								'name' => __('Single Course Image', 'woothemes-sensei'), | |
| 294 | +								'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'), | |
| 295 | 295 | 'type' => 'checkbox', | 
| 296 | 296 | 'default' => false, | 
| 297 | 297 | 'section' => 'course-settings' | 
| 298 | 298 | ); | 
| 299 | 299 | |
| 300 | 300 | $fields['course_single_image_width'] = array( | 
| 301 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), | |
| 302 | - 'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), | |
| 301 | +								'name' => __('Image Width - Single', 'woothemes-sensei'), | |
| 302 | +								'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), | |
| 303 | 303 | 'type' => 'text', | 
| 304 | 304 | 'default' => '100', | 
| 305 | 305 | 'section' => 'course-settings', | 
| @@ -307,8 +307,8 @@ discard block | ||
| 307 | 307 | ); | 
| 308 | 308 | |
| 309 | 309 | $fields['course_single_image_height'] = array( | 
| 310 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), | |
| 311 | - 'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), | |
| 310 | +								'name' => __('Image Height - Single', 'woothemes-sensei'), | |
| 311 | +								'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), | |
| 312 | 312 | 'type' => 'text', | 
| 313 | 313 | 'default' => '100', | 
| 314 | 314 | 'section' => 'course-settings', | 
| @@ -316,16 +316,16 @@ discard block | ||
| 316 | 316 | ); | 
| 317 | 317 | |
| 318 | 318 | $fields['course_single_image_hard_crop'] = array( | 
| 319 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), | |
| 320 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), | |
| 319 | +								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), | |
| 320 | +								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), | |
| 321 | 321 | 'type' => 'checkbox', | 
| 322 | 322 | 'default' => false, | 
| 323 | 323 | 'section' => 'course-settings' | 
| 324 | 324 | ); | 
| 325 | 325 | |
| 326 | 326 | $fields['course_single_content_display'] = array( | 
| 327 | - 'name' => __( 'Single Course page displays:', 'woothemes-sensei' ), | |
| 328 | - 'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ), | |
| 327 | +								'name' => __('Single Course page displays:', 'woothemes-sensei'), | |
| 328 | +								'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'), | |
| 329 | 329 | 'type' => 'select', | 
| 330 | 330 | 'default' => 'excerpt', | 
| 331 | 331 | 'section' => 'course-settings', | 
| @@ -334,18 +334,18 @@ discard block | ||
| 334 | 334 | ); | 
| 335 | 335 | |
| 336 | 336 | $fields['course_archive_featured_enable'] = array( | 
| 337 | - 'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ), | |
| 338 | - 'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), | |
| 337 | +								'name' => __('Featured Courses Panel', 'woothemes-sensei'), | |
| 338 | +								'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'), | |
| 339 | 339 | 'type' => 'checkbox', | 
| 340 | 340 | 'default' => true, | 
| 341 | 341 | 'section' => 'course-settings' | 
| 342 | 342 | ); | 
| 343 | 343 | |
| 344 | 344 | $fields['course_archive_more_link_text'] = array( | 
| 345 | - 'name' => __( 'More link text', 'woothemes-sensei' ), | |
| 346 | - 'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ), | |
| 345 | +								'name' => __('More link text', 'woothemes-sensei'), | |
| 346 | +								'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'), | |
| 347 | 347 | 'type' => 'text', | 
| 348 | - 'default' => __ ( 'More', 'woothemes-sensei' ), | |
| 348 | +								'default' => __('More', 'woothemes-sensei'), | |
| 349 | 349 | 'section' => 'course-settings', | 
| 350 | 350 | 'required' => 0 | 
| 351 | 351 | ); | 
| @@ -353,32 +353,32 @@ discard block | ||
| 353 | 353 | // Lesson Settings | 
| 354 | 354 | |
| 355 | 355 | $fields['lesson_comments'] = array( | 
| 356 | - 'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ), | |
| 357 | - 'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ), | |
| 356 | +								'name' => __('Allow Comments for Lessons', 'woothemes-sensei'), | |
| 357 | +								'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'), | |
| 358 | 358 | 'type' => 'checkbox', | 
| 359 | 359 | 'default' => true, | 
| 360 | 360 | 'section' => 'lesson-settings' | 
| 361 | 361 | ); | 
| 362 | 362 | |
| 363 | 363 | $fields['lesson_author'] = array( | 
| 364 | - 'name' => __( 'Display Lesson Author', 'woothemes-sensei' ), | |
| 365 | - 'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ), | |
| 364 | +								'name' => __('Display Lesson Author', 'woothemes-sensei'), | |
| 365 | +								'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'), | |
| 366 | 366 | 'type' => 'checkbox', | 
| 367 | 367 | 'default' => true, | 
| 368 | 368 | 'section' => 'lesson-settings' | 
| 369 | 369 | ); | 
| 370 | 370 | |
| 371 | 371 | $fields['course_lesson_image_enable'] = array( | 
| 372 | - 'name' => __( 'Course Lesson Images', 'woothemes-sensei' ), | |
| 373 | - 'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ), | |
| 372 | +								'name' => __('Course Lesson Images', 'woothemes-sensei'), | |
| 373 | +								'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'), | |
| 374 | 374 | 'type' => 'checkbox', | 
| 375 | 375 | 'default' => false, | 
| 376 | 376 | 'section' => 'lesson-settings' | 
| 377 | 377 | ); | 
| 378 | 378 | |
| 379 | 379 | $fields['lesson_archive_image_width'] = array( | 
| 380 | - 'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ), | |
| 381 | - 'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), | |
| 380 | +								'name' => __('Image Width - Course Lessons', 'woothemes-sensei'), | |
| 381 | +								'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), | |
| 382 | 382 | 'type' => 'text', | 
| 383 | 383 | 'default' => '100', | 
| 384 | 384 | 'section' => 'lesson-settings', | 
| @@ -386,8 +386,8 @@ discard block | ||
| 386 | 386 | ); | 
| 387 | 387 | |
| 388 | 388 | $fields['lesson_archive_image_height'] = array( | 
| 389 | - 'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ), | |
| 390 | - 'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), | |
| 389 | +								'name' => __('Image Height - Course Lessons', 'woothemes-sensei'), | |
| 390 | +								'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), | |
| 391 | 391 | 'type' => 'text', | 
| 392 | 392 | 'default' => '100', | 
| 393 | 393 | 'section' => 'lesson-settings', | 
| @@ -395,24 +395,24 @@ discard block | ||
| 395 | 395 | ); | 
| 396 | 396 | |
| 397 | 397 | $fields['lesson_archive_image_hard_crop'] = array( | 
| 398 | - 'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ), | |
| 399 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), | |
| 398 | +								'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'), | |
| 399 | +								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), | |
| 400 | 400 | 'type' => 'checkbox', | 
| 401 | 401 | 'default' => false, | 
| 402 | 402 | 'section' => 'lesson-settings' | 
| 403 | 403 | ); | 
| 404 | 404 | |
| 405 | 405 | $fields['lesson_single_image_enable'] = array( | 
| 406 | - 'name' => __( 'Single Lesson Images', 'woothemes-sensei' ), | |
| 407 | - 'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ), | |
| 406 | +								'name' => __('Single Lesson Images', 'woothemes-sensei'), | |
| 407 | +								'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'), | |
| 408 | 408 | 'type' => 'checkbox', | 
| 409 | 409 | 'default' => false, | 
| 410 | 410 | 'section' => 'lesson-settings' | 
| 411 | 411 | ); | 
| 412 | 412 | |
| 413 | 413 | $fields['lesson_single_image_width'] = array( | 
| 414 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), | |
| 415 | - 'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), | |
| 414 | +								'name' => __('Image Width - Single', 'woothemes-sensei'), | |
| 415 | +								'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), | |
| 416 | 416 | 'type' => 'text', | 
| 417 | 417 | 'default' => '100', | 
| 418 | 418 | 'section' => 'lesson-settings', | 
| @@ -420,8 +420,8 @@ discard block | ||
| 420 | 420 | ); | 
| 421 | 421 | |
| 422 | 422 | $fields['lesson_single_image_height'] = array( | 
| 423 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), | |
| 424 | - 'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), | |
| 423 | +								'name' => __('Image Height - Single', 'woothemes-sensei'), | |
| 424 | +								'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), | |
| 425 | 425 | 'type' => 'text', | 
| 426 | 426 | 'default' => '100', | 
| 427 | 427 | 'section' => 'lesson-settings', | 
| @@ -429,8 +429,8 @@ discard block | ||
| 429 | 429 | ); | 
| 430 | 430 | |
| 431 | 431 | $fields['lesson_single_image_hard_crop'] = array( | 
| 432 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), | |
| 433 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), | |
| 432 | +								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), | |
| 433 | +								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), | |
| 434 | 434 | 'type' => 'checkbox', | 
| 435 | 435 | 'default' => false, | 
| 436 | 436 | 'section' => 'lesson-settings' | 
| @@ -438,20 +438,20 @@ discard block | ||
| 438 | 438 | |
| 439 | 439 | // Learner Profile settings | 
| 440 | 440 | |
| 441 | - $profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); | |
| 442 | - $profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%'; | |
| 441 | +		$profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei')); | |
| 442 | + $profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%'; | |
| 443 | 443 | |
| 444 | 444 | $fields['learner_profile_enable'] = array( | 
| 445 | - 'name' => __( 'Public learner profiles', 'woothemes-sensei' ), | |
| 446 | - 'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ), | |
| 445 | +							'name' => __('Public learner profiles', 'woothemes-sensei'), | |
| 446 | +							'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example), | |
| 447 | 447 | 'type' => 'checkbox', | 
| 448 | 448 | 'default' => true, | 
| 449 | 449 | 'section' => 'learner-profile-settings' | 
| 450 | 450 | ); | 
| 451 | 451 | |
| 452 | 452 | $fields['learner_profile_show_courses'] = array( | 
| 453 | - 'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ), | |
| 454 | - 'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ), | |
| 453 | +							'name' => __('Show learner\'s courses', 'woothemes-sensei'), | |
| 454 | +							'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'), | |
| 455 | 455 | 'type' => 'checkbox', | 
| 456 | 456 | 'default' => true, | 
| 457 | 457 | 'section' => 'learner-profile-settings' | 
| @@ -460,70 +460,70 @@ discard block | ||
| 460 | 460 | // Email notifications | 
| 461 | 461 | |
| 462 | 462 | $learner_email_options = array( | 
| 463 | - 'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ), | |
| 464 | - 'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ), | |
| 463 | +			'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'), | |
| 464 | +			'learner-completed-course' => __('They complete a course', 'woothemes-sensei'), | |
| 465 | 465 | ); | 
| 466 | 466 | |
| 467 | 467 | $teacher_email_options = array( | 
| 468 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), | |
| 469 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), | |
| 470 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), | |
| 471 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), | |
| 472 | - 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), | |
| 468 | +            'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'), | |
| 469 | +            'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'), | |
| 470 | +            'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'), | |
| 471 | +            'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'), | |
| 472 | +			'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'), | |
| 473 | 473 | ); | 
| 474 | 474 | |
| 475 | 475 | $global_email_options = array( | 
| 476 | - 'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ), | |
| 476 | +			'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'), | |
| 477 | 477 | ); | 
| 478 | 478 | |
| 479 | 479 | $fields['email_learners'] = array( | 
| 480 | - 'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ), | |
| 481 | - 'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ), | |
| 480 | +								'name' => __('Emails Sent to Learners', 'woothemes-sensei'), | |
| 481 | +								'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'), | |
| 482 | 482 | 'type' => 'multicheck', | 
| 483 | 483 | 'options' => $learner_email_options, | 
| 484 | - 'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ), | |
| 484 | +								'defaults' => array('learner-graded-quiz', 'learner-completed-course'), | |
| 485 | 485 | 'section' => 'email-notification-settings' | 
| 486 | 486 | ); | 
| 487 | 487 | |
| 488 | 488 | $fields['email_teachers'] = array( | 
| 489 | - 'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ), | |
| 490 | - 'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ), | |
| 489 | +								'name' => __('Emails Sent to Teachers', 'woothemes-sensei'), | |
| 490 | +								'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'), | |
| 491 | 491 | 'type' => 'multicheck', | 
| 492 | 492 | 'options' => $teacher_email_options, | 
| 493 | - 'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ), | |
| 493 | +								'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'), | |
| 494 | 494 | 'section' => 'email-notification-settings' | 
| 495 | 495 | ); | 
| 496 | 496 | |
| 497 | 497 | $fields['email_global'] = array( | 
| 498 | - 'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ), | |
| 499 | - 'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ), | |
| 498 | +								'name' => __('Emails Sent to All Users', 'woothemes-sensei'), | |
| 499 | +								'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'), | |
| 500 | 500 | 'type' => 'multicheck', | 
| 501 | 501 | 'options' => $global_email_options, | 
| 502 | - 'defaults' => array( 'new-message-reply' ), | |
| 502 | +								'defaults' => array('new-message-reply'), | |
| 503 | 503 | 'section' => 'email-notification-settings' | 
| 504 | 504 | ); | 
| 505 | 505 | |
| 506 | 506 | $fields['email_from_name'] = array( | 
| 507 | - 'name' => __( '"From" Name', 'woothemes-sensei' ), | |
| 508 | - 'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ), | |
| 507 | +								'name' => __('"From" Name', 'woothemes-sensei'), | |
| 508 | +								'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'), | |
| 509 | 509 | 'type' => 'text', | 
| 510 | - 'default' => get_bloginfo( 'name' ), | |
| 510 | +								'default' => get_bloginfo('name'), | |
| 511 | 511 | 'section' => 'email-notification-settings', | 
| 512 | 512 | 'required' => 1 | 
| 513 | 513 | ); | 
| 514 | 514 | |
| 515 | 515 | $fields['email_from_address'] = array( | 
| 516 | - 'name' => __( '"From" Address', 'woothemes-sensei' ), | |
| 517 | - 'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ), | |
| 516 | +								'name' => __('"From" Address', 'woothemes-sensei'), | |
| 517 | +								'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'), | |
| 518 | 518 | 'type' => 'text', | 
| 519 | - 'default' => get_bloginfo( 'admin_email' ), | |
| 519 | +								'default' => get_bloginfo('admin_email'), | |
| 520 | 520 | 'section' => 'email-notification-settings', | 
| 521 | 521 | 'required' => 1 | 
| 522 | 522 | ); | 
| 523 | 523 | |
| 524 | 524 | $fields['email_header_image'] = array( | 
| 525 | - 'name' => __( 'Header Image', 'woothemes-sensei' ), | |
| 526 | - 'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ), | |
| 525 | +								'name' => __('Header Image', 'woothemes-sensei'), | |
| 526 | +								'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'), | |
| 527 | 527 | 'type' => 'text', | 
| 528 | 528 | 'default' => '', | 
| 529 | 529 | 'section' => 'email-notification-settings', | 
| @@ -531,17 +531,17 @@ discard block | ||
| 531 | 531 | ); | 
| 532 | 532 | |
| 533 | 533 | $fields['email_footer_text'] = array( | 
| 534 | - 'name' => __( 'Email Footer Text', 'woothemes-sensei' ), | |
| 535 | - 'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ), | |
| 534 | +								'name' => __('Email Footer Text', 'woothemes-sensei'), | |
| 535 | +								'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'), | |
| 536 | 536 | 'type' => 'textarea', | 
| 537 | - 'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), | |
| 537 | +								'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')), | |
| 538 | 538 | 'section' => 'email-notification-settings', | 
| 539 | 539 | 'required' => 0 | 
| 540 | 540 | ); | 
| 541 | 541 | |
| 542 | 542 | $fields['email_base_color'] = array( | 
| 543 | - 'name' => __( 'Base Colour', 'woothemes-sensei' ), | |
| 544 | - 'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), | |
| 543 | +								'name' => __('Base Colour', 'woothemes-sensei'), | |
| 544 | +								'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'), | |
| 545 | 545 | 'type' => 'color', | 
| 546 | 546 | 'default' => '#557da1', | 
| 547 | 547 | 'section' => 'email-notification-settings', | 
| @@ -549,8 +549,8 @@ discard block | ||
| 549 | 549 | ); | 
| 550 | 550 | |
| 551 | 551 | $fields['email_background_color'] = array( | 
| 552 | - 'name' => __( 'Background Colour', 'woothemes-sensei' ), | |
| 553 | - 'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), | |
| 552 | +								'name' => __('Background Colour', 'woothemes-sensei'), | |
| 553 | +								'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'), | |
| 554 | 554 | 'type' => 'color', | 
| 555 | 555 | 'default' => '#f5f5f5', | 
| 556 | 556 | 'section' => 'email-notification-settings', | 
| @@ -558,8 +558,8 @@ discard block | ||
| 558 | 558 | ); | 
| 559 | 559 | |
| 560 | 560 | $fields['email_body_background_color'] = array( | 
| 561 | - 'name' => __( 'Body Background Colour', 'woothemes-sensei' ), | |
| 562 | - 'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), | |
| 561 | +								'name' => __('Body Background Colour', 'woothemes-sensei'), | |
| 562 | +								'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'), | |
| 563 | 563 | 'type' => 'color', | 
| 564 | 564 | 'default' => '#fdfdfd', | 
| 565 | 565 | 'section' => 'email-notification-settings', | 
| @@ -567,35 +567,35 @@ discard block | ||
| 567 | 567 | ); | 
| 568 | 568 | |
| 569 | 569 | $fields['email_text_color'] = array( | 
| 570 | - 'name' => __( 'Body Text Colour', 'woothemes-sensei' ), | |
| 571 | - 'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), | |
| 570 | +								'name' => __('Body Text Colour', 'woothemes-sensei'), | |
| 571 | +								'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'), | |
| 572 | 572 | 'type' => 'color', | 
| 573 | 573 | 'default' => '#505050', | 
| 574 | 574 | 'section' => 'email-notification-settings', | 
| 575 | 575 | 'required' => 1 | 
| 576 | 576 | ); | 
| 577 | 577 | |
| 578 | -		if ( Sensei_WC::is_woocommerce_present() ) { | |
| 578 | +		if (Sensei_WC::is_woocommerce_present()) { | |
| 579 | 579 | // WooCommerce Settings | 
| 580 | 580 | $fields['woocommerce_enabled'] = array( | 
| 581 | - 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), | |
| 582 | - 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), | |
| 581 | +									'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'), | |
| 582 | +									'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'), | |
| 583 | 583 | 'type' => 'checkbox', | 
| 584 | 584 | 'default' => true, | 
| 585 | 585 | 'section' => 'woocommerce-settings' | 
| 586 | 586 | ); | 
| 587 | 587 | |
| 588 | 588 | $fields['course_archive_free_enable'] = array( | 
| 589 | - 'name' => __( 'Free Courses Panel', 'woothemes-sensei' ), | |
| 590 | - 'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), | |
| 589 | +									'name' => __('Free Courses Panel', 'woothemes-sensei'), | |
| 590 | +									'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'), | |
| 591 | 591 | 'type' => 'checkbox', | 
| 592 | 592 | 'default' => true, | 
| 593 | 593 | 'section' => 'woocommerce-settings' | 
| 594 | 594 | ); | 
| 595 | 595 | |
| 596 | 596 | $fields['course_archive_paid_enable'] = array( | 
| 597 | - 'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ), | |
| 598 | - 'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), | |
| 597 | +									'name' => __('Paid Courses Panel', 'woothemes-sensei'), | |
| 598 | +									'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'), | |
| 599 | 599 | 'type' => 'checkbox', | 
| 600 | 600 | 'default' => true, | 
| 601 | 601 | 'section' => 'woocommerce-settings' | 
| @@ -603,18 +603,18 @@ discard block | ||
| 603 | 603 | |
| 604 | 604 | } // End If Statement | 
| 605 | 605 | |
| 606 | -		if ( 'en_US' !== get_locale() ) { | |
| 606 | +		if ('en_US' !== get_locale()) { | |
| 607 | 607 | $fields['install_language_pack'] = array( | 
| 608 | - 'name' => __( 'Install Language Pack', 'woothemes-sensei' ), | |
| 609 | - 'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ), | |
| 608 | +				'name'        => __('Install Language Pack', 'woothemes-sensei'), | |
| 609 | +				'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'), | |
| 610 | 610 | 'type' => 'button', | 
| 611 | 611 | 'section' => 'language-settings', | 
| 612 | 612 | 'target' => Sensei_Language_Pack_Manager::get_install_uri(), | 
| 613 | - 'label' => __( 'Install', 'woothemes-sensei' ) | |
| 613 | +				'label'       => __('Install', 'woothemes-sensei') | |
| 614 | 614 | ); | 
| 615 | 615 | } | 
| 616 | 616 | |
| 617 | - $this->fields = apply_filters( 'sensei_settings_fields', $fields ); | |
| 617 | +		$this->fields = apply_filters('sensei_settings_fields', $fields); | |
| 618 | 618 | |
| 619 | 619 | } // End init_fields() | 
| 620 | 620 | |
| @@ -624,20 +624,20 @@ discard block | ||
| 624 | 624 | * @param $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1. | 
| 625 | 625 | * @return array Options between 0.1 and 10 seconds. | 
| 626 | 626 | */ | 
| 627 | -	private function get_duration_options ( $include_milliseconds = true ) { | |
| 628 | - $numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' ); | |
| 627 | +	private function get_duration_options($include_milliseconds = true) { | |
| 628 | +		$numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0'); | |
| 629 | 629 | $options = array(); | 
| 630 | 630 | |
| 631 | -		if ( true == (bool)$include_milliseconds ) { | |
| 632 | - $milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' ); | |
| 633 | -			foreach ( $milliseconds as $k => $v ) { | |
| 631 | +		if (true == (bool) $include_milliseconds) { | |
| 632 | +			$milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9'); | |
| 633 | +			foreach ($milliseconds as $k => $v) { | |
| 634 | 634 | $options[$v] = $v; | 
| 635 | 635 | } | 
| 636 | 636 |  		} else { | 
| 637 | 637 | $options['0.5'] = '0.5'; | 
| 638 | 638 | } | 
| 639 | 639 | |
| 640 | -		foreach ( $numbers as $k => $v ) { | |
| 640 | +		foreach ($numbers as $k => $v) { | |
| 641 | 641 | $options[$v] = $v; | 
| 642 | 642 | } | 
| 643 | 643 | |
| @@ -653,25 +653,25 @@ discard block | ||
| 653 | 653 |  	private function pages_array() { | 
| 654 | 654 | // REFACTOR - Transform this into a field type instead. | 
| 655 | 655 | // Setup an array of portfolio gallery terms for a dropdown. | 
| 656 | - $args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ); | |
| 657 | - $pages_dropdown = wp_dropdown_pages( $args ); | |
| 656 | +		$args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC'); | |
| 657 | + $pages_dropdown = wp_dropdown_pages($args); | |
| 658 | 658 | $page_items = array(); | 
| 659 | 659 | |
| 660 | 660 | // Quick string hack to make sure we get the pages with the indents. | 
| 661 | - $pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown ); | |
| 662 | - $pages_dropdown = str_replace( '</select>', '', $pages_dropdown ); | |
| 663 | - $pages_split = explode( '</option>', $pages_dropdown ); | |
| 661 | +		$pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown); | |
| 662 | +		$pages_dropdown = str_replace('</select>', '', $pages_dropdown); | |
| 663 | +		$pages_split = explode('</option>', $pages_dropdown); | |
| 664 | 664 | |
| 665 | - $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); | |
| 665 | +		$page_items[] = __('Select a Page:', 'woothemes-sensei'); | |
| 666 | 666 | |
| 667 | -		foreach ( $pages_split as $k => $v ) { | |
| 667 | +		foreach ($pages_split as $k => $v) { | |
| 668 | 668 | $id = ''; | 
| 669 | 669 | // Get the ID value. | 
| 670 | - preg_match( '/value="(.*?)"/i', $v, $matches ); | |
| 670 | +		    preg_match('/value="(.*?)"/i', $v, $matches); | |
| 671 | 671 | |
| 672 | -		    if ( isset( $matches[1] ) ) { | |
| 672 | +		    if (isset($matches[1])) { | |
| 673 | 673 | $id = $matches[1]; | 
| 674 | - $page_items[$id] = trim( strip_tags( $v ) ); | |
| 674 | + $page_items[$id] = trim(strip_tags($v)); | |
| 675 | 675 | } // End If Statement | 
| 676 | 676 | } // End For Loop | 
| 677 | 677 | |
| @@ -695,10 +695,10 @@ discard block | ||
| 695 | 695 | * | 
| 696 | 696 | * @since 1.9.0 | 
| 697 | 697 | */ | 
| 698 | -    public static function flush_rewrite_rules(){ | |
| 698 | +    public static function flush_rewrite_rules() { | |
| 699 | 699 | |
| 700 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] | |
| 701 | -            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { | |
| 700 | + if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page'] | |
| 701 | +            && isset($_POST['action']) && 'update' == $_POST['action']) { | |
| 702 | 702 | |
| 703 | 703 | Sensei()->initiate_rewrite_rules_flush(); | 
| 704 | 704 | |
| @@ -712,4 +712,4 @@ discard block | ||
| 712 | 712 | * @ignore only for backward compatibility | 
| 713 | 713 | * @since 1.9.0 | 
| 714 | 714 | */ | 
| 715 | -class WooThemes_Sensei_Settings extends Sensei_Settings{} | |
| 715 | +class WooThemes_Sensei_Settings extends Sensei_Settings {} | |
| @@ -10,1343 +10,1343 @@ discard block | ||
| 10 | 10 | */ | 
| 11 | 11 |  class Sensei_Main { | 
| 12 | 12 | |
| 13 | - /** | |
| 14 | - * @var string | |
| 15 | - * Reference to the main plugin file | |
| 16 | - */ | |
| 17 | - private $file; | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * @var Sensei_Main $_instance to the the main and only instance of the Sensei class. | |
| 21 | - * @since 1.8.0 | |
| 22 | - */ | |
| 23 | - protected static $_instance = null; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * Main reference to the plugins current version | |
| 27 | - */ | |
| 28 | - public $version; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * Public token, referencing for the text domain. | |
| 32 | - */ | |
| 33 | - public $token = 'woothemes-sensei'; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * Plugin url and path for use when access resources. | |
| 37 | - */ | |
| 38 | - public $plugin_url; | |
| 39 | - public $plugin_path; | |
| 40 | - public $template_url; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * @var Sensei_PostTypes | |
| 44 | - * All Sensei sub classes. Currently used to access functionality contained within | |
| 45 | - * within Sensei sub classes e.g. Sensei()->course->all_courses() | |
| 46 | - */ | |
| 47 | - public $post_types; | |
| 48 | - | |
| 49 | - /** | |
| 50 | - * @var WooThemes_Sensei_Settings | |
| 51 | - */ | |
| 52 | - public $settings; | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * @var WooThemes_Sensei_Course_Results | |
| 56 | - */ | |
| 57 | - public $course_results; | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * @var Sensei_Updates | |
| 61 | - */ | |
| 62 | - public $updates; | |
| 63 | - /** | |
| 64 | - * @var WooThemes_Sensei_Course | |
| 65 | - */ | |
| 66 | - public $course; | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * @var WooThemes_Sensei_Lesson | |
| 70 | - */ | |
| 71 | - public $lesson; | |
| 72 | - | |
| 73 | - /** | |
| 74 | - * @var WooThemes_Sensei_Quiz | |
| 75 | - */ | |
| 76 | - public $quiz; | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * @var WooThemes_Sensei_Question | |
| 80 | - */ | |
| 81 | - public $question; | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * @var WooThemes_Sensei_Admin | |
| 85 | - */ | |
| 86 | - public $admin; | |
| 87 | - | |
| 88 | - /** | |
| 89 | - * @var WooThemes_Sensei_Frontend | |
| 90 | - */ | |
| 91 | - public $frontend; | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * @var Sensei_Notices | |
| 95 | - */ | |
| 96 | - public $notices; | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * @var WooThemes_Sensei_Grading | |
| 100 | - */ | |
| 101 | - public $grading; | |
| 102 | - | |
| 103 | - /** | |
| 104 | - * @var WooThemes_Sensei_Emails | |
| 105 | - */ | |
| 106 | - public $emails; | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * @var WooThemes_Sensei_Learner_Profiles | |
| 110 | - */ | |
| 111 | - public $learner_profiles; | |
| 112 | - | |
| 113 | - /** | |
| 114 | - * @var Sensei_Teacher | |
| 115 | - */ | |
| 116 | - public $teacher; | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * @var WooThemes_Sensei_Learners | |
| 120 | - */ | |
| 121 | - public $learners; | |
| 122 | - | |
| 123 | - /** | |
| 124 | - * @var array | |
| 125 | - * Global instance for access to the permissions message shown | |
| 126 | - * when users do not have the right privileges to access resources. | |
| 127 | - */ | |
| 128 | - public $permissions_message; | |
| 129 | - | |
| 130 | - /** | |
| 131 | - * @var Sensei_Core_Modules Sensei Modules functionality | |
| 132 | - */ | |
| 133 | - public $modules; | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * @var Sensei_Analysis | |
| 137 | - */ | |
| 138 | - public $analysis; | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * Constructor method. | |
| 142 | - * @param string $file The base file of the plugin. | |
| 143 | - * @since 1.0.0 | |
| 144 | - */ | |
| 145 | -    public function __construct ( $file ) { | |
| 146 | - | |
| 147 | - // Setup object data | |
| 148 | - $this->file = $file; | |
| 149 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); | |
| 150 | - $this->plugin_path = trailingslashit( dirname( $file ) ); | |
| 151 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); | |
| 152 | - $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); | |
| 153 | - | |
| 154 | - // Initialize the core Sensei functionality | |
| 155 | - $this->init(); | |
| 156 | - | |
| 157 | - // Installation | |
| 158 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); | |
| 159 | - | |
| 160 | - // Run this on activation. | |
| 161 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); | |
| 162 | - | |
| 163 | - // Image Sizes | |
| 164 | - $this->init_image_sizes(); | |
| 165 | - | |
| 166 | - // Force WooCommerce Required Settings | |
| 167 | - $this->set_woocommerce_functionality(); | |
| 168 | - | |
| 169 | - // load all hooks | |
| 170 | - $this->load_hooks(); | |
| 171 | - | |
| 172 | - } // End __construct() | |
| 173 | - | |
| 174 | - /** | |
| 175 | - * Load the foundations of Sensei. | |
| 176 | - * @since 1.9.0 | |
| 177 | - */ | |
| 178 | -    protected function init(){ | |
| 179 | - | |
| 180 | - // Localisation | |
| 181 | - $this->load_plugin_textdomain(); | |
| 182 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); | |
| 183 | - | |
| 184 | - // load the shortcode loader into memory, so as to listen to all for | |
| 185 | - // all shortcodes on the front end | |
| 186 | - new Sensei_Shortcode_Loader(); | |
| 187 | - | |
| 188 | - } | |
| 189 | - | |
| 190 | - /** | |
| 191 | - * Global Sensei Instance | |
| 192 | - * | |
| 193 | - * Ensure that only one instance of the main Sensei class can be loaded. | |
| 194 | - * | |
| 195 | - * @since 1.8.0 | |
| 196 | - * @static | |
| 197 | - * @see WC() | |
| 198 | - * @return WooThemes_Sensei Instance. | |
| 199 | - */ | |
| 200 | -    public static function instance() { | |
| 13 | + /** | |
| 14 | + * @var string | |
| 15 | + * Reference to the main plugin file | |
| 16 | + */ | |
| 17 | + private $file; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * @var Sensei_Main $_instance to the the main and only instance of the Sensei class. | |
| 21 | + * @since 1.8.0 | |
| 22 | + */ | |
| 23 | + protected static $_instance = null; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * Main reference to the plugins current version | |
| 27 | + */ | |
| 28 | + public $version; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * Public token, referencing for the text domain. | |
| 32 | + */ | |
| 33 | + public $token = 'woothemes-sensei'; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * Plugin url and path for use when access resources. | |
| 37 | + */ | |
| 38 | + public $plugin_url; | |
| 39 | + public $plugin_path; | |
| 40 | + public $template_url; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * @var Sensei_PostTypes | |
| 44 | + * All Sensei sub classes. Currently used to access functionality contained within | |
| 45 | + * within Sensei sub classes e.g. Sensei()->course->all_courses() | |
| 46 | + */ | |
| 47 | + public $post_types; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * @var WooThemes_Sensei_Settings | |
| 51 | + */ | |
| 52 | + public $settings; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * @var WooThemes_Sensei_Course_Results | |
| 56 | + */ | |
| 57 | + public $course_results; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * @var Sensei_Updates | |
| 61 | + */ | |
| 62 | + public $updates; | |
| 63 | + /** | |
| 64 | + * @var WooThemes_Sensei_Course | |
| 65 | + */ | |
| 66 | + public $course; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * @var WooThemes_Sensei_Lesson | |
| 70 | + */ | |
| 71 | + public $lesson; | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * @var WooThemes_Sensei_Quiz | |
| 75 | + */ | |
| 76 | + public $quiz; | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * @var WooThemes_Sensei_Question | |
| 80 | + */ | |
| 81 | + public $question; | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * @var WooThemes_Sensei_Admin | |
| 85 | + */ | |
| 86 | + public $admin; | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * @var WooThemes_Sensei_Frontend | |
| 90 | + */ | |
| 91 | + public $frontend; | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * @var Sensei_Notices | |
| 95 | + */ | |
| 96 | + public $notices; | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * @var WooThemes_Sensei_Grading | |
| 100 | + */ | |
| 101 | + public $grading; | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * @var WooThemes_Sensei_Emails | |
| 105 | + */ | |
| 106 | + public $emails; | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * @var WooThemes_Sensei_Learner_Profiles | |
| 110 | + */ | |
| 111 | + public $learner_profiles; | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * @var Sensei_Teacher | |
| 115 | + */ | |
| 116 | + public $teacher; | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * @var WooThemes_Sensei_Learners | |
| 120 | + */ | |
| 121 | + public $learners; | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * @var array | |
| 125 | + * Global instance for access to the permissions message shown | |
| 126 | + * when users do not have the right privileges to access resources. | |
| 127 | + */ | |
| 128 | + public $permissions_message; | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * @var Sensei_Core_Modules Sensei Modules functionality | |
| 132 | + */ | |
| 133 | + public $modules; | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * @var Sensei_Analysis | |
| 137 | + */ | |
| 138 | + public $analysis; | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Constructor method. | |
| 142 | + * @param string $file The base file of the plugin. | |
| 143 | + * @since 1.0.0 | |
| 144 | + */ | |
| 145 | +	public function __construct ( $file ) { | |
| 146 | + | |
| 147 | + // Setup object data | |
| 148 | + $this->file = $file; | |
| 149 | + $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); | |
| 150 | + $this->plugin_path = trailingslashit( dirname( $file ) ); | |
| 151 | + $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); | |
| 152 | + $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); | |
| 153 | + | |
| 154 | + // Initialize the core Sensei functionality | |
| 155 | + $this->init(); | |
| 156 | + | |
| 157 | + // Installation | |
| 158 | + if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); | |
| 159 | + | |
| 160 | + // Run this on activation. | |
| 161 | + register_activation_hook( $this->file, array( $this, 'activation' ) ); | |
| 162 | + | |
| 163 | + // Image Sizes | |
| 164 | + $this->init_image_sizes(); | |
| 165 | + | |
| 166 | + // Force WooCommerce Required Settings | |
| 167 | + $this->set_woocommerce_functionality(); | |
| 168 | + | |
| 169 | + // load all hooks | |
| 170 | + $this->load_hooks(); | |
| 171 | + | |
| 172 | + } // End __construct() | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * Load the foundations of Sensei. | |
| 176 | + * @since 1.9.0 | |
| 177 | + */ | |
| 178 | +	protected function init(){ | |
| 179 | + | |
| 180 | + // Localisation | |
| 181 | + $this->load_plugin_textdomain(); | |
| 182 | + add_action( 'init', array( $this, 'load_localisation' ), 0 ); | |
| 183 | + | |
| 184 | + // load the shortcode loader into memory, so as to listen to all for | |
| 185 | + // all shortcodes on the front end | |
| 186 | + new Sensei_Shortcode_Loader(); | |
| 187 | + | |
| 188 | + } | |
| 189 | + | |
| 190 | + /** | |
| 191 | + * Global Sensei Instance | |
| 192 | + * | |
| 193 | + * Ensure that only one instance of the main Sensei class can be loaded. | |
| 194 | + * | |
| 195 | + * @since 1.8.0 | |
| 196 | + * @static | |
| 197 | + * @see WC() | |
| 198 | + * @return WooThemes_Sensei Instance. | |
| 199 | + */ | |
| 200 | +	public static function instance() { | |
| 201 | 201 | |
| 202 | -        if ( is_null( self::$_instance ) ) { | |
| 202 | +		if ( is_null( self::$_instance ) ) { | |
| 203 | 203 | |
| 204 | - //Sensei requires a reference to the main Sensei plugin file | |
| 205 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; | |
| 204 | + //Sensei requires a reference to the main Sensei plugin file | |
| 205 | + $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; | |
| 206 | 206 | |
| 207 | - self::$_instance = new self( $sensei_main_plugin_file ); | |
| 207 | + self::$_instance = new self( $sensei_main_plugin_file ); | |
| 208 | 208 | |
| 209 | - // load the global class objects needed throughout Sensei | |
| 210 | - self::$_instance->initialize_global_objects(); | |
| 209 | + // load the global class objects needed throughout Sensei | |
| 210 | + self::$_instance->initialize_global_objects(); | |
| 211 | 211 | |
| 212 | - } | |
| 212 | + } | |
| 213 | 213 | |
| 214 | - return self::$_instance; | |
| 214 | + return self::$_instance; | |
| 215 | 215 | |
| 216 | - } // end instance() | |
| 216 | + } // end instance() | |
| 217 | 217 | |
| 218 | - /** | |
| 219 | - * This function is linked into the activation | |
| 220 | - * hook to reset flush the urls to ensure Sensei post types show up. | |
| 221 | - * | |
| 222 | - * @since 1.9.0 | |
| 223 | - * | |
| 224 | - * @param $plugin | |
| 225 | - */ | |
| 226 | -    public static function activation_flush_rules( $plugin ){ | |
| 218 | + /** | |
| 219 | + * This function is linked into the activation | |
| 220 | + * hook to reset flush the urls to ensure Sensei post types show up. | |
| 221 | + * | |
| 222 | + * @since 1.9.0 | |
| 223 | + * | |
| 224 | + * @param $plugin | |
| 225 | + */ | |
| 226 | +	public static function activation_flush_rules( $plugin ){ | |
| 227 | 227 | |
| 228 | -        if( strpos( $plugin, '/woothemes-sensei.php' ) > 0  ){ | |
| 228 | +		if( strpos( $plugin, '/woothemes-sensei.php' ) > 0  ){ | |
| 229 | 229 | |
| 230 | - flush_rewrite_rules(true); | |
| 230 | + flush_rewrite_rules(true); | |
| 231 | 231 | |
| 232 | - } | |
| 232 | + } | |
| 233 | 233 | |
| 234 | - } | |
| 234 | + } | |
| 235 | 235 | |
| 236 | - /** | |
| 237 | - * Cloning is forbidden. | |
| 238 | - * @since 1.8.0 | |
| 239 | - */ | |
| 240 | -    public function __clone() { | |
| 241 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); | |
| 242 | - } | |
| 236 | + /** | |
| 237 | + * Cloning is forbidden. | |
| 238 | + * @since 1.8.0 | |
| 239 | + */ | |
| 240 | +	public function __clone() { | |
| 241 | + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); | |
| 242 | + } | |
| 243 | 243 | |
| 244 | - /** | |
| 245 | - * Unserializing instances of this class is forbidden. | |
| 246 | - * @since 1.8.0 | |
| 247 | - */ | |
| 248 | -    public function __wakeup() { | |
| 249 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); | |
| 250 | - } | |
| 244 | + /** | |
| 245 | + * Unserializing instances of this class is forbidden. | |
| 246 | + * @since 1.8.0 | |
| 247 | + */ | |
| 248 | +	public function __wakeup() { | |
| 249 | + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); | |
| 250 | + } | |
| 251 | 251 | |
| 252 | - /** | |
| 253 | - * Load the properties for the main Sensei object | |
| 254 | - * | |
| 255 | - * @since 1.9.0 | |
| 256 | - */ | |
| 257 | -    public function initialize_global_objects(){ | |
| 252 | + /** | |
| 253 | + * Load the properties for the main Sensei object | |
| 254 | + * | |
| 255 | + * @since 1.9.0 | |
| 256 | + */ | |
| 257 | +	public function initialize_global_objects(){ | |
| 258 | 258 | |
| 259 | - // Setup post types. | |
| 260 | - $this->post_types = new Sensei_PostTypes(); | |
| 259 | + // Setup post types. | |
| 260 | + $this->post_types = new Sensei_PostTypes(); | |
| 261 | 261 | |
| 262 | - // Lad the updates class | |
| 263 | - $this->updates = new Sensei_Updates( $this ); | |
| 262 | + // Lad the updates class | |
| 263 | + $this->updates = new Sensei_Updates( $this ); | |
| 264 | 264 | |
| 265 | - // Setup settings | |
| 266 | - $this->settings = new Sensei_Settings(); | |
| 265 | + // Setup settings | |
| 266 | + $this->settings = new Sensei_Settings(); | |
| 267 | 267 | |
| 268 | - // Load Course Results Class | |
| 269 | - $this->course_results = new Sensei_Course_Results(); | |
| 268 | + // Load Course Results Class | |
| 269 | + $this->course_results = new Sensei_Course_Results(); | |
| 270 | 270 | |
| 271 | - // Load the teacher role | |
| 272 | - $this->teacher = new Sensei_Teacher(); | |
| 271 | + // Load the teacher role | |
| 272 | + $this->teacher = new Sensei_Teacher(); | |
| 273 | 273 | |
| 274 | - // Add the Course class | |
| 275 | - $this->course = $this->post_types->course; | |
| 274 | + // Add the Course class | |
| 275 | + $this->course = $this->post_types->course; | |
| 276 | 276 | |
| 277 | - // Add the lesson class | |
| 278 | - $this->lesson = $this->post_types->lesson; | |
| 277 | + // Add the lesson class | |
| 278 | + $this->lesson = $this->post_types->lesson; | |
| 279 | 279 | |
| 280 | - // Add the question class | |
| 281 | - $this->question = $this->post_types->question; | |
| 280 | + // Add the question class | |
| 281 | + $this->question = $this->post_types->question; | |
| 282 | 282 | |
| 283 | - //Add the quiz class | |
| 284 | - $this->quiz = $this->post_types->quiz; | |
| 283 | + //Add the quiz class | |
| 284 | + $this->quiz = $this->post_types->quiz; | |
| 285 | 285 | |
| 286 | - // load the modules class after all plugsin are loaded | |
| 287 | - add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); | |
| 286 | + // load the modules class after all plugsin are loaded | |
| 287 | + add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); | |
| 288 | 288 | |
| 289 | - // Load Learner Management Functionality | |
| 290 | - $this->learners = new Sensei_Learner_Management( $this->file ); | |
| 289 | + // Load Learner Management Functionality | |
| 290 | + $this->learners = new Sensei_Learner_Management( $this->file ); | |
| 291 | 291 | |
| 292 | - // Differentiate between administration and frontend logic. | |
| 293 | -        if ( is_admin() ) { | |
| 292 | + // Differentiate between administration and frontend logic. | |
| 293 | +		if ( is_admin() ) { | |
| 294 | 294 | |
| 295 | - // Load Admin Welcome class | |
| 296 | - new Sensei_Welcome(); | |
| 295 | + // Load Admin Welcome class | |
| 296 | + new Sensei_Welcome(); | |
| 297 | 297 | |
| 298 | - // Load Admin Class | |
| 299 | - $this->admin = new Sensei_Admin( $this->file ); | |
| 298 | + // Load Admin Class | |
| 299 | + $this->admin = new Sensei_Admin( $this->file ); | |
| 300 | 300 | |
| 301 | - // Load Analysis Reports | |
| 302 | - $this->analysis = new Sensei_Analysis( $this->file ); | |
| 301 | + // Load Analysis Reports | |
| 302 | + $this->analysis = new Sensei_Analysis( $this->file ); | |
| 303 | 303 | |
| 304 | -        } else { | |
| 304 | +		} else { | |
| 305 | 305 | |
| 306 | - // Load Frontend Class | |
| 307 | - $this->frontend = new Sensei_Frontend(); | |
| 306 | + // Load Frontend Class | |
| 307 | + $this->frontend = new Sensei_Frontend(); | |
| 308 | 308 | |
| 309 | - // Load notice Class | |
| 310 | - $this->notices = new Sensei_Notices(); | |
| 309 | + // Load notice Class | |
| 310 | + $this->notices = new Sensei_Notices(); | |
| 311 | 311 | |
| 312 | - // Load built in themes support integration | |
| 313 | - new Sensei_Theme_Integration_Loader(); | |
| 312 | + // Load built in themes support integration | |
| 313 | + new Sensei_Theme_Integration_Loader(); | |
| 314 | 314 | |
| 315 | 315 | |
| 316 | - } | |
| 316 | + } | |
| 317 | 317 | |
| 318 | - // Load Grading Functionality | |
| 319 | - $this->grading = new Sensei_Grading( $this->file ); | |
| 318 | + // Load Grading Functionality | |
| 319 | + $this->grading = new Sensei_Grading( $this->file ); | |
| 320 | 320 | |
| 321 | - // Load Email Class | |
| 322 | - $this->emails = new Sensei_Emails( $this->file ); | |
| 321 | + // Load Email Class | |
| 322 | + $this->emails = new Sensei_Emails( $this->file ); | |
| 323 | 323 | |
| 324 | - // Load Learner Profiles Class | |
| 325 | - $this->learner_profiles = new Sensei_Learner_Profiles(); | |
| 324 | + // Load Learner Profiles Class | |
| 325 | + $this->learner_profiles = new Sensei_Learner_Profiles(); | |
| 326 | 326 | |
| 327 | - } | |
| 327 | + } | |
| 328 | 328 | |
| 329 | - /** | |
| 330 | - * Initialize all Sensei hooks | |
| 331 | - * | |
| 332 | - * @since 1.9.0 | |
| 333 | - */ | |
| 334 | -    public function load_hooks(){ | |
| 335 | - | |
| 336 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); | |
| 337 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); | |
| 338 | - | |
| 339 | - // WooCommerce Payment Actions | |
| 340 | - add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 341 | - add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 342 | - add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 343 | - add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 344 | - add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); | |
| 345 | - add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); | |
| 346 | - add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); | |
| 347 | - | |
| 348 | - // WooCommerce Subscriptions Actions | |
| 349 | - add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); | |
| 350 | - add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 351 | - add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 352 | - add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 353 | - add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 354 | - | |
| 355 | - // Add Email link to course orders | |
| 356 | - add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); | |
| 357 | - | |
| 358 | - // Filter comment counts | |
| 359 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); | |
| 360 | - | |
| 361 | - add_action( 'body_class', array( $this, 'body_class' ) ); | |
| 362 | - | |
| 363 | - // Check for and activate JetPack LaTeX support | |
| 364 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules | |
| 365 | - | |
| 366 | - // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 | |
| 367 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); | |
| 368 | - | |
| 369 | - } | |
| 370 | - | |
| 371 | - /** | |
| 372 | - * Run Sensei updates. | |
| 373 | - * @access public | |
| 374 | - * @since 1.1.0 | |
| 375 | - * @return void | |
| 376 | - */ | |
| 377 | -    public function run_updates() { | |
| 378 | - // Run updates if administrator | |
| 379 | -        if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { | |
| 380 | - | |
| 381 | - $this->updates->update(); | |
| 382 | - | |
| 383 | - } // End If Statement | |
| 384 | - } // End run_updates() | |
| 385 | - | |
| 386 | - | |
| 387 | - | |
| 388 | - /** | |
| 389 | - * Setup required WooCommerce settings. | |
| 390 | - * @access public | |
| 391 | - * @since 1.1.0 | |
| 392 | - * @return void | |
| 393 | - */ | |
| 394 | -    public function set_woocommerce_functionality() { | |
| 395 | - // Disable guest checkout if a course is in the cart as we need a valid user to store data for | |
| 396 | - add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); | |
| 397 | - | |
| 398 | - // Mark orders with virtual products as complete rather then stay processing | |
| 399 | - add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); | |
| 400 | - | |
| 401 | - } // End set_woocommerce_functionality() | |
| 402 | - | |
| 403 | - /** | |
| 404 | - * Disable guest checkout if a course product is in the cart | |
| 405 | - * @param boolean $guest_checkout Current guest checkout setting | |
| 406 | - * @return boolean Modified guest checkout setting | |
| 407 | - */ | |
| 408 | -    public function disable_guest_checkout( $guest_checkout ) { | |
| 409 | - global $woocommerce; | |
| 410 | - | |
| 411 | -        if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
| 412 | - | |
| 413 | -            if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { | |
| 414 | -                foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { | |
| 415 | -                    if( isset( $product['product_id'] ) ) { | |
| 416 | - $args = array( | |
| 417 | - 'posts_per_page' => -1, | |
| 418 | - 'post_type' => 'course', | |
| 419 | - 'meta_query' => array( | |
| 420 | - array( | |
| 421 | - 'key' => '_course_woocommerce_product', | |
| 422 | - 'value' => $product['product_id'] | |
| 423 | - ) | |
| 424 | - ) | |
| 425 | - ); | |
| 426 | - $posts = get_posts( $args ); | |
| 427 | -                        if( $posts && count( $posts ) > 0 ) { | |
| 428 | -                            foreach( $posts as $course ) { | |
| 429 | - $guest_checkout = ''; | |
| 430 | - break; | |
| 431 | - } | |
| 432 | - } | |
| 433 | - } | |
| 434 | - } | |
| 435 | - } | |
| 436 | - } | |
| 437 | - | |
| 438 | - return $guest_checkout; | |
| 439 | - } | |
| 440 | - | |
| 441 | - /** | |
| 442 | - * Change order status with virtual products to completed | |
| 443 | - * @since 1.1.0 | |
| 444 | - * @param string $order_status | |
| 445 | - * @param int $order_id | |
| 446 | - * @return string | |
| 447 | - **/ | |
| 448 | -    public function virtual_order_payment_complete( $order_status, $order_id ) { | |
| 449 | - $order = new WC_Order( $order_id ); | |
| 450 | - if ( ! isset ( $order ) ) return ''; | |
| 451 | -        if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { | |
| 452 | - $virtual_order = true; | |
| 453 | - | |
| 454 | -            if ( count( $order->get_items() ) > 0 ) { | |
| 455 | -                foreach( $order->get_items() as $item ) { | |
| 456 | -                    if ( $item['product_id'] > 0 ) { | |
| 457 | - $_product = $order->get_product_from_item( $item ); | |
| 458 | -                        if ( ! $_product->is_virtual() ) { | |
| 459 | - $virtual_order = false; | |
| 460 | - break; | |
| 461 | - } // End If Statement | |
| 462 | - } // End If Statement | |
| 463 | - } // End For Loop | |
| 464 | - } // End If Statement | |
| 465 | - | |
| 466 | - // virtual order, mark as completed | |
| 467 | -            if ( $virtual_order ) { | |
| 468 | - return 'completed'; | |
| 469 | - } // End If Statement | |
| 470 | - } // End If Statement | |
| 471 | - return $order_status; | |
| 472 | - } | |
| 473 | - | |
| 474 | - /** | |
| 475 | - * Register the widgets. | |
| 476 | - * @access public | |
| 477 | - * @since 1.0.0 | |
| 478 | - * @return void | |
| 479 | - */ | |
| 480 | -    public function register_widgets () { | |
| 481 | - // Widget List (key => value is filename => widget class). | |
| 482 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', | |
| 483 | - 'lesson-component' => 'Lesson_Component', | |
| 484 | - 'course-categories' => 'Course_Categories', | |
| 485 | - 'category-courses' => 'Category_Courses' ) | |
| 486 | - ); | |
| 487 | -        foreach ( $widget_list as $key => $value ) { | |
| 488 | -            if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' ) ) { | |
| 489 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); | |
| 490 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); | |
| 491 | - } | |
| 492 | - } // End For Loop | |
| 493 | - | |
| 494 | - do_action( 'sensei_register_widgets' ); | |
| 495 | - | |
| 496 | - } // End register_widgets() | |
| 497 | - | |
| 498 | - /** | |
| 499 | - * Load the plugin's localisation file. | |
| 500 | - * @access public | |
| 501 | - * @since 1.0.0 | |
| 502 | - * @return void | |
| 503 | - */ | |
| 504 | -    public function load_localisation () { | |
| 505 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); | |
| 506 | - } // End load_localisation() | |
| 507 | - | |
| 508 | - /** | |
| 509 | - * Load the plugin textdomain from the main WordPress "languages" folder. | |
| 510 | - * @access public | |
| 511 | - * @since 1.0.0 | |
| 512 | - * @return void | |
| 513 | - */ | |
| 514 | -    public function load_plugin_textdomain () { | |
| 515 | - $domain = 'woothemes-sensei'; | |
| 516 | - // The "plugin_locale" filter is also used in load_plugin_textdomain() | |
| 517 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); | |
| 518 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); | |
| 519 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); | |
| 520 | - } // End load_plugin_textdomain() | |
| 521 | - | |
| 522 | - /** | |
| 523 | - * Run on activation. | |
| 524 | - * @access public | |
| 525 | - * @since 1.0.0 | |
| 526 | - * @return void | |
| 527 | - */ | |
| 528 | -    public function activation () { | |
| 529 | - $this->register_plugin_version(); | |
| 530 | - } // End activation() | |
| 531 | - | |
| 532 | - | |
| 533 | - /** | |
| 534 | - * Register activation hooks. | |
| 535 | - * @access public | |
| 536 | - * @since 1.0.0 | |
| 537 | - * @return void | |
| 538 | - */ | |
| 539 | -    public function install () { | |
| 540 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); | |
| 541 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); | |
| 542 | - } // End install() | |
| 543 | - | |
| 544 | - | |
| 545 | - /** | |
| 546 | - * Run on activation of the plugin. | |
| 547 | - * @access public | |
| 548 | - * @since 1.0.0 | |
| 549 | - * @return void | |
| 550 | - */ | |
| 551 | -    public function activate_sensei () { | |
| 552 | - update_option( 'skip_install_sensei_pages', 0 ); | |
| 553 | - update_option( 'sensei_installed', 1 ); | |
| 554 | - } // End activate_sensei() | |
| 555 | - | |
| 556 | - /** | |
| 557 | - * Register the plugin's version. | |
| 558 | - * @access public | |
| 559 | - * @since 1.0.0 | |
| 560 | - * @return void | |
| 561 | - */ | |
| 562 | -    private function register_plugin_version () { | |
| 563 | -        if ( $this->version != '' ) { | |
| 564 | - | |
| 565 | - // Check previous version to see if forced updates must run | |
| 566 | - // $old_version = get_option( 'woothemes-sensei-version', false ); | |
| 567 | -            // if( $old_version && version_compare( $old_version, '1.7.0', '<' )  ) { | |
| 568 | - // update_option( 'woothemes-sensei-force-updates', $this->version ); | |
| 569 | -            // } else { | |
| 570 | - // delete_option( 'woothemes-sensei-force-updates' ); | |
| 571 | - // } | |
| 572 | - | |
| 573 | - update_option( 'woothemes-sensei-version', $this->version ); | |
| 574 | - } | |
| 575 | - } // End register_plugin_version() | |
| 576 | - | |
| 577 | - /** | |
| 578 | - * Ensure that "post-thumbnails" support is available for those themes that don't register it. | |
| 579 | - * @access public | |
| 580 | - * @since 1.0.1 | |
| 581 | - * @return void | |
| 582 | - */ | |
| 583 | -    public function ensure_post_thumbnails_support () { | |
| 584 | -        if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } | |
| 585 | - } // End ensure_post_thumbnails_support() | |
| 586 | - | |
| 587 | - | |
| 588 | - /** | |
| 589 | - * template_loader function. | |
| 590 | - * | |
| 591 | - * @access public | |
| 592 | - * @param mixed $template | |
| 593 | - * @return void | |
| 594 | - * @deprecated | |
| 595 | - */ | |
| 596 | -    public function template_loader ( $template = '' ) { | |
| 597 | - | |
| 598 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); | |
| 599 | - Sensei_Templates::template_loader( $template ); | |
| 600 | - | |
| 601 | - } // End template_loader() | |
| 602 | - | |
| 603 | - /** | |
| 604 | - * Determine the relative path to the plugin's directory. | |
| 605 | - * @access public | |
| 606 | - * @since 1.0.0 | |
| 607 | - * @return string $sensei_plugin_path | |
| 608 | - */ | |
| 609 | -    public function plugin_path () { | |
| 610 | - | |
| 611 | -        if ( $this->plugin_path ) { | |
| 612 | - | |
| 613 | - $sensei_plugin_path = $this->plugin_path; | |
| 614 | - | |
| 615 | -        }else{ | |
| 616 | - | |
| 617 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); | |
| 618 | - | |
| 619 | - } | |
| 620 | - | |
| 621 | - return $sensei_plugin_path; | |
| 622 | - | |
| 623 | - } // End plugin_path() | |
| 624 | - | |
| 625 | - | |
| 626 | - /** | |
| 627 | - * Retrieve the ID of a specified page setting. | |
| 628 | - * @access public | |
| 629 | - * @since 1.0.0 | |
| 630 | - * @param string $page | |
| 631 | - * @return int | |
| 632 | - */ | |
| 633 | -    public function get_page_id ( $page ) { | |
| 634 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); | |
| 635 | - return ( $page ) ? $page : -1; | |
| 636 | - } // End get_page_id() | |
| 637 | - | |
| 638 | - | |
| 639 | - /** | |
| 640 | - * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course. | |
| 641 | - * @access public | |
| 642 | - * @since 1.0.0 | |
| 643 | - * @param int $course_id (default: 0) | |
| 644 | - * @param array/Object $order_user (default: array()) Specific user's data. | |
| 645 | - * @return bool|int | |
| 646 | - */ | |
| 647 | -    public function woocommerce_course_update ( $course_id = 0, $order_user = array()  ) { | |
| 648 | - global $current_user; | |
| 649 | - | |
| 650 | - if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; | |
| 651 | - | |
| 652 | - $data_update = false; | |
| 653 | - | |
| 654 | - // Get the product ID | |
| 655 | - $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); | |
| 656 | - | |
| 657 | - // Check if in the admin | |
| 658 | -        if ( is_admin() ) { | |
| 659 | - $user_login = $order_user['user_login']; | |
| 660 | - $user_email = $order_user['user_email']; | |
| 661 | - $user_url = $order_user['user_url']; | |
| 662 | - $user_id = $order_user['ID']; | |
| 663 | -        } else { | |
| 664 | - $user_login = $current_user->user_login; | |
| 665 | - $user_email = $current_user->user_email; | |
| 666 | - $user_url = $current_user->user_url; | |
| 667 | - $user_id = $current_user->ID; | |
| 668 | - } // End If Statement | |
| 669 | - | |
| 670 | - // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? | |
| 671 | - $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); | |
| 672 | -        if( 0 < absint( $course_prerequisite_id ) ) { | |
| 673 | - $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); | |
| 674 | -            if ( ! $prereq_course_complete ) { | |
| 675 | - // Remove all course user meta | |
| 676 | - return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); | |
| 677 | - } | |
| 678 | - } | |
| 679 | - | |
| 680 | - $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); | |
| 681 | - | |
| 682 | -        if( ! $is_user_taking_course ) { | |
| 683 | - | |
| 684 | -            if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { | |
| 685 | - | |
| 686 | - $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); | |
| 687 | - | |
| 688 | - $is_user_taking_course = false; | |
| 689 | -                if ( true == $activity_logged ) { | |
| 690 | - $is_user_taking_course = true; | |
| 691 | - } // End If Statement | |
| 692 | - } // End If Statement | |
| 693 | - } | |
| 694 | - | |
| 695 | - return $is_user_taking_course; | |
| 696 | - } // End woocommerce_course_update() | |
| 697 | - | |
| 698 | - | |
| 699 | - /** | |
| 700 | - * check_user_permissions function. | |
| 701 | - * | |
| 702 | - * @access public | |
| 703 | - * @param string $page (default: '') | |
| 704 | - * | |
| 705 | - * @return bool | |
| 706 | - */ | |
| 707 | -    public function check_user_permissions ( $page = '' ) { | |
| 708 | - // REFACTOR | |
| 709 | - global $current_user, $post; | |
| 710 | - | |
| 711 | - // if use is not logged in | |
| 712 | - // skipped for single lesson | |
| 713 | -        if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') | |
| 714 | -            && 'lesson-single' !=  $page ){ | |
| 715 | -            $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); | |
| 716 | -            $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); | |
| 717 | - return false; | |
| 718 | - } | |
| 719 | - | |
| 720 | - $user_allowed = false; | |
| 721 | - | |
| 722 | -        switch ( $page ) { | |
| 723 | - case 'course-single': | |
| 724 | - // check for prerequisite course or lesson, | |
| 725 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); | |
| 726 | - $update_course = $this->woocommerce_course_update( $post->ID ); | |
| 727 | - // Count completed lessons | |
| 728 | -                if ( 0 < absint( $course_prerequisite_id ) ) { | |
| 729 | - | |
| 730 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); | |
| 731 | - | |
| 732 | - } | |
| 733 | -                else { | |
| 734 | - $prerequisite_complete = true; | |
| 735 | - } // End If Statement | |
| 736 | - // Handles restrictions | |
| 737 | -                if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { | |
| 738 | -                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 739 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 740 | -                    $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); | |
| 741 | -                } else { | |
| 742 | - $user_allowed = true; | |
| 743 | - } // End If Statement | |
| 744 | - break; | |
| 745 | - case 'lesson-single': | |
| 746 | - // Check for WC purchase | |
| 747 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); | |
| 748 | - | |
| 749 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); | |
| 750 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); | |
| 751 | - | |
| 752 | -                if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { | |
| 753 | - $user_allowed = true; | |
| 754 | -                } elseif( $this->access_settings() && false == $is_preview ) { | |
| 755 | - | |
| 756 | - $user_allowed = true; | |
| 757 | - | |
| 758 | -                } else { | |
| 759 | -                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 760 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 761 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); | |
| 762 | -                    if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { | |
| 763 | -                        if ( $is_preview ) { | |
| 764 | -                            $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); | |
| 765 | -                        } else { | |
| 766 | -                            $this->permissions_message['message'] =  sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); | |
| 767 | - } | |
| 768 | -                    } else { | |
| 769 | -                        if ( $is_preview ) { | |
| 770 | -                            $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); | |
| 771 | -                        } else { | |
| 772 | - /** This filter is documented in class-woothemes-sensei-frontend.php */ | |
| 773 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); | |
| 774 | - } | |
| 775 | - } // End If Statement | |
| 776 | - } // End If Statement | |
| 777 | - break; | |
| 778 | - case 'quiz-single': | |
| 779 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); | |
| 780 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); | |
| 781 | - | |
| 782 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); | |
| 783 | -                if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { | |
| 784 | - | |
| 785 | - // Check for prerequisite lesson for this quiz | |
| 786 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); | |
| 787 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); | |
| 788 | - | |
| 789 | - // Handle restrictions | |
| 790 | -                    if( sensei_all_access() ) { | |
| 791 | - $user_allowed = true; | |
| 792 | -                    } else { | |
| 793 | -                        if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { | |
| 794 | -                            $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 795 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; | |
| 796 | -                            $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); | |
| 797 | -                        } else { | |
| 798 | - $user_allowed = true; | |
| 799 | - } // End If Statement | |
| 800 | - } // End If Statement | |
| 801 | -                } elseif( $this->access_settings() ) { | |
| 802 | - // Check if the user has started the course | |
| 803 | - | |
| 804 | -                    if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { | |
| 805 | - | |
| 806 | - $user_allowed = false; | |
| 807 | -                        $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 808 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 809 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); | |
| 810 | -                        if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { | |
| 811 | -                            $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); | |
| 812 | -                        } else { | |
| 813 | -                            $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); | |
| 814 | - } // End If Statement | |
| 815 | -                    } else { | |
| 816 | - $user_allowed = true; | |
| 817 | - } // End If Statement | |
| 818 | -                } else { | |
| 819 | -                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 820 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 821 | -                    $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); | |
| 822 | - } // End If Statement | |
| 823 | - break; | |
| 824 | - default: | |
| 825 | - $user_allowed = true; | |
| 826 | - break; | |
| 827 | - | |
| 828 | - } // End Switch Statement | |
| 829 | - | |
| 830 | - /** | |
| 831 | - * filter the permissions message shown on sensei post types. | |
| 832 | - * | |
| 833 | - * @since 1.8.7 | |
| 834 | - * | |
| 835 | -         * @param array $permissions_message{ | |
| 836 | - * | |
| 837 | - * @type string $title | |
| 838 | - * @type string $message | |
| 839 | - * | |
| 840 | - * } | |
| 841 | - * @param string $post_id | |
| 842 | - */ | |
| 843 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); | |
| 844 | - | |
| 845 | - | |
| 846 | -        if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { | |
| 847 | - $user_allowed = true; | |
| 848 | - } | |
| 849 | - | |
| 850 | - return apply_filters( 'sensei_access_permissions', $user_allowed ); | |
| 851 | - } // End get_placeholder_image() | |
| 852 | - | |
| 853 | - | |
| 854 | - /** | |
| 855 | - * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check. | |
| 856 | - * @since 1.0.0 | |
| 857 | - * @access public | |
| 858 | - * @return bool | |
| 859 | - */ | |
| 860 | -    public function access_settings () { | |
| 861 | - | |
| 862 | - if( sensei_all_access() ) return true; | |
| 863 | - | |
| 864 | -        if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { | |
| 865 | -            if ( is_user_logged_in() ) { | |
| 866 | - return true; | |
| 867 | -            } else { | |
| 868 | - return false; | |
| 869 | - } // End If Statement | |
| 870 | -        } else { | |
| 871 | - return true; | |
| 872 | - } // End If Statement | |
| 873 | - } // End access_settings() | |
| 874 | - | |
| 875 | - /** | |
| 876 | - * sensei_woocommerce_complete_order description | |
| 877 | - * @since 1.0.3 | |
| 878 | - * @access public | |
| 879 | - * @param int $order_id WC order ID | |
| 880 | - * @return void | |
| 881 | - */ | |
| 882 | -    public function sensei_woocommerce_complete_order ( $order_id = 0 ) { | |
| 883 | - $order_user = array(); | |
| 884 | - // Check for WooCommerce | |
| 885 | -        if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { | |
| 886 | - // Get order object | |
| 887 | - $order = new WC_Order( $order_id ); | |
| 888 | - $user = get_user_by( 'id', $order->get_user_id() ); | |
| 889 | - $order_user['ID'] = $user->ID; | |
| 890 | - $order_user['user_login'] = $user->user_login; | |
| 891 | - $order_user['user_email'] = $user->user_email; | |
| 892 | - $order_user['user_url'] = $user->user_url; | |
| 893 | - // Run through each product ordered | |
| 894 | -            if ( 0 < sizeof( $order->get_items() ) ) { | |
| 895 | -                foreach( $order->get_items() as $item ) { | |
| 896 | - $product_type = ''; | |
| 897 | -                    if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { | |
| 898 | - $item_id = $item['variation_id']; | |
| 899 | - $product_type = 'variation'; | |
| 900 | -                    } else { | |
| 901 | - $item_id = $item['product_id']; | |
| 902 | - } // End If Statement | |
| 903 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); | |
| 904 | - // Get courses that use the WC product | |
| 905 | - $courses = $this->post_types->course->get_product_courses( $_product->id ); | |
| 906 | - // Loop and update those courses | |
| 907 | -                    foreach ( $courses as $course_item ) { | |
| 908 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); | |
| 909 | - } // End For Loop | |
| 910 | - } // End For Loop | |
| 911 | - } // End If Statement | |
| 912 | - // Add meta to indicate that payment has been completed successfully | |
| 913 | - update_post_meta( $order_id, 'sensei_payment_complete', '1' ); | |
| 914 | - } // End If Statement | |
| 915 | - } // End sensei_woocommerce_complete_order() | |
| 916 | - | |
| 917 | - /** | |
| 918 | - * Runs when an order is cancelled. | |
| 919 | - * @since 1.2.0 | |
| 920 | - * @access public | |
| 921 | - * @param integer $order_id order ID | |
| 922 | - * @return void | |
| 923 | - */ | |
| 924 | -    public function sensei_woocommerce_cancel_order ( $order_id ) { | |
| 925 | - | |
| 926 | - // Get order object | |
| 927 | - $order = new WC_Order( $order_id ); | |
| 928 | - | |
| 929 | - // Run through each product ordered | |
| 930 | -        if ( 0 < sizeof( $order->get_items() ) ) { | |
| 931 | - | |
| 932 | - // Get order user | |
| 933 | - $user_id = $order->__get( 'user_id' ); | |
| 934 | - | |
| 935 | -            foreach( $order->get_items() as $item ) { | |
| 936 | - | |
| 937 | - $product_type = ''; | |
| 938 | -                if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { | |
| 939 | - $item_id = $item['variation_id']; | |
| 940 | - $product_type = 'variation'; | |
| 941 | -                } else { | |
| 942 | - $item_id = $item['product_id']; | |
| 943 | - } // End If Statement | |
| 944 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); | |
| 945 | - | |
| 946 | - // Get courses that use the WC product | |
| 947 | - $courses = array(); | |
| 948 | - $courses = $this->post_types->course->get_product_courses( $item_id ); | |
| 949 | - | |
| 950 | - // Loop and update those courses | |
| 951 | -                foreach ($courses as $course_item){ | |
| 952 | - // Check and Remove course from courses user meta | |
| 953 | - $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); | |
| 954 | - } // End For Loop | |
| 955 | - } // End For Loop | |
| 956 | - } // End If Statement | |
| 957 | - } // End sensei_woocommerce_cancel_order() | |
| 958 | - | |
| 959 | - /** | |
| 960 | - * Runs when an subscription is cancelled or expires. | |
| 961 | - * @since 1.3.3 | |
| 962 | - * @access public | |
| 963 | - * @param integer $user_id User ID | |
| 964 | - * @param integer $subscription_key Subscription Unique Key | |
| 965 | - * @return void | |
| 966 | - */ | |
| 967 | -    public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { | |
| 968 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); | |
| 969 | - self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); | |
| 970 | - } | |
| 971 | - | |
| 972 | - /** | |
| 973 | - * Runs when an subscription is re-activated after suspension. | |
| 974 | - * @since 1.3.3 | |
| 975 | - * @access public | |
| 976 | - * @param integer $user_id User ID | |
| 977 | - * @param integer $subscription_key Subscription Unique Key | |
| 978 | - * @return void | |
| 979 | - */ | |
| 980 | -    public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { | |
| 981 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); | |
| 982 | - $order = new WC_Order( $subscription['order_id'] ); | |
| 983 | - $user = get_user_by( 'id', $order->get_user_id() ); | |
| 984 | - $order_user = array(); | |
| 985 | - $order_user['ID'] = $user->ID; | |
| 986 | - $order_user['user_login'] = $user->user_login; | |
| 987 | - $order_user['user_email'] = $user->user_email; | |
| 988 | - $order_user['user_url'] = $user->user_url; | |
| 989 | - $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); | |
| 990 | -        foreach ( $courses as $course_item ){ | |
| 991 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); | |
| 992 | - } // End For Loop | |
| 993 | - } // End sensei_woocommerce_reactivate_subscription | |
| 994 | - | |
| 995 | - /** | |
| 996 | - * Returns the WooCommerce Product Object | |
| 997 | - * | |
| 998 | - * The code caters for pre and post WooCommerce 2.2 installations. | |
| 999 | - * | |
| 1000 | - * @since 1.1.1 | |
| 1001 | - * @access public | |
| 1002 | - * @param integer $wc_product_id Product ID or Variation ID | |
| 1003 | - * @param string $product_type '' or 'variation' | |
| 1004 | - * @return WC_Product $wc_product_object | |
| 1005 | - */ | |
| 1006 | -    public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { | |
| 1007 | - | |
| 1008 | - $wc_product_object = false; | |
| 1009 | -        if ( 0 < intval( $wc_product_id ) ) { | |
| 1010 | - | |
| 1011 | - // Get the product | |
| 1012 | -            if ( function_exists( 'wc_get_product' ) ) { | |
| 1013 | - | |
| 1014 | - $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 | |
| 1015 | - | |
| 1016 | -            } elseif ( function_exists( 'get_product' ) ) { | |
| 1017 | - | |
| 1018 | - $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 | |
| 1019 | - | |
| 1020 | -            } else { | |
| 1021 | - | |
| 1022 | - // Pre WC 2.0 | |
| 1023 | -                if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { | |
| 1024 | - | |
| 1025 | - $wc_product_object = new WC_Product_Variation( $wc_product_id ); | |
| 1026 | - | |
| 1027 | -                } else { | |
| 1028 | - | |
| 1029 | - $wc_product_object = new WC_Product( $wc_product_id ); | |
| 1030 | - | |
| 1031 | - } // End If Statement | |
| 1032 | - | |
| 1033 | - } // End If Statement | |
| 1034 | - | |
| 1035 | - } // End If Statement | |
| 1036 | - | |
| 1037 | - return $wc_product_object; | |
| 1038 | - | |
| 1039 | - } // End sensei_get_woocommerce_product_object() | |
| 1040 | - | |
| 1041 | - /** | |
| 1042 | - * load_class loads in class files | |
| 1043 | - * @since 1.2.0 | |
| 1044 | - * @access public | |
| 1045 | - * @return void | |
| 1046 | - */ | |
| 1047 | -    public function load_class ( $class_name = '' ) { | |
| 1048 | -        if ( '' != $class_name && '' != $this->token ) { | |
| 1049 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); | |
| 1050 | - } // End If Statement | |
| 1051 | - } // End load_class() | |
| 1052 | - | |
| 1053 | - /** | |
| 1054 | - * sensei_activate_subscription runs when a subscription product is purchased | |
| 1055 | - * @since 1.2.0 | |
| 1056 | - * @access public | |
| 1057 | - * @param integer $order_id order ID | |
| 1058 | - * @return void | |
| 1059 | - */ | |
| 1060 | -    public function sensei_activate_subscription(  $order_id = 0 ) { | |
| 1061 | -        if ( 0 < intval( $order_id ) ) { | |
| 1062 | - $order = new WC_Order( $order_id ); | |
| 1063 | -            $user = get_user_by('id', $order->user_id); | |
| 1064 | - $order_user['ID'] = $user->ID; | |
| 1065 | - $order_user['user_login'] = $user->user_login; | |
| 1066 | - $order_user['user_email'] = $user->user_email; | |
| 1067 | - $order_user['user_url'] = $user->user_url; | |
| 1068 | - // Run through each product ordered | |
| 1069 | -            if (sizeof($order->get_items())>0) { | |
| 1070 | -                foreach($order->get_items() as $item) { | |
| 1071 | - $product_type = ''; | |
| 1072 | -                    if (isset($item['variation_id']) && $item['variation_id'] > 0) { | |
| 1073 | - $item_id = $item['variation_id']; | |
| 1074 | - $product_type = 'subscription_variation'; | |
| 1075 | -                    } else { | |
| 1076 | - $item_id = $item['product_id']; | |
| 1077 | - } // End If Statement | |
| 1078 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); | |
| 1079 | - // Get courses that use the WC product | |
| 1080 | - $courses = array(); | |
| 1081 | -                    if ( $product_type == 'subscription_variation' ) { | |
| 1082 | - $courses = $this->post_types->course->get_product_courses( $item_id ); | |
| 1083 | - } // End If Statement | |
| 1084 | - // Loop and update those courses | |
| 1085 | -                    foreach ($courses as $course_item){ | |
| 1086 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); | |
| 1087 | - } // End For Loop | |
| 1088 | - } // End For Loop | |
| 1089 | - } // End If Statement | |
| 1090 | - } // End If Statement | |
| 1091 | - } // End sensei_activate_subscription() | |
| 1092 | - | |
| 1093 | - /** | |
| 1094 | - * sensei_woocommerce_email_course_details adds detail to email | |
| 1095 | - * @since 1.4.5 | |
| 1096 | - * @access public | |
| 1097 | - * @param WC_Order $order | |
| 1098 | - * @return void | |
| 1099 | - */ | |
| 1100 | -    public function sensei_woocommerce_email_course_details( $order ) { | |
| 1101 | - global $woocommerce; | |
| 1102 | - | |
| 1103 | - // exit early if not wc-completed or wc-processing | |
| 1104 | - if( 'wc-completed' != $order->post_status | |
| 1105 | -            && 'wc-processing' != $order->post_status  ) { | |
| 1106 | - return; | |
| 1107 | - } | |
| 1108 | - | |
| 1109 | - $order_items = $order->get_items(); | |
| 1110 | - $order_id = $order->id; | |
| 1111 | - | |
| 1112 | - //If object have items go through them all to find course | |
| 1113 | -        if ( 0 < sizeof( $order_items ) ) { | |
| 1114 | - | |
| 1115 | - $course_details_html = '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; | |
| 1116 | - $order_contains_courses = false; | |
| 1117 | - | |
| 1118 | - | |
| 1119 | -            foreach ( $order_items as $item ) { | |
| 1120 | - | |
| 1121 | - $product_type = ''; | |
| 1122 | -                if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { | |
| 1123 | - // If item has variation_id then its from variation | |
| 1124 | - $item_id = $item['variation_id']; | |
| 1125 | - $product_type = 'variation'; | |
| 1126 | -                } else { | |
| 1127 | - // If not its real product set its id to item_id | |
| 1128 | - $item_id = $item['product_id']; | |
| 1129 | - } // End If Statement | |
| 1130 | - | |
| 1131 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); | |
| 1132 | - | |
| 1133 | -                if( $user_id ) { | |
| 1134 | - | |
| 1135 | - // Get all courses for product | |
| 1136 | - $args = array( | |
| 1137 | - 'posts_per_page' => -1, | |
| 1138 | - 'post_type' => 'course', | |
| 1139 | - 'meta_query' => array( | |
| 1140 | - array( | |
| 1141 | - 'key' => '_course_woocommerce_product', | |
| 1142 | - 'value' => $item_id | |
| 1143 | - ) | |
| 1144 | - ), | |
| 1145 | - 'orderby' => 'menu_order date', | |
| 1146 | - 'order' => 'ASC', | |
| 1147 | - ); | |
| 1148 | - $courses = get_posts( $args ); | |
| 1149 | - | |
| 1150 | -                    if( $courses && count( $courses ) > 0 ) { | |
| 1151 | - | |
| 1152 | -                        foreach( $courses as $course ) { | |
| 1153 | - | |
| 1154 | - $title = $course->post_title; | |
| 1155 | - $permalink = get_permalink( $course->ID ); | |
| 1156 | - $order_contains_courses = true; | |
| 1157 | - $course_details_html .= '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; | |
| 1158 | - } | |
| 1159 | - | |
| 1160 | - | |
| 1161 | - } // end if has courses | |
| 1162 | - | |
| 1163 | - } // end if $userPid | |
| 1164 | - | |
| 1165 | - } // end for each order item | |
| 1166 | - | |
| 1167 | - // Output Course details | |
| 1168 | -            if( $order_contains_courses ){ | |
| 1169 | - | |
| 1170 | - echo $course_details_html; | |
| 1171 | - | |
| 1172 | - } | |
| 1173 | - | |
| 1174 | - | |
| 1175 | - } // end if order items not empty | |
| 1176 | - | |
| 1177 | - } // end func email course details | |
| 1178 | - | |
| 1179 | - /** | |
| 1180 | - * Filtering wp_count_comments to ensure that Sensei comments are ignored | |
| 1181 | - * @since 1.4.0 | |
| 1182 | - * @access public | |
| 1183 | - * @param array $comments | |
| 1184 | - * @param integer $post_id | |
| 1185 | - * @return array | |
| 1186 | - */ | |
| 1187 | -    public function sensei_count_comments( $comments, $post_id ) { | |
| 1188 | - global $wpdb; | |
| 1189 | - | |
| 1190 | - $post_id = (int) $post_id; | |
| 1191 | - | |
| 1192 | -        $count = wp_cache_get("comments-{$post_id}", 'counts'); | |
| 1193 | - | |
| 1194 | -        if ( false !== $count ) { | |
| 1195 | - return $count; | |
| 1196 | - } | |
| 1197 | - | |
| 1198 | - $statuses = array( '' ); // Default to the WP normal comments | |
| 1199 | -        $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); | |
| 1200 | -        foreach ( (array) $stati AS $status ) { | |
| 1201 | -            if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { | |
| 1202 | - $statuses[] = $status['comment_type']; | |
| 1203 | - } | |
| 1204 | - } | |
| 1205 | -        $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; | |
| 1206 | - | |
| 1207 | - if ( $post_id > 0 ) | |
| 1208 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); | |
| 1209 | - | |
| 1210 | -        $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); | |
| 1211 | - | |
| 1212 | - $total = 0; | |
| 1213 | -        $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); | |
| 1214 | -        foreach ( (array) $count as $row ) { | |
| 1215 | - // Don't count post-trashed toward totals | |
| 1216 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) | |
| 1217 | - $total += $row['num_comments']; | |
| 1218 | - if ( isset( $approved[$row['comment_approved']] ) ) | |
| 1219 | - $stats[$approved[$row['comment_approved']]] = $row['num_comments']; | |
| 1220 | - } | |
| 1221 | - | |
| 1222 | - $stats['total_comments'] = $total; | |
| 1223 | -        foreach ( $approved as $key ) { | |
| 1224 | - if ( empty($stats[$key]) ) | |
| 1225 | - $stats[$key] = 0; | |
| 1226 | - } | |
| 1227 | - | |
| 1228 | - $stats = (object) $stats; | |
| 1229 | -        wp_cache_set("comments-{$post_id}", $stats, 'counts'); | |
| 1230 | - | |
| 1231 | - return $stats; | |
| 1232 | - } | |
| 1233 | - | |
| 1234 | - /** | |
| 1235 | - * Init images. | |
| 1236 | - * | |
| 1237 | - * @since 1.4.5 | |
| 1238 | - * @access public | |
| 1239 | - * @return void | |
| 1240 | - */ | |
| 1241 | -    public function init_image_sizes() { | |
| 1242 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); | |
| 1243 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); | |
| 1244 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); | |
| 1245 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); | |
| 1246 | - | |
| 1247 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); | |
| 1248 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); | |
| 1249 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); | |
| 1250 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); | |
| 1251 | - } | |
| 1252 | - | |
| 1253 | - /** | |
| 1254 | - * Get an image size. | |
| 1255 | - * | |
| 1256 | -     * Variable is filtered by sensei_get_image_size_{image_size} | |
| 1257 | - * | |
| 1258 | - * @since 1.4.5 | |
| 1259 | - * @access public | |
| 1260 | - * @param mixed $image_size | |
| 1261 | - * @return string | |
| 1262 | - */ | |
| 1263 | -    public function get_image_size( $image_size ) { | |
| 1264 | - | |
| 1265 | - // Only return sizes we define in settings | |
| 1266 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) | |
| 1267 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); | |
| 1268 | - | |
| 1269 | -        if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { | |
| 1270 | - $this->settings->settings[ $image_size . '_width' ] = false; | |
| 1271 | - } | |
| 1272 | -        if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { | |
| 1273 | - $this->settings->settings[ $image_size . '_height' ] = false; | |
| 1274 | - } | |
| 1275 | -        if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { | |
| 1276 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; | |
| 1277 | - } | |
| 1278 | - | |
| 1279 | - $size = array_filter( array( | |
| 1280 | - 'width' => $this->settings->settings[ $image_size . '_width' ], | |
| 1281 | - 'height' => $this->settings->settings[ $image_size . '_height' ], | |
| 1282 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] | |
| 1283 | - ) ); | |
| 1284 | - | |
| 1285 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; | |
| 1286 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; | |
| 1287 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; | |
| 1288 | - | |
| 1289 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); | |
| 1290 | - } | |
| 1291 | - | |
| 1292 | -    public function body_class( $classes ) { | |
| 1293 | -        if( is_sensei() ) { | |
| 1294 | - $classes[] = 'sensei'; | |
| 1295 | - } | |
| 1296 | - return $classes; | |
| 1297 | - } | |
| 1298 | - | |
| 1299 | - /** | |
| 1300 | - * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers | |
| 1301 | - * | |
| 1302 | - * @return null | |
| 1303 | - * @since 1.7.0 | |
| 1304 | - */ | |
| 1305 | -    public function jetpack_latex_support() { | |
| 1306 | -        if ( function_exists( 'latex_markup') ) { | |
| 1307 | - add_filter( 'sensei_question_title', 'latex_markup' ); | |
| 1308 | - add_filter( 'sensei_answer_text', 'latex_markup' ); | |
| 1309 | - } | |
| 1310 | - } | |
| 1311 | - | |
| 1312 | - /** | |
| 1313 | - * Load the module functionality. | |
| 1314 | - * | |
| 1315 | - * This function is hooked into plugins_loaded to avoid conflicts with | |
| 1316 | - * the retired modules extension. | |
| 1317 | - * | |
| 1318 | - * @since 1.8.0 | |
| 1319 | - */ | |
| 1320 | -    public function load_modules_class(){ | |
| 1321 | - global $sensei_modules; | |
| 1322 | - | |
| 1323 | - if( !class_exists( 'Sensei_Modules' ) | |
| 1324 | -            &&  'Sensei_Modules' != get_class( $sensei_modules ) ) { | |
| 1325 | - | |
| 1326 | - //Load the modules class | |
| 1327 | - require_once( 'class-sensei-modules.php'); | |
| 1328 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); | |
| 1329 | - | |
| 1330 | -        }else{ | |
| 1331 | - // fallback for people still using the modules extension. | |
| 1332 | - global $sensei_modules; | |
| 1333 | - Sensei()->modules = $sensei_modules; | |
| 1334 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); | |
| 1335 | - } | |
| 1336 | - } | |
| 1337 | - | |
| 1338 | - /** | |
| 1339 | - * Tell the user to that the modules extension is no longer needed. | |
| 1340 | - * | |
| 1341 | - * @since 1.8.0 | |
| 1342 | - */ | |
| 1343 | -    public function disable_sensei_modules_extension(){ ?> | |
| 329 | + /** | |
| 330 | + * Initialize all Sensei hooks | |
| 331 | + * | |
| 332 | + * @since 1.9.0 | |
| 333 | + */ | |
| 334 | +	public function load_hooks(){ | |
| 335 | + | |
| 336 | + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); | |
| 337 | + add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); | |
| 338 | + | |
| 339 | + // WooCommerce Payment Actions | |
| 340 | + add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 341 | + add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 342 | + add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 343 | + add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); | |
| 344 | + add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); | |
| 345 | + add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); | |
| 346 | + add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); | |
| 347 | + | |
| 348 | + // WooCommerce Subscriptions Actions | |
| 349 | + add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); | |
| 350 | + add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 351 | + add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 352 | + add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 353 | + add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); | |
| 354 | + | |
| 355 | + // Add Email link to course orders | |
| 356 | + add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); | |
| 357 | + | |
| 358 | + // Filter comment counts | |
| 359 | + add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); | |
| 360 | + | |
| 361 | + add_action( 'body_class', array( $this, 'body_class' ) ); | |
| 362 | + | |
| 363 | + // Check for and activate JetPack LaTeX support | |
| 364 | + add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules | |
| 365 | + | |
| 366 | + // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 | |
| 367 | + add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); | |
| 368 | + | |
| 369 | + } | |
| 370 | + | |
| 371 | + /** | |
| 372 | + * Run Sensei updates. | |
| 373 | + * @access public | |
| 374 | + * @since 1.1.0 | |
| 375 | + * @return void | |
| 376 | + */ | |
| 377 | +	public function run_updates() { | |
| 378 | + // Run updates if administrator | |
| 379 | +		if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { | |
| 380 | + | |
| 381 | + $this->updates->update(); | |
| 382 | + | |
| 383 | + } // End If Statement | |
| 384 | + } // End run_updates() | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + /** | |
| 389 | + * Setup required WooCommerce settings. | |
| 390 | + * @access public | |
| 391 | + * @since 1.1.0 | |
| 392 | + * @return void | |
| 393 | + */ | |
| 394 | +	public function set_woocommerce_functionality() { | |
| 395 | + // Disable guest checkout if a course is in the cart as we need a valid user to store data for | |
| 396 | + add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); | |
| 397 | + | |
| 398 | + // Mark orders with virtual products as complete rather then stay processing | |
| 399 | + add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); | |
| 400 | + | |
| 401 | + } // End set_woocommerce_functionality() | |
| 402 | + | |
| 403 | + /** | |
| 404 | + * Disable guest checkout if a course product is in the cart | |
| 405 | + * @param boolean $guest_checkout Current guest checkout setting | |
| 406 | + * @return boolean Modified guest checkout setting | |
| 407 | + */ | |
| 408 | +	public function disable_guest_checkout( $guest_checkout ) { | |
| 409 | + global $woocommerce; | |
| 410 | + | |
| 411 | +		if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
| 412 | + | |
| 413 | +			if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { | |
| 414 | +				foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { | |
| 415 | +					if( isset( $product['product_id'] ) ) { | |
| 416 | + $args = array( | |
| 417 | + 'posts_per_page' => -1, | |
| 418 | + 'post_type' => 'course', | |
| 419 | + 'meta_query' => array( | |
| 420 | + array( | |
| 421 | + 'key' => '_course_woocommerce_product', | |
| 422 | + 'value' => $product['product_id'] | |
| 423 | + ) | |
| 424 | + ) | |
| 425 | + ); | |
| 426 | + $posts = get_posts( $args ); | |
| 427 | +						if( $posts && count( $posts ) > 0 ) { | |
| 428 | +							foreach( $posts as $course ) { | |
| 429 | + $guest_checkout = ''; | |
| 430 | + break; | |
| 431 | + } | |
| 432 | + } | |
| 433 | + } | |
| 434 | + } | |
| 435 | + } | |
| 436 | + } | |
| 437 | + | |
| 438 | + return $guest_checkout; | |
| 439 | + } | |
| 440 | + | |
| 441 | + /** | |
| 442 | + * Change order status with virtual products to completed | |
| 443 | + * @since 1.1.0 | |
| 444 | + * @param string $order_status | |
| 445 | + * @param int $order_id | |
| 446 | + * @return string | |
| 447 | + **/ | |
| 448 | +	public function virtual_order_payment_complete( $order_status, $order_id ) { | |
| 449 | + $order = new WC_Order( $order_id ); | |
| 450 | + if ( ! isset ( $order ) ) return ''; | |
| 451 | +		if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { | |
| 452 | + $virtual_order = true; | |
| 453 | + | |
| 454 | +			if ( count( $order->get_items() ) > 0 ) { | |
| 455 | +				foreach( $order->get_items() as $item ) { | |
| 456 | +					if ( $item['product_id'] > 0 ) { | |
| 457 | + $_product = $order->get_product_from_item( $item ); | |
| 458 | +						if ( ! $_product->is_virtual() ) { | |
| 459 | + $virtual_order = false; | |
| 460 | + break; | |
| 461 | + } // End If Statement | |
| 462 | + } // End If Statement | |
| 463 | + } // End For Loop | |
| 464 | + } // End If Statement | |
| 465 | + | |
| 466 | + // virtual order, mark as completed | |
| 467 | +			if ( $virtual_order ) { | |
| 468 | + return 'completed'; | |
| 469 | + } // End If Statement | |
| 470 | + } // End If Statement | |
| 471 | + return $order_status; | |
| 472 | + } | |
| 473 | + | |
| 474 | + /** | |
| 475 | + * Register the widgets. | |
| 476 | + * @access public | |
| 477 | + * @since 1.0.0 | |
| 478 | + * @return void | |
| 479 | + */ | |
| 480 | +	public function register_widgets () { | |
| 481 | + // Widget List (key => value is filename => widget class). | |
| 482 | + $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', | |
| 483 | + 'lesson-component' => 'Lesson_Component', | |
| 484 | + 'course-categories' => 'Course_Categories', | |
| 485 | + 'category-courses' => 'Category_Courses' ) | |
| 486 | + ); | |
| 487 | +		foreach ( $widget_list as $key => $value ) { | |
| 488 | +			if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' ) ) { | |
| 489 | + require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); | |
| 490 | + register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); | |
| 491 | + } | |
| 492 | + } // End For Loop | |
| 493 | + | |
| 494 | + do_action( 'sensei_register_widgets' ); | |
| 495 | + | |
| 496 | + } // End register_widgets() | |
| 497 | + | |
| 498 | + /** | |
| 499 | + * Load the plugin's localisation file. | |
| 500 | + * @access public | |
| 501 | + * @since 1.0.0 | |
| 502 | + * @return void | |
| 503 | + */ | |
| 504 | +	public function load_localisation () { | |
| 505 | + load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); | |
| 506 | + } // End load_localisation() | |
| 507 | + | |
| 508 | + /** | |
| 509 | + * Load the plugin textdomain from the main WordPress "languages" folder. | |
| 510 | + * @access public | |
| 511 | + * @since 1.0.0 | |
| 512 | + * @return void | |
| 513 | + */ | |
| 514 | +	public function load_plugin_textdomain () { | |
| 515 | + $domain = 'woothemes-sensei'; | |
| 516 | + // The "plugin_locale" filter is also used in load_plugin_textdomain() | |
| 517 | + $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); | |
| 518 | + load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); | |
| 519 | + load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); | |
| 520 | + } // End load_plugin_textdomain() | |
| 521 | + | |
| 522 | + /** | |
| 523 | + * Run on activation. | |
| 524 | + * @access public | |
| 525 | + * @since 1.0.0 | |
| 526 | + * @return void | |
| 527 | + */ | |
| 528 | +	public function activation () { | |
| 529 | + $this->register_plugin_version(); | |
| 530 | + } // End activation() | |
| 531 | + | |
| 532 | + | |
| 533 | + /** | |
| 534 | + * Register activation hooks. | |
| 535 | + * @access public | |
| 536 | + * @since 1.0.0 | |
| 537 | + * @return void | |
| 538 | + */ | |
| 539 | +	public function install () { | |
| 540 | + register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); | |
| 541 | + register_activation_hook( $this->file, 'flush_rewrite_rules' ); | |
| 542 | + } // End install() | |
| 543 | + | |
| 544 | + | |
| 545 | + /** | |
| 546 | + * Run on activation of the plugin. | |
| 547 | + * @access public | |
| 548 | + * @since 1.0.0 | |
| 549 | + * @return void | |
| 550 | + */ | |
| 551 | +	public function activate_sensei () { | |
| 552 | + update_option( 'skip_install_sensei_pages', 0 ); | |
| 553 | + update_option( 'sensei_installed', 1 ); | |
| 554 | + } // End activate_sensei() | |
| 555 | + | |
| 556 | + /** | |
| 557 | + * Register the plugin's version. | |
| 558 | + * @access public | |
| 559 | + * @since 1.0.0 | |
| 560 | + * @return void | |
| 561 | + */ | |
| 562 | +	private function register_plugin_version () { | |
| 563 | +		if ( $this->version != '' ) { | |
| 564 | + | |
| 565 | + // Check previous version to see if forced updates must run | |
| 566 | + // $old_version = get_option( 'woothemes-sensei-version', false ); | |
| 567 | +			// if( $old_version && version_compare( $old_version, '1.7.0', '<' )  ) { | |
| 568 | + // update_option( 'woothemes-sensei-force-updates', $this->version ); | |
| 569 | +			// } else { | |
| 570 | + // delete_option( 'woothemes-sensei-force-updates' ); | |
| 571 | + // } | |
| 572 | + | |
| 573 | + update_option( 'woothemes-sensei-version', $this->version ); | |
| 574 | + } | |
| 575 | + } // End register_plugin_version() | |
| 576 | + | |
| 577 | + /** | |
| 578 | + * Ensure that "post-thumbnails" support is available for those themes that don't register it. | |
| 579 | + * @access public | |
| 580 | + * @since 1.0.1 | |
| 581 | + * @return void | |
| 582 | + */ | |
| 583 | +	public function ensure_post_thumbnails_support () { | |
| 584 | +		if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } | |
| 585 | + } // End ensure_post_thumbnails_support() | |
| 586 | + | |
| 587 | + | |
| 588 | + /** | |
| 589 | + * template_loader function. | |
| 590 | + * | |
| 591 | + * @access public | |
| 592 | + * @param mixed $template | |
| 593 | + * @return void | |
| 594 | + * @deprecated | |
| 595 | + */ | |
| 596 | +	public function template_loader ( $template = '' ) { | |
| 597 | + | |
| 598 | + _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); | |
| 599 | + Sensei_Templates::template_loader( $template ); | |
| 600 | + | |
| 601 | + } // End template_loader() | |
| 602 | + | |
| 603 | + /** | |
| 604 | + * Determine the relative path to the plugin's directory. | |
| 605 | + * @access public | |
| 606 | + * @since 1.0.0 | |
| 607 | + * @return string $sensei_plugin_path | |
| 608 | + */ | |
| 609 | +	public function plugin_path () { | |
| 610 | + | |
| 611 | +		if ( $this->plugin_path ) { | |
| 612 | + | |
| 613 | + $sensei_plugin_path = $this->plugin_path; | |
| 614 | + | |
| 615 | +		}else{ | |
| 616 | + | |
| 617 | + $sensei_plugin_path = plugin_dir_path( __FILE__ ); | |
| 618 | + | |
| 619 | + } | |
| 620 | + | |
| 621 | + return $sensei_plugin_path; | |
| 622 | + | |
| 623 | + } // End plugin_path() | |
| 624 | + | |
| 625 | + | |
| 626 | + /** | |
| 627 | + * Retrieve the ID of a specified page setting. | |
| 628 | + * @access public | |
| 629 | + * @since 1.0.0 | |
| 630 | + * @param string $page | |
| 631 | + * @return int | |
| 632 | + */ | |
| 633 | +	public function get_page_id ( $page ) { | |
| 634 | + $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); | |
| 635 | + return ( $page ) ? $page : -1; | |
| 636 | + } // End get_page_id() | |
| 637 | + | |
| 638 | + | |
| 639 | + /** | |
| 640 | + * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course. | |
| 641 | + * @access public | |
| 642 | + * @since 1.0.0 | |
| 643 | + * @param int $course_id (default: 0) | |
| 644 | + * @param array/Object $order_user (default: array()) Specific user's data. | |
| 645 | + * @return bool|int | |
| 646 | + */ | |
| 647 | +	public function woocommerce_course_update ( $course_id = 0, $order_user = array()  ) { | |
| 648 | + global $current_user; | |
| 649 | + | |
| 650 | + if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; | |
| 651 | + | |
| 652 | + $data_update = false; | |
| 653 | + | |
| 654 | + // Get the product ID | |
| 655 | + $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); | |
| 656 | + | |
| 657 | + // Check if in the admin | |
| 658 | +		if ( is_admin() ) { | |
| 659 | + $user_login = $order_user['user_login']; | |
| 660 | + $user_email = $order_user['user_email']; | |
| 661 | + $user_url = $order_user['user_url']; | |
| 662 | + $user_id = $order_user['ID']; | |
| 663 | +		} else { | |
| 664 | + $user_login = $current_user->user_login; | |
| 665 | + $user_email = $current_user->user_email; | |
| 666 | + $user_url = $current_user->user_url; | |
| 667 | + $user_id = $current_user->ID; | |
| 668 | + } // End If Statement | |
| 669 | + | |
| 670 | + // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? | |
| 671 | + $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); | |
| 672 | +		if( 0 < absint( $course_prerequisite_id ) ) { | |
| 673 | + $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); | |
| 674 | +			if ( ! $prereq_course_complete ) { | |
| 675 | + // Remove all course user meta | |
| 676 | + return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); | |
| 677 | + } | |
| 678 | + } | |
| 679 | + | |
| 680 | + $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); | |
| 681 | + | |
| 682 | +		if( ! $is_user_taking_course ) { | |
| 683 | + | |
| 684 | +			if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { | |
| 685 | + | |
| 686 | + $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); | |
| 687 | + | |
| 688 | + $is_user_taking_course = false; | |
| 689 | +				if ( true == $activity_logged ) { | |
| 690 | + $is_user_taking_course = true; | |
| 691 | + } // End If Statement | |
| 692 | + } // End If Statement | |
| 693 | + } | |
| 694 | + | |
| 695 | + return $is_user_taking_course; | |
| 696 | + } // End woocommerce_course_update() | |
| 697 | + | |
| 698 | + | |
| 699 | + /** | |
| 700 | + * check_user_permissions function. | |
| 701 | + * | |
| 702 | + * @access public | |
| 703 | + * @param string $page (default: '') | |
| 704 | + * | |
| 705 | + * @return bool | |
| 706 | + */ | |
| 707 | +	public function check_user_permissions ( $page = '' ) { | |
| 708 | + // REFACTOR | |
| 709 | + global $current_user, $post; | |
| 710 | + | |
| 711 | + // if use is not logged in | |
| 712 | + // skipped for single lesson | |
| 713 | +		if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') | |
| 714 | +			&& 'lesson-single' !=  $page ){ | |
| 715 | +			$this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); | |
| 716 | +			$this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); | |
| 717 | + return false; | |
| 718 | + } | |
| 719 | + | |
| 720 | + $user_allowed = false; | |
| 721 | + | |
| 722 | +		switch ( $page ) { | |
| 723 | + case 'course-single': | |
| 724 | + // check for prerequisite course or lesson, | |
| 725 | + $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); | |
| 726 | + $update_course = $this->woocommerce_course_update( $post->ID ); | |
| 727 | + // Count completed lessons | |
| 728 | +				if ( 0 < absint( $course_prerequisite_id ) ) { | |
| 729 | + | |
| 730 | + $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); | |
| 731 | + | |
| 732 | + } | |
| 733 | +				else { | |
| 734 | + $prerequisite_complete = true; | |
| 735 | + } // End If Statement | |
| 736 | + // Handles restrictions | |
| 737 | +				if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { | |
| 738 | +					$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 739 | + $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 740 | +					$this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); | |
| 741 | +				} else { | |
| 742 | + $user_allowed = true; | |
| 743 | + } // End If Statement | |
| 744 | + break; | |
| 745 | + case 'lesson-single': | |
| 746 | + // Check for WC purchase | |
| 747 | + $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); | |
| 748 | + | |
| 749 | + $update_course = $this->woocommerce_course_update( $lesson_course_id ); | |
| 750 | + $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); | |
| 751 | + | |
| 752 | +				if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { | |
| 753 | + $user_allowed = true; | |
| 754 | +				} elseif( $this->access_settings() && false == $is_preview ) { | |
| 755 | + | |
| 756 | + $user_allowed = true; | |
| 757 | + | |
| 758 | +				} else { | |
| 759 | +					$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 760 | + $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 761 | + $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); | |
| 762 | +					if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { | |
| 763 | +						if ( $is_preview ) { | |
| 764 | +							$this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); | |
| 765 | +						} else { | |
| 766 | +							$this->permissions_message['message'] =  sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); | |
| 767 | + } | |
| 768 | +					} else { | |
| 769 | +						if ( $is_preview ) { | |
| 770 | +							$this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); | |
| 771 | +						} else { | |
| 772 | + /** This filter is documented in class-woothemes-sensei-frontend.php */ | |
| 773 | + $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); | |
| 774 | + } | |
| 775 | + } // End If Statement | |
| 776 | + } // End If Statement | |
| 777 | + break; | |
| 778 | + case 'quiz-single': | |
| 779 | + $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); | |
| 780 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); | |
| 781 | + | |
| 782 | + $update_course = $this->woocommerce_course_update( $lesson_course_id ); | |
| 783 | +				if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { | |
| 784 | + | |
| 785 | + // Check for prerequisite lesson for this quiz | |
| 786 | + $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); | |
| 787 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); | |
| 788 | + | |
| 789 | + // Handle restrictions | |
| 790 | +					if( sensei_all_access() ) { | |
| 791 | + $user_allowed = true; | |
| 792 | +					} else { | |
| 793 | +						if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { | |
| 794 | +							$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 795 | + $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; | |
| 796 | +							$this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); | |
| 797 | +						} else { | |
| 798 | + $user_allowed = true; | |
| 799 | + } // End If Statement | |
| 800 | + } // End If Statement | |
| 801 | +				} elseif( $this->access_settings() ) { | |
| 802 | + // Check if the user has started the course | |
| 803 | + | |
| 804 | +					if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { | |
| 805 | + | |
| 806 | + $user_allowed = false; | |
| 807 | +						$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 808 | + $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 809 | + $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); | |
| 810 | +						if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { | |
| 811 | +							$this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); | |
| 812 | +						} else { | |
| 813 | +							$this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); | |
| 814 | + } // End If Statement | |
| 815 | +					} else { | |
| 816 | + $user_allowed = true; | |
| 817 | + } // End If Statement | |
| 818 | +				} else { | |
| 819 | +					$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); | |
| 820 | + $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; | |
| 821 | +					$this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); | |
| 822 | + } // End If Statement | |
| 823 | + break; | |
| 824 | + default: | |
| 825 | + $user_allowed = true; | |
| 826 | + break; | |
| 827 | + | |
| 828 | + } // End Switch Statement | |
| 829 | + | |
| 830 | + /** | |
| 831 | + * filter the permissions message shown on sensei post types. | |
| 832 | + * | |
| 833 | + * @since 1.8.7 | |
| 834 | + * | |
| 835 | +		 * @param array $permissions_message{ | |
| 836 | + * | |
| 837 | + * @type string $title | |
| 838 | + * @type string $message | |
| 839 | + * | |
| 840 | + * } | |
| 841 | + * @param string $post_id | |
| 842 | + */ | |
| 843 | + $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); | |
| 844 | + | |
| 845 | + | |
| 846 | +		if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { | |
| 847 | + $user_allowed = true; | |
| 848 | + } | |
| 849 | + | |
| 850 | + return apply_filters( 'sensei_access_permissions', $user_allowed ); | |
| 851 | + } // End get_placeholder_image() | |
| 852 | + | |
| 853 | + | |
| 854 | + /** | |
| 855 | + * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check. | |
| 856 | + * @since 1.0.0 | |
| 857 | + * @access public | |
| 858 | + * @return bool | |
| 859 | + */ | |
| 860 | +	public function access_settings () { | |
| 861 | + | |
| 862 | + if( sensei_all_access() ) return true; | |
| 863 | + | |
| 864 | +		if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { | |
| 865 | +			if ( is_user_logged_in() ) { | |
| 866 | + return true; | |
| 867 | +			} else { | |
| 868 | + return false; | |
| 869 | + } // End If Statement | |
| 870 | +		} else { | |
| 871 | + return true; | |
| 872 | + } // End If Statement | |
| 873 | + } // End access_settings() | |
| 874 | + | |
| 875 | + /** | |
| 876 | + * sensei_woocommerce_complete_order description | |
| 877 | + * @since 1.0.3 | |
| 878 | + * @access public | |
| 879 | + * @param int $order_id WC order ID | |
| 880 | + * @return void | |
| 881 | + */ | |
| 882 | +	public function sensei_woocommerce_complete_order ( $order_id = 0 ) { | |
| 883 | + $order_user = array(); | |
| 884 | + // Check for WooCommerce | |
| 885 | +		if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { | |
| 886 | + // Get order object | |
| 887 | + $order = new WC_Order( $order_id ); | |
| 888 | + $user = get_user_by( 'id', $order->get_user_id() ); | |
| 889 | + $order_user['ID'] = $user->ID; | |
| 890 | + $order_user['user_login'] = $user->user_login; | |
| 891 | + $order_user['user_email'] = $user->user_email; | |
| 892 | + $order_user['user_url'] = $user->user_url; | |
| 893 | + // Run through each product ordered | |
| 894 | +			if ( 0 < sizeof( $order->get_items() ) ) { | |
| 895 | +				foreach( $order->get_items() as $item ) { | |
| 896 | + $product_type = ''; | |
| 897 | +					if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { | |
| 898 | + $item_id = $item['variation_id']; | |
| 899 | + $product_type = 'variation'; | |
| 900 | +					} else { | |
| 901 | + $item_id = $item['product_id']; | |
| 902 | + } // End If Statement | |
| 903 | + $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); | |
| 904 | + // Get courses that use the WC product | |
| 905 | + $courses = $this->post_types->course->get_product_courses( $_product->id ); | |
| 906 | + // Loop and update those courses | |
| 907 | +					foreach ( $courses as $course_item ) { | |
| 908 | + $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); | |
| 909 | + } // End For Loop | |
| 910 | + } // End For Loop | |
| 911 | + } // End If Statement | |
| 912 | + // Add meta to indicate that payment has been completed successfully | |
| 913 | + update_post_meta( $order_id, 'sensei_payment_complete', '1' ); | |
| 914 | + } // End If Statement | |
| 915 | + } // End sensei_woocommerce_complete_order() | |
| 916 | + | |
| 917 | + /** | |
| 918 | + * Runs when an order is cancelled. | |
| 919 | + * @since 1.2.0 | |
| 920 | + * @access public | |
| 921 | + * @param integer $order_id order ID | |
| 922 | + * @return void | |
| 923 | + */ | |
| 924 | +	public function sensei_woocommerce_cancel_order ( $order_id ) { | |
| 925 | + | |
| 926 | + // Get order object | |
| 927 | + $order = new WC_Order( $order_id ); | |
| 928 | + | |
| 929 | + // Run through each product ordered | |
| 930 | +		if ( 0 < sizeof( $order->get_items() ) ) { | |
| 931 | + | |
| 932 | + // Get order user | |
| 933 | + $user_id = $order->__get( 'user_id' ); | |
| 934 | + | |
| 935 | +			foreach( $order->get_items() as $item ) { | |
| 936 | + | |
| 937 | + $product_type = ''; | |
| 938 | +				if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { | |
| 939 | + $item_id = $item['variation_id']; | |
| 940 | + $product_type = 'variation'; | |
| 941 | +				} else { | |
| 942 | + $item_id = $item['product_id']; | |
| 943 | + } // End If Statement | |
| 944 | + $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); | |
| 945 | + | |
| 946 | + // Get courses that use the WC product | |
| 947 | + $courses = array(); | |
| 948 | + $courses = $this->post_types->course->get_product_courses( $item_id ); | |
| 949 | + | |
| 950 | + // Loop and update those courses | |
| 951 | +				foreach ($courses as $course_item){ | |
| 952 | + // Check and Remove course from courses user meta | |
| 953 | + $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); | |
| 954 | + } // End For Loop | |
| 955 | + } // End For Loop | |
| 956 | + } // End If Statement | |
| 957 | + } // End sensei_woocommerce_cancel_order() | |
| 958 | + | |
| 959 | + /** | |
| 960 | + * Runs when an subscription is cancelled or expires. | |
| 961 | + * @since 1.3.3 | |
| 962 | + * @access public | |
| 963 | + * @param integer $user_id User ID | |
| 964 | + * @param integer $subscription_key Subscription Unique Key | |
| 965 | + * @return void | |
| 966 | + */ | |
| 967 | +	public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { | |
| 968 | + $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); | |
| 969 | + self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); | |
| 970 | + } | |
| 971 | + | |
| 972 | + /** | |
| 973 | + * Runs when an subscription is re-activated after suspension. | |
| 974 | + * @since 1.3.3 | |
| 975 | + * @access public | |
| 976 | + * @param integer $user_id User ID | |
| 977 | + * @param integer $subscription_key Subscription Unique Key | |
| 978 | + * @return void | |
| 979 | + */ | |
| 980 | +	public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { | |
| 981 | + $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); | |
| 982 | + $order = new WC_Order( $subscription['order_id'] ); | |
| 983 | + $user = get_user_by( 'id', $order->get_user_id() ); | |
| 984 | + $order_user = array(); | |
| 985 | + $order_user['ID'] = $user->ID; | |
| 986 | + $order_user['user_login'] = $user->user_login; | |
| 987 | + $order_user['user_email'] = $user->user_email; | |
| 988 | + $order_user['user_url'] = $user->user_url; | |
| 989 | + $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); | |
| 990 | +		foreach ( $courses as $course_item ){ | |
| 991 | + $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); | |
| 992 | + } // End For Loop | |
| 993 | + } // End sensei_woocommerce_reactivate_subscription | |
| 994 | + | |
| 995 | + /** | |
| 996 | + * Returns the WooCommerce Product Object | |
| 997 | + * | |
| 998 | + * The code caters for pre and post WooCommerce 2.2 installations. | |
| 999 | + * | |
| 1000 | + * @since 1.1.1 | |
| 1001 | + * @access public | |
| 1002 | + * @param integer $wc_product_id Product ID or Variation ID | |
| 1003 | + * @param string $product_type '' or 'variation' | |
| 1004 | + * @return WC_Product $wc_product_object | |
| 1005 | + */ | |
| 1006 | +	public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { | |
| 1007 | + | |
| 1008 | + $wc_product_object = false; | |
| 1009 | +		if ( 0 < intval( $wc_product_id ) ) { | |
| 1010 | + | |
| 1011 | + // Get the product | |
| 1012 | +			if ( function_exists( 'wc_get_product' ) ) { | |
| 1013 | + | |
| 1014 | + $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 | |
| 1015 | + | |
| 1016 | +			} elseif ( function_exists( 'get_product' ) ) { | |
| 1017 | + | |
| 1018 | + $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 | |
| 1019 | + | |
| 1020 | +			} else { | |
| 1021 | + | |
| 1022 | + // Pre WC 2.0 | |
| 1023 | +				if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { | |
| 1024 | + | |
| 1025 | + $wc_product_object = new WC_Product_Variation( $wc_product_id ); | |
| 1026 | + | |
| 1027 | +				} else { | |
| 1028 | + | |
| 1029 | + $wc_product_object = new WC_Product( $wc_product_id ); | |
| 1030 | + | |
| 1031 | + } // End If Statement | |
| 1032 | + | |
| 1033 | + } // End If Statement | |
| 1034 | + | |
| 1035 | + } // End If Statement | |
| 1036 | + | |
| 1037 | + return $wc_product_object; | |
| 1038 | + | |
| 1039 | + } // End sensei_get_woocommerce_product_object() | |
| 1040 | + | |
| 1041 | + /** | |
| 1042 | + * load_class loads in class files | |
| 1043 | + * @since 1.2.0 | |
| 1044 | + * @access public | |
| 1045 | + * @return void | |
| 1046 | + */ | |
| 1047 | +	public function load_class ( $class_name = '' ) { | |
| 1048 | +		if ( '' != $class_name && '' != $this->token ) { | |
| 1049 | + require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); | |
| 1050 | + } // End If Statement | |
| 1051 | + } // End load_class() | |
| 1052 | + | |
| 1053 | + /** | |
| 1054 | + * sensei_activate_subscription runs when a subscription product is purchased | |
| 1055 | + * @since 1.2.0 | |
| 1056 | + * @access public | |
| 1057 | + * @param integer $order_id order ID | |
| 1058 | + * @return void | |
| 1059 | + */ | |
| 1060 | +	public function sensei_activate_subscription(  $order_id = 0 ) { | |
| 1061 | +		if ( 0 < intval( $order_id ) ) { | |
| 1062 | + $order = new WC_Order( $order_id ); | |
| 1063 | +			$user = get_user_by('id', $order->user_id); | |
| 1064 | + $order_user['ID'] = $user->ID; | |
| 1065 | + $order_user['user_login'] = $user->user_login; | |
| 1066 | + $order_user['user_email'] = $user->user_email; | |
| 1067 | + $order_user['user_url'] = $user->user_url; | |
| 1068 | + // Run through each product ordered | |
| 1069 | +			if (sizeof($order->get_items())>0) { | |
| 1070 | +				foreach($order->get_items() as $item) { | |
| 1071 | + $product_type = ''; | |
| 1072 | +					if (isset($item['variation_id']) && $item['variation_id'] > 0) { | |
| 1073 | + $item_id = $item['variation_id']; | |
| 1074 | + $product_type = 'subscription_variation'; | |
| 1075 | +					} else { | |
| 1076 | + $item_id = $item['product_id']; | |
| 1077 | + } // End If Statement | |
| 1078 | + $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); | |
| 1079 | + // Get courses that use the WC product | |
| 1080 | + $courses = array(); | |
| 1081 | +					if ( $product_type == 'subscription_variation' ) { | |
| 1082 | + $courses = $this->post_types->course->get_product_courses( $item_id ); | |
| 1083 | + } // End If Statement | |
| 1084 | + // Loop and update those courses | |
| 1085 | +					foreach ($courses as $course_item){ | |
| 1086 | + $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); | |
| 1087 | + } // End For Loop | |
| 1088 | + } // End For Loop | |
| 1089 | + } // End If Statement | |
| 1090 | + } // End If Statement | |
| 1091 | + } // End sensei_activate_subscription() | |
| 1092 | + | |
| 1093 | + /** | |
| 1094 | + * sensei_woocommerce_email_course_details adds detail to email | |
| 1095 | + * @since 1.4.5 | |
| 1096 | + * @access public | |
| 1097 | + * @param WC_Order $order | |
| 1098 | + * @return void | |
| 1099 | + */ | |
| 1100 | +	public function sensei_woocommerce_email_course_details( $order ) { | |
| 1101 | + global $woocommerce; | |
| 1102 | + | |
| 1103 | + // exit early if not wc-completed or wc-processing | |
| 1104 | + if( 'wc-completed' != $order->post_status | |
| 1105 | +			&& 'wc-processing' != $order->post_status  ) { | |
| 1106 | + return; | |
| 1107 | + } | |
| 1108 | + | |
| 1109 | + $order_items = $order->get_items(); | |
| 1110 | + $order_id = $order->id; | |
| 1111 | + | |
| 1112 | + //If object have items go through them all to find course | |
| 1113 | +		if ( 0 < sizeof( $order_items ) ) { | |
| 1114 | + | |
| 1115 | + $course_details_html = '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; | |
| 1116 | + $order_contains_courses = false; | |
| 1117 | + | |
| 1118 | + | |
| 1119 | +			foreach ( $order_items as $item ) { | |
| 1120 | + | |
| 1121 | + $product_type = ''; | |
| 1122 | +				if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { | |
| 1123 | + // If item has variation_id then its from variation | |
| 1124 | + $item_id = $item['variation_id']; | |
| 1125 | + $product_type = 'variation'; | |
| 1126 | +				} else { | |
| 1127 | + // If not its real product set its id to item_id | |
| 1128 | + $item_id = $item['product_id']; | |
| 1129 | + } // End If Statement | |
| 1130 | + | |
| 1131 | + $user_id = get_post_meta( $order_id, '_customer_user', true ); | |
| 1132 | + | |
| 1133 | +				if( $user_id ) { | |
| 1134 | + | |
| 1135 | + // Get all courses for product | |
| 1136 | + $args = array( | |
| 1137 | + 'posts_per_page' => -1, | |
| 1138 | + 'post_type' => 'course', | |
| 1139 | + 'meta_query' => array( | |
| 1140 | + array( | |
| 1141 | + 'key' => '_course_woocommerce_product', | |
| 1142 | + 'value' => $item_id | |
| 1143 | + ) | |
| 1144 | + ), | |
| 1145 | + 'orderby' => 'menu_order date', | |
| 1146 | + 'order' => 'ASC', | |
| 1147 | + ); | |
| 1148 | + $courses = get_posts( $args ); | |
| 1149 | + | |
| 1150 | +					if( $courses && count( $courses ) > 0 ) { | |
| 1151 | + | |
| 1152 | +						foreach( $courses as $course ) { | |
| 1153 | + | |
| 1154 | + $title = $course->post_title; | |
| 1155 | + $permalink = get_permalink( $course->ID ); | |
| 1156 | + $order_contains_courses = true; | |
| 1157 | + $course_details_html .= '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; | |
| 1158 | + } | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + } // end if has courses | |
| 1162 | + | |
| 1163 | + } // end if $userPid | |
| 1164 | + | |
| 1165 | + } // end for each order item | |
| 1166 | + | |
| 1167 | + // Output Course details | |
| 1168 | +			if( $order_contains_courses ){ | |
| 1169 | + | |
| 1170 | + echo $course_details_html; | |
| 1171 | + | |
| 1172 | + } | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + } // end if order items not empty | |
| 1176 | + | |
| 1177 | + } // end func email course details | |
| 1178 | + | |
| 1179 | + /** | |
| 1180 | + * Filtering wp_count_comments to ensure that Sensei comments are ignored | |
| 1181 | + * @since 1.4.0 | |
| 1182 | + * @access public | |
| 1183 | + * @param array $comments | |
| 1184 | + * @param integer $post_id | |
| 1185 | + * @return array | |
| 1186 | + */ | |
| 1187 | +	public function sensei_count_comments( $comments, $post_id ) { | |
| 1188 | + global $wpdb; | |
| 1189 | + | |
| 1190 | + $post_id = (int) $post_id; | |
| 1191 | + | |
| 1192 | +		$count = wp_cache_get("comments-{$post_id}", 'counts'); | |
| 1193 | + | |
| 1194 | +		if ( false !== $count ) { | |
| 1195 | + return $count; | |
| 1196 | + } | |
| 1197 | + | |
| 1198 | + $statuses = array( '' ); // Default to the WP normal comments | |
| 1199 | +		$stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); | |
| 1200 | +		foreach ( (array) $stati AS $status ) { | |
| 1201 | +			if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { | |
| 1202 | + $statuses[] = $status['comment_type']; | |
| 1203 | + } | |
| 1204 | + } | |
| 1205 | +		$where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; | |
| 1206 | + | |
| 1207 | + if ( $post_id > 0 ) | |
| 1208 | + $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); | |
| 1209 | + | |
| 1210 | +		$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); | |
| 1211 | + | |
| 1212 | + $total = 0; | |
| 1213 | +		$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); | |
| 1214 | +		foreach ( (array) $count as $row ) { | |
| 1215 | + // Don't count post-trashed toward totals | |
| 1216 | + if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) | |
| 1217 | + $total += $row['num_comments']; | |
| 1218 | + if ( isset( $approved[$row['comment_approved']] ) ) | |
| 1219 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; | |
| 1220 | + } | |
| 1221 | + | |
| 1222 | + $stats['total_comments'] = $total; | |
| 1223 | +		foreach ( $approved as $key ) { | |
| 1224 | + if ( empty($stats[$key]) ) | |
| 1225 | + $stats[$key] = 0; | |
| 1226 | + } | |
| 1227 | + | |
| 1228 | + $stats = (object) $stats; | |
| 1229 | +		wp_cache_set("comments-{$post_id}", $stats, 'counts'); | |
| 1230 | + | |
| 1231 | + return $stats; | |
| 1232 | + } | |
| 1233 | + | |
| 1234 | + /** | |
| 1235 | + * Init images. | |
| 1236 | + * | |
| 1237 | + * @since 1.4.5 | |
| 1238 | + * @access public | |
| 1239 | + * @return void | |
| 1240 | + */ | |
| 1241 | +	public function init_image_sizes() { | |
| 1242 | + $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); | |
| 1243 | + $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); | |
| 1244 | + $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); | |
| 1245 | + $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); | |
| 1246 | + | |
| 1247 | + add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); | |
| 1248 | + add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); | |
| 1249 | + add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); | |
| 1250 | + add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); | |
| 1251 | + } | |
| 1252 | + | |
| 1253 | + /** | |
| 1254 | + * Get an image size. | |
| 1255 | + * | |
| 1256 | +	 * Variable is filtered by sensei_get_image_size_{image_size} | |
| 1257 | + * | |
| 1258 | + * @since 1.4.5 | |
| 1259 | + * @access public | |
| 1260 | + * @param mixed $image_size | |
| 1261 | + * @return string | |
| 1262 | + */ | |
| 1263 | +	public function get_image_size( $image_size ) { | |
| 1264 | + | |
| 1265 | + // Only return sizes we define in settings | |
| 1266 | + if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) | |
| 1267 | + return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); | |
| 1268 | + | |
| 1269 | +		if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { | |
| 1270 | + $this->settings->settings[ $image_size . '_width' ] = false; | |
| 1271 | + } | |
| 1272 | +		if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { | |
| 1273 | + $this->settings->settings[ $image_size . '_height' ] = false; | |
| 1274 | + } | |
| 1275 | +		if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { | |
| 1276 | + $this->settings->settings[ $image_size . '_hard_crop' ] = false; | |
| 1277 | + } | |
| 1278 | + | |
| 1279 | + $size = array_filter( array( | |
| 1280 | + 'width' => $this->settings->settings[ $image_size . '_width' ], | |
| 1281 | + 'height' => $this->settings->settings[ $image_size . '_height' ], | |
| 1282 | + 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] | |
| 1283 | + ) ); | |
| 1284 | + | |
| 1285 | + $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; | |
| 1286 | + $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; | |
| 1287 | + $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; | |
| 1288 | + | |
| 1289 | + return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); | |
| 1290 | + } | |
| 1291 | + | |
| 1292 | +	public function body_class( $classes ) { | |
| 1293 | +		if( is_sensei() ) { | |
| 1294 | + $classes[] = 'sensei'; | |
| 1295 | + } | |
| 1296 | + return $classes; | |
| 1297 | + } | |
| 1298 | + | |
| 1299 | + /** | |
| 1300 | + * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers | |
| 1301 | + * | |
| 1302 | + * @return null | |
| 1303 | + * @since 1.7.0 | |
| 1304 | + */ | |
| 1305 | +	public function jetpack_latex_support() { | |
| 1306 | +		if ( function_exists( 'latex_markup') ) { | |
| 1307 | + add_filter( 'sensei_question_title', 'latex_markup' ); | |
| 1308 | + add_filter( 'sensei_answer_text', 'latex_markup' ); | |
| 1309 | + } | |
| 1310 | + } | |
| 1311 | + | |
| 1312 | + /** | |
| 1313 | + * Load the module functionality. | |
| 1314 | + * | |
| 1315 | + * This function is hooked into plugins_loaded to avoid conflicts with | |
| 1316 | + * the retired modules extension. | |
| 1317 | + * | |
| 1318 | + * @since 1.8.0 | |
| 1319 | + */ | |
| 1320 | +	public function load_modules_class(){ | |
| 1321 | + global $sensei_modules; | |
| 1322 | + | |
| 1323 | + if( !class_exists( 'Sensei_Modules' ) | |
| 1324 | +			&&  'Sensei_Modules' != get_class( $sensei_modules ) ) { | |
| 1325 | + | |
| 1326 | + //Load the modules class | |
| 1327 | + require_once( 'class-sensei-modules.php'); | |
| 1328 | + Sensei()->modules = new Sensei_Core_Modules( $this->file ); | |
| 1329 | + | |
| 1330 | +		}else{ | |
| 1331 | + // fallback for people still using the modules extension. | |
| 1332 | + global $sensei_modules; | |
| 1333 | + Sensei()->modules = $sensei_modules; | |
| 1334 | + add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); | |
| 1335 | + } | |
| 1336 | + } | |
| 1337 | + | |
| 1338 | + /** | |
| 1339 | + * Tell the user to that the modules extension is no longer needed. | |
| 1340 | + * | |
| 1341 | + * @since 1.8.0 | |
| 1342 | + */ | |
| 1343 | +	public function disable_sensei_modules_extension(){ ?> | |
| 1344 | 1344 | <div class="notice updated fade"> | 
| 1345 | 1345 | <p> | 
| 1346 | 1346 | <?php | 
| 1347 | - $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; | |
| 1348 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; | |
| 1349 | - ?> | |
| 1347 | + $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; | |
| 1348 | + $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; | |
| 1349 | + ?> | |
| 1350 | 1350 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. | 
| 1351 | 1351 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). | 
| 1352 | 1352 | </p> | 
| @@ -1354,46 +1354,46 @@ discard block | ||
| 1354 | 1354 | |
| 1355 | 1355 | <?php }// end function | 
| 1356 | 1356 | |
| 1357 | - /** | |
| 1358 | - * Sensei wide rewrite flush call. | |
| 1359 | - * | |
| 1360 | - * To use this simply update the option 'sensei_flush_rewrite_rules' to 1 | |
| 1361 | - * | |
| 1362 | - * After the option is one the Rules will be flushed. | |
| 1363 | - * | |
| 1364 | - * @since 1.9.0 | |
| 1365 | - */ | |
| 1366 | -    public function flush_rewrite_rules(){ | |
| 1357 | + /** | |
| 1358 | + * Sensei wide rewrite flush call. | |
| 1359 | + * | |
| 1360 | + * To use this simply update the option 'sensei_flush_rewrite_rules' to 1 | |
| 1361 | + * | |
| 1362 | + * After the option is one the Rules will be flushed. | |
| 1363 | + * | |
| 1364 | + * @since 1.9.0 | |
| 1365 | + */ | |
| 1366 | +	public function flush_rewrite_rules(){ | |
| 1367 | 1367 | |
| 1368 | - // ensures that the rewrite rules are flushed on the second | |
| 1369 | - // attempt. This ensure that the settings for any other process | |
| 1370 | - // have been completed and saved to the database before we refresh the | |
| 1371 | - // rewrite rules. | |
| 1372 | -        $option =  get_option('sensei_flush_rewrite_rules'); | |
| 1373 | -        if( '1' == $option ) { | |
| 1368 | + // ensures that the rewrite rules are flushed on the second | |
| 1369 | + // attempt. This ensure that the settings for any other process | |
| 1370 | + // have been completed and saved to the database before we refresh the | |
| 1371 | + // rewrite rules. | |
| 1372 | +		$option =  get_option('sensei_flush_rewrite_rules'); | |
| 1373 | +		if( '1' == $option ) { | |
| 1374 | 1374 | |
| 1375 | -            update_option('sensei_flush_rewrite_rules', '2'); | |
| 1375 | +			update_option('sensei_flush_rewrite_rules', '2'); | |
| 1376 | 1376 | |
| 1377 | -        }elseif( '2' == $option ) { | |
| 1377 | +		}elseif( '2' == $option ) { | |
| 1378 | 1378 | |
| 1379 | - flush_rewrite_rules(); | |
| 1380 | -            update_option('sensei_flush_rewrite_rules', '0'); | |
| 1379 | + flush_rewrite_rules(); | |
| 1380 | +			update_option('sensei_flush_rewrite_rules', '0'); | |
| 1381 | 1381 | |
| 1382 | - } | |
| 1382 | + } | |
| 1383 | 1383 | |
| 1384 | - } // end flush_rewrite_rules | |
| 1384 | + } // end flush_rewrite_rules | |
| 1385 | 1385 | |
| 1386 | - /** | |
| 1387 | - * Calling this function will tell Sensei to flush rewrite | |
| 1388 | - * rules on the next load. | |
| 1389 | - * | |
| 1390 | - * @since 1.9.0 | |
| 1391 | - */ | |
| 1392 | -    public function initiate_rewrite_rules_flush(){ | |
| 1386 | + /** | |
| 1387 | + * Calling this function will tell Sensei to flush rewrite | |
| 1388 | + * rules on the next load. | |
| 1389 | + * | |
| 1390 | + * @since 1.9.0 | |
| 1391 | + */ | |
| 1392 | +	public function initiate_rewrite_rules_flush(){ | |
| 1393 | 1393 | |
| 1394 | -        update_option('sensei_flush_rewrite_rules', '1'); | |
| 1394 | +		update_option('sensei_flush_rewrite_rules', '1'); | |
| 1395 | 1395 | |
| 1396 | - } | |
| 1396 | + } | |
| 1397 | 1397 | |
| 1398 | 1398 | } // End Class | 
| 1399 | 1399 | |
| @@ -25,8 +25,8 @@ discard block | ||
| 25 | 25 | |
| 26 | 26 | /** | 
| 27 | 27 | * Check if WooCommerce is present. | 
| 28 | - * | |
| 29 | - * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present() | |
| 28 | + * | |
| 29 | + * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present() | |
| 30 | 30 | * @access public | 
| 31 | 31 | * @since 1.0.2 | 
| 32 | 32 | * @static | 
| @@ -34,14 +34,14 @@ discard block | ||
| 34 | 34 | */ | 
| 35 | 35 |  	public static function sensei_is_woocommerce_present () { | 
| 36 | 36 | |
| 37 | - return Sensei_WC::is_woocommerce_present(); | |
| 37 | + return Sensei_WC::is_woocommerce_present(); | |
| 38 | 38 | |
| 39 | 39 | } // End sensei_is_woocommerce_present() | 
| 40 | 40 | |
| 41 | 41 | /** | 
| 42 | 42 | * Check if WooCommerce is active. | 
| 43 | - * | |
| 44 | - * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active | |
| 43 | + * | |
| 44 | + * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active | |
| 45 | 45 | * @access public | 
| 46 | 46 | * @since 1.0.2 | 
| 47 | 47 | * @static | 
| @@ -186,15 +186,15 @@ discard block | ||
| 186 | 186 | add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); | 
| 187 | 187 | } | 
| 188 | 188 | |
| 189 | - //Get the comments | |
| 190 | - /** | |
| 191 | - * This filter runs inside Sensei_Utils::sensei_check_for_activity | |
| 192 | - * | |
| 193 | - * It runs while getting the comments for the given request. | |
| 194 | - * | |
| 195 | - * @param int|array $comments | |
| 196 | - */ | |
| 197 | -        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) ); | |
| 189 | + //Get the comments | |
| 190 | + /** | |
| 191 | + * This filter runs inside Sensei_Utils::sensei_check_for_activity | |
| 192 | + * | |
| 193 | + * It runs while getting the comments for the given request. | |
| 194 | + * | |
| 195 | + * @param int|array $comments | |
| 196 | + */ | |
| 197 | +		$comments = apply_filters('sensei_check_for_activity', get_comments( $args ) ); | |
| 198 | 198 | |
| 199 | 199 | remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); | 
| 200 | 200 | remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); | 
| @@ -279,18 +279,18 @@ discard block | ||
| 279 | 279 | return $dataset_changes; | 
| 280 | 280 | } // End sensei_delete_activities() | 
| 281 | 281 | |
| 282 | - /** | |
| 283 | - * Delete all activity for specified user | |
| 284 | - * @access public | |
| 282 | + /** | |
| 283 | + * Delete all activity for specified user | |
| 284 | + * @access public | |
| 285 | 285 | * @since 1.5.0 | 
| 286 | - * @param integer $user_id User ID | |
| 287 | - * @return boolean | |
| 288 | - */ | |
| 289 | -    public static function delete_all_user_activity( $user_id = 0 ) { | |
| 286 | + * @param integer $user_id User ID | |
| 287 | + * @return boolean | |
| 288 | + */ | |
| 289 | +	public static function delete_all_user_activity( $user_id = 0 ) { | |
| 290 | 290 | |
| 291 | - $dataset_changes = false; | |
| 291 | + $dataset_changes = false; | |
| 292 | 292 | |
| 293 | -    	if( $user_id ) { | |
| 293 | +		if( $user_id ) { | |
| 294 | 294 | |
| 295 | 295 | $activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true ); | 
| 296 | 296 | |
| @@ -335,35 +335,35 @@ discard block | ||
| 335 | 335 | return $activity_value; | 
| 336 | 336 | } // End sensei_get_activity_value() | 
| 337 | 337 | |
| 338 | - /** | |
| 339 | - * Checks if a user (by email) has bought an item. | |
| 340 | - * | |
| 341 | - * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id) | |
| 342 | - * @access public | |
| 343 | - * @since 1.0.0 | |
| 344 | - * @param string $customer_email | |
| 345 | - * @param int $user_id | |
| 346 | - * @param int $product_id | |
| 347 | - * @return bool | |
| 348 | - */ | |
| 349 | -    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) { | |
| 338 | + /** | |
| 339 | + * Checks if a user (by email) has bought an item. | |
| 340 | + * | |
| 341 | + * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id) | |
| 342 | + * @access public | |
| 343 | + * @since 1.0.0 | |
| 344 | + * @param string $customer_email | |
| 345 | + * @param int $user_id | |
| 346 | + * @param int $product_id | |
| 347 | + * @return bool | |
| 348 | + */ | |
| 349 | +	public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) { | |
| 350 | 350 | |
| 351 | - $emails = array(); | |
| 351 | + $emails = array(); | |
| 352 | 352 | |
| 353 | -        if ( $user_id ) { | |
| 354 | - $user = get_user_by( 'id', intval( $user_id ) ); | |
| 355 | - $emails[] = $user->user_email; | |
| 356 | - } | |
| 353 | +		if ( $user_id ) { | |
| 354 | + $user = get_user_by( 'id', intval( $user_id ) ); | |
| 355 | + $emails[] = $user->user_email; | |
| 356 | + } | |
| 357 | 357 | |
| 358 | - if ( is_email( $customer_email ) ) | |
| 359 | - $emails[] = $customer_email; | |
| 358 | + if ( is_email( $customer_email ) ) | |
| 359 | + $emails[] = $customer_email; | |
| 360 | 360 | |
| 361 | - if ( sizeof( $emails ) == 0 ) | |
| 362 | - return false; | |
| 361 | + if ( sizeof( $emails ) == 0 ) | |
| 362 | + return false; | |
| 363 | 363 | |
| 364 | - return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); | |
| 364 | + return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); | |
| 365 | 365 | |
| 366 | - } // End sensei_customer_bought_product() | |
| 366 | + } // End sensei_customer_bought_product() | |
| 367 | 367 | |
| 368 | 368 | /** | 
| 369 | 369 | * Load the WordPress rich text editor | 
| @@ -399,7 +399,7 @@ discard block | ||
| 399 | 399 | /** | 
| 400 | 400 | * Save quiz answers submitted by users | 
| 401 | 401 | * @param array $submitted User's quiz answers | 
| 402 | - * @param int $user_id | |
| 402 | + * @param int $user_id | |
| 403 | 403 | * @return boolean Whether the answers were saved or not | 
| 404 | 404 | */ | 
| 405 | 405 |  	public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) { | 
| @@ -468,72 +468,72 @@ discard block | ||
| 468 | 468 | |
| 469 | 469 | require_once( ABSPATH . 'wp-admin/includes/admin.php' ); | 
| 470 | 470 | |
| 471 | - /** | |
| 472 | - * Filter the data array for the Sensei wp_handle_upload function call | |
| 473 | - * | |
| 474 | - * This filter was mainly added for Unit Testing purposes. | |
| 475 | - * | |
| 476 | - * @since 1.7.4 | |
| 477 | - * | |
| 478 | -         * @param array  $file_upload_args { | |
| 479 | - * array of current values | |
| 480 | - * | |
| 481 | - * @type string test_form set to false by default | |
| 482 | - * } | |
| 483 | - */ | |
| 484 | -        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) ); | |
| 485 | - | |
| 486 | - $file_return = wp_handle_upload( $file, $file_upload_args ); | |
| 487 | - | |
| 488 | -        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { | |
| 489 | - return false; | |
| 490 | -        } else { | |
| 471 | + /** | |
| 472 | + * Filter the data array for the Sensei wp_handle_upload function call | |
| 473 | + * | |
| 474 | + * This filter was mainly added for Unit Testing purposes. | |
| 475 | + * | |
| 476 | + * @since 1.7.4 | |
| 477 | + * | |
| 478 | +		 * @param array  $file_upload_args { | |
| 479 | + * array of current values | |
| 480 | + * | |
| 481 | + * @type string test_form set to false by default | |
| 482 | + * } | |
| 483 | + */ | |
| 484 | +		$file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) ); | |
| 485 | + | |
| 486 | + $file_return = wp_handle_upload( $file, $file_upload_args ); | |
| 487 | + | |
| 488 | +		if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { | |
| 489 | + return false; | |
| 490 | +		} else { | |
| 491 | 491 | |
| 492 | - $filename = $file_return['file']; | |
| 492 | + $filename = $file_return['file']; | |
| 493 | 493 | |
| 494 | - $attachment = array( | |
| 495 | - 'post_mime_type' => $file_return['type'], | |
| 496 | - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), | |
| 497 | - 'post_content' => '', | |
| 498 | - 'post_status' => 'inherit', | |
| 499 | - 'guid' => $file_return['url'] | |
| 500 | - ); | |
| 494 | + $attachment = array( | |
| 495 | + 'post_mime_type' => $file_return['type'], | |
| 496 | + 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), | |
| 497 | + 'post_content' => '', | |
| 498 | + 'post_status' => 'inherit', | |
| 499 | + 'guid' => $file_return['url'] | |
| 500 | + ); | |
| 501 | 501 | |
| 502 | - $attachment_id = wp_insert_attachment( $attachment, $filename ); | |
| 502 | + $attachment_id = wp_insert_attachment( $attachment, $filename ); | |
| 503 | 503 | |
| 504 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); | |
| 505 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); | |
| 506 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); | |
| 504 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); | |
| 505 | + $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); | |
| 506 | + wp_update_attachment_metadata( $attachment_id, $attachment_data ); | |
| 507 | 507 | |
| 508 | -            if( 0 < intval( $attachment_id ) ) { | |
| 509 | - return $attachment_id; | |
| 510 | - } | |
| 511 | - } | |
| 508 | +			if( 0 < intval( $attachment_id ) ) { | |
| 509 | + return $attachment_id; | |
| 510 | + } | |
| 511 | + } | |
| 512 | 512 | |
| 513 | - return false; | |
| 513 | + return false; | |
| 514 | 514 | } | 
| 515 | 515 | |
| 516 | 516 | /** | 
| 517 | 517 | * Grade quiz automatically | 
| 518 | - * | |
| 519 | - * This function grades each question automatically if the are auto gradable. | |
| 520 | - * It store all question grades. | |
| 521 | - * | |
| 522 | - * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead | |
| 523 | - * | |
| 518 | + * | |
| 519 | + * This function grades each question automatically if the are auto gradable. | |
| 520 | + * It store all question grades. | |
| 521 | + * | |
| 522 | + * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead | |
| 523 | + * | |
| 524 | 524 | * @param integer $quiz_id ID of quiz | 
| 525 | 525 |  	 * @param  array $submitted questions id ans answers { | 
| 526 | - * @type int $question_id | |
| 527 | - * @type mixed $answer | |
| 528 | - * } | |
| 526 | + * @type int $question_id | |
| 527 | + * @type mixed $answer | |
| 528 | + * } | |
| 529 | 529 | * @param integer $total_questions Total questions in quiz (not used) | 
| 530 | - * @param string $quiz_grade_type Optional defaults to auto | |
| 531 | - * | |
| 530 | + * @param string $quiz_grade_type Optional defaults to auto | |
| 531 | + * | |
| 532 | 532 | * @return int $quiz_grade total sum of all question grades | 
| 533 | 533 | */ | 
| 534 | 534 |  	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) { | 
| 535 | 535 | |
| 536 | - return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type ); | |
| 536 | + return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type ); | |
| 537 | 537 | |
| 538 | 538 | } // End sensei_grade_quiz_auto() | 
| 539 | 539 | |
| @@ -542,7 +542,7 @@ discard block | ||
| 542 | 542 | * @param integer $quiz_id ID of quiz | 
| 543 | 543 | * @param integer $grade Grade received | 
| 544 | 544 | * @param integer $user_id ID of user being graded | 
| 545 | - * @param string $quiz_grade_type default 'auto' | |
| 545 | + * @param string $quiz_grade_type default 'auto' | |
| 546 | 546 | * @return boolean | 
| 547 | 547 | */ | 
| 548 | 548 |  	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) { | 
| @@ -566,21 +566,21 @@ discard block | ||
| 566 | 566 | |
| 567 | 567 | /** | 
| 568 | 568 | * Grade question automatically | 
| 569 | - * | |
| 570 | - * This function checks the question typ and then grades it accordingly. | |
| 571 | - * | |
| 572 | - * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead | |
| 573 | - * | |
| 569 | + * | |
| 570 | + * This function checks the question typ and then grades it accordingly. | |
| 571 | + * | |
| 572 | + * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead | |
| 573 | + * | |
| 574 | 574 | * @param integer $question_id | 
| 575 | - * @param string $question_type of the standard Sensei question types | |
| 575 | + * @param string $question_type of the standard Sensei question types | |
| 576 | 576 | * @param string $answer | 
| 577 | - * @param int $user_id | |
| 578 | - * | |
| 577 | + * @param int $user_id | |
| 578 | + * | |
| 579 | 579 | * @return int $question_grade | 
| 580 | 580 | */ | 
| 581 | 581 |  	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) { | 
| 582 | 582 | |
| 583 | - return WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id ); | |
| 583 | + return WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id ); | |
| 584 | 584 | |
| 585 | 585 | } // end sensei_grade_question_auto | 
| 586 | 586 | |
| @@ -588,7 +588,7 @@ discard block | ||
| 588 | 588 | * Grade question | 
| 589 | 589 | * @param integer $question_id ID of question | 
| 590 | 590 | * @param integer $grade Grade received | 
| 591 | - * @param int $user_id | |
| 591 | + * @param int $user_id | |
| 592 | 592 | * @return boolean | 
| 593 | 593 | */ | 
| 594 | 594 |  	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) { | 
| @@ -627,35 +627,35 @@ discard block | ||
| 627 | 627 | } | 
| 628 | 628 | |
| 629 | 629 | |
| 630 | - /** | |
| 631 | - * Alias to Woothemes_Sensei_Utils::sensei_start_lesson | |
| 632 | - * | |
| 633 | - * @since 1.7.4 | |
| 634 | - * | |
| 635 | - * @param integer $user_id | |
| 636 | - * @param integer $lesson_id | |
| 637 | - * @param bool $complete | |
| 638 | - * | |
| 639 | - * @return mixed boolean or comment_ID | |
| 640 | - */ | |
| 641 | -    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) { | |
| 630 | + /** | |
| 631 | + * Alias to Woothemes_Sensei_Utils::sensei_start_lesson | |
| 632 | + * | |
| 633 | + * @since 1.7.4 | |
| 634 | + * | |
| 635 | + * @param integer $user_id | |
| 636 | + * @param integer $lesson_id | |
| 637 | + * @param bool $complete | |
| 638 | + * | |
| 639 | + * @return mixed boolean or comment_ID | |
| 640 | + */ | |
| 641 | +	public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) { | |
| 642 | 642 | |
| 643 | - return self::sensei_start_lesson( $lesson_id, $user_id, $complete ); | |
| 643 | + return self::sensei_start_lesson( $lesson_id, $user_id, $complete ); | |
| 644 | 644 | |
| 645 | - }// end user_start_lesson() | |
| 645 | + }// end user_start_lesson() | |
| 646 | 646 | |
| 647 | 647 | /** | 
| 648 | 648 | * Mark a lesson as started for user | 
| 649 | - * | |
| 650 | - * Will also start the lesson course for the user if the user hans't started taking it already. | |
| 651 | - * | |
| 652 | - * @since 1.6.0 | |
| 653 | - * | |
| 649 | + * | |
| 650 | + * Will also start the lesson course for the user if the user hans't started taking it already. | |
| 651 | + * | |
| 652 | + * @since 1.6.0 | |
| 653 | + * | |
| 654 | 654 | * @param integer $lesson_id ID of lesson | 
| 655 | 655 | * @param int| string $user_id default 0 | 
| 656 | - * @param bool $complete default false | |
| 657 | - * | |
| 658 | - * @return mixed boolean or comment_ID | |
| 656 | + * @param bool $complete default false | |
| 657 | + * | |
| 658 | + * @return mixed boolean or comment_ID | |
| 659 | 659 | */ | 
| 660 | 660 |  	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) { | 
| 661 | 661 | |
| @@ -701,21 +701,21 @@ discard block | ||
| 701 | 701 |  				$metadata['start'] = current_time('mysql'); | 
| 702 | 702 | $activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata ); | 
| 703 | 703 | |
| 704 | -            } else { | |
| 704 | +			} else { | |
| 705 | 705 | |
| 706 | - // if users is already taking the lesson and the status changes to complete update it | |
| 707 | - $current_user_activity = get_comment($activity_logged); | |
| 708 | - if( $status=='complete' && | |
| 709 | -                    $status != $current_user_activity->comment_approved  ){ | |
| 706 | + // if users is already taking the lesson and the status changes to complete update it | |
| 707 | + $current_user_activity = get_comment($activity_logged); | |
| 708 | + if( $status=='complete' && | |
| 709 | +					$status != $current_user_activity->comment_approved  ){ | |
| 710 | 710 | |
| 711 | - $comment = array(); | |
| 712 | - $comment['comment_ID'] = $activity_logged; | |
| 713 | - $comment['comment_approved'] = $status; | |
| 714 | - wp_update_comment( $comment ); | |
| 711 | + $comment = array(); | |
| 712 | + $comment['comment_ID'] = $activity_logged; | |
| 713 | + $comment['comment_approved'] = $status; | |
| 714 | + wp_update_comment( $comment ); | |
| 715 | 715 | |
| 716 | - } | |
| 716 | + } | |
| 717 | 717 | |
| 718 | - } | |
| 718 | + } | |
| 719 | 719 | |
| 720 | 720 |  			if ( $complete ) { | 
| 721 | 721 | // Run this *after* the lesson status has been created/updated | 
| @@ -861,7 +861,7 @@ discard block | ||
| 861 | 861 | /** | 
| 862 | 862 | * Returns the answer_notes for a specific question and user, or sensei_user_answer entry | 
| 863 | 863 | * | 
| 864 | - * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead | |
| 864 | + * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead | |
| 865 | 865 | * @param mixed $question | 
| 866 | 866 | * @param int $user_id | 
| 867 | 867 | * @return string | 
| @@ -921,7 +921,7 @@ discard block | ||
| 921 | 921 | * Add answer notes to question | 
| 922 | 922 | * @param integer $question_id ID of question | 
| 923 | 923 | * @param integer $user_id ID of user | 
| 924 | - * @param string $notes | |
| 924 | + * @param string $notes | |
| 925 | 925 | * @return boolean | 
| 926 | 926 | */ | 
| 927 | 927 |  	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) { | 
| @@ -979,17 +979,17 @@ discard block | ||
| 979 | 979 | * @return void | 
| 980 | 980 | */ | 
| 981 | 981 |  	public static function sort_array_by_key( $array, $key ) { | 
| 982 | - $sorter = array(); | |
| 983 | - $ret = array(); | |
| 984 | - reset( $array ); | |
| 985 | -	    foreach ( $array as $ii => $va ) { | |
| 986 | - $sorter[$ii] = $va[$key]; | |
| 987 | - } // End For Loop | |
| 988 | - asort( $sorter ); | |
| 989 | -	    foreach ( $sorter as $ii => $va ) { | |
| 990 | - $ret[$ii] = $array[$ii]; | |
| 991 | - } // End For Loop | |
| 992 | - $array = $ret; | |
| 982 | + $sorter = array(); | |
| 983 | + $ret = array(); | |
| 984 | + reset( $array ); | |
| 985 | +		foreach ( $array as $ii => $va ) { | |
| 986 | + $sorter[$ii] = $va[$key]; | |
| 987 | + } // End For Loop | |
| 988 | + asort( $sorter ); | |
| 989 | +		foreach ( $sorter as $ii => $va ) { | |
| 990 | + $ret[$ii] = $array[$ii]; | |
| 991 | + } // End For Loop | |
| 992 | + $array = $ret; | |
| 993 | 993 | } // End sort_array_by_key() | 
| 994 | 994 | |
| 995 | 995 | /** | 
| @@ -1002,21 +1002,21 @@ discard block | ||
| 1002 | 1002 | $questions_array = array(); | 
| 1003 | 1003 |  		if ( 0 < $quiz_id ) { | 
| 1004 | 1004 | $question_args = array( 'post_type' => 'question', | 
| 1005 | - 'posts_per_page' => -1, | |
| 1006 | - 'orderby' => 'ID', | |
| 1007 | - 'order' => 'ASC', | |
| 1008 | - 'meta_query' => array( | |
| 1005 | + 'posts_per_page' => -1, | |
| 1006 | + 'orderby' => 'ID', | |
| 1007 | + 'order' => 'ASC', | |
| 1008 | + 'meta_query' => array( | |
| 1009 | 1009 | array( | 
| 1010 | 1010 | 'key' => '_quiz_id', | 
| 1011 | 1011 | 'value' => $quiz_id, | 
| 1012 | 1012 | ) | 
| 1013 | 1013 | ), | 
| 1014 | - 'post_status' => 'any', | |
| 1015 | - 'suppress_filters' => 0 | |
| 1016 | - ); | |
| 1017 | - $questions_array = get_posts( $question_args ); | |
| 1018 | - } // End If Statement | |
| 1019 | - return $questions_array; | |
| 1014 | + 'post_status' => 'any', | |
| 1015 | + 'suppress_filters' => 0 | |
| 1016 | + ); | |
| 1017 | + $questions_array = get_posts( $question_args ); | |
| 1018 | + } // End If Statement | |
| 1019 | + return $questions_array; | |
| 1020 | 1020 | } // End lesson_quiz_questions() | 
| 1021 | 1021 | |
| 1022 | 1022 | /** | 
| @@ -1174,7 +1174,7 @@ discard block | ||
| 1174 | 1174 | * Set the status message displayed to the user for a quiz | 
| 1175 | 1175 | * @param integer $lesson_id ID of quiz lesson | 
| 1176 | 1176 | * @param integer $user_id ID of user | 
| 1177 | - * @param bool $is_lesson | |
| 1177 | + * @param bool $is_lesson | |
| 1178 | 1178 | * @return array Status code and message | 
| 1179 | 1179 | */ | 
| 1180 | 1180 |  	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) { | 
| @@ -1257,20 +1257,20 @@ discard block | ||
| 1257 | 1257 | } | 
| 1258 | 1258 | } | 
| 1259 | 1259 | |
| 1260 | - // add next lesson button | |
| 1261 | - $nav_id_array = sensei_get_prev_next_lessons( $lesson_id ); | |
| 1262 | - $next_lesson_id = absint( $nav_id_array['next_lesson'] ); | |
| 1260 | + // add next lesson button | |
| 1261 | + $nav_id_array = sensei_get_prev_next_lessons( $lesson_id ); | |
| 1262 | + $next_lesson_id = absint( $nav_id_array['next_lesson'] ); | |
| 1263 | 1263 | |
| 1264 | - // Output HTML | |
| 1265 | -                if ( ( 0 < $next_lesson_id ) ) { | |
| 1266 | - $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) ) | |
| 1267 | - . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei') | |
| 1268 | - .'</a>'; | |
| 1264 | + // Output HTML | |
| 1265 | +				if ( ( 0 < $next_lesson_id ) ) { | |
| 1266 | + $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) ) | |
| 1267 | + . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei') | |
| 1268 | + .'</a>'; | |
| 1269 | 1269 | |
| 1270 | - } | |
| 1270 | + } | |
| 1271 | 1271 | |
| 1272 | 1272 | } | 
| 1273 | - // Lesson/Quiz not complete | |
| 1273 | + // Lesson/Quiz not complete | |
| 1274 | 1274 |  			else { | 
| 1275 | 1275 | // Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete) | 
| 1276 | 1276 |  				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) { | 
| @@ -1310,7 +1310,7 @@ discard block | ||
| 1310 | 1310 | $message = apply_filters( 'sensei_user_quiz_status_' . $status, $message ); | 
| 1311 | 1311 | |
| 1312 | 1312 |  		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) { | 
| 1313 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); | |
| 1313 | + $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); | |
| 1314 | 1314 | $extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '</a></p>'; | 
| 1315 | 1315 | } | 
| 1316 | 1316 | |
| @@ -1368,9 +1368,9 @@ discard block | ||
| 1368 | 1368 | $user_id = get_current_user_id(); | 
| 1369 | 1369 | } | 
| 1370 | 1370 | |
| 1371 | -            if( ! $user_id > 0 ){ | |
| 1372 | - return false; | |
| 1373 | - } | |
| 1371 | +			if( ! $user_id > 0 ){ | |
| 1372 | + return false; | |
| 1373 | + } | |
| 1374 | 1374 | |
| 1375 | 1375 | $user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) ); | 
| 1376 | 1376 |  			if( $user_course_status_id ) { | 
| @@ -1494,7 +1494,7 @@ discard block | ||
| 1494 | 1494 | * Check if a user has completed a course or not | 
| 1495 | 1495 | * | 
| 1496 | 1496 | * @param int | WP_Post | WP_Comment $course course_id or sensei_course_status entry | 
| 1497 | - * | |
| 1497 | + * | |
| 1498 | 1498 | * @param int $user_id | 
| 1499 | 1499 | * @return boolean | 
| 1500 | 1500 | */ | 
| @@ -1512,14 +1512,14 @@ discard block | ||
| 1512 | 1512 | $user_id = get_current_user_id(); | 
| 1513 | 1513 | } | 
| 1514 | 1514 | |
| 1515 | -                if( is_a( $course, 'WP_Post' ) ){ | |
| 1516 | - $course = $course->ID; | |
| 1517 | - } | |
| 1515 | +				if( is_a( $course, 'WP_Post' ) ){ | |
| 1516 | + $course = $course->ID; | |
| 1517 | + } | |
| 1518 | 1518 | |
| 1519 | 1519 | $user_course_status = Sensei_Utils::user_course_status( $course , $user_id ); | 
| 1520 | 1520 |  				if( isset( $user_course_status->comment_approved ) ){ | 
| 1521 | - $user_course_status = $user_course_status->comment_approved; | |
| 1522 | - } | |
| 1521 | + $user_course_status = $user_course_status->comment_approved; | |
| 1522 | + } | |
| 1523 | 1523 | |
| 1524 | 1524 | } | 
| 1525 | 1525 |  			if( $user_course_status && 'complete' == $user_course_status ) { | 
| @@ -1544,11 +1544,11 @@ discard block | ||
| 1544 | 1544 | $user_id = get_current_user_id(); | 
| 1545 | 1545 | } | 
| 1546 | 1546 | |
| 1547 | - $activity_args = array( | |
| 1548 | - 'post_id' => $lesson_id, | |
| 1549 | - 'user_id' => $user_id, | |
| 1550 | - 'type' => 'sensei_lesson_status', | |
| 1551 | - 'field' => 'comment_ID' ); | |
| 1547 | + $activity_args = array( | |
| 1548 | + 'post_id' => $lesson_id, | |
| 1549 | + 'user_id' => $user_id, | |
| 1550 | + 'type' => 'sensei_lesson_status', | |
| 1551 | + 'field' => 'comment_ID' ); | |
| 1552 | 1552 | |
| 1553 | 1553 | $user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args ); | 
| 1554 | 1554 |  			if( $user_lesson_status_id ) { | 
| @@ -1561,7 +1561,7 @@ discard block | ||
| 1561 | 1561 | /** | 
| 1562 | 1562 | * Check if a user has completed a lesson or not | 
| 1563 | 1563 | * | 
| 1564 | - * @uses Sensei() | |
| 1564 | + * @uses Sensei() | |
| 1565 | 1565 | * @param mixed $lesson lesson_id or sensei_lesson_status entry | 
| 1566 | 1566 | * @param int $user_id | 
| 1567 | 1567 | * @return boolean | 
| @@ -1582,10 +1582,10 @@ discard block | ||
| 1582 | 1582 | $user_id = get_current_user_id(); | 
| 1583 | 1583 | } | 
| 1584 | 1584 | |
| 1585 | - // the user is not logged in | |
| 1586 | -                if( ! $user_id > 0 ){ | |
| 1587 | - return false; | |
| 1588 | - } | |
| 1585 | + // the user is not logged in | |
| 1586 | +				if( ! $user_id > 0 ){ | |
| 1587 | + return false; | |
| 1588 | + } | |
| 1589 | 1589 | $_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id ); | 
| 1590 | 1590 | |
| 1591 | 1591 |  				if ( $_user_lesson_status ) { | 
| @@ -1664,9 +1664,9 @@ discard block | ||
| 1664 | 1664 | */ | 
| 1665 | 1665 |  	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) { | 
| 1666 | 1666 | |
| 1667 | -        if( ! $user_id ) { | |
| 1668 | - $user_id = get_current_user_id(); | |
| 1669 | - } | |
| 1667 | +		if( ! $user_id ) { | |
| 1668 | + $user_id = get_current_user_id(); | |
| 1669 | + } | |
| 1670 | 1670 | |
| 1671 | 1671 |  		if( $lesson_id > 0 && $user_id > 0 ) { | 
| 1672 | 1672 | |
| @@ -1717,12 +1717,12 @@ discard block | ||
| 1717 | 1717 | * Sets the status for the lesson | 
| 1718 | 1718 | * | 
| 1719 | 1719 | * @since 1.7.0 | 
| 1720 | - * | |
| 1720 | + * | |
| 1721 | 1721 | * @param int|string $user_id | 
| 1722 | 1722 | * @param int|string $lesson_id | 
| 1723 | 1723 | * @param string $status | 
| 1724 | 1724 | * @param array $metadata | 
| 1725 | - * | |
| 1725 | + * | |
| 1726 | 1726 | * @return mixed false or comment_ID | 
| 1727 | 1727 | */ | 
| 1728 | 1728 |  	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) { | 
| @@ -1838,7 +1838,7 @@ discard block | ||
| 1838 | 1838 | /** | 
| 1839 | 1839 | * Adjust the comment query to be faster on the database, used by Analysis admin | 
| 1840 | 1840 | * @since 1.7.0 | 
| 1841 | - * @param array $pieces | |
| 1841 | + * @param array $pieces | |
| 1842 | 1842 | * @return array $pieces | 
| 1843 | 1843 | */ | 
| 1844 | 1844 |  	public static function comment_total_sum_meta_value_filter( $pieces ) { | 
| @@ -1873,360 +1873,360 @@ discard block | ||
| 1873 | 1873 | return $pieces; | 
| 1874 | 1874 | } | 
| 1875 | 1875 | |
| 1876 | - /** | |
| 1877 | - * | |
| 1878 | - * Alias to Woothemes_Sensei_Utils::update_user_data | |
| 1879 | - * @since 1.7.4 | |
| 1880 | - * | |
| 1881 | - * @param string $data_key maximum 39 characters allowed | |
| 1882 | - * @param int $post_id | |
| 1883 | - * @param mixed $value | |
| 1884 | - * @param int $user_id | |
| 1885 | - * | |
| 1886 | - * @return bool $success | |
| 1887 | - */ | |
| 1888 | -    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){ | |
| 1889 | - | |
| 1890 | - return self::update_user_data( $data_key, $post_id, $value , $user_id ); | |
| 1891 | - | |
| 1892 | - }// end add_user_data | |
| 1893 | - | |
| 1894 | - /** | |
| 1895 | - * add user specific data to the passed in sensei post type id | |
| 1896 | - * | |
| 1897 | - * This function saves comment meta on the users current status. If no status is available | |
| 1898 | - * status will be created. It only operates on the available sensei Post types: course, lesson, quiz. | |
| 1899 | - * | |
| 1900 | - * @since 1.7.4 | |
| 1901 | - * | |
| 1902 | - * @param string $data_key maximum 39 characters allowed | |
| 1903 | - * @param int $post_id | |
| 1904 | - * @param mixed $value | |
| 1905 | - * @param int $user_id | |
| 1906 | - * | |
| 1907 | - * @return bool $success | |
| 1908 | - */ | |
| 1909 | -    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){ | |
| 1910 | - | |
| 1911 | -        if( ! ( $user_id > 0 ) ){ | |
| 1912 | - $user_id = get_current_user_id(); | |
| 1913 | - } | |
| 1914 | - | |
| 1915 | - $supported_post_types = array( 'course', 'lesson' ); | |
| 1916 | - $post_type = get_post_type( $post_id ); | |
| 1917 | - if( empty( $post_id ) || empty( $data_key ) | |
| 1918 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 1919 | - || !get_userdata( $user_id ) | |
| 1920 | -            || ! in_array( $post_type, $supported_post_types )  ){ | |
| 1921 | - | |
| 1922 | - return false; | |
| 1923 | - } | |
| 1924 | - | |
| 1925 | - // check if there and existing Sensei status on this post type if not create it | |
| 1926 | - // and get the activity ID | |
| 1927 | - $status_function = 'user_'.$post_type.'_status'; | |
| 1928 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 1929 | -        if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 1930 | - | |
| 1931 | - $start_function = 'user_start_'.$post_type; | |
| 1932 | - $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); | |
| 1933 | - | |
| 1934 | -        }else{ | |
| 1935 | - | |
| 1936 | - $sensei_user_activity_id = $sensei_user_status->comment_ID; | |
| 1937 | - | |
| 1938 | - } | |
| 1939 | - | |
| 1940 | - // store the data | |
| 1941 | - $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value ); | |
| 1942 | - | |
| 1943 | - return $success; | |
| 1944 | - | |
| 1945 | - }//update_user_data | |
| 1946 | - | |
| 1947 | - /** | |
| 1948 | - * Get the user data stored on the passed in post type | |
| 1949 | - * | |
| 1950 | - * This function gets the comment meta on the lesson or course status | |
| 1951 | - * | |
| 1952 | - * @since 1.7.4 | |
| 1953 | - * | |
| 1954 | - * @param $data_key | |
| 1955 | - * @param $post_id | |
| 1956 | - * @param int $user_id | |
| 1957 | - * | |
| 1958 | - * @return mixed $user_data_value | |
| 1959 | - */ | |
| 1960 | -    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){ | |
| 1961 | - | |
| 1962 | - $user_data_value = true; | |
| 1963 | - | |
| 1964 | -        if( ! ( $user_id > 0 ) ){ | |
| 1965 | - $user_id = get_current_user_id(); | |
| 1966 | - } | |
| 1967 | - | |
| 1968 | - $supported_post_types = array( 'course', 'lesson' ); | |
| 1969 | - $post_type = get_post_type( $post_id ); | |
| 1970 | - if( empty( $post_id ) || empty( $data_key ) | |
| 1971 | - || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 1972 | - || ! get_userdata( $user_id ) | |
| 1973 | -            || !in_array( $post_type, $supported_post_types )  ){ | |
| 1974 | - | |
| 1975 | - return false; | |
| 1976 | - } | |
| 1977 | - | |
| 1978 | - // check if there and existing Sensei status on this post type if not create it | |
| 1979 | - // and get the activity ID | |
| 1980 | - $status_function = 'user_'.$post_type.'_status'; | |
| 1981 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 1982 | -        if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 1983 | - return false; | |
| 1984 | - } | |
| 1985 | - | |
| 1986 | - $sensei_user_activity_id = $sensei_user_status->comment_ID; | |
| 1987 | - $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true ); | |
| 1988 | - | |
| 1989 | - return $user_data_value; | |
| 1990 | - | |
| 1991 | - }// end get_user_data | |
| 1992 | - | |
| 1993 | - /** | |
| 1994 | - * Delete the Sensei user data for the given key, Sensei post type and user combination. | |
| 1995 | - * | |
| 1996 | - * @param int $data_key | |
| 1997 | - * @param int $post_id | |
| 1998 | - * @param int $user_id | |
| 1999 | - * | |
| 2000 | - * @return bool $deleted | |
| 2001 | - */ | |
| 2002 | -    public static function delete_user_data( $data_key, $post_id , $user_id ){ | |
| 2003 | - $deleted = true; | |
| 1876 | + /** | |
| 1877 | + * | |
| 1878 | + * Alias to Woothemes_Sensei_Utils::update_user_data | |
| 1879 | + * @since 1.7.4 | |
| 1880 | + * | |
| 1881 | + * @param string $data_key maximum 39 characters allowed | |
| 1882 | + * @param int $post_id | |
| 1883 | + * @param mixed $value | |
| 1884 | + * @param int $user_id | |
| 1885 | + * | |
| 1886 | + * @return bool $success | |
| 1887 | + */ | |
| 1888 | +	public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){ | |
| 1889 | + | |
| 1890 | + return self::update_user_data( $data_key, $post_id, $value , $user_id ); | |
| 1891 | + | |
| 1892 | + }// end add_user_data | |
| 1893 | + | |
| 1894 | + /** | |
| 1895 | + * add user specific data to the passed in sensei post type id | |
| 1896 | + * | |
| 1897 | + * This function saves comment meta on the users current status. If no status is available | |
| 1898 | + * status will be created. It only operates on the available sensei Post types: course, lesson, quiz. | |
| 1899 | + * | |
| 1900 | + * @since 1.7.4 | |
| 1901 | + * | |
| 1902 | + * @param string $data_key maximum 39 characters allowed | |
| 1903 | + * @param int $post_id | |
| 1904 | + * @param mixed $value | |
| 1905 | + * @param int $user_id | |
| 1906 | + * | |
| 1907 | + * @return bool $success | |
| 1908 | + */ | |
| 1909 | +	public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){ | |
| 1910 | + | |
| 1911 | +		if( ! ( $user_id > 0 ) ){ | |
| 1912 | + $user_id = get_current_user_id(); | |
| 1913 | + } | |
| 1914 | + | |
| 1915 | + $supported_post_types = array( 'course', 'lesson' ); | |
| 1916 | + $post_type = get_post_type( $post_id ); | |
| 1917 | + if( empty( $post_id ) || empty( $data_key ) | |
| 1918 | + || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 1919 | + || !get_userdata( $user_id ) | |
| 1920 | +			|| ! in_array( $post_type, $supported_post_types )  ){ | |
| 1921 | + | |
| 1922 | + return false; | |
| 1923 | + } | |
| 1924 | + | |
| 1925 | + // check if there and existing Sensei status on this post type if not create it | |
| 1926 | + // and get the activity ID | |
| 1927 | + $status_function = 'user_'.$post_type.'_status'; | |
| 1928 | + $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 1929 | +		if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 1930 | + | |
| 1931 | + $start_function = 'user_start_'.$post_type; | |
| 1932 | + $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); | |
| 1933 | + | |
| 1934 | +		}else{ | |
| 1935 | + | |
| 1936 | + $sensei_user_activity_id = $sensei_user_status->comment_ID; | |
| 1937 | + | |
| 1938 | + } | |
| 1939 | + | |
| 1940 | + // store the data | |
| 1941 | + $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value ); | |
| 1942 | + | |
| 1943 | + return $success; | |
| 1944 | + | |
| 1945 | + }//update_user_data | |
| 1946 | + | |
| 1947 | + /** | |
| 1948 | + * Get the user data stored on the passed in post type | |
| 1949 | + * | |
| 1950 | + * This function gets the comment meta on the lesson or course status | |
| 1951 | + * | |
| 1952 | + * @since 1.7.4 | |
| 1953 | + * | |
| 1954 | + * @param $data_key | |
| 1955 | + * @param $post_id | |
| 1956 | + * @param int $user_id | |
| 1957 | + * | |
| 1958 | + * @return mixed $user_data_value | |
| 1959 | + */ | |
| 1960 | +	public static function get_user_data( $data_key, $post_id, $user_id = 0  ){ | |
| 1961 | + | |
| 1962 | + $user_data_value = true; | |
| 1963 | + | |
| 1964 | +		if( ! ( $user_id > 0 ) ){ | |
| 1965 | + $user_id = get_current_user_id(); | |
| 1966 | + } | |
| 1967 | + | |
| 1968 | + $supported_post_types = array( 'course', 'lesson' ); | |
| 1969 | + $post_type = get_post_type( $post_id ); | |
| 1970 | + if( empty( $post_id ) || empty( $data_key ) | |
| 1971 | + || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 1972 | + || ! get_userdata( $user_id ) | |
| 1973 | +			|| !in_array( $post_type, $supported_post_types )  ){ | |
| 2004 | 1974 | |
| 2005 | -        if( ! ( $user_id > 0 ) ){ | |
| 2006 | - $user_id = get_current_user_id(); | |
| 2007 | - } | |
| 1975 | + return false; | |
| 1976 | + } | |
| 2008 | 1977 | |
| 2009 | - $supported_post_types = array( 'course', 'lesson' ); | |
| 2010 | - $post_type = get_post_type( $post_id ); | |
| 2011 | - if( empty( $post_id ) || empty( $data_key ) | |
| 2012 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 2013 | - || ! get_userdata( $user_id ) | |
| 2014 | -            || !in_array( $post_type, $supported_post_types )  ){ | |
| 1978 | + // check if there and existing Sensei status on this post type if not create it | |
| 1979 | + // and get the activity ID | |
| 1980 | + $status_function = 'user_'.$post_type.'_status'; | |
| 1981 | + $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 1982 | +		if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 1983 | + return false; | |
| 1984 | + } | |
| 2015 | 1985 | |
| 2016 | - return false; | |
| 2017 | - } | |
| 1986 | + $sensei_user_activity_id = $sensei_user_status->comment_ID; | |
| 1987 | + $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true ); | |
| 1988 | + | |
| 1989 | + return $user_data_value; | |
| 1990 | + | |
| 1991 | + }// end get_user_data | |
| 1992 | + | |
| 1993 | + /** | |
| 1994 | + * Delete the Sensei user data for the given key, Sensei post type and user combination. | |
| 1995 | + * | |
| 1996 | + * @param int $data_key | |
| 1997 | + * @param int $post_id | |
| 1998 | + * @param int $user_id | |
| 1999 | + * | |
| 2000 | + * @return bool $deleted | |
| 2001 | + */ | |
| 2002 | +	public static function delete_user_data( $data_key, $post_id , $user_id ){ | |
| 2003 | + $deleted = true; | |
| 2004 | + | |
| 2005 | +		if( ! ( $user_id > 0 ) ){ | |
| 2006 | + $user_id = get_current_user_id(); | |
| 2007 | + } | |
| 2008 | + | |
| 2009 | + $supported_post_types = array( 'course', 'lesson' ); | |
| 2010 | + $post_type = get_post_type( $post_id ); | |
| 2011 | + if( empty( $post_id ) || empty( $data_key ) | |
| 2012 | + || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 2013 | + || ! get_userdata( $user_id ) | |
| 2014 | +			|| !in_array( $post_type, $supported_post_types )  ){ | |
| 2015 | + | |
| 2016 | + return false; | |
| 2017 | + } | |
| 2018 | 2018 | |
| 2019 | - // check if there and existing Sensei status on this post type if not create it | |
| 2020 | - // and get the activity ID | |
| 2021 | - $status_function = 'user_'.$post_type.'_status'; | |
| 2022 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 2023 | -        if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 2024 | - return false; | |
| 2025 | - } | |
| 2019 | + // check if there and existing Sensei status on this post type if not create it | |
| 2020 | + // and get the activity ID | |
| 2021 | + $status_function = 'user_'.$post_type.'_status'; | |
| 2022 | + $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 2023 | +		if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 2024 | + return false; | |
| 2025 | + } | |
| 2026 | 2026 | |
| 2027 | - $sensei_user_activity_id = $sensei_user_status->comment_ID; | |
| 2028 | - $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key ); | |
| 2027 | + $sensei_user_activity_id = $sensei_user_status->comment_ID; | |
| 2028 | + $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key ); | |
| 2029 | 2029 | |
| 2030 | - return $deleted; | |
| 2030 | + return $deleted; | |
| 2031 | 2031 | |
| 2032 | - }// end delete_user_data | |
| 2032 | + }// end delete_user_data | |
| 2033 | 2033 | |
| 2034 | 2034 | |
| 2035 | - /** | |
| 2036 | - * The function creates a drop down. Never write up a Sensei select statement again. | |
| 2037 | - * | |
| 2038 | - * @since 1.8.0 | |
| 2039 | - * | |
| 2040 | - * @param string $selected_value | |
| 2041 | -     * @param $options{ | |
| 2042 | - * @type string $value the value saved in the database | |
| 2043 | - * @type string $option what the user will see in the list of items | |
| 2044 | - * } | |
| 2045 | -     * @param array $attributes{ | |
| 2046 | - * @type string $attribute type such name or id etc. | |
| 2047 | - * @type string $value | |
| 2048 | - * } | |
| 2049 | - * @param bool $enable_none_option | |
| 2050 | - * | |
| 2051 | - * @return string $drop_down_element | |
| 2052 | - */ | |
| 2053 | -    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) { | |
| 2035 | + /** | |
| 2036 | + * The function creates a drop down. Never write up a Sensei select statement again. | |
| 2037 | + * | |
| 2038 | + * @since 1.8.0 | |
| 2039 | + * | |
| 2040 | + * @param string $selected_value | |
| 2041 | +	 * @param $options{ | |
| 2042 | + * @type string $value the value saved in the database | |
| 2043 | + * @type string $option what the user will see in the list of items | |
| 2044 | + * } | |
| 2045 | +	 * @param array $attributes{ | |
| 2046 | + * @type string $attribute type such name or id etc. | |
| 2047 | + * @type string $value | |
| 2048 | + * } | |
| 2049 | + * @param bool $enable_none_option | |
| 2050 | + * | |
| 2051 | + * @return string $drop_down_element | |
| 2052 | + */ | |
| 2053 | +	public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) { | |
| 2054 | 2054 | |
| 2055 | - $drop_down_element = ''; | |
| 2055 | + $drop_down_element = ''; | |
| 2056 | 2056 | |
| 2057 | - // setup the basic attributes | |
| 2058 | -        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) { | |
| 2057 | + // setup the basic attributes | |
| 2058 | +		if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) { | |
| 2059 | 2059 | |
| 2060 | - $attributes['name'] = 'sensei-options'; | |
| 2060 | + $attributes['name'] = 'sensei-options'; | |
| 2061 | 2061 | |
| 2062 | - } | |
| 2062 | + } | |
| 2063 | 2063 | |
| 2064 | -        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) { | |
| 2064 | +		if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) { | |
| 2065 | 2065 | |
| 2066 | - $attributes['id'] = 'sensei-options'; | |
| 2066 | + $attributes['id'] = 'sensei-options'; | |
| 2067 | 2067 | |
| 2068 | - } | |
| 2068 | + } | |
| 2069 | 2069 | |
| 2070 | -        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) { | |
| 2070 | +		if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) { | |
| 2071 | 2071 | |
| 2072 | - $attributes['class'] ='chosen_select widefat'; | |
| 2072 | + $attributes['class'] ='chosen_select widefat'; | |
| 2073 | 2073 | |
| 2074 | - } | |
| 2074 | + } | |
| 2075 | 2075 | |
| 2076 | - // create element attributes | |
| 2077 | - $combined_attributes = ''; | |
| 2078 | -        foreach( $attributes as $attribute => $value ){ | |
| 2076 | + // create element attributes | |
| 2077 | + $combined_attributes = ''; | |
| 2078 | +		foreach( $attributes as $attribute => $value ){ | |
| 2079 | 2079 | |
| 2080 | - $combined_attributes .= $attribute . '="'.$value.'"' . ' '; | |
| 2080 | + $combined_attributes .= $attribute . '="'.$value.'"' . ' '; | |
| 2081 | 2081 | |
| 2082 | - }// end for each | |
| 2082 | + }// end for each | |
| 2083 | 2083 | |
| 2084 | 2084 | |
| 2085 | - // create the select element | |
| 2086 | - $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n"; | |
| 2085 | + // create the select element | |
| 2086 | + $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n"; | |
| 2087 | 2087 | |
| 2088 | - // show the none option if the client requested | |
| 2089 | -        if( $enable_none_option ) { | |
| 2090 | -            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; | |
| 2091 | - } | |
| 2088 | + // show the none option if the client requested | |
| 2089 | +		if( $enable_none_option ) { | |
| 2090 | +			$drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; | |
| 2091 | + } | |
| 2092 | 2092 | |
| 2093 | -        if ( count( $options ) > 0 ) { | |
| 2093 | +		if ( count( $options ) > 0 ) { | |
| 2094 | 2094 | |
| 2095 | -            foreach ($options as $value => $option ){ | |
| 2095 | +			foreach ($options as $value => $option ){ | |
| 2096 | 2096 | |
| 2097 | - $element = ''; | |
| 2098 | - $element.= '<option value="' . esc_attr( $value ) . '"'; | |
| 2099 | - $element .= selected( $value, $selected_value, false ) . '>'; | |
| 2100 | - $element .= esc_html( $option ) . '</option>' . "\n"; | |
| 2097 | + $element = ''; | |
| 2098 | + $element.= '<option value="' . esc_attr( $value ) . '"'; | |
| 2099 | + $element .= selected( $value, $selected_value, false ) . '>'; | |
| 2100 | + $element .= esc_html( $option ) . '</option>' . "\n"; | |
| 2101 | 2101 | |
| 2102 | - // add the element to the select html | |
| 2103 | - $drop_down_element.= $element; | |
| 2104 | - } // End For Loop | |
| 2102 | + // add the element to the select html | |
| 2103 | + $drop_down_element.= $element; | |
| 2104 | + } // End For Loop | |
| 2105 | 2105 | |
| 2106 | - } // End If Statement | |
| 2106 | + } // End If Statement | |
| 2107 | 2107 | |
| 2108 | - $drop_down_element .= '</select>' . "\n"; | |
| 2108 | + $drop_down_element .= '</select>' . "\n"; | |
| 2109 | 2109 | |
| 2110 | - return $drop_down_element; | |
| 2110 | + return $drop_down_element; | |
| 2111 | 2111 | |
| 2112 | - }// generate_drop_down | |
| 2112 | + }// generate_drop_down | |
| 2113 | 2113 | |
| 2114 | - /** | |
| 2115 | - * Wrapper for the default php round() function. | |
| 2116 | - * This allows us to give more control to a user on how they can round Sensei | |
| 2117 | - * decimals passed through this function. | |
| 2118 | - * | |
| 2119 | - * @since 1.8.5 | |
| 2120 | - * | |
| 2121 | - * @param double $val | |
| 2122 | - * @param int $precision | |
| 2123 | - * @param $mode | |
| 2124 | - * @param string $context | |
| 2125 | - * | |
| 2126 | - * @return double $val | |
| 2127 | - */ | |
| 2128 | -    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){ | |
| 2114 | + /** | |
| 2115 | + * Wrapper for the default php round() function. | |
| 2116 | + * This allows us to give more control to a user on how they can round Sensei | |
| 2117 | + * decimals passed through this function. | |
| 2118 | + * | |
| 2119 | + * @since 1.8.5 | |
| 2120 | + * | |
| 2121 | + * @param double $val | |
| 2122 | + * @param int $precision | |
| 2123 | + * @param $mode | |
| 2124 | + * @param string $context | |
| 2125 | + * | |
| 2126 | + * @return double $val | |
| 2127 | + */ | |
| 2128 | +	public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){ | |
| 2129 | 2129 | |
| 2130 | - /**å | |
| 2130 | + /**å | |
| 2131 | 2131 | * Change the precision for the Sensei_Utils::round function. | 
| 2132 | 2132 | * the precision given will be passed into the php round function | 
| 2133 | 2133 | * @since 1.8.5 | 
| 2134 | 2134 | */ | 
| 2135 | - $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode ); | |
| 2136 | - | |
| 2137 | - /** | |
| 2138 | - * Change the mode for the Sensei_Utils::round function. | |
| 2139 | - * the mode given will be passed into the php round function | |
| 2140 | - * | |
| 2141 | - * This applies only to PHP version 5.3.0 and greater | |
| 2142 | - * | |
| 2143 | - * @since 1.8.5 | |
| 2144 | - */ | |
| 2145 | - $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision ); | |
| 2135 | + $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode ); | |
| 2136 | + | |
| 2137 | + /** | |
| 2138 | + * Change the mode for the Sensei_Utils::round function. | |
| 2139 | + * the mode given will be passed into the php round function | |
| 2140 | + * | |
| 2141 | + * This applies only to PHP version 5.3.0 and greater | |
| 2142 | + * | |
| 2143 | + * @since 1.8.5 | |
| 2144 | + */ | |
| 2145 | + $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision ); | |
| 2146 | 2146 | |
| 2147 | -        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) { | |
| 2147 | +		if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) { | |
| 2148 | 2148 | |
| 2149 | - return round( $val, $precision, $mode ); | |
| 2149 | + return round( $val, $precision, $mode ); | |
| 2150 | 2150 | |
| 2151 | -        }else{ | |
| 2151 | +		}else{ | |
| 2152 | 2152 | |
| 2153 | - return round( $val, $precision ); | |
| 2153 | + return round( $val, $precision ); | |
| 2154 | 2154 | |
| 2155 | - } | |
| 2155 | + } | |
| 2156 | 2156 | |
| 2157 | - } | |
| 2157 | + } | |
| 2158 | 2158 | |
| 2159 | - /** | |
| 2160 | - * Returns the current url with all the query vars | |
| 2161 | - * | |
| 2162 | - * @since 1.9.0 | |
| 2163 | - * @return string $url | |
| 2164 | - */ | |
| 2165 | -    public static function get_current_url(){ | |
| 2159 | + /** | |
| 2160 | + * Returns the current url with all the query vars | |
| 2161 | + * | |
| 2162 | + * @since 1.9.0 | |
| 2163 | + * @return string $url | |
| 2164 | + */ | |
| 2165 | +	public static function get_current_url(){ | |
| 2166 | 2166 | |
| 2167 | - global $wp; | |
| 2168 | - $current_url = trailingslashit( home_url( $wp->request ) ); | |
| 2169 | -        if ( isset( $_GET ) ) { | |
| 2167 | + global $wp; | |
| 2168 | + $current_url = trailingslashit( home_url( $wp->request ) ); | |
| 2169 | +		if ( isset( $_GET ) ) { | |
| 2170 | 2170 | |
| 2171 | -            foreach ($_GET as $param => $val ) { | |
| 2171 | +			foreach ($_GET as $param => $val ) { | |
| 2172 | 2172 | |
| 2173 | - $current_url = add_query_arg( $param, $val , $current_url ); | |
| 2173 | + $current_url = add_query_arg( $param, $val , $current_url ); | |
| 2174 | 2174 | |
| 2175 | - } | |
| 2176 | - } | |
| 2175 | + } | |
| 2176 | + } | |
| 2177 | 2177 | |
| 2178 | - return $current_url; | |
| 2179 | - } | |
| 2178 | + return $current_url; | |
| 2179 | + } | |
| 2180 | 2180 | |
| 2181 | - /** | |
| 2182 | - * Restore the global WP_Query | |
| 2183 | - * | |
| 2184 | - * @since 1.9.0 | |
| 2185 | - */ | |
| 2186 | -    public static function restore_wp_query() { | |
| 2181 | + /** | |
| 2182 | + * Restore the global WP_Query | |
| 2183 | + * | |
| 2184 | + * @since 1.9.0 | |
| 2185 | + */ | |
| 2186 | +	public static function restore_wp_query() { | |
| 2187 | 2187 | |
| 2188 | - wp_reset_query(); | |
| 2188 | + wp_reset_query(); | |
| 2189 | 2189 | |
| 2190 | - } | |
| 2190 | + } | |
| 2191 | 2191 | |
| 2192 | - /** | |
| 2193 | - * Merge two arrays in a zip like fashion. | |
| 2194 | - * If one array is longer than the other the elements will be apended | |
| 2195 | - * to the end of the resulting array. | |
| 2196 | - * | |
| 2197 | - * @since 1.9.0 | |
| 2198 | - * | |
| 2199 | - * @param array $array_a | |
| 2200 | - * @param array $array_b | |
| 2201 | - * @return array $merged_array | |
| 2202 | - */ | |
| 2203 | -    public static function array_zip_merge( $array_a, $array_b ){ | |
| 2192 | + /** | |
| 2193 | + * Merge two arrays in a zip like fashion. | |
| 2194 | + * If one array is longer than the other the elements will be apended | |
| 2195 | + * to the end of the resulting array. | |
| 2196 | + * | |
| 2197 | + * @since 1.9.0 | |
| 2198 | + * | |
| 2199 | + * @param array $array_a | |
| 2200 | + * @param array $array_b | |
| 2201 | + * @return array $merged_array | |
| 2202 | + */ | |
| 2203 | +	public static function array_zip_merge( $array_a, $array_b ){ | |
| 2204 | 2204 | |
| 2205 | -        if( ! is_array( $array_a ) || ! is_array( $array_b )  ){ | |
| 2206 | -            trigger_error('array_zip_merge requires both arrays to be indexed arrays '); | |
| 2207 | - } | |
| 2205 | +		if( ! is_array( $array_a ) || ! is_array( $array_b )  ){ | |
| 2206 | +			trigger_error('array_zip_merge requires both arrays to be indexed arrays '); | |
| 2207 | + } | |
| 2208 | 2208 | |
| 2209 | - $merged_array = array(); | |
| 2210 | - $total_elements = count( $array_a ) + count( $array_b ); | |
| 2209 | + $merged_array = array(); | |
| 2210 | + $total_elements = count( $array_a ) + count( $array_b ); | |
| 2211 | 2211 | |
| 2212 | - // Zip arrays | |
| 2213 | -        for ( $i = 0; $i < $total_elements; $i++) { | |
| 2212 | + // Zip arrays | |
| 2213 | +		for ( $i = 0; $i < $total_elements; $i++) { | |
| 2214 | 2214 | |
| 2215 | - // if has an element at current index push a on top | |
| 2216 | -            if( isset( $array_a[ $i ] ) ){ | |
| 2217 | - $merged_array[] = $array_a[ $i ] ; | |
| 2218 | - } | |
| 2215 | + // if has an element at current index push a on top | |
| 2216 | +			if( isset( $array_a[ $i ] ) ){ | |
| 2217 | + $merged_array[] = $array_a[ $i ] ; | |
| 2218 | + } | |
| 2219 | 2219 | |
| 2220 | - // next if $array_b has an element at current index push a on top of the element | |
| 2221 | - // from a if there was one, if not the element before that. | |
| 2222 | -            if( isset( $array_b[ $i ] ) ){ | |
| 2223 | - $merged_array[] = $array_b[ $i ] ; | |
| 2224 | - } | |
| 2220 | + // next if $array_b has an element at current index push a on top of the element | |
| 2221 | + // from a if there was one, if not the element before that. | |
| 2222 | +			if( isset( $array_b[ $i ] ) ){ | |
| 2223 | + $merged_array[] = $array_b[ $i ] ; | |
| 2224 | + } | |
| 2225 | 2225 | |
| 2226 | - } | |
| 2226 | + } | |
| 2227 | 2227 | |
| 2228 | - return $merged_array; | |
| 2229 | - } | |
| 2228 | + return $merged_array; | |
| 2229 | + } | |
| 2230 | 2230 | |
| 2231 | 2231 | } // End Class | 
| 2232 | 2232 | |
| @@ -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 Utilities Class | 
| @@ -18,9 +18,9 @@ discard block | ||
| 18 | 18 | * @since 1.0.0 | 
| 19 | 19 | * @return string The URL to the placeholder thumbnail image. | 
| 20 | 20 | */ | 
| 21 | -	public static function get_placeholder_image () { | |
| 21 | +	public static function get_placeholder_image() { | |
| 22 | 22 | |
| 23 | - return esc_url( apply_filters( 'sensei_placeholder_thumbnail', Sensei()->plugin_url . 'assets/images/placeholder.png' ) ); | |
| 23 | +		return esc_url(apply_filters('sensei_placeholder_thumbnail', Sensei()->plugin_url.'assets/images/placeholder.png')); | |
| 24 | 24 | } // End get_placeholder_image() | 
| 25 | 25 | |
| 26 | 26 | /** | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | * @static | 
| 33 | 33 | * @return bool | 
| 34 | 34 | */ | 
| 35 | -	public static function sensei_is_woocommerce_present () { | |
| 35 | +	public static function sensei_is_woocommerce_present() { | |
| 36 | 36 | |
| 37 | 37 | return Sensei_WC::is_woocommerce_present(); | 
| 38 | 38 | |
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | * @static | 
| 48 | 48 | * @return boolean | 
| 49 | 49 | */ | 
| 50 | -	public static function sensei_is_woocommerce_activated () { | |
| 50 | +	public static function sensei_is_woocommerce_activated() { | |
| 51 | 51 | |
| 52 | 52 | return Sensei_WC::is_woocommerce_active(); | 
| 53 | 53 | |
| @@ -60,70 +60,70 @@ discard block | ||
| 60 | 60 | * @param array $args (default: array()) | 
| 61 | 61 | * @return bool | int | 
| 62 | 62 | */ | 
| 63 | -	public static function sensei_log_activity ( $args = array() ) { | |
| 63 | +	public static function sensei_log_activity($args = array()) { | |
| 64 | 64 | global $wpdb; | 
| 65 | 65 | |
| 66 | 66 | // Args, minimum data required for WP | 
| 67 | 67 | $data = array( | 
| 68 | - 'comment_post_ID' => intval( $args['post_id'] ), | |
| 68 | + 'comment_post_ID' => intval($args['post_id']), | |
| 69 | 69 | 'comment_author' => '', // Not needed | 
| 70 | 70 | 'comment_author_email' => '', // Not needed | 
| 71 | 71 | 'comment_author_url' => '', // Not needed | 
| 72 | - 'comment_content' => !empty($args['data']) ? esc_html( $args['data'] ) : '', | |
| 73 | - 'comment_type' => esc_attr( $args['type'] ), | |
| 74 | - 'user_id' => intval( $args['user_id'] ), | |
| 75 | - 'comment_approved' => !empty($args['status']) ? esc_html( $args['status'] ) : 'log', // 'log' == 'sensei_user_answer' | |
| 72 | + 'comment_content' => ! empty($args['data']) ? esc_html($args['data']) : '', | |
| 73 | + 'comment_type' => esc_attr($args['type']), | |
| 74 | + 'user_id' => intval($args['user_id']), | |
| 75 | + 'comment_approved' => ! empty($args['status']) ? esc_html($args['status']) : 'log', // 'log' == 'sensei_user_answer' | |
| 76 | 76 | ); | 
| 77 | 77 | // Allow extra data | 
| 78 | -		if ( !empty($args['username']) ) { | |
| 79 | - $data['comment_author'] = sanitize_user( $args['username'] ); | |
| 78 | +		if ( ! empty($args['username'])) { | |
| 79 | + $data['comment_author'] = sanitize_user($args['username']); | |
| 80 | 80 | } | 
| 81 | -		if ( !empty($args['user_email']) ) { | |
| 82 | - $data['comment_author_email'] = sanitize_email( $args['user_email'] ); | |
| 81 | +		if ( ! empty($args['user_email'])) { | |
| 82 | + $data['comment_author_email'] = sanitize_email($args['user_email']); | |
| 83 | 83 | } | 
| 84 | -		if ( !empty($args['user_url']) ) { | |
| 85 | - $data['comment_author_url'] = esc_url( $args['user_url'] ); | |
| 84 | +		if ( ! empty($args['user_url'])) { | |
| 85 | + $data['comment_author_url'] = esc_url($args['user_url']); | |
| 86 | 86 | } | 
| 87 | -		if ( !empty($args['parent']) ) { | |
| 87 | +		if ( ! empty($args['parent'])) { | |
| 88 | 88 | $data['comment_parent'] = $args['parent']; | 
| 89 | 89 | } | 
| 90 | 90 | // Sanity check | 
| 91 | -		if ( empty($args['user_id']) ) { | |
| 92 | -			_deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') ); | |
| 91 | +		if (empty($args['user_id'])) { | |
| 92 | +			_deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei')); | |
| 93 | 93 | return false; | 
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | - do_action( 'sensei_log_activity_before', $args, $data ); | |
| 96 | +		do_action('sensei_log_activity_before', $args, $data); | |
| 97 | 97 | |
| 98 | 98 | $flush_cache = false; | 
| 99 | 99 | |
| 100 | 100 | // Custom Logic | 
| 101 | 101 | // Check if comment exists first | 
| 102 | - $comment_id = $wpdb->get_var( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type'] ) ); | |
| 103 | -		if ( ! $comment_id ) { | |
| 102 | +		$comment_id = $wpdb->get_var($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type'])); | |
| 103 | +		if ( ! $comment_id) { | |
| 104 | 104 | // Add the comment | 
| 105 | - $comment_id = wp_insert_comment( $data ); | |
| 105 | + $comment_id = wp_insert_comment($data); | |
| 106 | 106 | |
| 107 | 107 | $flush_cache = true; | 
| 108 | -		} elseif ( isset( $args['action'] ) && 'update' == $args['action'] ) { | |
| 108 | +		} elseif (isset($args['action']) && 'update' == $args['action']) { | |
| 109 | 109 | // Update the comment if an update was requested | 
| 110 | 110 | $data['comment_ID'] = $comment_id; | 
| 111 | 111 | // By default update the timestamp of the comment | 
| 112 | -			if ( empty($args['keep_time']) ) { | |
| 112 | +			if (empty($args['keep_time'])) { | |
| 113 | 113 |  				$data['comment_date'] = current_time('mysql'); | 
| 114 | 114 | } | 
| 115 | - wp_update_comment( $data ); | |
| 115 | + wp_update_comment($data); | |
| 116 | 116 | $flush_cache = true; | 
| 117 | 117 | } // End If Statement | 
| 118 | 118 | |
| 119 | 119 | // Manually Flush the Cache | 
| 120 | -		if ( $flush_cache ) { | |
| 120 | +		if ($flush_cache) { | |
| 121 | 121 | wp_cache_flush(); | 
| 122 | 122 | } | 
| 123 | 123 | |
| 124 | - do_action( 'sensei_log_activity_after', $args, $data, $comment_id ); | |
| 124 | +		do_action('sensei_log_activity_after', $args, $data, $comment_id); | |
| 125 | 125 | |
| 126 | -		if ( 0 < $comment_id ) { | |
| 126 | +		if (0 < $comment_id) { | |
| 127 | 127 | // Return the ID so that it can be used for meta data storage | 
| 128 | 128 | return $comment_id; | 
| 129 | 129 |  		} else { | 
| @@ -140,41 +140,41 @@ discard block | ||
| 140 | 140 | * @param bool $return_comments (default: false) | 
| 141 | 141 | * @return mixed | int | 
| 142 | 142 | */ | 
| 143 | -	public static function sensei_check_for_activity ( $args = array(), $return_comments = false ) { | |
| 143 | +	public static function sensei_check_for_activity($args = array(), $return_comments = false) { | |
| 144 | 144 | |
| 145 | 145 | global $wp_version; | 
| 146 | -		if ( !$return_comments ) { | |
| 146 | +		if ( ! $return_comments) { | |
| 147 | 147 | $args['count'] = true; | 
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | 150 | // Are we only retrieving a single entry, or not care about the order... | 
| 151 | -		if ( isset( $args['count'] ) || isset( $args['post_id'] ) ){ | |
| 151 | +		if (isset($args['count']) || isset($args['post_id'])) { | |
| 152 | 152 | |
| 153 | 153 | // ...then we don't need to ask the db to order the results, this overrides WP default behaviour | 
| 154 | -			if ( version_compare( $wp_version, '4.1', '>=' ) ) { | |
| 154 | +			if (version_compare($wp_version, '4.1', '>=')) { | |
| 155 | 155 | $args['order'] = false; | 
| 156 | 156 | $args['orderby'] = false; | 
| 157 | 157 | } | 
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | 160 | // A user ID of 0 is in valid, so shortcut this | 
| 161 | -		if ( isset( $args['user_id'] ) && 0 == intval ( $args['user_id'] ) ) { | |
| 162 | -			_deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') ); | |
| 161 | +		if (isset($args['user_id']) && 0 == intval($args['user_id'])) { | |
| 162 | +			_deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei')); | |
| 163 | 163 | return false; | 
| 164 | 164 | } | 
| 165 | 165 | // Check for legacy code | 
| 166 | -		if ( isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes') ) ) { | |
| 167 | -			_deprecated_argument( __FUNCTION__, '1.7', sprintf( __('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type'] ) ); | |
| 166 | +		if (isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes'))) { | |
| 167 | +			_deprecated_argument(__FUNCTION__, '1.7', sprintf(__('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type'])); | |
| 168 | 168 | return false; | 
| 169 | 169 | } | 
| 170 | 170 | // Are we checking for specific comment_approved statuses? | 
| 171 | -		if ( isset($args['status']) ) { | |
| 171 | +		if (isset($args['status'])) { | |
| 172 | 172 | // Temporarily store as a custom status if requesting an array... | 
| 173 | -			if ( is_array( $args['status'] ) && version_compare($wp_version, '4.1', '<') ) { | |
| 173 | +			if (is_array($args['status']) && version_compare($wp_version, '4.1', '<')) { | |
| 174 | 174 | // Encode now, decode later | 
| 175 | - $args['status'] = implode( ",", $args['status'] ); | |
| 175 | +				$args['status'] = implode(",", $args['status']); | |
| 176 | 176 | // ...use a filter to switch the encoding back | 
| 177 | - add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); | |
| 177 | +				add_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter')); | |
| 178 | 178 | } | 
| 179 | 179 | } | 
| 180 | 180 |  		else { | 
| @@ -182,8 +182,8 @@ discard block | ||
| 182 | 182 | } | 
| 183 | 183 | |
| 184 | 184 | // Take into account WP < 4.1 will automatically add ' comment_approved = 1 OR comment_approved = 0 ' | 
| 185 | -		if ( ( is_array( $args['status'] ) || 'any' == $args['status'] ) && version_compare($wp_version, '4.1', '<') ) { | |
| 186 | - add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); | |
| 185 | +		if ((is_array($args['status']) || 'any' == $args['status']) && version_compare($wp_version, '4.1', '<')) { | |
| 186 | +			add_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter')); | |
| 187 | 187 | } | 
| 188 | 188 | |
| 189 | 189 | //Get the comments | 
| @@ -194,14 +194,14 @@ discard block | ||
| 194 | 194 | * | 
| 195 | 195 | * @param int|array $comments | 
| 196 | 196 | */ | 
| 197 | -        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) ); | |
| 197 | +        $comments = apply_filters('sensei_check_for_activity', get_comments($args)); | |
| 198 | 198 | |
| 199 | - remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); | |
| 200 | - remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); | |
| 199 | +		remove_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter')); | |
| 200 | +		remove_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter')); | |
| 201 | 201 | // Return comments | 
| 202 | -		if ( $return_comments ) { | |
| 202 | +		if ($return_comments) { | |
| 203 | 203 | // Could check for array of 1 and just return the 1 item? | 
| 204 | -			if ( is_array($comments) && 1 == count($comments) ) { | |
| 204 | +			if (is_array($comments) && 1 == count($comments)) { | |
| 205 | 205 | $comments = array_shift($comments); | 
| 206 | 206 | } | 
| 207 | 207 | |
| @@ -219,31 +219,31 @@ discard block | ||
| 219 | 219 | * @param array $args (default: array()) | 
| 220 | 220 | * @return array | 
| 221 | 221 | */ | 
| 222 | -	public static function sensei_activity_ids ( $args = array() ) { | |
| 222 | +	public static function sensei_activity_ids($args = array()) { | |
| 223 | 223 | |
| 224 | 224 | |
| 225 | - $comments = Sensei_Utils::sensei_check_for_activity( $args, true ); | |
| 225 | + $comments = Sensei_Utils::sensei_check_for_activity($args, true); | |
| 226 | 226 | // Need to always use an array, even with only 1 item | 
| 227 | -		if ( !is_array($comments) ) { | |
| 228 | - $comments = array( $comments ); | |
| 227 | +		if ( ! is_array($comments)) { | |
| 228 | + $comments = array($comments); | |
| 229 | 229 | } | 
| 230 | 230 | |
| 231 | 231 | $post_ids = array(); | 
| 232 | 232 | // Count comments | 
| 233 | -		if ( is_array( $comments ) && ( 0 < intval( count( $comments ) ) ) ) { | |
| 234 | -			foreach ( $comments as $key => $value  ) { | |
| 233 | +		if (is_array($comments) && (0 < intval(count($comments)))) { | |
| 234 | +			foreach ($comments as $key => $value) { | |
| 235 | 235 | // Add matches to id array | 
| 236 | -				if ( isset( $args['field'] ) && 'comment' == $args['field'] ) { | |
| 237 | - array_push( $post_ids, $value->comment_ID ); | |
| 238 | -				} elseif( isset( $args['field'] ) && 'user_id' == $args['field'] ) { | |
| 239 | - array_push( $post_ids, $value->user_id ); | |
| 236 | +				if (isset($args['field']) && 'comment' == $args['field']) { | |
| 237 | + array_push($post_ids, $value->comment_ID); | |
| 238 | +				} elseif (isset($args['field']) && 'user_id' == $args['field']) { | |
| 239 | + array_push($post_ids, $value->user_id); | |
| 240 | 240 |  				} else { | 
| 241 | - array_push( $post_ids, $value->comment_post_ID ); | |
| 241 | + array_push($post_ids, $value->comment_post_ID); | |
| 242 | 242 | } // End If Statement | 
| 243 | 243 | } // End For Loop | 
| 244 | 244 | // Reset array indexes | 
| 245 | - $post_ids = array_unique( $post_ids ); | |
| 246 | - $post_ids = array_values( $post_ids ); | |
| 245 | + $post_ids = array_unique($post_ids); | |
| 246 | + $post_ids = array_values($post_ids); | |
| 247 | 247 | } // End If Statement | 
| 248 | 248 | |
| 249 | 249 | return $post_ids; | 
| @@ -257,20 +257,20 @@ discard block | ||
| 257 | 257 | * @param array $args (default: array()) | 
| 258 | 258 | * @return boolean | 
| 259 | 259 | */ | 
| 260 | -	public static function sensei_delete_activities ( $args = array() ) { | |
| 260 | +	public static function sensei_delete_activities($args = array()) { | |
| 261 | 261 | |
| 262 | 262 | $dataset_changes = false; | 
| 263 | 263 | |
| 264 | 264 | // If activity exists remove activity from log | 
| 265 | - $comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => intval( $args['post_id'] ), 'user_id' => intval( $args['user_id'] ), 'type' => esc_attr( $args['type'] ) ), true ); | |
| 266 | -		if( $comments ) { | |
| 265 | +		$comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => intval($args['post_id']), 'user_id' => intval($args['user_id']), 'type' => esc_attr($args['type'])), true); | |
| 266 | +		if ($comments) { | |
| 267 | 267 | // Need to always return an array, even with only 1 item | 
| 268 | -			if ( !is_array( $comments ) ) { | |
| 269 | - $comments = array( $comments ); | |
| 268 | +			if ( ! is_array($comments)) { | |
| 269 | + $comments = array($comments); | |
| 270 | 270 | } | 
| 271 | -			foreach ( $comments as $key => $value  ) { | |
| 272 | -				if ( isset( $value->comment_ID ) && 0 < $value->comment_ID ) { | |
| 273 | - $dataset_changes = wp_delete_comment( intval( $value->comment_ID ), true ); | |
| 271 | +			foreach ($comments as $key => $value) { | |
| 272 | +				if (isset($value->comment_ID) && 0 < $value->comment_ID) { | |
| 273 | + $dataset_changes = wp_delete_comment(intval($value->comment_ID), true); | |
| 274 | 274 | } // End If Statement | 
| 275 | 275 | } // End For Loop | 
| 276 | 276 | // Manually flush the cache | 
| @@ -286,25 +286,25 @@ discard block | ||
| 286 | 286 | * @param integer $user_id User ID | 
| 287 | 287 | * @return boolean | 
| 288 | 288 | */ | 
| 289 | -    public static function delete_all_user_activity( $user_id = 0 ) { | |
| 289 | +    public static function delete_all_user_activity($user_id = 0) { | |
| 290 | 290 | |
| 291 | 291 | $dataset_changes = false; | 
| 292 | 292 | |
| 293 | -    	if( $user_id ) { | |
| 293 | +    	if ($user_id) { | |
| 294 | 294 | |
| 295 | - $activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true ); | |
| 295 | +			$activities = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user_id), true); | |
| 296 | 296 | |
| 297 | -			if( $activities ) { | |
| 297 | +			if ($activities) { | |
| 298 | 298 | |
| 299 | 299 | // Need to always return an array, even with only 1 item | 
| 300 | -				if ( ! is_array( $activities ) ) { | |
| 301 | - $activities = array( $activities ); | |
| 300 | +				if ( ! is_array($activities)) { | |
| 301 | + $activities = array($activities); | |
| 302 | 302 | } | 
| 303 | 303 | |
| 304 | -				foreach( $activities as $activity ) { | |
| 305 | - if( '' == $activity->comment_type ) continue; | |
| 306 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; | |
| 307 | - $dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true ); | |
| 304 | +				foreach ($activities as $activity) { | |
| 305 | +					if ('' == $activity->comment_type) continue; | |
| 306 | +					if (strpos('sensei_', $activity->comment_type) != 0) continue; | |
| 307 | + $dataset_changes = wp_delete_comment(intval($activity->comment_ID), true); | |
| 308 | 308 | wp_cache_flush(); | 
| 309 | 309 | } | 
| 310 | 310 | } | 
| @@ -321,14 +321,14 @@ discard block | ||
| 321 | 321 | * @param array $args (default: array()) | 
| 322 | 322 | * @return string | 
| 323 | 323 | */ | 
| 324 | -	public static function sensei_get_activity_value ( $args = array() ) { | |
| 324 | +	public static function sensei_get_activity_value($args = array()) { | |
| 325 | 325 | |
| 326 | 326 | |
| 327 | 327 | $activity_value = false; | 
| 328 | -		if ( !empty($args['field']) ) { | |
| 329 | - $comment = Sensei_Utils::sensei_check_for_activity( $args, true ); | |
| 328 | +		if ( ! empty($args['field'])) { | |
| 329 | + $comment = Sensei_Utils::sensei_check_for_activity($args, true); | |
| 330 | 330 | |
| 331 | -			if ( isset( $comment->{$args['field']} ) && '' != $comment->{$args['field']} ) { | |
| 331 | +			if (isset($comment->{$args['field']} ) && '' != $comment->{$args['field']} ) { | |
| 332 | 332 |  				$activity_value = $comment->{$args['field']}; | 
| 333 | 333 | } // End If Statement | 
| 334 | 334 | } | 
| @@ -346,22 +346,22 @@ discard block | ||
| 346 | 346 | * @param int $product_id | 
| 347 | 347 | * @return bool | 
| 348 | 348 | */ | 
| 349 | -    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) { | |
| 349 | +    public static function sensei_customer_bought_product($customer_email, $user_id, $product_id) { | |
| 350 | 350 | |
| 351 | 351 | $emails = array(); | 
| 352 | 352 | |
| 353 | -        if ( $user_id ) { | |
| 354 | - $user = get_user_by( 'id', intval( $user_id ) ); | |
| 353 | +        if ($user_id) { | |
| 354 | +            $user = get_user_by('id', intval($user_id)); | |
| 355 | 355 | $emails[] = $user->user_email; | 
| 356 | 356 | } | 
| 357 | 357 | |
| 358 | - if ( is_email( $customer_email ) ) | |
| 358 | + if (is_email($customer_email)) | |
| 359 | 359 | $emails[] = $customer_email; | 
| 360 | 360 | |
| 361 | - if ( sizeof( $emails ) == 0 ) | |
| 361 | + if (sizeof($emails) == 0) | |
| 362 | 362 | return false; | 
| 363 | 363 | |
| 364 | - return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); | |
| 364 | + return Sensei_WC::has_customer_bought_product($user_id, $product_id); | |
| 365 | 365 | |
| 366 | 366 | } // End sensei_customer_bought_product() | 
| 367 | 367 | |
| @@ -372,9 +372,9 @@ discard block | ||
| 372 | 372 | * @param string $input_name Name for text area form element | 
| 373 | 373 | * @return void | 
| 374 | 374 | */ | 
| 375 | -	public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) { | |
| 375 | +	public static function sensei_text_editor($content = '', $editor_id = 'senseitexteditor', $input_name = '') { | |
| 376 | 376 | |
| 377 | - if( ! $input_name ) $input_name = $editor_id; | |
| 377 | + if ( ! $input_name) $input_name = $editor_id; | |
| 378 | 378 | |
| 379 | 379 | $buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext'; | 
| 380 | 380 | |
| @@ -392,7 +392,7 @@ discard block | ||
| 392 | 392 | 'quicktags' => false | 
| 393 | 393 | ); | 
| 394 | 394 | |
| 395 | - wp_editor( $content, $editor_id, $settings ); | |
| 395 | + wp_editor($content, $editor_id, $settings); | |
| 396 | 396 | |
| 397 | 397 | } // End sensei_text_editor() | 
| 398 | 398 | |
| @@ -402,57 +402,57 @@ discard block | ||
| 402 | 402 | * @param int $user_id | 
| 403 | 403 | * @return boolean Whether the answers were saved or not | 
| 404 | 404 | */ | 
| 405 | -	public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) { | |
| 405 | +	public static function sensei_save_quiz_answers($submitted = array(), $user_id = 0) { | |
| 406 | 406 | |
| 407 | -		if( intval( $user_id ) == 0 ) { | |
| 407 | +		if (intval($user_id) == 0) { | |
| 408 | 408 | $user_id = get_current_user_id(); | 
| 409 | 409 | } | 
| 410 | 410 | |
| 411 | 411 | $answers_saved = false; | 
| 412 | 412 | |
| 413 | -		if( $submitted && intval( $user_id ) > 0 ) { | |
| 413 | +		if ($submitted && intval($user_id) > 0) { | |
| 414 | 414 | |
| 415 | -			foreach( $submitted as $question_id => $answer ) { | |
| 415 | +			foreach ($submitted as $question_id => $answer) { | |
| 416 | 416 | |
| 417 | 417 | // Get question type | 
| 418 | - $question_type = Sensei()->question->get_question_type( $question_id ); | |
| 418 | + $question_type = Sensei()->question->get_question_type($question_id); | |
| 419 | 419 | |
| 420 | 420 | // Sanitise answer | 
| 421 | -				if( 0 == get_magic_quotes_gpc() ) { | |
| 422 | - $answer = wp_unslash( $answer ); | |
| 421 | +				if (0 == get_magic_quotes_gpc()) { | |
| 422 | + $answer = wp_unslash($answer); | |
| 423 | 423 | } | 
| 424 | -				switch( $question_type ) { | |
| 425 | - case 'multi-line': $answer = nl2br( $answer ); break; | |
| 424 | +				switch ($question_type) { | |
| 425 | + case 'multi-line': $answer = nl2br($answer); break; | |
| 426 | 426 | case 'single-line': break; | 
| 427 | 427 | case 'gap-fill': break; | 
| 428 | - default: $answer = maybe_serialize( $answer ); break; | |
| 428 | + default: $answer = maybe_serialize($answer); break; | |
| 429 | 429 | } | 
| 430 | 430 | $args = array( | 
| 431 | 431 | 'post_id' => $question_id, | 
| 432 | - 'data' => base64_encode( $answer ), | |
| 432 | + 'data' => base64_encode($answer), | |
| 433 | 433 | 'type' => 'sensei_user_answer', /* FIELD SIZE 20 */ | 
| 434 | 434 | 'user_id' => $user_id, | 
| 435 | 435 | 'action' => 'update' | 
| 436 | 436 | ); | 
| 437 | - $answers_saved = Sensei_Utils::sensei_log_activity( $args ); | |
| 437 | + $answers_saved = Sensei_Utils::sensei_log_activity($args); | |
| 438 | 438 | } | 
| 439 | 439 | |
| 440 | 440 | // Handle file upload questions | 
| 441 | -			if( isset( $_FILES ) ) { | |
| 442 | -				foreach( $_FILES as $field => $file ) { | |
| 443 | -					if( strpos( $field, 'file_upload_' ) !== false ) { | |
| 444 | - $question_id = str_replace( 'file_upload_', '', $field ); | |
| 445 | -						if( $file && $question_id ) { | |
| 446 | - $attachment_id = self::upload_file( $file ); | |
| 447 | -							if( $attachment_id ) { | |
| 441 | +			if (isset($_FILES)) { | |
| 442 | +				foreach ($_FILES as $field => $file) { | |
| 443 | +					if (strpos($field, 'file_upload_') !== false) { | |
| 444 | +						$question_id = str_replace('file_upload_', '', $field); | |
| 445 | +						if ($file && $question_id) { | |
| 446 | + $attachment_id = self::upload_file($file); | |
| 447 | +							if ($attachment_id) { | |
| 448 | 448 | $args = array( | 
| 449 | 449 | 'post_id' => $question_id, | 
| 450 | - 'data' => base64_encode( $attachment_id ), | |
| 450 | + 'data' => base64_encode($attachment_id), | |
| 451 | 451 | 'type' => 'sensei_user_answer', /* FIELD SIZE 20 */ | 
| 452 | 452 | 'user_id' => $user_id, | 
| 453 | 453 | 'action' => 'update' | 
| 454 | 454 | ); | 
| 455 | - $answers_saved = Sensei_Utils::sensei_log_activity( $args ); | |
| 455 | + $answers_saved = Sensei_Utils::sensei_log_activity($args); | |
| 456 | 456 | } | 
| 457 | 457 | } | 
| 458 | 458 | } | 
| @@ -464,9 +464,9 @@ discard block | ||
| 464 | 464 | |
| 465 | 465 | } // End sensei_save_quiz_answers() | 
| 466 | 466 | |
| 467 | -	public static function upload_file( $file = array() ) { | |
| 467 | +	public static function upload_file($file = array()) { | |
| 468 | 468 | |
| 469 | - require_once( ABSPATH . 'wp-admin/includes/admin.php' ); | |
| 469 | + require_once(ABSPATH.'wp-admin/includes/admin.php'); | |
| 470 | 470 | |
| 471 | 471 | /** | 
| 472 | 472 | * Filter the data array for the Sensei wp_handle_upload function call | 
| @@ -481,11 +481,11 @@ discard block | ||
| 481 | 481 | * @type string test_form set to false by default | 
| 482 | 482 | * } | 
| 483 | 483 | */ | 
| 484 | -        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) ); | |
| 484 | +        $file_upload_args = apply_filters('sensei_file_upload_args', array('test_form' => false)); | |
| 485 | 485 | |
| 486 | - $file_return = wp_handle_upload( $file, $file_upload_args ); | |
| 486 | + $file_return = wp_handle_upload($file, $file_upload_args); | |
| 487 | 487 | |
| 488 | -        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { | |
| 488 | +        if (isset($file_return['error']) || isset($file_return['upload_error_handler'])) { | |
| 489 | 489 | return false; | 
| 490 | 490 |          } else { | 
| 491 | 491 | |
| @@ -493,19 +493,19 @@ discard block | ||
| 493 | 493 | |
| 494 | 494 | $attachment = array( | 
| 495 | 495 | 'post_mime_type' => $file_return['type'], | 
| 496 | - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), | |
| 496 | +                'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 497 | 497 | 'post_content' => '', | 
| 498 | 498 | 'post_status' => 'inherit', | 
| 499 | 499 | 'guid' => $file_return['url'] | 
| 500 | 500 | ); | 
| 501 | 501 | |
| 502 | - $attachment_id = wp_insert_attachment( $attachment, $filename ); | |
| 502 | + $attachment_id = wp_insert_attachment($attachment, $filename); | |
| 503 | 503 | |
| 504 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); | |
| 505 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); | |
| 506 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); | |
| 504 | + require_once(ABSPATH.'wp-admin/includes/image.php'); | |
| 505 | + $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename); | |
| 506 | + wp_update_attachment_metadata($attachment_id, $attachment_data); | |
| 507 | 507 | |
| 508 | -            if( 0 < intval( $attachment_id ) ) { | |
| 508 | +            if (0 < intval($attachment_id)) { | |
| 509 | 509 | return $attachment_id; | 
| 510 | 510 | } | 
| 511 | 511 | } | 
| @@ -531,9 +531,9 @@ discard block | ||
| 531 | 531 | * | 
| 532 | 532 | * @return int $quiz_grade total sum of all question grades | 
| 533 | 533 | */ | 
| 534 | -	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) { | |
| 534 | +	public static function sensei_grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') { | |
| 535 | 535 | |
| 536 | - return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type ); | |
| 536 | + return Sensei_Grading::grade_quiz_auto($quiz_id, $submitted, $total_questions, $quiz_grade_type); | |
| 537 | 537 | |
| 538 | 538 | } // End sensei_grade_quiz_auto() | 
| 539 | 539 | |
| @@ -545,20 +545,20 @@ discard block | ||
| 545 | 545 | * @param string $quiz_grade_type default 'auto' | 
| 546 | 546 | * @return boolean | 
| 547 | 547 | */ | 
| 548 | -	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) { | |
| 549 | -		if( intval( $user_id ) == 0 ) { | |
| 548 | +	public static function sensei_grade_quiz($quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto') { | |
| 549 | +		if (intval($user_id) == 0) { | |
| 550 | 550 | $user_id = get_current_user_id(); | 
| 551 | 551 | } | 
| 552 | 552 | |
| 553 | 553 | $activity_logged = false; | 
| 554 | -		if( intval( $quiz_id ) > 0 && intval( $user_id ) > 0 ) { | |
| 555 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); | |
| 556 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); | |
| 557 | - $activity_logged = update_comment_meta( $user_lesson_status->comment_ID, 'grade', $grade ); | |
| 554 | +		if (intval($quiz_id) > 0 && intval($user_id) > 0) { | |
| 555 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); | |
| 556 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); | |
| 557 | + $activity_logged = update_comment_meta($user_lesson_status->comment_ID, 'grade', $grade); | |
| 558 | 558 | |
| 559 | - $quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) ); | |
| 559 | + $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true)); | |
| 560 | 560 | |
| 561 | - do_action( 'sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type ); | |
| 561 | +			do_action('sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type); | |
| 562 | 562 | } | 
| 563 | 563 | |
| 564 | 564 | return $activity_logged; | 
| @@ -578,9 +578,9 @@ discard block | ||
| 578 | 578 | * | 
| 579 | 579 | * @return int $question_grade | 
| 580 | 580 | */ | 
| 581 | -	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) { | |
| 581 | +	public static function sensei_grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) { | |
| 582 | 582 | |
| 583 | - return WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id ); | |
| 583 | + return WooThemes_Sensei_Grading::grade_question_auto($question_id, $question_type, $answer, $user_id); | |
| 584 | 584 | |
| 585 | 585 | } // end sensei_grade_question_auto | 
| 586 | 586 | |
| @@ -591,20 +591,20 @@ discard block | ||
| 591 | 591 | * @param int $user_id | 
| 592 | 592 | * @return boolean | 
| 593 | 593 | */ | 
| 594 | -	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) { | |
| 595 | -		if( intval( $user_id ) == 0 ) { | |
| 594 | +	public static function sensei_grade_question($question_id = 0, $grade = 0, $user_id = 0) { | |
| 595 | +		if (intval($user_id) == 0) { | |
| 596 | 596 | $user_id = get_current_user_id(); | 
| 597 | 597 | } | 
| 598 | 598 | |
| 599 | 599 | $activity_logged = false; | 
| 600 | -		if( intval( $question_id ) > 0 && intval( $user_id ) > 0 ) { | |
| 600 | +		if (intval($question_id) > 0 && intval($user_id) > 0) { | |
| 601 | 601 | |
| 602 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); | |
| 603 | - $activity_logged = update_comment_meta( $user_answer_id, 'user_grade', $grade ); | |
| 602 | +			$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); | |
| 603 | + $activity_logged = update_comment_meta($user_answer_id, 'user_grade', $grade); | |
| 604 | 604 | |
| 605 | - $answer_notes = get_post_meta( $question_id, '_answer_feedback', true ); | |
| 606 | -			if ( !empty($answer_notes) ) { | |
| 607 | - update_comment_meta( $user_answer_id, 'answer_note', base64_encode( $answer_notes ) ); | |
| 605 | + $answer_notes = get_post_meta($question_id, '_answer_feedback', true); | |
| 606 | +			if ( ! empty($answer_notes)) { | |
| 607 | + update_comment_meta($user_answer_id, 'answer_note', base64_encode($answer_notes)); | |
| 608 | 608 | } | 
| 609 | 609 | |
| 610 | 610 | } | 
| @@ -612,15 +612,15 @@ discard block | ||
| 612 | 612 | return $activity_logged; | 
| 613 | 613 | } | 
| 614 | 614 | |
| 615 | -	public static function sensei_delete_question_grade( $question_id = 0, $user_id = 0 ) { | |
| 616 | -		if( intval( $user_id ) == 0 ) { | |
| 615 | +	public static function sensei_delete_question_grade($question_id = 0, $user_id = 0) { | |
| 616 | +		if (intval($user_id) == 0) { | |
| 617 | 617 | $user_id = get_current_user_id(); | 
| 618 | 618 | } | 
| 619 | 619 | |
| 620 | 620 | $activity_logged = false; | 
| 621 | -		if( intval( $question_id ) > 0 ) { | |
| 622 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); | |
| 623 | - $activity_logged = delete_comment_meta( $user_answer_id, 'user_grade' ); | |
| 621 | +		if (intval($question_id) > 0) { | |
| 622 | +			$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); | |
| 623 | + $activity_logged = delete_comment_meta($user_answer_id, 'user_grade'); | |
| 624 | 624 | } | 
| 625 | 625 | |
| 626 | 626 | return $activity_logged; | 
| @@ -638,9 +638,9 @@ discard block | ||
| 638 | 638 | * | 
| 639 | 639 | * @return mixed boolean or comment_ID | 
| 640 | 640 | */ | 
| 641 | -    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) { | |
| 641 | +    public static function user_start_lesson($user_id = 0, $lesson_id = 0, $complete = false) { | |
| 642 | 642 | |
| 643 | - return self::sensei_start_lesson( $lesson_id, $user_id, $complete ); | |
| 643 | + return self::sensei_start_lesson($lesson_id, $user_id, $complete); | |
| 644 | 644 | |
| 645 | 645 | }// end user_start_lesson() | 
| 646 | 646 | |
| @@ -657,22 +657,22 @@ discard block | ||
| 657 | 657 | * | 
| 658 | 658 | * @return mixed boolean or comment_ID | 
| 659 | 659 | */ | 
| 660 | -	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) { | |
| 660 | +	public static function sensei_start_lesson($lesson_id = 0, $user_id = 0, $complete = false) { | |
| 661 | 661 | |
| 662 | 662 | |
| 663 | -		if( intval( $user_id ) == 0 ) { | |
| 663 | +		if (intval($user_id) == 0) { | |
| 664 | 664 | $user_id = get_current_user_id(); | 
| 665 | 665 | } | 
| 666 | 666 | |
| 667 | 667 | $activity_logged = false; | 
| 668 | 668 | |
| 669 | -		if( intval( $lesson_id ) > 0 ) { | |
| 669 | +		if (intval($lesson_id) > 0) { | |
| 670 | 670 | |
| 671 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); | |
| 672 | -			if( $course_id ) { | |
| 673 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, $user_id ); | |
| 674 | -				if( ! $is_user_taking_course ) { | |
| 675 | - Sensei_Utils::user_start_course( $user_id, $course_id ); | |
| 671 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); | |
| 672 | +			if ($course_id) { | |
| 673 | + $is_user_taking_course = Sensei_Utils::user_started_course($course_id, $user_id); | |
| 674 | +				if ( ! $is_user_taking_course) { | |
| 675 | + Sensei_Utils::user_start_course($user_id, $course_id); | |
| 676 | 676 | } | 
| 677 | 677 | } | 
| 678 | 678 | |
| @@ -680,12 +680,12 @@ discard block | ||
| 680 | 680 | $status = 'in-progress'; | 
| 681 | 681 | |
| 682 | 682 | // Note: When this action runs the lesson status may not yet exist | 
| 683 | - do_action( 'sensei_user_lesson_start', $user_id, $lesson_id ); | |
| 683 | +			do_action('sensei_user_lesson_start', $user_id, $lesson_id); | |
| 684 | 684 | |
| 685 | -			if( $complete ) { | |
| 685 | +			if ($complete) { | |
| 686 | 686 | |
| 687 | - $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); | |
| 688 | -				if ( $has_questions ) { | |
| 687 | + $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); | |
| 688 | +				if ($has_questions) { | |
| 689 | 689 | $status = 'passed'; // Force a pass | 
| 690 | 690 | $metadata['grade'] = 0; | 
| 691 | 691 | } | 
| @@ -695,31 +695,31 @@ discard block | ||
| 695 | 695 | } | 
| 696 | 696 | |
| 697 | 697 | // Check if user is already taking the lesson | 
| 698 | - $activity_logged = Sensei_Utils::user_started_lesson( $lesson_id, $user_id ); | |
| 699 | -			if( ! $activity_logged ) { | |
| 698 | + $activity_logged = Sensei_Utils::user_started_lesson($lesson_id, $user_id); | |
| 699 | +			if ( ! $activity_logged) { | |
| 700 | 700 | |
| 701 | 701 |  				$metadata['start'] = current_time('mysql'); | 
| 702 | - $activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata ); | |
| 702 | + $activity_logged = Sensei_Utils::update_lesson_status($user_id, $lesson_id, $status, $metadata); | |
| 703 | 703 | |
| 704 | 704 |              } else { | 
| 705 | 705 | |
| 706 | 706 | // if users is already taking the lesson and the status changes to complete update it | 
| 707 | 707 | $current_user_activity = get_comment($activity_logged); | 
| 708 | - if( $status=='complete' && | |
| 709 | -                    $status != $current_user_activity->comment_approved  ){ | |
| 708 | + if ($status == 'complete' && | |
| 709 | +                    $status != $current_user_activity->comment_approved) { | |
| 710 | 710 | |
| 711 | 711 | $comment = array(); | 
| 712 | 712 | $comment['comment_ID'] = $activity_logged; | 
| 713 | 713 | $comment['comment_approved'] = $status; | 
| 714 | - wp_update_comment( $comment ); | |
| 714 | + wp_update_comment($comment); | |
| 715 | 715 | |
| 716 | 716 | } | 
| 717 | 717 | |
| 718 | 718 | } | 
| 719 | 719 | |
| 720 | -			if ( $complete ) { | |
| 720 | +			if ($complete) { | |
| 721 | 721 | // Run this *after* the lesson status has been created/updated | 
| 722 | - do_action( 'sensei_user_lesson_end', $user_id, $lesson_id ); | |
| 722 | +				do_action('sensei_user_lesson_end', $user_id, $lesson_id); | |
| 723 | 723 | } | 
| 724 | 724 | |
| 725 | 725 | } | 
| @@ -734,20 +734,20 @@ discard block | ||
| 734 | 734 | * @param int $user_id | 
| 735 | 735 | * @return boolean | 
| 736 | 736 | */ | 
| 737 | -	public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) { | |
| 737 | +	public static function sensei_remove_user_from_lesson($lesson_id = 0, $user_id = 0, $from_course = false) { | |
| 738 | 738 | |
| 739 | 739 | |
| 740 | - if( ! $lesson_id ) return false; | |
| 740 | + if ( ! $lesson_id) return false; | |
| 741 | 741 | |
| 742 | -		if( intval( $user_id ) == 0 ) { | |
| 742 | +		if (intval($user_id) == 0) { | |
| 743 | 743 | $user_id = get_current_user_id(); | 
| 744 | 744 | } | 
| 745 | 745 | |
| 746 | 746 | // Process quiz | 
| 747 | - $lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); | |
| 747 | + $lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); | |
| 748 | 748 | |
| 749 | 749 | // Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade | 
| 750 | - Sensei_Utils::sensei_delete_quiz_answers( $lesson_quiz_id, $user_id ); | |
| 750 | + Sensei_Utils::sensei_delete_quiz_answers($lesson_quiz_id, $user_id); | |
| 751 | 751 | |
| 752 | 752 | // Delete lesson status | 
| 753 | 753 | $args = array( | 
| @@ -756,10 +756,10 @@ discard block | ||
| 756 | 756 | 'user_id' => $user_id, | 
| 757 | 757 | ); | 
| 758 | 758 | // This auto deletes the corresponding meta data, such as the quiz grade, and questions asked | 
| 759 | - Sensei_Utils::sensei_delete_activities( $args ); | |
| 759 | + Sensei_Utils::sensei_delete_activities($args); | |
| 760 | 760 | |
| 761 | -		if( ! $from_course ) { | |
| 762 | - do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id ); | |
| 761 | +		if ( ! $from_course) { | |
| 762 | +			do_action('sensei_user_lesson_reset', $user_id, $lesson_id); | |
| 763 | 763 | } | 
| 764 | 764 | |
| 765 | 765 | return true; | 
| @@ -772,19 +772,19 @@ discard block | ||
| 772 | 772 | * @param int $user_id | 
| 773 | 773 | * @return boolean | 
| 774 | 774 | */ | 
| 775 | -	public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) { | |
| 775 | +	public static function sensei_remove_user_from_course($course_id = 0, $user_id = 0) { | |
| 776 | 776 | |
| 777 | 777 | |
| 778 | - if( ! $course_id ) return false; | |
| 778 | + if ( ! $course_id) return false; | |
| 779 | 779 | |
| 780 | -		if( intval( $user_id ) == 0 ) { | |
| 780 | +		if (intval($user_id) == 0) { | |
| 781 | 781 | $user_id = get_current_user_id(); | 
| 782 | 782 | } | 
| 783 | 783 | |
| 784 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); | |
| 784 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); | |
| 785 | 785 | |
| 786 | -		foreach( $lesson_ids as $lesson_id ) { | |
| 787 | - Sensei_Utils::sensei_remove_user_from_lesson( $lesson_id, $user_id, true ); | |
| 786 | +		foreach ($lesson_ids as $lesson_id) { | |
| 787 | + Sensei_Utils::sensei_remove_user_from_lesson($lesson_id, $user_id, true); | |
| 788 | 788 | } | 
| 789 | 789 | |
| 790 | 790 | // Delete course status | 
| @@ -794,36 +794,36 @@ discard block | ||
| 794 | 794 | 'user_id' => $user_id, | 
| 795 | 795 | ); | 
| 796 | 796 | |
| 797 | - Sensei_Utils::sensei_delete_activities( $args ); | |
| 797 | + Sensei_Utils::sensei_delete_activities($args); | |
| 798 | 798 | |
| 799 | - do_action( 'sensei_user_course_reset', $user_id, $course_id ); | |
| 799 | +		do_action('sensei_user_course_reset', $user_id, $course_id); | |
| 800 | 800 | |
| 801 | 801 | return true; | 
| 802 | 802 | } | 
| 803 | 803 | |
| 804 | -	public static function sensei_get_quiz_questions( $quiz_id = 0 ) { | |
| 804 | +	public static function sensei_get_quiz_questions($quiz_id = 0) { | |
| 805 | 805 | |
| 806 | 806 | |
| 807 | 807 | $questions = array(); | 
| 808 | 808 | |
| 809 | -		if( intval( $quiz_id ) > 0 ) { | |
| 810 | - $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); | |
| 811 | - $questions = Sensei_Utils::array_sort_reorder( $questions ); | |
| 809 | +		if (intval($quiz_id) > 0) { | |
| 810 | + $questions = Sensei()->lesson->lesson_quiz_questions($quiz_id); | |
| 811 | + $questions = Sensei_Utils::array_sort_reorder($questions); | |
| 812 | 812 | } | 
| 813 | 813 | |
| 814 | 814 | return $questions; | 
| 815 | 815 | } | 
| 816 | 816 | |
| 817 | -	public static function sensei_get_quiz_total( $quiz_id = 0 ) { | |
| 817 | +	public static function sensei_get_quiz_total($quiz_id = 0) { | |
| 818 | 818 | |
| 819 | 819 | |
| 820 | 820 | $quiz_total = 0; | 
| 821 | 821 | |
| 822 | -		if( $quiz_id > 0 ) { | |
| 823 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); | |
| 822 | +		if ($quiz_id > 0) { | |
| 823 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); | |
| 824 | 824 | $question_grade = 0; | 
| 825 | -			foreach( $questions as $question ) { | |
| 826 | - $question_grade = Sensei()->question->get_question_grade( $question->ID ); | |
| 825 | +			foreach ($questions as $question) { | |
| 826 | + $question_grade = Sensei()->question->get_question_grade($question->ID); | |
| 827 | 827 | $quiz_total += $question_grade; | 
| 828 | 828 | } | 
| 829 | 829 | } | 
| @@ -838,20 +838,20 @@ discard block | ||
| 838 | 838 | * @param int $user_id | 
| 839 | 839 | * @return string | 
| 840 | 840 | */ | 
| 841 | -	public static function sensei_get_user_question_grade( $question = 0, $user_id = 0 ) { | |
| 841 | +	public static function sensei_get_user_question_grade($question = 0, $user_id = 0) { | |
| 842 | 842 | $question_grade = false; | 
| 843 | -		if( $question ) { | |
| 844 | -			if ( is_object( $question ) ) { | |
| 843 | +		if ($question) { | |
| 844 | +			if (is_object($question)) { | |
| 845 | 845 | $user_answer_id = $question->comment_ID; | 
| 846 | 846 | } | 
| 847 | 847 |  			else { | 
| 848 | -				if( intval( $user_id ) == 0 ) { | |
| 848 | +				if (intval($user_id) == 0) { | |
| 849 | 849 | $user_id = get_current_user_id(); | 
| 850 | 850 | } | 
| 851 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); | |
| 851 | +				$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); | |
| 852 | 852 | } | 
| 853 | -			if ( $user_answer_id ) { | |
| 854 | - $question_grade = get_comment_meta( $user_answer_id, 'user_grade', true ); | |
| 853 | +			if ($user_answer_id) { | |
| 854 | + $question_grade = get_comment_meta($user_answer_id, 'user_grade', true); | |
| 855 | 855 | } | 
| 856 | 856 | } | 
| 857 | 857 | |
| @@ -866,52 +866,52 @@ discard block | ||
| 866 | 866 | * @param int $user_id | 
| 867 | 867 | * @return string | 
| 868 | 868 | */ | 
| 869 | -	public static function sensei_get_user_question_answer_notes( $question = 0, $user_id = 0 ) { | |
| 869 | +	public static function sensei_get_user_question_answer_notes($question = 0, $user_id = 0) { | |
| 870 | 870 | $answer_notes = false; | 
| 871 | -		if( $question ) { | |
| 872 | -			if ( is_object( $question ) ) { | |
| 871 | +		if ($question) { | |
| 872 | +			if (is_object($question)) { | |
| 873 | 873 | $user_answer_id = $question->comment_ID; | 
| 874 | 874 | } | 
| 875 | 875 |  			else { | 
| 876 | -				if( intval( $user_id ) == 0 ) { | |
| 876 | +				if (intval($user_id) == 0) { | |
| 877 | 877 | $user_id = get_current_user_id(); | 
| 878 | 878 | } | 
| 879 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); | |
| 879 | +				$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); | |
| 880 | 880 | } | 
| 881 | -			if ( $user_answer_id ) { | |
| 882 | - $answer_notes = base64_decode( get_comment_meta( $user_answer_id, 'answer_note', true ) ); | |
| 881 | +			if ($user_answer_id) { | |
| 882 | + $answer_notes = base64_decode(get_comment_meta($user_answer_id, 'answer_note', true)); | |
| 883 | 883 | } | 
| 884 | 884 | } | 
| 885 | 885 | |
| 886 | 886 | return $answer_notes; | 
| 887 | 887 | } | 
| 888 | 888 | |
| 889 | -	public static function sensei_delete_quiz_answers( $quiz_id = 0, $user_id = 0 ) { | |
| 890 | -		if( intval( $user_id ) == 0 ) { | |
| 889 | +	public static function sensei_delete_quiz_answers($quiz_id = 0, $user_id = 0) { | |
| 890 | +		if (intval($user_id) == 0) { | |
| 891 | 891 | $user_id = get_current_user_id(); | 
| 892 | 892 | } | 
| 893 | 893 | |
| 894 | 894 | $delete_answers = false; | 
| 895 | -		if( intval( $quiz_id ) > 0 ) { | |
| 896 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); | |
| 897 | -			foreach( $questions as $question ) { | |
| 898 | - $delete_answers = Sensei_Utils::sensei_delete_activities( array( 'post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ) ); | |
| 895 | +		if (intval($quiz_id) > 0) { | |
| 896 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); | |
| 897 | +			foreach ($questions as $question) { | |
| 898 | +				$delete_answers = Sensei_Utils::sensei_delete_activities(array('post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer')); | |
| 899 | 899 | } | 
| 900 | 900 | } | 
| 901 | 901 | |
| 902 | 902 | return $delete_answers; | 
| 903 | 903 | } | 
| 904 | 904 | |
| 905 | -	public static function sensei_delete_quiz_grade( $quiz_id = 0, $user_id = 0 ) { | |
| 906 | -		if( intval( $user_id ) == 0 ) { | |
| 905 | +	public static function sensei_delete_quiz_grade($quiz_id = 0, $user_id = 0) { | |
| 906 | +		if (intval($user_id) == 0) { | |
| 907 | 907 | $user_id = get_current_user_id(); | 
| 908 | 908 | } | 
| 909 | 909 | |
| 910 | 910 | $delete_grade = false; | 
| 911 | -		if( intval( $quiz_id ) > 0 ) { | |
| 912 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); | |
| 913 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); | |
| 914 | - $delete_grade = delete_comment_meta( $user_lesson_status->comment_ID, 'grade' ); | |
| 911 | +		if (intval($quiz_id) > 0) { | |
| 912 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); | |
| 913 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); | |
| 914 | + $delete_grade = delete_comment_meta($user_lesson_status->comment_ID, 'grade'); | |
| 915 | 915 | } | 
| 916 | 916 | |
| 917 | 917 | return $delete_grade; | 
| @@ -924,20 +924,20 @@ discard block | ||
| 924 | 924 | * @param string $notes | 
| 925 | 925 | * @return boolean | 
| 926 | 926 | */ | 
| 927 | -	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) { | |
| 928 | -		if( intval( $user_id ) == 0 ) { | |
| 927 | +	public static function sensei_add_answer_notes($question_id = 0, $user_id = 0, $notes = '') { | |
| 928 | +		if (intval($user_id) == 0) { | |
| 929 | 929 | $user_id = get_current_user_id(); | 
| 930 | 930 | } | 
| 931 | 931 | |
| 932 | 932 | $activity_logged = false; | 
| 933 | 933 | |
| 934 | -		if( intval( $question_id ) > 0 ) { | |
| 935 | - $notes = base64_encode( $notes ); | |
| 934 | +		if (intval($question_id) > 0) { | |
| 935 | + $notes = base64_encode($notes); | |
| 936 | 936 | |
| 937 | 937 | // Don't store empty values, no point | 
| 938 | -			if ( !empty($notes) ) { | |
| 939 | - $user_lesson_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); | |
| 940 | - $activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes ); | |
| 938 | +			if ( ! empty($notes)) { | |
| 939 | +				$user_lesson_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); | |
| 940 | + $activity_logged = update_comment_meta($user_lesson_id, 'answer_note', $notes); | |
| 941 | 941 | } | 
| 942 | 942 |  			else { | 
| 943 | 943 | $activity_logged = true; | 
| @@ -953,16 +953,16 @@ discard block | ||
| 953 | 953 | * @param array $return_array data to be ordered | 
| 954 | 954 | * @return array $return_array ordered data | 
| 955 | 955 | */ | 
| 956 | -	public static function array_sort_reorder( $return_array ) { | |
| 957 | -		if ( isset( $_GET['orderby'] ) && '' != esc_html( $_GET['orderby'] ) ) { | |
| 956 | +	public static function array_sort_reorder($return_array) { | |
| 957 | +		if (isset($_GET['orderby']) && '' != esc_html($_GET['orderby'])) { | |
| 958 | 958 | $sort_key = ''; | 
| 959 | 959 |  			// if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->sortable_columns ) ) { | 
| 960 | 960 | // $sort_key = esc_html( $_GET['orderby'] ); | 
| 961 | 961 | // } // End If Statement | 
| 962 | -			if ( '' != $sort_key ) { | |
| 963 | - Sensei_Utils::sort_array_by_key($return_array,$sort_key); | |
| 964 | -				if ( isset( $_GET['order'] ) && 'desc' == esc_html( $_GET['order'] ) ) { | |
| 965 | - $return_array = array_reverse( $return_array, true ); | |
| 962 | +			if ('' != $sort_key) { | |
| 963 | + Sensei_Utils::sort_array_by_key($return_array, $sort_key); | |
| 964 | +				if (isset($_GET['order']) && 'desc' == esc_html($_GET['order'])) { | |
| 965 | + $return_array = array_reverse($return_array, true); | |
| 966 | 966 | } // End If Statement | 
| 967 | 967 | } // End If Statement | 
| 968 | 968 | return $return_array; | 
| @@ -978,15 +978,15 @@ discard block | ||
| 978 | 978 | * @param $key string column name in array | 
| 979 | 979 | * @return void | 
| 980 | 980 | */ | 
| 981 | -	public static function sort_array_by_key( $array, $key ) { | |
| 981 | +	public static function sort_array_by_key($array, $key) { | |
| 982 | 982 | $sorter = array(); | 
| 983 | 983 | $ret = array(); | 
| 984 | - reset( $array ); | |
| 985 | -	    foreach ( $array as $ii => $va ) { | |
| 984 | + reset($array); | |
| 985 | +	    foreach ($array as $ii => $va) { | |
| 986 | 986 | $sorter[$ii] = $va[$key]; | 
| 987 | 987 | } // End For Loop | 
| 988 | - asort( $sorter ); | |
| 989 | -	    foreach ( $sorter as $ii => $va ) { | |
| 988 | + asort($sorter); | |
| 989 | +	    foreach ($sorter as $ii => $va) { | |
| 990 | 990 | $ret[$ii] = $array[$ii]; | 
| 991 | 991 | } // End For Loop | 
| 992 | 992 | $array = $ret; | 
| @@ -998,10 +998,10 @@ discard block | ||
| 998 | 998 | * @param integer $quiz_id | 
| 999 | 999 | * @return array of quiz questions | 
| 1000 | 1000 | */ | 
| 1001 | -	public static function lesson_quiz_questions( $quiz_id = 0 ) { | |
| 1001 | +	public static function lesson_quiz_questions($quiz_id = 0) { | |
| 1002 | 1002 | $questions_array = array(); | 
| 1003 | -		if ( 0 < $quiz_id ) { | |
| 1004 | - $question_args = array( 'post_type' => 'question', | |
| 1003 | +		if (0 < $quiz_id) { | |
| 1004 | +			$question_args = array('post_type'         => 'question', | |
| 1005 | 1005 | 'posts_per_page' => -1, | 
| 1006 | 1006 | 'orderby' => 'ID', | 
| 1007 | 1007 | 'order' => 'ASC', | 
| @@ -1014,7 +1014,7 @@ discard block | ||
| 1014 | 1014 | 'post_status' => 'any', | 
| 1015 | 1015 | 'suppress_filters' => 0 | 
| 1016 | 1016 | ); | 
| 1017 | - $questions_array = get_posts( $question_args ); | |
| 1017 | + $questions_array = get_posts($question_args); | |
| 1018 | 1018 | } // End If Statement | 
| 1019 | 1019 | return $questions_array; | 
| 1020 | 1020 | } // End lesson_quiz_questions() | 
| @@ -1024,25 +1024,25 @@ discard block | ||
| 1024 | 1024 | * @param integer $course_id ID of course | 
| 1025 | 1025 | * @return integer Pass mark for course | 
| 1026 | 1026 | */ | 
| 1027 | -	public static function sensei_course_pass_grade( $course_id = 0 ) { | |
| 1027 | +	public static function sensei_course_pass_grade($course_id = 0) { | |
| 1028 | 1028 | |
| 1029 | 1029 | |
| 1030 | 1030 | $course_passmark = 0; | 
| 1031 | 1031 | |
| 1032 | -		if( $course_id > 0 ) { | |
| 1033 | - $lessons = Sensei()->course->course_lessons( $course_id ); | |
| 1032 | +		if ($course_id > 0) { | |
| 1033 | + $lessons = Sensei()->course->course_lessons($course_id); | |
| 1034 | 1034 | $lesson_count = 0; | 
| 1035 | 1035 | $total_passmark = 0; | 
| 1036 | -			foreach( $lessons as $lesson ) { | |
| 1036 | +			foreach ($lessons as $lesson) { | |
| 1037 | 1037 | |
| 1038 | 1038 | // Get Quiz ID | 
| 1039 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID ); | |
| 1039 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson->ID); | |
| 1040 | 1040 | |
| 1041 | 1041 | // Check for a pass being required | 
| 1042 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); | |
| 1043 | -				if ( $pass_required ) { | |
| 1042 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); | |
| 1043 | +				if ($pass_required) { | |
| 1044 | 1044 | // Get quiz passmark | 
| 1045 | - $quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) ); | |
| 1045 | + $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true)); | |
| 1046 | 1046 | |
| 1047 | 1047 | // Add up total passmark | 
| 1048 | 1048 | $total_passmark += $quiz_passmark; | 
| @@ -1051,12 +1051,12 @@ discard block | ||
| 1051 | 1051 | } | 
| 1052 | 1052 | } | 
| 1053 | 1053 | // Might be a case of no required lessons | 
| 1054 | -			if ( $lesson_count ) { | |
| 1055 | - $course_passmark = ( $total_passmark / $lesson_count ); | |
| 1054 | +			if ($lesson_count) { | |
| 1055 | + $course_passmark = ($total_passmark / $lesson_count); | |
| 1056 | 1056 | } | 
| 1057 | 1057 | } | 
| 1058 | 1058 | |
| 1059 | - return Sensei_Utils::round( $course_passmark ); | |
| 1059 | + return Sensei_Utils::round($course_passmark); | |
| 1060 | 1060 | } | 
| 1061 | 1061 | |
| 1062 | 1062 | /** | 
| @@ -1065,27 +1065,27 @@ discard block | ||
| 1065 | 1065 | * @param integer $user_id ID of user | 
| 1066 | 1066 | * @return integer User's total grade | 
| 1067 | 1067 | */ | 
| 1068 | -	public static function sensei_course_user_grade( $course_id = 0, $user_id = 0 ) { | |
| 1068 | +	public static function sensei_course_user_grade($course_id = 0, $user_id = 0) { | |
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | -		if( intval( $user_id ) == 0 ) { | |
| 1071 | +		if (intval($user_id) == 0) { | |
| 1072 | 1072 | $user_id = get_current_user_id(); | 
| 1073 | 1073 | } | 
| 1074 | 1074 | |
| 1075 | 1075 | $total_grade = 0; | 
| 1076 | 1076 | |
| 1077 | -		if( $course_id > 0 && $user_id > 0 ) { | |
| 1078 | - $lessons = Sensei()->course->course_lessons( $course_id ); | |
| 1077 | +		if ($course_id > 0 && $user_id > 0) { | |
| 1078 | + $lessons = Sensei()->course->course_lessons($course_id); | |
| 1079 | 1079 | $lesson_count = 0; | 
| 1080 | 1080 | $total_grade = 0; | 
| 1081 | -			foreach( $lessons as $lesson ) { | |
| 1081 | +			foreach ($lessons as $lesson) { | |
| 1082 | 1082 | |
| 1083 | 1083 | // Check for lesson having questions, thus a quiz, thus having a grade | 
| 1084 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); | |
| 1085 | -				if ( $has_questions ) { | |
| 1086 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, $user_id ); | |
| 1084 | + $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true); | |
| 1085 | +				if ($has_questions) { | |
| 1086 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, $user_id); | |
| 1087 | 1087 | // Get user quiz grade | 
| 1088 | - $quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); | |
| 1088 | + $quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); | |
| 1089 | 1089 | |
| 1090 | 1090 | // Add up total grade | 
| 1091 | 1091 | $total_grade += $quiz_grade; | 
| @@ -1095,13 +1095,13 @@ discard block | ||
| 1095 | 1095 | } | 
| 1096 | 1096 | |
| 1097 | 1097 | // Might be a case of no lessons with quizzes | 
| 1098 | -			if ( $lesson_count ) { | |
| 1099 | - $total_grade = ( $total_grade / $lesson_count ); | |
| 1098 | +			if ($lesson_count) { | |
| 1099 | + $total_grade = ($total_grade / $lesson_count); | |
| 1100 | 1100 | } | 
| 1101 | 1101 | |
| 1102 | 1102 | } | 
| 1103 | 1103 | |
| 1104 | - return Sensei_Utils::round( $total_grade ); | |
| 1104 | + return Sensei_Utils::round($total_grade); | |
| 1105 | 1105 | } | 
| 1106 | 1106 | |
| 1107 | 1107 | /** | 
| @@ -1110,18 +1110,18 @@ discard block | ||
| 1110 | 1110 | * @param integer $user_id ID of user | 
| 1111 | 1111 | * @return boolean | 
| 1112 | 1112 | */ | 
| 1113 | -	public static function sensei_user_passed_course( $course_id = 0, $user_id = 0 ) { | |
| 1114 | -		if( intval( $user_id ) == 0 ) { | |
| 1113 | +	public static function sensei_user_passed_course($course_id = 0, $user_id = 0) { | |
| 1114 | +		if (intval($user_id) == 0) { | |
| 1115 | 1115 | $user_id = get_current_user_id(); | 
| 1116 | 1116 | } | 
| 1117 | 1117 | |
| 1118 | 1118 | $pass = false; | 
| 1119 | 1119 | |
| 1120 | -		if( $course_id > 0 && $user_id > 0 ) { | |
| 1121 | - $passmark = Sensei_Utils::sensei_course_pass_grade( $course_id ); | |
| 1122 | - $user_grade = Sensei_Utils::sensei_course_user_grade( $course_id, $user_id ); | |
| 1120 | +		if ($course_id > 0 && $user_id > 0) { | |
| 1121 | + $passmark = Sensei_Utils::sensei_course_pass_grade($course_id); | |
| 1122 | + $user_grade = Sensei_Utils::sensei_course_user_grade($course_id, $user_id); | |
| 1123 | 1123 | |
| 1124 | -			if( $user_grade >= $passmark ) { | |
| 1124 | +			if ($user_grade >= $passmark) { | |
| 1125 | 1125 | $pass = true; | 
| 1126 | 1126 | } | 
| 1127 | 1127 | } | 
| @@ -1136,38 +1136,38 @@ discard block | ||
| 1136 | 1136 | * @param integer $user_id ID of user | 
| 1137 | 1137 | * @return array Status code and message | 
| 1138 | 1138 | */ | 
| 1139 | -	public static function sensei_user_course_status_message( $course_id = 0, $user_id = 0 ) { | |
| 1140 | -		if( intval( $user_id ) == 0 ) { | |
| 1139 | +	public static function sensei_user_course_status_message($course_id = 0, $user_id = 0) { | |
| 1140 | +		if (intval($user_id) == 0) { | |
| 1141 | 1141 | $user_id = get_current_user_id(); | 
| 1142 | 1142 | } | 
| 1143 | 1143 | |
| 1144 | 1144 | $status = 'not_started'; | 
| 1145 | 1145 | $box_class = 'info'; | 
| 1146 | - $message = __( 'You have not started this course yet.', 'woothemes-sensei' ); | |
| 1146 | +		$message = __('You have not started this course yet.', 'woothemes-sensei'); | |
| 1147 | 1147 | |
| 1148 | -		if( $course_id > 0 && $user_id > 0 ) { | |
| 1148 | +		if ($course_id > 0 && $user_id > 0) { | |
| 1149 | 1149 | |
| 1150 | - $started_course = Sensei_Utils::user_started_course( $course_id, $user_id ); | |
| 1150 | + $started_course = Sensei_Utils::user_started_course($course_id, $user_id); | |
| 1151 | 1151 | |
| 1152 | -			if( $started_course ) { | |
| 1153 | - $passmark = Sensei_Utils::sensei_course_pass_grade( $course_id ); // This happens inside sensei_user_passed_course()! | |
| 1154 | - $user_grade = Sensei_Utils::sensei_course_user_grade( $course_id, $user_id ); // This happens inside sensei_user_passed_course()! | |
| 1155 | -				if( $user_grade >= $passmark ) { | |
| 1152 | +			if ($started_course) { | |
| 1153 | + $passmark = Sensei_Utils::sensei_course_pass_grade($course_id); // This happens inside sensei_user_passed_course()! | |
| 1154 | + $user_grade = Sensei_Utils::sensei_course_user_grade($course_id, $user_id); // This happens inside sensei_user_passed_course()! | |
| 1155 | +				if ($user_grade >= $passmark) { | |
| 1156 | 1156 | $status = 'passed'; | 
| 1157 | 1157 | $box_class = 'tick'; | 
| 1158 | - $message = sprintf( __( 'You have passed this course with a grade of %1$d%%.', 'woothemes-sensei' ), $user_grade ); | |
| 1158 | +					$message = sprintf(__('You have passed this course with a grade of %1$d%%.', 'woothemes-sensei'), $user_grade); | |
| 1159 | 1159 |  				} else { | 
| 1160 | 1160 | $status = 'failed'; | 
| 1161 | 1161 | $box_class = 'alert'; | 
| 1162 | - $message = sprintf( __( 'You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei' ), $passmark, $user_grade ); | |
| 1162 | +					$message = sprintf(__('You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei'), $passmark, $user_grade); | |
| 1163 | 1163 | } | 
| 1164 | 1164 | } | 
| 1165 | 1165 | |
| 1166 | 1166 | } | 
| 1167 | 1167 | |
| 1168 | - $message = apply_filters( 'sensei_user_course_status_' . $status, $message ); | |
| 1168 | +		$message = apply_filters('sensei_user_course_status_'.$status, $message); | |
| 1169 | 1169 | |
| 1170 | - return array( 'status' => $status, 'box_class' => $box_class, 'message' => $message ); | |
| 1170 | +		return array('status' => $status, 'box_class' => $box_class, 'message' => $message); | |
| 1171 | 1171 | } | 
| 1172 | 1172 | |
| 1173 | 1173 | /** | 
| @@ -1177,94 +1177,94 @@ discard block | ||
| 1177 | 1177 | * @param bool $is_lesson | 
| 1178 | 1178 | * @return array Status code and message | 
| 1179 | 1179 | */ | 
| 1180 | -	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) { | |
| 1180 | +	public static function sensei_user_quiz_status_message($lesson_id = 0, $user_id = 0, $is_lesson = false) { | |
| 1181 | 1181 | global $current_user; | 
| 1182 | -		if( intval( $user_id ) == 0 ) { | |
| 1182 | +		if (intval($user_id) == 0) { | |
| 1183 | 1183 | $user_id = $current_user->ID; | 
| 1184 | 1184 | } | 
| 1185 | 1185 | |
| 1186 | 1186 | $status = 'not_started'; | 
| 1187 | 1187 | $box_class = 'info'; | 
| 1188 | - $message = __( "You have not taken this lesson's quiz yet", 'woothemes-sensei' ); | |
| 1188 | +		$message = __("You have not taken this lesson's quiz yet", 'woothemes-sensei'); | |
| 1189 | 1189 | $extra = ''; | 
| 1190 | 1190 | |
| 1191 | -		if( $lesson_id > 0 && $user_id > 0 ) { | |
| 1191 | +		if ($lesson_id > 0 && $user_id > 0) { | |
| 1192 | 1192 | |
| 1193 | 1193 | // Prerequisite lesson | 
| 1194 | - $prerequisite = get_post_meta( $lesson_id, '_lesson_prerequisite', true ); | |
| 1194 | + $prerequisite = get_post_meta($lesson_id, '_lesson_prerequisite', true); | |
| 1195 | 1195 | |
| 1196 | 1196 | // Course ID | 
| 1197 | - $course_id = absint( get_post_meta( $lesson_id, '_lesson_course', true ) ); | |
| 1197 | + $course_id = absint(get_post_meta($lesson_id, '_lesson_course', true)); | |
| 1198 | 1198 | |
| 1199 | 1199 | // Has user started course | 
| 1200 | - $started_course = Sensei_Utils::user_started_course( $course_id, $user_id ); | |
| 1200 | + $started_course = Sensei_Utils::user_started_course($course_id, $user_id); | |
| 1201 | 1201 | |
| 1202 | 1202 | // Has user completed lesson | 
| 1203 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); | |
| 1204 | - $lesson_complete = Sensei_Utils::user_completed_lesson( $user_lesson_status ); | |
| 1203 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); | |
| 1204 | + $lesson_complete = Sensei_Utils::user_completed_lesson($user_lesson_status); | |
| 1205 | 1205 | |
| 1206 | 1206 | // Quiz ID | 
| 1207 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); | |
| 1207 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); | |
| 1208 | 1208 | |
| 1209 | 1209 | // Quiz grade | 
| 1210 | 1210 | $quiz_grade = 0; | 
| 1211 | -			if ( $user_lesson_status ) { | |
| 1212 | - $quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); | |
| 1211 | +			if ($user_lesson_status) { | |
| 1212 | + $quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); | |
| 1213 | 1213 | } | 
| 1214 | 1214 | |
| 1215 | 1215 | // Quiz passmark | 
| 1216 | - $quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) ); | |
| 1216 | + $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true)); | |
| 1217 | 1217 | $quiz_passmark_float = (float) $quiz_passmark; | 
| 1218 | 1218 | |
| 1219 | 1219 | // Pass required | 
| 1220 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); | |
| 1220 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); | |
| 1221 | 1221 | |
| 1222 | 1222 | // Quiz questions | 
| 1223 | - $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); | |
| 1223 | + $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); | |
| 1224 | 1224 | |
| 1225 | -			if ( ! $started_course ) { | |
| 1225 | +			if ( ! $started_course) { | |
| 1226 | 1226 | |
| 1227 | 1227 | $status = 'not_started_course'; | 
| 1228 | 1228 | $box_class = 'info'; | 
| 1229 | - $message = sprintf( __( 'Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . esc_attr( __( 'Sign Up', 'woothemes-sensei' ) ) . '">', '</a>' ); | |
| 1229 | +				$message = sprintf(__('Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.esc_attr(__('Sign Up', 'woothemes-sensei')).'">', '</a>'); | |
| 1230 | 1230 | |
| 1231 | -			} elseif ( ! is_user_logged_in() ) { | |
| 1231 | +			} elseif ( ! is_user_logged_in()) { | |
| 1232 | 1232 | |
| 1233 | 1233 | $status = 'login_required'; | 
| 1234 | 1234 | $box_class = 'info'; | 
| 1235 | - $message = __( 'You must be logged in to take this quiz', 'woothemes-sensei' ); | |
| 1235 | +				$message = __('You must be logged in to take this quiz', 'woothemes-sensei'); | |
| 1236 | 1236 | |
| 1237 | 1237 | } | 
| 1238 | 1238 | // Lesson/Quiz is marked as complete thus passing any quiz restrictions | 
| 1239 | -			elseif ( $lesson_complete ) { | |
| 1239 | +			elseif ($lesson_complete) { | |
| 1240 | 1240 | |
| 1241 | 1241 | $status = 'passed'; | 
| 1242 | 1242 | $box_class = 'tick'; | 
| 1243 | 1243 | // Lesson status will be "complete" (has no Quiz) | 
| 1244 | -				if ( ! $has_quiz_questions ) { | |
| 1245 | - $message = sprintf( __( 'Congratulations! You have passed this lesson.', 'woothemes-sensei' ) ); | |
| 1244 | +				if ( ! $has_quiz_questions) { | |
| 1245 | +					$message = sprintf(__('Congratulations! You have passed this lesson.', 'woothemes-sensei')); | |
| 1246 | 1246 | } | 
| 1247 | 1247 | // Lesson status will be "graded" (no passmark required so might have failed all the questions) | 
| 1248 | -				elseif ( empty( $quiz_grade ) ) { | |
| 1249 | - $message = sprintf( __( 'Congratulations! You have completed this lesson.', 'woothemes-sensei' ) ); | |
| 1248 | +				elseif (empty($quiz_grade)) { | |
| 1249 | +					$message = sprintf(__('Congratulations! You have completed this lesson.', 'woothemes-sensei')); | |
| 1250 | 1250 | } | 
| 1251 | 1251 | // Lesson status will be "passed" (passmark reached) | 
| 1252 | -				elseif ( ! empty( $quiz_grade ) && abs( $quiz_grade ) >= 0 ) { | |
| 1253 | -					if( $is_lesson ) { | |
| 1254 | - $message = sprintf( __( 'Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_grade ) ); | |
| 1252 | +				elseif ( ! empty($quiz_grade) && abs($quiz_grade) >= 0) { | |
| 1253 | +					if ($is_lesson) { | |
| 1254 | +						$message = sprintf(__('Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_grade)); | |
| 1255 | 1255 |  					} else { | 
| 1256 | - $message = sprintf( __( 'Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_grade ) ); | |
| 1256 | +						$message = sprintf(__('Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_grade)); | |
| 1257 | 1257 | } | 
| 1258 | 1258 | } | 
| 1259 | 1259 | |
| 1260 | 1260 | // add next lesson button | 
| 1261 | - $nav_id_array = sensei_get_prev_next_lessons( $lesson_id ); | |
| 1262 | - $next_lesson_id = absint( $nav_id_array['next_lesson'] ); | |
| 1261 | + $nav_id_array = sensei_get_prev_next_lessons($lesson_id); | |
| 1262 | + $next_lesson_id = absint($nav_id_array['next_lesson']); | |
| 1263 | 1263 | |
| 1264 | 1264 | // Output HTML | 
| 1265 | -                if ( ( 0 < $next_lesson_id ) ) { | |
| 1266 | - $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) ) | |
| 1267 | - . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei') | |
| 1265 | +                if ((0 < $next_lesson_id)) { | |
| 1266 | + $message .= ' '.'<a class="next-lesson" href="'.esc_url(get_permalink($next_lesson_id)) | |
| 1267 | +                                . '" rel="next"><span class="meta-nav"></span>'.__('Next Lesson', 'woothemes-sensei') | |
| 1268 | 1268 | .'</a>'; | 
| 1269 | 1269 | |
| 1270 | 1270 | } | 
| @@ -1273,33 +1273,33 @@ discard block | ||
| 1273 | 1273 | // Lesson/Quiz not complete | 
| 1274 | 1274 |  			else { | 
| 1275 | 1275 | // Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete) | 
| 1276 | -				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) { | |
| 1276 | +				if (isset($user_lesson_status->comment_approved) && 'ungraded' == $user_lesson_status->comment_approved) { | |
| 1277 | 1277 | $status = 'complete'; | 
| 1278 | 1278 | $box_class = 'info'; | 
| 1279 | -					if( $is_lesson ) { | |
| 1280 | - $message = sprintf( __( 'You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . esc_attr( get_the_title( $quiz_id ) ) . '">', '</a>' ); | |
| 1279 | +					if ($is_lesson) { | |
| 1280 | +						$message = sprintf(__('You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($quiz_id)).'" title="'.esc_attr(get_the_title($quiz_id)).'">', '</a>'); | |
| 1281 | 1281 |  					} else { | 
| 1282 | - $message = sprintf( __( 'You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ) ); | |
| 1282 | +						$message = sprintf(__('You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark)); | |
| 1283 | 1283 | } | 
| 1284 | 1284 | } | 
| 1285 | 1285 | // Lesson status must be "failed" | 
| 1286 | -				elseif ( isset( $user_lesson_status->comment_approved ) && 'failed' == $user_lesson_status->comment_approved ) { | |
| 1286 | +				elseif (isset($user_lesson_status->comment_approved) && 'failed' == $user_lesson_status->comment_approved) { | |
| 1287 | 1287 | $status = 'failed'; | 
| 1288 | 1288 | $box_class = 'alert'; | 
| 1289 | -					if( $is_lesson ) { | |
| 1290 | - $message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ), Sensei_Utils::round( $quiz_grade ) ); | |
| 1289 | +					if ($is_lesson) { | |
| 1290 | +						$message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark), Sensei_Utils::round($quiz_grade)); | |
| 1291 | 1291 |  					} else { | 
| 1292 | - $message = sprintf( __( 'You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ), Sensei_Utils::round( $quiz_grade ) ); | |
| 1292 | +						$message = sprintf(__('You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark), Sensei_Utils::round($quiz_grade)); | |
| 1293 | 1293 | } | 
| 1294 | 1294 | } | 
| 1295 | 1295 | // Lesson/Quiz requires a pass | 
| 1296 | -				elseif( $pass_required ) { | |
| 1296 | +				elseif ($pass_required) { | |
| 1297 | 1297 | $status = 'not_started'; | 
| 1298 | 1298 | $box_class = 'info'; | 
| 1299 | -					if( $is_lesson ) { | |
| 1300 | - $message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ) ); | |
| 1299 | +					if ($is_lesson) { | |
| 1300 | +						$message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark)); | |
| 1301 | 1301 |  					} else { | 
| 1302 | - $message = sprintf( __( 'You require %1$d%% to pass this quiz.', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ) ); | |
| 1302 | +						$message = sprintf(__('You require %1$d%% to pass this quiz.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark)); | |
| 1303 | 1303 | } | 
| 1304 | 1304 | } | 
| 1305 | 1305 | } | 
| @@ -1307,15 +1307,15 @@ discard block | ||
| 1307 | 1307 | } | 
| 1308 | 1308 | |
| 1309 | 1309 | // Legacy filter | 
| 1310 | - $message = apply_filters( 'sensei_user_quiz_status_' . $status, $message ); | |
| 1310 | +		$message = apply_filters('sensei_user_quiz_status_'.$status, $message); | |
| 1311 | 1311 | |
| 1312 | -		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) { | |
| 1313 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); | |
| 1314 | - $extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '</a></p>'; | |
| 1312 | +		if ($is_lesson && ! in_array($status, array('login_required', 'not_started_course'))) { | |
| 1313 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); | |
| 1314 | +			$extra = '<p><a class="button" href="'.esc_url(get_permalink($quiz_id)).'" title="'.__('View the lesson quiz', 'woothemes-sensei').'">'.__('View the lesson quiz', 'woothemes-sensei').'</a></p>'; | |
| 1315 | 1315 | } | 
| 1316 | 1316 | |
| 1317 | 1317 | // Filter of all messages | 
| 1318 | - return apply_filters( 'sensei_user_quiz_status', array( 'status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra ), $lesson_id, $user_id, $is_lesson ); | |
| 1318 | +		return apply_filters('sensei_user_quiz_status', array('status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra), $lesson_id, $user_id, $is_lesson); | |
| 1319 | 1319 | } | 
| 1320 | 1320 | |
| 1321 | 1321 | /** | 
| @@ -1325,14 +1325,14 @@ discard block | ||
| 1325 | 1325 | * @param integer $course_id Course ID | 
| 1326 | 1326 | * @return mixed boolean or comment_ID | 
| 1327 | 1327 | */ | 
| 1328 | -	public static function user_start_course( $user_id = 0, $course_id = 0 ) { | |
| 1328 | +	public static function user_start_course($user_id = 0, $course_id = 0) { | |
| 1329 | 1329 | |
| 1330 | 1330 | $activity_logged = false; | 
| 1331 | 1331 | |
| 1332 | -		if( $user_id && $course_id ) { | |
| 1332 | +		if ($user_id && $course_id) { | |
| 1333 | 1333 | // Check if user is already on the Course | 
| 1334 | - $activity_logged = Sensei_Utils::user_started_course( $course_id, $user_id ); | |
| 1335 | -			if ( ! $activity_logged ) { | |
| 1334 | + $activity_logged = Sensei_Utils::user_started_course($course_id, $user_id); | |
| 1335 | +			if ( ! $activity_logged) { | |
| 1336 | 1336 | |
| 1337 | 1337 | // Add user to course | 
| 1338 | 1338 | $course_metadata = array( | 
| @@ -1341,11 +1341,11 @@ discard block | ||
| 1341 | 1341 | 'complete' => 0, | 
| 1342 | 1342 | ); | 
| 1343 | 1343 | |
| 1344 | - $activity_logged = Sensei_Utils::update_course_status( $user_id, $course_id, $course_status = 'in-progress', $course_metadata ); | |
| 1344 | + $activity_logged = Sensei_Utils::update_course_status($user_id, $course_id, $course_status = 'in-progress', $course_metadata); | |
| 1345 | 1345 | |
| 1346 | 1346 | // Allow further actions | 
| 1347 | -				if ( $activity_logged ) { | |
| 1348 | - do_action( 'sensei_user_course_start', $user_id, $course_id ); | |
| 1347 | +				if ($activity_logged) { | |
| 1348 | +					do_action('sensei_user_course_start', $user_id, $course_id); | |
| 1349 | 1349 | } | 
| 1350 | 1350 | } | 
| 1351 | 1351 | } | 
| @@ -1361,19 +1361,19 @@ discard block | ||
| 1361 | 1361 | * @param int $user_id | 
| 1362 | 1362 | * @return mixed false or comment_ID | 
| 1363 | 1363 | */ | 
| 1364 | -	public static function user_started_course( $course_id = 0, $user_id = 0 ) { | |
| 1364 | +	public static function user_started_course($course_id = 0, $user_id = 0) { | |
| 1365 | 1365 | |
| 1366 | -		if( $course_id ) { | |
| 1367 | -			if( ! $user_id ) { | |
| 1366 | +		if ($course_id) { | |
| 1367 | +			if ( ! $user_id) { | |
| 1368 | 1368 | $user_id = get_current_user_id(); | 
| 1369 | 1369 | } | 
| 1370 | 1370 | |
| 1371 | -            if( ! $user_id > 0 ){ | |
| 1371 | +            if ( ! $user_id > 0) { | |
| 1372 | 1372 | return false; | 
| 1373 | 1373 | } | 
| 1374 | 1374 | |
| 1375 | - $user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) ); | |
| 1376 | -			if( $user_course_status_id ) { | |
| 1375 | +			$user_course_status_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID')); | |
| 1376 | +			if ($user_course_status_id) { | |
| 1377 | 1377 | return $user_course_status_id; | 
| 1378 | 1378 | } | 
| 1379 | 1379 | } | 
| @@ -1388,17 +1388,17 @@ discard block | ||
| 1388 | 1388 | * @param integer $user_id User ID | 
| 1389 | 1389 | * @return int | 
| 1390 | 1390 | */ | 
| 1391 | -	public static function user_complete_course( $course_id = 0, $user_id = 0 ) { | |
| 1391 | +	public static function user_complete_course($course_id = 0, $user_id = 0) { | |
| 1392 | 1392 | global $wp_version; | 
| 1393 | 1393 | |
| 1394 | -		if( $course_id ) { | |
| 1395 | -			if( ! $user_id ) { | |
| 1394 | +		if ($course_id) { | |
| 1395 | +			if ( ! $user_id) { | |
| 1396 | 1396 | $user_id = get_current_user_id(); | 
| 1397 | 1397 | } | 
| 1398 | 1398 | |
| 1399 | 1399 | $course_status = 'in-progress'; | 
| 1400 | 1400 | $course_metadata = array(); | 
| 1401 | - $course_completion = Sensei()->settings->settings[ 'course_completion' ]; | |
| 1401 | + $course_completion = Sensei()->settings->settings['course_completion']; | |
| 1402 | 1402 | $lessons_completed = $total_lessons = 0; | 
| 1403 | 1403 | $lesson_status_args = array( | 
| 1404 | 1404 | 'user_id' => $user_id, | 
| @@ -1407,8 +1407,8 @@ discard block | ||
| 1407 | 1407 | ); | 
| 1408 | 1408 | |
| 1409 | 1409 | // Grab all of this Courses' lessons, looping through each... | 
| 1410 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); | |
| 1411 | - $total_lessons = count( $lesson_ids ); | |
| 1410 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); | |
| 1411 | + $total_lessons = count($lesson_ids); | |
| 1412 | 1412 | // ...if course completion not set to 'passed', and all lessons are complete or graded, | 
| 1413 | 1413 | // ......then all lessons are 'passed' | 
| 1414 | 1414 | // ...else if course completion is set to 'passed', check if each lesson has questions... | 
| @@ -1421,29 +1421,29 @@ discard block | ||
| 1421 | 1421 | // The below checks if a lesson is fully completed, though maybe should be Utils::user_completed_lesson() | 
| 1422 | 1422 | $all_lesson_statuses = array(); | 
| 1423 | 1423 | // In WordPress 4.1 get_comments() allows a single query to cover multiple comment_post_IDs | 
| 1424 | -			if ( version_compare($wp_version, '4.1', '>=') ) { | |
| 1424 | +			if (version_compare($wp_version, '4.1', '>=')) { | |
| 1425 | 1425 | $lesson_status_args['post__in'] = $lesson_ids; | 
| 1426 | - $all_lesson_statuses = Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true ); | |
| 1426 | + $all_lesson_statuses = Sensei_Utils::sensei_check_for_activity($lesson_status_args, true); | |
| 1427 | 1427 | // Need to always return an array, even with only 1 item | 
| 1428 | -				if ( !is_array($all_lesson_statuses) ) { | |
| 1429 | - $all_lesson_statuses = array( $all_lesson_statuses ); | |
| 1428 | +				if ( ! is_array($all_lesson_statuses)) { | |
| 1429 | + $all_lesson_statuses = array($all_lesson_statuses); | |
| 1430 | 1430 | } | 
| 1431 | 1431 | } | 
| 1432 | 1432 | // ...otherwise check each one | 
| 1433 | 1433 |  			else { | 
| 1434 | -				foreach( $lesson_ids as $lesson_id ) { | |
| 1434 | +				foreach ($lesson_ids as $lesson_id) { | |
| 1435 | 1435 | $lesson_status_args['post_id'] = $lesson_id; | 
| 1436 | - $each_lesson_status = Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true ); | |
| 1436 | + $each_lesson_status = Sensei_Utils::sensei_check_for_activity($lesson_status_args, true); | |
| 1437 | 1437 | // Check for valid return before using | 
| 1438 | -					if ( !empty($each_lesson_status->comment_approved) ) { | |
| 1438 | +					if ( ! empty($each_lesson_status->comment_approved)) { | |
| 1439 | 1439 | $all_lesson_statuses[] = $each_lesson_status; | 
| 1440 | 1440 | } | 
| 1441 | 1441 | } | 
| 1442 | 1442 | } | 
| 1443 | -			foreach( $all_lesson_statuses as $lesson_status ) { | |
| 1443 | +			foreach ($all_lesson_statuses as $lesson_status) { | |
| 1444 | 1444 | // If lessons are complete without needing quizzes to be passed | 
| 1445 | -				if ( 'passed' != $course_completion ) { | |
| 1446 | -					switch ( $lesson_status->comment_approved ) { | |
| 1445 | +				if ('passed' != $course_completion) { | |
| 1446 | +					switch ($lesson_status->comment_approved) { | |
| 1447 | 1447 | // A user cannot 'complete' a course if a lesson... | 
| 1448 | 1448 | case 'in-progress': // ...is still in progress | 
| 1449 | 1449 | case 'ungraded': // ...hasn't yet been graded | 
| @@ -1455,7 +1455,7 @@ discard block | ||
| 1455 | 1455 | } | 
| 1456 | 1456 | } | 
| 1457 | 1457 |  				else { | 
| 1458 | -					switch ( $lesson_status->comment_approved ) { | |
| 1458 | +					switch ($lesson_status->comment_approved) { | |
| 1459 | 1459 | case 'complete': // Lesson has no quiz/questions | 
| 1460 | 1460 | case 'graded': // Lesson has quiz, but it's not important what the grade was | 
| 1461 | 1461 | case 'passed': // Lesson has quiz and the user passed | 
| @@ -1469,20 +1469,20 @@ discard block | ||
| 1469 | 1469 | } | 
| 1470 | 1470 | } | 
| 1471 | 1471 | } // Each lesson | 
| 1472 | -			if ( $lessons_completed == $total_lessons ) { | |
| 1472 | +			if ($lessons_completed == $total_lessons) { | |
| 1473 | 1473 | $course_status = 'complete'; | 
| 1474 | 1474 | } | 
| 1475 | 1475 | |
| 1476 | 1476 | // Update meta data on how many lessons have been completed | 
| 1477 | 1477 | $course_metadata['complete'] = $lessons_completed; | 
| 1478 | 1478 | // update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above | 
| 1479 | - $course_metadata['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ); | |
| 1479 | + $course_metadata['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)); | |
| 1480 | 1480 | |
| 1481 | - $activity_logged = Sensei_Utils::update_course_status( $user_id, $course_id, $course_status, $course_metadata ); | |
| 1481 | + $activity_logged = Sensei_Utils::update_course_status($user_id, $course_id, $course_status, $course_metadata); | |
| 1482 | 1482 | |
| 1483 | 1483 | // Allow further actions | 
| 1484 | -			if ( 'complete' == $course_status ) { | |
| 1485 | - do_action( 'sensei_user_course_end', $user_id, $course_id ); | |
| 1484 | +			if ('complete' == $course_status) { | |
| 1485 | +				do_action('sensei_user_course_end', $user_id, $course_id); | |
| 1486 | 1486 | } | 
| 1487 | 1487 | return $activity_logged; | 
| 1488 | 1488 | } | 
| @@ -1498,31 +1498,31 @@ discard block | ||
| 1498 | 1498 | * @param int $user_id | 
| 1499 | 1499 | * @return boolean | 
| 1500 | 1500 | */ | 
| 1501 | -	public static function user_completed_course( $course , $user_id = 0 ) { | |
| 1501 | +	public static function user_completed_course($course, $user_id = 0) { | |
| 1502 | 1502 | |
| 1503 | -		if( $course ) { | |
| 1504 | -			if ( is_object( $course ) && is_a( $course,'WP_Comment') ) { | |
| 1503 | +		if ($course) { | |
| 1504 | +			if (is_object($course) && is_a($course, 'WP_Comment')) { | |
| 1505 | 1505 | $user_course_status = $course->comment_approved; | 
| 1506 | 1506 | } | 
| 1507 | -			elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { | |
| 1507 | +			elseif ( ! is_numeric($course) && ! is_a($course, 'WP_Post')) { | |
| 1508 | 1508 | $user_course_status = $course; | 
| 1509 | 1509 | } | 
| 1510 | 1510 |  			else { | 
| 1511 | -				if( ! $user_id ) { | |
| 1511 | +				if ( ! $user_id) { | |
| 1512 | 1512 | $user_id = get_current_user_id(); | 
| 1513 | 1513 | } | 
| 1514 | 1514 | |
| 1515 | -                if( is_a( $course, 'WP_Post' ) ){ | |
| 1516 | - $course = $course->ID; | |
| 1515 | +                if (is_a($course, 'WP_Post')) { | |
| 1516 | + $course = $course->ID; | |
| 1517 | 1517 | } | 
| 1518 | 1518 | |
| 1519 | - $user_course_status = Sensei_Utils::user_course_status( $course , $user_id ); | |
| 1520 | -				if( isset( $user_course_status->comment_approved ) ){ | |
| 1519 | + $user_course_status = Sensei_Utils::user_course_status($course, $user_id); | |
| 1520 | +				if (isset($user_course_status->comment_approved)) { | |
| 1521 | 1521 | $user_course_status = $user_course_status->comment_approved; | 
| 1522 | 1522 | } | 
| 1523 | 1523 | |
| 1524 | 1524 | } | 
| 1525 | -			if( $user_course_status && 'complete' == $user_course_status ) { | |
| 1525 | +			if ($user_course_status && 'complete' == $user_course_status) { | |
| 1526 | 1526 | return true; | 
| 1527 | 1527 | } | 
| 1528 | 1528 | } | 
| @@ -1537,10 +1537,10 @@ discard block | ||
| 1537 | 1537 | * @param int $user_id | 
| 1538 | 1538 | * @return mixed false or comment_ID | 
| 1539 | 1539 | */ | 
| 1540 | -	public static function user_started_lesson( $lesson_id = 0, $user_id = 0 ) { | |
| 1540 | +	public static function user_started_lesson($lesson_id = 0, $user_id = 0) { | |
| 1541 | 1541 | |
| 1542 | -		if( $lesson_id ) { | |
| 1543 | -			if( ! $user_id ) { | |
| 1542 | +		if ($lesson_id) { | |
| 1543 | +			if ( ! $user_id) { | |
| 1544 | 1544 | $user_id = get_current_user_id(); | 
| 1545 | 1545 | } | 
| 1546 | 1546 | |
| @@ -1550,8 +1550,8 @@ discard block | ||
| 1550 | 1550 | 'type' => 'sensei_lesson_status', | 
| 1551 | 1551 | 'field' => 'comment_ID' ); | 
| 1552 | 1552 | |
| 1553 | - $user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args ); | |
| 1554 | -			if( $user_lesson_status_id ) { | |
| 1553 | + $user_lesson_status_id = Sensei_Utils::sensei_get_activity_value($activity_args); | |
| 1554 | +			if ($user_lesson_status_id) { | |
| 1555 | 1555 | return $user_lesson_status_id; | 
| 1556 | 1556 | } | 
| 1557 | 1557 | } | 
| @@ -1566,29 +1566,29 @@ discard block | ||
| 1566 | 1566 | * @param int $user_id | 
| 1567 | 1567 | * @return boolean | 
| 1568 | 1568 | */ | 
| 1569 | -	public static function user_completed_lesson( $lesson = 0, $user_id = 0 ) { | |
| 1569 | +	public static function user_completed_lesson($lesson = 0, $user_id = 0) { | |
| 1570 | 1570 | |
| 1571 | -		if( $lesson ) { | |
| 1571 | +		if ($lesson) { | |
| 1572 | 1572 | $lesson_id = 0; | 
| 1573 | -			if ( is_object( $lesson ) ) { | |
| 1573 | +			if (is_object($lesson)) { | |
| 1574 | 1574 | $user_lesson_status = $lesson->comment_approved; | 
| 1575 | 1575 | $lesson_id = $lesson->comment_post_ID; | 
| 1576 | 1576 | } | 
| 1577 | -			elseif ( ! is_numeric( $lesson ) ) { | |
| 1577 | +			elseif ( ! is_numeric($lesson)) { | |
| 1578 | 1578 | $user_lesson_status = $lesson; | 
| 1579 | 1579 | } | 
| 1580 | 1580 |  			else { | 
| 1581 | -				if( ! $user_id ) { | |
| 1581 | +				if ( ! $user_id) { | |
| 1582 | 1582 | $user_id = get_current_user_id(); | 
| 1583 | 1583 | } | 
| 1584 | 1584 | |
| 1585 | 1585 | // the user is not logged in | 
| 1586 | -                if( ! $user_id > 0 ){ | |
| 1586 | +                if ( ! $user_id > 0) { | |
| 1587 | 1587 | return false; | 
| 1588 | 1588 | } | 
| 1589 | - $_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id ); | |
| 1589 | + $_user_lesson_status = Sensei_Utils::user_lesson_status($lesson, $user_id); | |
| 1590 | 1590 | |
| 1591 | -				if ( $_user_lesson_status ) { | |
| 1591 | +				if ($_user_lesson_status) { | |
| 1592 | 1592 | $user_lesson_status = $_user_lesson_status->comment_approved; | 
| 1593 | 1593 | } | 
| 1594 | 1594 |  				else { | 
| @@ -1596,12 +1596,12 @@ discard block | ||
| 1596 | 1596 | } | 
| 1597 | 1597 | $lesson_id = $lesson; | 
| 1598 | 1598 | } | 
| 1599 | -			if ( 'in-progress' != $user_lesson_status ) { | |
| 1599 | +			if ('in-progress' != $user_lesson_status) { | |
| 1600 | 1600 | // Check for Passed or Completed Setting | 
| 1601 | 1601 | // Should we be checking for the Course completion setting? Surely that should only affect the Course completion, not bypass each Lesson setting | 
| 1602 | 1602 | // $course_completion = Sensei()->settings->settings[ 'course_completion' ]; | 
| 1603 | 1603 |  //				if ( 'passed' == $course_completion ) { | 
| 1604 | -					switch( $user_lesson_status ) { | |
| 1604 | +					switch ($user_lesson_status) { | |
| 1605 | 1605 | case 'complete': | 
| 1606 | 1606 | case 'graded': | 
| 1607 | 1607 | case 'passed': | 
| @@ -1610,13 +1610,13 @@ discard block | ||
| 1610 | 1610 | |
| 1611 | 1611 | case 'failed': | 
| 1612 | 1612 | // This may be 'completed' depending on... | 
| 1613 | -							if ( $lesson_id ) { | |
| 1613 | +							if ($lesson_id) { | |
| 1614 | 1614 | // Get Quiz ID, this won't be needed once all Quiz meta fields are stored on the Lesson | 
| 1615 | - $lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); | |
| 1616 | -								if ( $lesson_quiz_id ) { | |
| 1615 | + $lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); | |
| 1616 | +								if ($lesson_quiz_id) { | |
| 1617 | 1617 | // ...the quiz pass setting | 
| 1618 | - $pass_required = get_post_meta( $lesson_quiz_id, '_pass_required', true ); | |
| 1619 | -									if ( empty($pass_required) ) { | |
| 1618 | + $pass_required = get_post_meta($lesson_quiz_id, '_pass_required', true); | |
| 1619 | +									if (empty($pass_required)) { | |
| 1620 | 1620 | // We just require the user to have done the quiz, not to have passed | 
| 1621 | 1621 | return true; | 
| 1622 | 1622 | } | 
| @@ -1639,15 +1639,15 @@ discard block | ||
| 1639 | 1639 | * @param int $user_id | 
| 1640 | 1640 | * @return object | 
| 1641 | 1641 | */ | 
| 1642 | -	public static function user_course_status( $course_id = 0, $user_id = 0 ) { | |
| 1642 | +	public static function user_course_status($course_id = 0, $user_id = 0) { | |
| 1643 | 1643 | |
| 1644 | 1644 | |
| 1645 | -		if( $course_id ) { | |
| 1646 | -			if( ! $user_id ) { | |
| 1645 | +		if ($course_id) { | |
| 1646 | +			if ( ! $user_id) { | |
| 1647 | 1647 | $user_id = get_current_user_id(); | 
| 1648 | 1648 | } | 
| 1649 | 1649 | |
| 1650 | - $user_course_status = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status' ), true ); | |
| 1650 | +			$user_course_status = Sensei_Utils::sensei_check_for_activity(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status'), true); | |
| 1651 | 1651 | return $user_course_status; | 
| 1652 | 1652 | } | 
| 1653 | 1653 | |
| @@ -1662,27 +1662,27 @@ discard block | ||
| 1662 | 1662 | * @param int $user_id | 
| 1663 | 1663 | * @return object | bool | 
| 1664 | 1664 | */ | 
| 1665 | -	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) { | |
| 1665 | +	public static function user_lesson_status($lesson_id = 0, $user_id = 0) { | |
| 1666 | 1666 | |
| 1667 | -        if( ! $user_id ) { | |
| 1667 | +        if ( ! $user_id) { | |
| 1668 | 1668 | $user_id = get_current_user_id(); | 
| 1669 | 1669 | } | 
| 1670 | 1670 | |
| 1671 | -		if( $lesson_id > 0 && $user_id > 0 ) { | |
| 1671 | +		if ($lesson_id > 0 && $user_id > 0) { | |
| 1672 | 1672 | |
| 1673 | - $user_lesson_status = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status' ), true ); | |
| 1673 | +			$user_lesson_status = Sensei_Utils::sensei_check_for_activity(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status'), true); | |
| 1674 | 1674 | return $user_lesson_status; | 
| 1675 | 1675 | } | 
| 1676 | 1676 | |
| 1677 | 1677 | return false; | 
| 1678 | 1678 | } | 
| 1679 | 1679 | |
| 1680 | -	public static function is_preview_lesson( $lesson_id ) { | |
| 1680 | +	public static function is_preview_lesson($lesson_id) { | |
| 1681 | 1681 | $is_preview = false; | 
| 1682 | 1682 | |
| 1683 | -		if( 'lesson' == get_post_type( $lesson_id ) ) { | |
| 1684 | - $lesson_preview = get_post_meta( $lesson_id, '_lesson_preview', true ); | |
| 1685 | -			if ( isset( $lesson_preview ) && '' != $lesson_preview ) { | |
| 1683 | +		if ('lesson' == get_post_type($lesson_id)) { | |
| 1684 | + $lesson_preview = get_post_meta($lesson_id, '_lesson_preview', true); | |
| 1685 | +			if (isset($lesson_preview) && '' != $lesson_preview) { | |
| 1686 | 1686 | $is_preview = true; | 
| 1687 | 1687 | } | 
| 1688 | 1688 | } | 
| @@ -1690,22 +1690,22 @@ discard block | ||
| 1690 | 1690 | return $is_preview; | 
| 1691 | 1691 | } | 
| 1692 | 1692 | |
| 1693 | -	public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) { | |
| 1693 | +	public static function user_passed_quiz($quiz_id = 0, $user_id = 0) { | |
| 1694 | 1694 | |
| 1695 | - if( ! $quiz_id ) return false; | |
| 1695 | + if ( ! $quiz_id) return false; | |
| 1696 | 1696 | |
| 1697 | -		if( ! $user_id ) { | |
| 1697 | +		if ( ! $user_id) { | |
| 1698 | 1698 | $user_id = get_current_user_id(); | 
| 1699 | 1699 | } | 
| 1700 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); | |
| 1700 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); | |
| 1701 | 1701 | |
| 1702 | 1702 | // Quiz Grade | 
| 1703 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); | |
| 1704 | - $quiz_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); | |
| 1703 | + $lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); | |
| 1704 | + $quiz_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); | |
| 1705 | 1705 | |
| 1706 | 1706 | // Check if Grade is greater than or equal to pass percentage | 
| 1707 | - $quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) ); | |
| 1708 | -		if ( $quiz_passmark <= intval( $quiz_grade ) ) { | |
| 1707 | + $quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2)); | |
| 1708 | +		if ($quiz_passmark <= intval($quiz_grade)) { | |
| 1709 | 1709 | return true; | 
| 1710 | 1710 | } | 
| 1711 | 1711 | |
| @@ -1725,9 +1725,9 @@ discard block | ||
| 1725 | 1725 | * | 
| 1726 | 1726 | * @return mixed false or comment_ID | 
| 1727 | 1727 | */ | 
| 1728 | -	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) { | |
| 1728 | +	public static function update_lesson_status($user_id, $lesson_id, $status = 'in-progress', $metadata = array()) { | |
| 1729 | 1729 | $comment_id = false; | 
| 1730 | -		if ( !empty($status) ) { | |
| 1730 | +		if ( ! empty($status)) { | |
| 1731 | 1731 | $args = array( | 
| 1732 | 1732 | 'user_id' => $user_id, | 
| 1733 | 1733 | 'post_id' => $lesson_id, | 
| @@ -1736,18 +1736,18 @@ discard block | ||
| 1736 | 1736 | 'action' => 'update', // Update the existing status... | 
| 1737 | 1737 | 'keep_time' => true, // ...but don't change the existing timestamp | 
| 1738 | 1738 | ); | 
| 1739 | -			if( 'in-progress' == $status ) { | |
| 1740 | - unset( $args['keep_time'] ); // Keep updating what's happened | |
| 1739 | +			if ('in-progress' == $status) { | |
| 1740 | + unset($args['keep_time']); // Keep updating what's happened | |
| 1741 | 1741 | } | 
| 1742 | 1742 | |
| 1743 | - $comment_id = Sensei_Utils::sensei_log_activity( $args ); | |
| 1744 | -			if ( $comment_id && !empty($metadata) ) { | |
| 1745 | -				foreach( $metadata as $key => $value ) { | |
| 1746 | - update_comment_meta( $comment_id, $key, $value ); | |
| 1743 | + $comment_id = Sensei_Utils::sensei_log_activity($args); | |
| 1744 | +			if ($comment_id && ! empty($metadata)) { | |
| 1745 | +				foreach ($metadata as $key => $value) { | |
| 1746 | + update_comment_meta($comment_id, $key, $value); | |
| 1747 | 1747 | } | 
| 1748 | 1748 | } | 
| 1749 | 1749 | |
| 1750 | - do_action( 'sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id ); | |
| 1750 | +			do_action('sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id); | |
| 1751 | 1751 | } | 
| 1752 | 1752 | return $comment_id; | 
| 1753 | 1753 | } | 
| @@ -1763,9 +1763,9 @@ discard block | ||
| 1763 | 1763 | * @param array $metadata | 
| 1764 | 1764 | * @return mixed false or comment_ID | 
| 1765 | 1765 | */ | 
| 1766 | -	public static function update_course_status( $user_id, $course_id, $status = 'in-progress', $metadata = array() ) { | |
| 1766 | +	public static function update_course_status($user_id, $course_id, $status = 'in-progress', $metadata = array()) { | |
| 1767 | 1767 | $comment_id = false; | 
| 1768 | -		if ( !empty($status) ) { | |
| 1768 | +		if ( ! empty($status)) { | |
| 1769 | 1769 | $args = array( | 
| 1770 | 1770 | 'user_id' => $user_id, | 
| 1771 | 1771 | 'post_id' => $course_id, | 
| @@ -1774,17 +1774,17 @@ discard block | ||
| 1774 | 1774 | 'action' => 'update', // Update the existing status... | 
| 1775 | 1775 | 'keep_time' => true, // ...but don't change the existing timestamp | 
| 1776 | 1776 | ); | 
| 1777 | -			if( 'in-progress' == $status ) { | |
| 1778 | - unset( $args['keep_time'] ); // Keep updating what's happened | |
| 1777 | +			if ('in-progress' == $status) { | |
| 1778 | + unset($args['keep_time']); // Keep updating what's happened | |
| 1779 | 1779 | } | 
| 1780 | 1780 | |
| 1781 | - $comment_id = Sensei_Utils::sensei_log_activity( $args ); | |
| 1782 | -			if ( $comment_id && !empty($metadata) ) { | |
| 1783 | -				foreach( $metadata as $key => $value ) { | |
| 1784 | - update_comment_meta( $comment_id, $key, $value ); | |
| 1781 | + $comment_id = Sensei_Utils::sensei_log_activity($args); | |
| 1782 | +			if ($comment_id && ! empty($metadata)) { | |
| 1783 | +				foreach ($metadata as $key => $value) { | |
| 1784 | + update_comment_meta($comment_id, $key, $value); | |
| 1785 | 1785 | } | 
| 1786 | 1786 | } | 
| 1787 | - do_action( 'sensei_course_status_updated', $status, $user_id, $course_id, $comment_id ); | |
| 1787 | +			do_action('sensei_course_status_updated', $status, $user_id, $course_id, $comment_id); | |
| 1788 | 1788 | } | 
| 1789 | 1789 | return $comment_id; | 
| 1790 | 1790 | } | 
| @@ -1796,9 +1796,9 @@ discard block | ||
| 1796 | 1796 | * @param array $pieces (default: array()) | 
| 1797 | 1797 | * @return array | 
| 1798 | 1798 | */ | 
| 1799 | -	public static function single_comment_filter( $pieces ) { | |
| 1800 | - unset( $pieces['orderby'] ); | |
| 1801 | - unset( $pieces['order'] ); | |
| 1799 | +	public static function single_comment_filter($pieces) { | |
| 1800 | + unset($pieces['orderby']); | |
| 1801 | + unset($pieces['order']); | |
| 1802 | 1802 | |
| 1803 | 1803 | return $pieces; | 
| 1804 | 1804 | } | 
| @@ -1810,9 +1810,9 @@ discard block | ||
| 1810 | 1810 | * @param array $pieces (default: array()) | 
| 1811 | 1811 | * @return array | 
| 1812 | 1812 | */ | 
| 1813 | -	public static function comment_any_status_filter( $pieces ) { | |
| 1813 | +	public static function comment_any_status_filter($pieces) { | |
| 1814 | 1814 | |
| 1815 | - $pieces['where'] = str_replace( array( "( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND" ), '', $pieces['where'] ); | |
| 1815 | +		$pieces['where'] = str_replace(array("( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND"), '', $pieces['where']); | |
| 1816 | 1816 | |
| 1817 | 1817 | return $pieces; | 
| 1818 | 1818 | } | 
| @@ -1824,12 +1824,12 @@ discard block | ||
| 1824 | 1824 | * @param array $pieces (default: array()) | 
| 1825 | 1825 | * @return array | 
| 1826 | 1826 | */ | 
| 1827 | -	public static function comment_multiple_status_filter( $pieces ) { | |
| 1827 | +	public static function comment_multiple_status_filter($pieces) { | |
| 1828 | 1828 | |
| 1829 | - preg_match( "/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder ); | |
| 1830 | -		if ( !empty($placeholder[1]) ) { | |
| 1831 | - $statuses = explode( ',', $placeholder[1] ); | |
| 1832 | -			$pieces['where'] = str_replace( "comment_approved = '" . $placeholder[1] . "'", "comment_approved IN ('". implode( "', '", $statuses ) . "')", $pieces['where'] ); | |
| 1829 | +		preg_match("/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder); | |
| 1830 | +		if ( ! empty($placeholder[1])) { | |
| 1831 | +			$statuses = explode(',', $placeholder[1]); | |
| 1832 | +			$pieces['where'] = str_replace("comment_approved = '".$placeholder[1]."'", "comment_approved IN ('".implode("', '", $statuses)."')", $pieces['where']); | |
| 1833 | 1833 | } | 
| 1834 | 1834 | |
| 1835 | 1835 | return $pieces; | 
| @@ -1841,12 +1841,12 @@ discard block | ||
| 1841 | 1841 | * @param array $pieces | 
| 1842 | 1842 | * @return array $pieces | 
| 1843 | 1843 | */ | 
| 1844 | -	public static function comment_total_sum_meta_value_filter( $pieces ) { | |
| 1844 | +	public static function comment_total_sum_meta_value_filter($pieces) { | |
| 1845 | 1845 | global $wpdb, $wp_version; | 
| 1846 | 1846 | |
| 1847 | 1847 | $pieces['fields'] = " COUNT(*) AS total, SUM($wpdb->commentmeta.meta_value) AS meta_sum "; | 
| 1848 | - unset( $pieces['groupby'] ); | |
| 1849 | -		if ( version_compare($wp_version, '4.1', '>=') ) { | |
| 1848 | + unset($pieces['groupby']); | |
| 1849 | +		if (version_compare($wp_version, '4.1', '>=')) { | |
| 1850 | 1850 | $args['order'] = false; | 
| 1851 | 1851 | $args['orderby'] = false; | 
| 1852 | 1852 | } | 
| @@ -1861,12 +1861,12 @@ discard block | ||
| 1861 | 1861 | * @param array $pieces (default: array()) | 
| 1862 | 1862 | * @return array | 
| 1863 | 1863 | */ | 
| 1864 | -	public static function get_posts_count_only_filter( $pieces ) { | |
| 1864 | +	public static function get_posts_count_only_filter($pieces) { | |
| 1865 | 1865 | global $wp_version; | 
| 1866 | 1866 | |
| 1867 | 1867 | $pieces['fields'] = " COUNT(*) AS total "; | 
| 1868 | - unset( $pieces['groupby'] ); | |
| 1869 | -		if ( version_compare($wp_version, '4.1', '>=') ) { | |
| 1868 | + unset($pieces['groupby']); | |
| 1869 | +		if (version_compare($wp_version, '4.1', '>=')) { | |
| 1870 | 1870 | $args['order'] = false; | 
| 1871 | 1871 | $args['orderby'] = false; | 
| 1872 | 1872 | } | 
| @@ -1885,9 +1885,9 @@ discard block | ||
| 1885 | 1885 | * | 
| 1886 | 1886 | * @return bool $success | 
| 1887 | 1887 | */ | 
| 1888 | -    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){ | |
| 1888 | +    public static function add_user_data($data_key, $post_id, $value = '', $user_id = 0) { | |
| 1889 | 1889 | |
| 1890 | - return self::update_user_data( $data_key, $post_id, $value , $user_id ); | |
| 1890 | + return self::update_user_data($data_key, $post_id, $value, $user_id); | |
| 1891 | 1891 | |
| 1892 | 1892 | }// end add_user_data | 
| 1893 | 1893 | |
| @@ -1906,18 +1906,18 @@ discard block | ||
| 1906 | 1906 | * | 
| 1907 | 1907 | * @return bool $success | 
| 1908 | 1908 | */ | 
| 1909 | -    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){ | |
| 1909 | +    public static function update_user_data($data_key, $post_id, $value = '', $user_id = 0) { | |
| 1910 | 1910 | |
| 1911 | -        if( ! ( $user_id > 0 ) ){ | |
| 1911 | +        if ( ! ($user_id > 0)) { | |
| 1912 | 1912 | $user_id = get_current_user_id(); | 
| 1913 | 1913 | } | 
| 1914 | 1914 | |
| 1915 | - $supported_post_types = array( 'course', 'lesson' ); | |
| 1916 | - $post_type = get_post_type( $post_id ); | |
| 1917 | - if( empty( $post_id ) || empty( $data_key ) | |
| 1918 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 1919 | - || !get_userdata( $user_id ) | |
| 1920 | -            || ! in_array( $post_type, $supported_post_types )  ){ | |
| 1915 | +        $supported_post_types = array('course', 'lesson'); | |
| 1916 | + $post_type = get_post_type($post_id); | |
| 1917 | + if (empty($post_id) || empty($data_key) | |
| 1918 | + || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0) | |
| 1919 | + || ! get_userdata($user_id) | |
| 1920 | +            || ! in_array($post_type, $supported_post_types)) { | |
| 1921 | 1921 | |
| 1922 | 1922 | return false; | 
| 1923 | 1923 | } | 
| @@ -1925,20 +1925,20 @@ discard block | ||
| 1925 | 1925 | // check if there and existing Sensei status on this post type if not create it | 
| 1926 | 1926 | // and get the activity ID | 
| 1927 | 1927 | $status_function = 'user_'.$post_type.'_status'; | 
| 1928 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 1929 | -        if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 1928 | + $sensei_user_status = self::$status_function($post_id, $user_id); | |
| 1929 | +        if ( ! isset($sensei_user_status->comment_ID)) { | |
| 1930 | 1930 | |
| 1931 | 1931 | $start_function = 'user_start_'.$post_type; | 
| 1932 | - $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); | |
| 1932 | + $sensei_user_activity_id = self::$start_function($user_id, $post_id); | |
| 1933 | 1933 | |
| 1934 | -        }else{ | |
| 1934 | +        } else { | |
| 1935 | 1935 | |
| 1936 | 1936 | $sensei_user_activity_id = $sensei_user_status->comment_ID; | 
| 1937 | 1937 | |
| 1938 | 1938 | } | 
| 1939 | 1939 | |
| 1940 | 1940 | // store the data | 
| 1941 | - $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value ); | |
| 1941 | + $success = update_comment_meta($sensei_user_activity_id, $data_key, $value); | |
| 1942 | 1942 | |
| 1943 | 1943 | return $success; | 
| 1944 | 1944 | |
| @@ -1957,20 +1957,20 @@ discard block | ||
| 1957 | 1957 | * | 
| 1958 | 1958 | * @return mixed $user_data_value | 
| 1959 | 1959 | */ | 
| 1960 | -    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){ | |
| 1960 | +    public static function get_user_data($data_key, $post_id, $user_id = 0) { | |
| 1961 | 1961 | |
| 1962 | 1962 | $user_data_value = true; | 
| 1963 | 1963 | |
| 1964 | -        if( ! ( $user_id > 0 ) ){ | |
| 1964 | +        if ( ! ($user_id > 0)) { | |
| 1965 | 1965 | $user_id = get_current_user_id(); | 
| 1966 | 1966 | } | 
| 1967 | 1967 | |
| 1968 | - $supported_post_types = array( 'course', 'lesson' ); | |
| 1969 | - $post_type = get_post_type( $post_id ); | |
| 1970 | - if( empty( $post_id ) || empty( $data_key ) | |
| 1971 | - || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 1972 | - || ! get_userdata( $user_id ) | |
| 1973 | -            || !in_array( $post_type, $supported_post_types )  ){ | |
| 1968 | +        $supported_post_types = array('course', 'lesson'); | |
| 1969 | + $post_type = get_post_type($post_id); | |
| 1970 | + if (empty($post_id) || empty($data_key) | |
| 1971 | + || ! (intval($post_id) > 0) || ! (intval($user_id) > 0) | |
| 1972 | + || ! get_userdata($user_id) | |
| 1973 | +            || ! in_array($post_type, $supported_post_types)) { | |
| 1974 | 1974 | |
| 1975 | 1975 | return false; | 
| 1976 | 1976 | } | 
| @@ -1978,13 +1978,13 @@ discard block | ||
| 1978 | 1978 | // check if there and existing Sensei status on this post type if not create it | 
| 1979 | 1979 | // and get the activity ID | 
| 1980 | 1980 | $status_function = 'user_'.$post_type.'_status'; | 
| 1981 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 1982 | -        if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 1981 | + $sensei_user_status = self::$status_function($post_id, $user_id); | |
| 1982 | +        if ( ! isset($sensei_user_status->comment_ID)) { | |
| 1983 | 1983 | return false; | 
| 1984 | 1984 | } | 
| 1985 | 1985 | |
| 1986 | 1986 | $sensei_user_activity_id = $sensei_user_status->comment_ID; | 
| 1987 | - $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true ); | |
| 1987 | + $user_data_value = get_comment_meta($sensei_user_activity_id, $data_key, true); | |
| 1988 | 1988 | |
| 1989 | 1989 | return $user_data_value; | 
| 1990 | 1990 | |
| @@ -1999,19 +1999,19 @@ discard block | ||
| 1999 | 1999 | * | 
| 2000 | 2000 | * @return bool $deleted | 
| 2001 | 2001 | */ | 
| 2002 | -    public static function delete_user_data( $data_key, $post_id , $user_id ){ | |
| 2002 | +    public static function delete_user_data($data_key, $post_id, $user_id) { | |
| 2003 | 2003 | $deleted = true; | 
| 2004 | 2004 | |
| 2005 | -        if( ! ( $user_id > 0 ) ){ | |
| 2005 | +        if ( ! ($user_id > 0)) { | |
| 2006 | 2006 | $user_id = get_current_user_id(); | 
| 2007 | 2007 | } | 
| 2008 | 2008 | |
| 2009 | - $supported_post_types = array( 'course', 'lesson' ); | |
| 2010 | - $post_type = get_post_type( $post_id ); | |
| 2011 | - if( empty( $post_id ) || empty( $data_key ) | |
| 2012 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) | |
| 2013 | - || ! get_userdata( $user_id ) | |
| 2014 | -            || !in_array( $post_type, $supported_post_types )  ){ | |
| 2009 | +        $supported_post_types = array('course', 'lesson'); | |
| 2010 | + $post_type = get_post_type($post_id); | |
| 2011 | + if (empty($post_id) || empty($data_key) | |
| 2012 | + || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0) | |
| 2013 | + || ! get_userdata($user_id) | |
| 2014 | +            || ! in_array($post_type, $supported_post_types)) { | |
| 2015 | 2015 | |
| 2016 | 2016 | return false; | 
| 2017 | 2017 | } | 
| @@ -2019,13 +2019,13 @@ discard block | ||
| 2019 | 2019 | // check if there and existing Sensei status on this post type if not create it | 
| 2020 | 2020 | // and get the activity ID | 
| 2021 | 2021 | $status_function = 'user_'.$post_type.'_status'; | 
| 2022 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); | |
| 2023 | -        if( ! isset( $sensei_user_status->comment_ID ) ){ | |
| 2022 | + $sensei_user_status = self::$status_function($post_id, $user_id); | |
| 2023 | +        if ( ! isset($sensei_user_status->comment_ID)) { | |
| 2024 | 2024 | return false; | 
| 2025 | 2025 | } | 
| 2026 | 2026 | |
| 2027 | 2027 | $sensei_user_activity_id = $sensei_user_status->comment_ID; | 
| 2028 | - $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key ); | |
| 2028 | + $deleted = delete_comment_meta($sensei_user_activity_id, $data_key); | |
| 2029 | 2029 | |
| 2030 | 2030 | return $deleted; | 
| 2031 | 2031 | |
| @@ -2050,62 +2050,62 @@ discard block | ||
| 2050 | 2050 | * | 
| 2051 | 2051 | * @return string $drop_down_element | 
| 2052 | 2052 | */ | 
| 2053 | -    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) { | |
| 2053 | +    public static function generate_drop_down($selected_value, $options = array(), $attributes = array(), $enable_none_option = true) { | |
| 2054 | 2054 | |
| 2055 | 2055 | $drop_down_element = ''; | 
| 2056 | 2056 | |
| 2057 | 2057 | // setup the basic attributes | 
| 2058 | -        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) { | |
| 2058 | +        if ( ! isset($attributes['name']) || empty($attributes['name'])) { | |
| 2059 | 2059 | |
| 2060 | 2060 | $attributes['name'] = 'sensei-options'; | 
| 2061 | 2061 | |
| 2062 | 2062 | } | 
| 2063 | 2063 | |
| 2064 | -        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) { | |
| 2064 | +        if ( ! isset($attributes['id']) || empty($attributes['id'])) { | |
| 2065 | 2065 | |
| 2066 | 2066 | $attributes['id'] = 'sensei-options'; | 
| 2067 | 2067 | |
| 2068 | 2068 | } | 
| 2069 | 2069 | |
| 2070 | -        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) { | |
| 2070 | +        if ( ! isset($attributes['class']) || empty($attributes['class'])) { | |
| 2071 | 2071 | |
| 2072 | - $attributes['class'] ='chosen_select widefat'; | |
| 2072 | + $attributes['class'] = 'chosen_select widefat'; | |
| 2073 | 2073 | |
| 2074 | 2074 | } | 
| 2075 | 2075 | |
| 2076 | 2076 | // create element attributes | 
| 2077 | 2077 | $combined_attributes = ''; | 
| 2078 | -        foreach( $attributes as $attribute => $value ){ | |
| 2078 | +        foreach ($attributes as $attribute => $value) { | |
| 2079 | 2079 | |
| 2080 | - $combined_attributes .= $attribute . '="'.$value.'"' . ' '; | |
| 2080 | + $combined_attributes .= $attribute.'="'.$value.'"'.' '; | |
| 2081 | 2081 | |
| 2082 | 2082 | }// end for each | 
| 2083 | 2083 | |
| 2084 | 2084 | |
| 2085 | 2085 | // create the select element | 
| 2086 | - $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n"; | |
| 2086 | + $drop_down_element .= '<select '.$combined_attributes.' >'."\n"; | |
| 2087 | 2087 | |
| 2088 | 2088 | // show the none option if the client requested | 
| 2089 | -        if( $enable_none_option ) { | |
| 2090 | -            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; | |
| 2089 | +        if ($enable_none_option) { | |
| 2090 | +            $drop_down_element .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; | |
| 2091 | 2091 | } | 
| 2092 | 2092 | |
| 2093 | -        if ( count( $options ) > 0 ) { | |
| 2093 | +        if (count($options) > 0) { | |
| 2094 | 2094 | |
| 2095 | -            foreach ($options as $value => $option ){ | |
| 2095 | +            foreach ($options as $value => $option) { | |
| 2096 | 2096 | |
| 2097 | 2097 | $element = ''; | 
| 2098 | - $element.= '<option value="' . esc_attr( $value ) . '"'; | |
| 2099 | - $element .= selected( $value, $selected_value, false ) . '>'; | |
| 2100 | - $element .= esc_html( $option ) . '</option>' . "\n"; | |
| 2098 | + $element .= '<option value="'.esc_attr($value).'"'; | |
| 2099 | + $element .= selected($value, $selected_value, false).'>'; | |
| 2100 | + $element .= esc_html($option).'</option>'."\n"; | |
| 2101 | 2101 | |
| 2102 | 2102 | // add the element to the select html | 
| 2103 | - $drop_down_element.= $element; | |
| 2103 | + $drop_down_element .= $element; | |
| 2104 | 2104 | } // End For Loop | 
| 2105 | 2105 | |
| 2106 | 2106 | } // End If Statement | 
| 2107 | 2107 | |
| 2108 | - $drop_down_element .= '</select>' . "\n"; | |
| 2108 | + $drop_down_element .= '</select>'."\n"; | |
| 2109 | 2109 | |
| 2110 | 2110 | return $drop_down_element; | 
| 2111 | 2111 | |
| @@ -2125,14 +2125,14 @@ discard block | ||
| 2125 | 2125 | * | 
| 2126 | 2126 | * @return double $val | 
| 2127 | 2127 | */ | 
| 2128 | -    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){ | |
| 2128 | +    public static function round($val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '') { | |
| 2129 | 2129 | |
| 2130 | 2130 | /**å | 
| 2131 | 2131 | * Change the precision for the Sensei_Utils::round function. | 
| 2132 | 2132 | * the precision given will be passed into the php round function | 
| 2133 | 2133 | * @since 1.8.5 | 
| 2134 | 2134 | */ | 
| 2135 | - $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode ); | |
| 2135 | +        $precision = apply_filters('sensei_round_precision', $precision, $val, $context, $mode); | |
| 2136 | 2136 | |
| 2137 | 2137 | /** | 
| 2138 | 2138 | * Change the mode for the Sensei_Utils::round function. | 
| @@ -2142,15 +2142,15 @@ discard block | ||
| 2142 | 2142 | * | 
| 2143 | 2143 | * @since 1.8.5 | 
| 2144 | 2144 | */ | 
| 2145 | - $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision ); | |
| 2145 | +        $mode = apply_filters('sensei_round_mode', $mode, $val, $context, $precision); | |
| 2146 | 2146 | |
| 2147 | -        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) { | |
| 2147 | +        if (version_compare(PHP_VERSION, '5.3.0') >= 0) { | |
| 2148 | 2148 | |
| 2149 | - return round( $val, $precision, $mode ); | |
| 2149 | + return round($val, $precision, $mode); | |
| 2150 | 2150 | |
| 2151 | -        }else{ | |
| 2151 | +        } else { | |
| 2152 | 2152 | |
| 2153 | - return round( $val, $precision ); | |
| 2153 | + return round($val, $precision); | |
| 2154 | 2154 | |
| 2155 | 2155 | } | 
| 2156 | 2156 | |
| @@ -2162,15 +2162,15 @@ discard block | ||
| 2162 | 2162 | * @since 1.9.0 | 
| 2163 | 2163 | * @return string $url | 
| 2164 | 2164 | */ | 
| 2165 | -    public static function get_current_url(){ | |
| 2165 | +    public static function get_current_url() { | |
| 2166 | 2166 | |
| 2167 | 2167 | global $wp; | 
| 2168 | - $current_url = trailingslashit( home_url( $wp->request ) ); | |
| 2169 | -        if ( isset( $_GET ) ) { | |
| 2168 | + $current_url = trailingslashit(home_url($wp->request)); | |
| 2169 | +        if (isset($_GET)) { | |
| 2170 | 2170 | |
| 2171 | -            foreach ($_GET as $param => $val ) { | |
| 2171 | +            foreach ($_GET as $param => $val) { | |
| 2172 | 2172 | |
| 2173 | - $current_url = add_query_arg( $param, $val , $current_url ); | |
| 2173 | + $current_url = add_query_arg($param, $val, $current_url); | |
| 2174 | 2174 | |
| 2175 | 2175 | } | 
| 2176 | 2176 | } | 
| @@ -2200,27 +2200,27 @@ discard block | ||
| 2200 | 2200 | * @param array $array_b | 
| 2201 | 2201 | * @return array $merged_array | 
| 2202 | 2202 | */ | 
| 2203 | -    public static function array_zip_merge( $array_a, $array_b ){ | |
| 2203 | +    public static function array_zip_merge($array_a, $array_b) { | |
| 2204 | 2204 | |
| 2205 | -        if( ! is_array( $array_a ) || ! is_array( $array_b )  ){ | |
| 2205 | +        if ( ! is_array($array_a) || ! is_array($array_b)) { | |
| 2206 | 2206 |              trigger_error('array_zip_merge requires both arrays to be indexed arrays '); | 
| 2207 | 2207 | } | 
| 2208 | 2208 | |
| 2209 | 2209 | $merged_array = array(); | 
| 2210 | - $total_elements = count( $array_a ) + count( $array_b ); | |
| 2210 | + $total_elements = count($array_a) + count($array_b); | |
| 2211 | 2211 | |
| 2212 | 2212 | // Zip arrays | 
| 2213 | -        for ( $i = 0; $i < $total_elements; $i++) { | |
| 2213 | +        for ($i = 0; $i < $total_elements; $i++) { | |
| 2214 | 2214 | |
| 2215 | 2215 | // if has an element at current index push a on top | 
| 2216 | -            if( isset( $array_a[ $i ] ) ){ | |
| 2217 | - $merged_array[] = $array_a[ $i ] ; | |
| 2216 | +            if (isset($array_a[$i])) { | |
| 2217 | + $merged_array[] = $array_a[$i]; | |
| 2218 | 2218 | } | 
| 2219 | 2219 | |
| 2220 | 2220 | // next if $array_b has an element at current index push a on top of the element | 
| 2221 | 2221 | // from a if there was one, if not the element before that. | 
| 2222 | -            if( isset( $array_b[ $i ] ) ){ | |
| 2223 | - $merged_array[] = $array_b[ $i ] ; | |
| 2222 | +            if (isset($array_b[$i])) { | |
| 2223 | + $merged_array[] = $array_b[$i]; | |
| 2224 | 2224 | } | 
| 2225 | 2225 | |
| 2226 | 2226 | } | 
| @@ -2235,4 +2235,4 @@ discard block | ||
| 2235 | 2235 | * @ignore only for backward compatibility | 
| 2236 | 2236 | * @since 1.9.0 | 
| 2237 | 2237 | */ | 
| 2238 | -class WooThemes_Sensei_Utils extends Sensei_Utils{} | |
| 2239 | 2238 | \ No newline at end of file | 
| 2239 | +class WooThemes_Sensei_Utils extends Sensei_Utils {} | |
| 2240 | 2240 | \ No newline at end of file | 
| @@ -5,18 +5,18 @@ discard block | ||
| 5 | 5 | * Output tags. | 
| 6 | 6 | ***************************************************************************************************/ | 
| 7 | 7 | |
| 8 | - /** | |
| 9 | - * sensei_course_archive_next_link function. | |
| 10 | - * | |
| 11 | - * @access public | |
| 12 | - * @param string $type (default: 'newcourses') | |
| 13 | - * @return void | |
| 14 | - */ | |
| 15 | -    function sensei_course_archive_next_link( $type = 'newcourses' ) { | |
| 8 | + /** | |
| 9 | + * sensei_course_archive_next_link function. | |
| 10 | + * | |
| 11 | + * @access public | |
| 12 | + * @param string $type (default: 'newcourses') | |
| 13 | + * @return void | |
| 14 | + */ | |
| 15 | +	function sensei_course_archive_next_link( $type = 'newcourses' ) { | |
| 16 | 16 | |
| 17 | -        _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); | |
| 17 | +		_deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); | |
| 18 | 18 | |
| 19 | - } // End sensei_course_archive_next_link() | |
| 19 | + } // End sensei_course_archive_next_link() | |
| 20 | 20 | |
| 21 | 21 | /** | 
| 22 | 22 | * course_single_lessons function. | 
| @@ -26,14 +26,14 @@ discard block | ||
| 26 | 26 | */ | 
| 27 | 27 |  	 function course_single_lessons() { | 
| 28 | 28 | |
| 29 | - // load backwards compatible template name if it exists in the users theme | |
| 30 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); | |
| 31 | -         if( $located_template ){ | |
| 29 | + // load backwards compatible template name if it exists in the users theme | |
| 30 | + $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); | |
| 31 | +		 if( $located_template ){ | |
| 32 | 32 | |
| 33 | - Sensei_Templates::get_template( 'single-course/course-lessons.php' ); | |
| 34 | - return; | |
| 33 | + Sensei_Templates::get_template( 'single-course/course-lessons.php' ); | |
| 34 | + return; | |
| 35 | 35 | |
| 36 | - } | |
| 36 | + } | |
| 37 | 37 | |
| 38 | 38 | Sensei_Templates::get_template( 'single-course/lessons.php' ); | 
| 39 | 39 | |
| @@ -48,8 +48,8 @@ discard block | ||
| 48 | 48 | */ | 
| 49 | 49 |  	 function lesson_single_meta() { | 
| 50 | 50 | |
| 51 | -         _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); | |
| 52 | - sensei_the_single_lesson_meta(); | |
| 51 | +		 _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); | |
| 52 | + sensei_the_single_lesson_meta(); | |
| 53 | 53 | |
| 54 | 54 | } // End lesson_single_meta() | 
| 55 | 55 | |
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | * @access public | 
| 61 | 61 | * @param bool $return (default: false) | 
| 62 | 62 | * @return void | 
| 63 | - * @deprecated since 1.9.0 | |
| 63 | + * @deprecated since 1.9.0 | |
| 64 | 64 | */ | 
| 65 | 65 |  	 function quiz_questions( $return = false ) { | 
| 66 | 66 | |
| @@ -74,11 +74,11 @@ discard block | ||
| 74 | 74 | * @access public | 
| 75 | 75 | * @since 1.3.0 | 
| 76 | 76 | * @return void | 
| 77 | - * @deprecated | |
| 77 | + * @deprecated | |
| 78 | 78 | */ | 
| 79 | 79 |  	 function quiz_question_type( $question_type = 'multiple-choice' ) { | 
| 80 | 80 | |
| 81 | - Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); | |
| 81 | + Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); | |
| 82 | 82 | |
| 83 | 83 | } // End lesson_single_meta() | 
| 84 | 84 | |
| @@ -89,14 +89,14 @@ discard block | ||
| 89 | 89 | /** | 
| 90 | 90 | * sensei_check_prerequisite_course function. | 
| 91 | 91 | * | 
| 92 | - * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id ); | |
| 92 | + * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id ); | |
| 93 | 93 | * @access public | 
| 94 | 94 | * @param mixed $course_id | 
| 95 | 95 | * @return bool | 
| 96 | 96 | */ | 
| 97 | 97 |  	function sensei_check_prerequisite_course( $course_id ) { | 
| 98 | 98 | |
| 99 | - return Sensei_Course::is_prerequisite_complete( $course_id ); | |
| 99 | + return Sensei_Course::is_prerequisite_complete( $course_id ); | |
| 100 | 100 | |
| 101 | 101 | } // End sensei_check_prerequisite_course() | 
| 102 | 102 | |
| @@ -120,14 +120,14 @@ discard block | ||
| 120 | 120 | <span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span> | 
| 121 | 121 | |
| 122 | 122 | </form><?php | 
| 123 | - } // End If Statement | |
| 123 | + } // End If Statement | |
| 124 | 124 | } // End sensei_start_course_form() | 
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | /** | 
| 128 | 128 | * sensei_wc_add_to_cart function. | 
| 129 | 129 | * | 
| 130 | - * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id ); | |
| 130 | + * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id ); | |
| 131 | 131 | * @access public | 
| 132 | 132 | * @param mixed $course_id | 
| 133 | 133 | * @return void | 
| @@ -147,7 +147,7 @@ discard block | ||
| 147 | 147 | * @return bool | 
| 148 | 148 | */ | 
| 149 | 149 |  	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { | 
| 150 | - return Sensei_WC::is_product_in_cart( $wc_product_id ); | |
| 150 | + return Sensei_WC::is_product_in_cart( $wc_product_id ); | |
| 151 | 151 | } // End sensei_check_if_product_is_in_cart() | 
| 152 | 152 | |
| 153 | 153 | /** | 
| @@ -160,17 +160,17 @@ discard block | ||
| 160 | 160 |  	function sensei_simple_course_price( $post_id ) { | 
| 161 | 161 | |
| 162 | 162 | //WooCommerce Pricing | 
| 163 | -        if ( Sensei_WC::is_woocommerce_active() ) { | |
| 164 | - $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); | |
| 165 | -    	    if ( 0 < $wc_post_id ) { | |
| 166 | - // Get the product | |
| 167 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); | |
| 163 | +		if ( Sensei_WC::is_woocommerce_active() ) { | |
| 164 | + $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); | |
| 165 | +			if ( 0 < $wc_post_id ) { | |
| 166 | + // Get the product | |
| 167 | + $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); | |
| 168 | 168 | |
| 169 | -    	    	if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> | |
| 169 | +				if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> | |
| 170 | 170 | <span class="course-price"><?php echo $product->get_price_html(); ?></span> | 
| 171 | 171 | <?php } // End If Statement | 
| 172 | - } // End If Statement | |
| 173 | - } // End If Statement | |
| 172 | + } // End If Statement | |
| 173 | + } // End If Statement | |
| 174 | 174 | } // End sensei_simple_course_price() | 
| 175 | 175 | |
| 176 | 176 | /** | 
| @@ -197,7 +197,7 @@ discard block | ||
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | if ( ! $query->is_main_query() ) | 
| 200 | - return; | |
| 200 | + return; | |
| 201 | 201 | |
| 202 | 202 | // Apply Filter only if on frontend and when course archive is running | 
| 203 | 203 | $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); | 
| @@ -205,11 +205,11 @@ discard block | ||
| 205 | 205 |  		if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) { | 
| 206 | 206 | // Check for pagination settings | 
| 207 | 207 |     			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { | 
| 208 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); | |
| 209 | -    		} else { | |
| 210 | - $amount = $query->get( 'posts_per_page' ); | |
| 211 | - } // End If Statement | |
| 212 | - $query->set( 'posts_per_page', $amount ); | |
| 208 | + $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); | |
| 209 | +			} else { | |
| 210 | + $amount = $query->get( 'posts_per_page' ); | |
| 211 | + } // End If Statement | |
| 212 | + $query->set( 'posts_per_page', $amount ); | |
| 213 | 213 | } // End If Statement | 
| 214 | 214 | } // End sensei_course_archive_filter() | 
| 215 | 215 | add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 ); | 
| @@ -248,66 +248,66 @@ discard block | ||
| 248 | 248 | $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); | 
| 249 | 249 | $all_lessons = array(); | 
| 250 | 250 | |
| 251 | - $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); | |
| 252 | - | |
| 253 | -            foreach( (array) $modules as $module ) { | |
| 254 | - | |
| 255 | - $args = array( | |
| 256 | - 'post_type' => 'lesson', | |
| 257 | - 'post_status' => 'publish', | |
| 258 | - 'posts_per_page' => -1, | |
| 259 | - 'meta_query' => array( | |
| 260 | - array( | |
| 261 | - 'key' => '_lesson_course', | |
| 262 | - 'value' => intval( $lesson_course_id ), | |
| 263 | - 'compare' => '=' | |
| 264 | - ) | |
| 265 | - ), | |
| 266 | - 'tax_query' => array( | |
| 267 | - array( | |
| 268 | - 'taxonomy' => Sensei()->modules->taxonomy, | |
| 269 | - 'field' => 'id', | |
| 270 | - 'terms' => intval( $module->term_id ) | |
| 271 | - ) | |
| 272 | - ), | |
| 273 | - 'meta_key' => '_order_module_' . $module->term_id, | |
| 274 | - 'orderby' => 'meta_value_num date', | |
| 275 | - 'order' => 'ASC', | |
| 276 | - 'suppress_filters' => 0 | |
| 277 | - ); | |
| 278 | - | |
| 279 | - $lessons = get_posts( $args ); | |
| 280 | -                if ( 0 < count( $lessons ) ) { | |
| 281 | -                    foreach ($lessons as $lesson_item){ | |
| 282 | - $all_lessons[] = $lesson_item->ID; | |
| 283 | - } // End For Loop | |
| 284 | - } // End If Statement | |
| 285 | - } | |
| 286 | - | |
| 287 | - $args = array( | |
| 288 | - 'post_type' => 'lesson', | |
| 289 | - 'posts_per_page' => -1, | |
| 290 | - 'suppress_filters' => 0, | |
| 291 | - 'meta_key' => '_order_' . $lesson_course_id, | |
| 292 | - 'orderby' => 'meta_value_num date', | |
| 293 | - 'order' => 'ASC', | |
| 294 | - 'meta_query' => array( | |
| 295 | - array( | |
| 296 | - 'key' => '_lesson_course', | |
| 297 | - 'value' => intval( $lesson_course_id ), | |
| 298 | - ), | |
| 299 | - ), | |
| 300 | - 'post__not_in' => $all_lessons, | |
| 301 | - ); | |
| 302 | - | |
| 303 | - $other_lessons = get_posts( $args ); | |
| 304 | -            if ( 0 < count( $other_lessons ) ) { | |
| 251 | + $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); | |
| 252 | + | |
| 253 | +			foreach( (array) $modules as $module ) { | |
| 254 | + | |
| 255 | + $args = array( | |
| 256 | + 'post_type' => 'lesson', | |
| 257 | + 'post_status' => 'publish', | |
| 258 | + 'posts_per_page' => -1, | |
| 259 | + 'meta_query' => array( | |
| 260 | + array( | |
| 261 | + 'key' => '_lesson_course', | |
| 262 | + 'value' => intval( $lesson_course_id ), | |
| 263 | + 'compare' => '=' | |
| 264 | + ) | |
| 265 | + ), | |
| 266 | + 'tax_query' => array( | |
| 267 | + array( | |
| 268 | + 'taxonomy' => Sensei()->modules->taxonomy, | |
| 269 | + 'field' => 'id', | |
| 270 | + 'terms' => intval( $module->term_id ) | |
| 271 | + ) | |
| 272 | + ), | |
| 273 | + 'meta_key' => '_order_module_' . $module->term_id, | |
| 274 | + 'orderby' => 'meta_value_num date', | |
| 275 | + 'order' => 'ASC', | |
| 276 | + 'suppress_filters' => 0 | |
| 277 | + ); | |
| 278 | + | |
| 279 | + $lessons = get_posts( $args ); | |
| 280 | +				if ( 0 < count( $lessons ) ) { | |
| 281 | +					foreach ($lessons as $lesson_item){ | |
| 282 | + $all_lessons[] = $lesson_item->ID; | |
| 283 | + } // End For Loop | |
| 284 | + } // End If Statement | |
| 285 | + } | |
| 286 | + | |
| 287 | + $args = array( | |
| 288 | + 'post_type' => 'lesson', | |
| 289 | + 'posts_per_page' => -1, | |
| 290 | + 'suppress_filters' => 0, | |
| 291 | + 'meta_key' => '_order_' . $lesson_course_id, | |
| 292 | + 'orderby' => 'meta_value_num date', | |
| 293 | + 'order' => 'ASC', | |
| 294 | + 'meta_query' => array( | |
| 295 | + array( | |
| 296 | + 'key' => '_lesson_course', | |
| 297 | + 'value' => intval( $lesson_course_id ), | |
| 298 | + ), | |
| 299 | + ), | |
| 300 | + 'post__not_in' => $all_lessons, | |
| 301 | + ); | |
| 302 | + | |
| 303 | + $other_lessons = get_posts( $args ); | |
| 304 | +			if ( 0 < count( $other_lessons ) ) { | |
| 305 | 305 |  				foreach ($other_lessons as $lesson_item){ | 
| 306 | 306 | $all_lessons[] = $lesson_item->ID; | 
| 307 | 307 | } // End For Loop | 
| 308 | 308 | } // End If Statement | 
| 309 | 309 | |
| 310 | -            if ( 0 < count( $all_lessons ) ) { | |
| 310 | +			if ( 0 < count( $all_lessons ) ) { | |
| 311 | 311 | $found_index = false; | 
| 312 | 312 |  				foreach ( $all_lessons as $lesson ){ | 
| 313 | 313 |  					if ( $found_index && $return_values['next_lesson'] == 0 ) { | 
| @@ -338,9 +338,9 @@ discard block | ||
| 338 | 338 | */ | 
| 339 | 339 |    function sensei_get_excerpt( $post_id = '' ) { | 
| 340 | 340 | |
| 341 | - global $post; | |
| 342 | -      _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); | |
| 343 | - return get_the_excerpt(); | |
| 341 | + global $post; | |
| 342 | +	  _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); | |
| 343 | + return get_the_excerpt(); | |
| 344 | 344 | |
| 345 | 345 | } | 
| 346 | 346 | |
| @@ -365,7 +365,7 @@ discard block | ||
| 365 | 365 | */ | 
| 366 | 366 |  function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) { | 
| 367 | 367 | |
| 368 | - return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); | |
| 368 | + return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); | |
| 369 | 369 | |
| 370 | 370 | } // End sensei_has_user_completed_prerequisite_lesson() | 
| 371 | 371 | |
| @@ -480,27 +480,27 @@ discard block | ||
| 480 | 480 | |
| 481 | 481 |  	}else{ | 
| 482 | 482 | |
| 483 | - // if the loop has not been initiated check the first module has lessons | |
| 484 | -        if( -1 == $sensei_modules_loop[ 'current' ]  ){ | |
| 483 | + // if the loop has not been initiated check the first module has lessons | |
| 484 | +		if( -1 == $sensei_modules_loop[ 'current' ]  ){ | |
| 485 | 485 | |
| 486 | - $index = 0; | |
| 486 | + $index = 0; | |
| 487 | 487 | |
| 488 | -            if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { | |
| 489 | - // setup the query for the module lessons | |
| 490 | - $course_id = $sensei_modules_loop['course_id']; | |
| 488 | +			if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { | |
| 489 | + // setup the query for the module lessons | |
| 490 | + $course_id = $sensei_modules_loop['course_id']; | |
| 491 | 491 | |
| 492 | - $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; | |
| 493 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); | |
| 492 | + $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; | |
| 493 | + $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); | |
| 494 | 494 | |
| 495 | - // setup the global wp-query only if the lessons | |
| 496 | -                if( $modules_query->have_posts() ){ | |
| 495 | + // setup the global wp-query only if the lessons | |
| 496 | +				if( $modules_query->have_posts() ){ | |
| 497 | 497 | |
| 498 | - return true; | |
| 498 | + return true; | |
| 499 | 499 | |
| 500 | - } | |
| 501 | - } | |
| 502 | - } | |
| 503 | - // default to false if the first module doesn't have posts | |
| 500 | + } | |
| 501 | + } | |
| 502 | + } | |
| 503 | + // default to false if the first module doesn't have posts | |
| 504 | 504 | return false; | 
| 505 | 505 | |
| 506 | 506 | } | 
| @@ -604,41 +604,41 @@ discard block | ||
| 604 | 604 | */ | 
| 605 | 605 |  function sensei_get_the_module_status(){ | 
| 606 | 606 | |
| 607 | - global $sensei_modules_loop; | |
| 608 | - $module_title = $sensei_modules_loop['current_module']->name; | |
| 609 | - $module_term_id = $sensei_modules_loop['current_module']->term_id; | |
| 610 | - $course_id = $sensei_modules_loop['course_id']; | |
| 611 | - $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() ); | |
| 607 | + global $sensei_modules_loop; | |
| 608 | + $module_title = $sensei_modules_loop['current_module']->name; | |
| 609 | + $module_term_id = $sensei_modules_loop['current_module']->term_id; | |
| 610 | + $course_id = $sensei_modules_loop['course_id']; | |
| 611 | + $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() ); | |
| 612 | 612 | |
| 613 | - $module_status = ''; | |
| 614 | -    if ( $module_progress && $module_progress > 0) { | |
| 613 | + $module_status = ''; | |
| 614 | +	if ( $module_progress && $module_progress > 0) { | |
| 615 | 615 | |
| 616 | -        $module_status = __('Completed', 'woothemes-sensei'); | |
| 616 | +		$module_status = __('Completed', 'woothemes-sensei'); | |
| 617 | 617 | |
| 618 | -        if ($module_progress < 100) { | |
| 618 | +		if ($module_progress < 100) { | |
| 619 | 619 | |
| 620 | -            $module_status = __('In progress', 'woothemes-sensei'); | |
| 620 | +			$module_status = __('In progress', 'woothemes-sensei'); | |
| 621 | 621 | |
| 622 | - } | |
| 622 | + } | |
| 623 | 623 | |
| 624 | - } | |
| 624 | + } | |
| 625 | 625 | |
| 626 | - $module_status_html = '<p class="status module-status completed">' | |
| 627 | - . strtolower( str_replace( ' ', '-', $module_status ) ) | |
| 628 | - . '</p>'; | |
| 626 | + $module_status_html = '<p class="status module-status completed">' | |
| 627 | + . strtolower( str_replace( ' ', '-', $module_status ) ) | |
| 628 | + . '</p>'; | |
| 629 | 629 | |
| 630 | - /** | |
| 631 | - * Filter the module status. | |
| 632 | - * | |
| 633 | - * This fires within the sensei_get_the_module_status function. | |
| 634 | - * | |
| 635 | - * @since 1.9.0 | |
| 636 | - * | |
| 637 | - * @param $module_status_html | |
| 638 | - * @param $module_term_id | |
| 639 | - * @param $course_id | |
| 640 | - */ | |
| 641 | - return apply_filters( 'sensei_the_module_status_html', $module_status_html , $module_term_id, $course_id ); | |
| 630 | + /** | |
| 631 | + * Filter the module status. | |
| 632 | + * | |
| 633 | + * This fires within the sensei_get_the_module_status function. | |
| 634 | + * | |
| 635 | + * @since 1.9.0 | |
| 636 | + * | |
| 637 | + * @param $module_status_html | |
| 638 | + * @param $module_term_id | |
| 639 | + * @param $course_id | |
| 640 | + */ | |
| 641 | + return apply_filters( 'sensei_the_module_status_html', $module_status_html , $module_term_id, $course_id ); | |
| 642 | 642 | |
| 643 | 643 | } | 
| 644 | 644 | |
| @@ -648,7 +648,7 @@ discard block | ||
| 648 | 648 | */ | 
| 649 | 649 |  function sensei_the_module_status(){ | 
| 650 | 650 | |
| 651 | - echo sensei_get_the_module_status(); | |
| 651 | + echo sensei_get_the_module_status(); | |
| 652 | 652 | |
| 653 | 653 | } | 
| 654 | 654 | |
| @@ -669,21 +669,21 @@ discard block | ||
| 669 | 669 | */ | 
| 670 | 670 |  function sensei_quiz_has_questions(){ | 
| 671 | 671 | |
| 672 | - global $sensei_question_loop; | |
| 672 | + global $sensei_question_loop; | |
| 673 | 673 | |
| 674 | -    if( !isset( $sensei_question_loop['total'] ) ){ | |
| 675 | - return false; | |
| 676 | - } | |
| 674 | +	if( !isset( $sensei_question_loop['total'] ) ){ | |
| 675 | + return false; | |
| 676 | + } | |
| 677 | 677 | |
| 678 | -    if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){ | |
| 678 | +	if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){ | |
| 679 | 679 | |
| 680 | - return true; | |
| 680 | + return true; | |
| 681 | 681 | |
| 682 | -    }else{ | |
| 682 | +	}else{ | |
| 683 | 683 | |
| 684 | - return false; | |
| 684 | + return false; | |
| 685 | 685 | |
| 686 | - } | |
| 686 | + } | |
| 687 | 687 | |
| 688 | 688 | }// end sensei_quiz_has_questions | 
| 689 | 689 | |
| @@ -694,15 +694,14 @@ discard block | ||
| 694 | 694 | * execution. | 
| 695 | 695 | * | 
| 696 | 696 | * @since 1.9.0 | 
| 697 | - | |
| 698 | 697 | */ | 
| 699 | 698 |  function sensei_setup_the_question(){ | 
| 700 | 699 | |
| 701 | - global $sensei_question_loop; | |
| 700 | + global $sensei_question_loop; | |
| 702 | 701 | |
| 703 | - $sensei_question_loop['current']++; | |
| 704 | - $index = $sensei_question_loop['current']; | |
| 705 | - $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; | |
| 702 | + $sensei_question_loop['current']++; | |
| 703 | + $index = $sensei_question_loop['current']; | |
| 704 | + $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; | |
| 706 | 705 | |
| 707 | 706 | |
| 708 | 707 | }// end sensei_setup_the_question | 
| @@ -715,12 +714,12 @@ discard block | ||
| 715 | 714 | */ | 
| 716 | 715 |  function sensei_the_question_content(){ | 
| 717 | 716 | |
| 718 | - global $sensei_question_loop; | |
| 717 | + global $sensei_question_loop; | |
| 719 | 718 | |
| 720 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); | |
| 719 | + $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); | |
| 721 | 720 | |
| 722 | - // load the template that displays the question information. | |
| 723 | - WooThemes_Sensei_Question::load_question_template( $question_type ); | |
| 721 | + // load the template that displays the question information. | |
| 722 | + WooThemes_Sensei_Question::load_question_template( $question_type ); | |
| 724 | 723 | |
| 725 | 724 | }// end sensei_the_question_content | 
| 726 | 725 | |
| @@ -731,26 +730,26 @@ discard block | ||
| 731 | 730 | */ | 
| 732 | 731 |  function sensei_the_question_class(){ | 
| 733 | 732 | |
| 734 | - global $sensei_question_loop; | |
| 733 | + global $sensei_question_loop; | |
| 735 | 734 | |
| 736 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); | |
| 735 | + $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); | |
| 737 | 736 | |
| 738 | - /** | |
| 739 | - * filter the sensei question class within | |
| 740 | - * the quiz question loop. | |
| 741 | - * | |
| 742 | - * @since 1.9.0 | |
| 743 | - */ | |
| 744 | - $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); | |
| 737 | + /** | |
| 738 | + * filter the sensei question class within | |
| 739 | + * the quiz question loop. | |
| 740 | + * | |
| 741 | + * @since 1.9.0 | |
| 742 | + */ | |
| 743 | + $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); | |
| 745 | 744 | |
| 746 | - $html_classes = ''; | |
| 747 | -    foreach( $classes as $class ){ | |
| 745 | + $html_classes = ''; | |
| 746 | +	foreach( $classes as $class ){ | |
| 748 | 747 | |
| 749 | - $html_classes .= $class . ' '; | |
| 748 | + $html_classes .= $class . ' '; | |
| 750 | 749 | |
| 751 | - }// end foreach | |
| 750 | + }// end foreach | |
| 752 | 751 | |
| 753 | - esc_attr_e( trim( $html_classes ) ); | |
| 752 | + esc_attr_e( trim( $html_classes ) ); | |
| 754 | 753 | |
| 755 | 754 | } | 
| 756 | 755 | |
| @@ -761,12 +760,12 @@ discard block | ||
| 761 | 760 | */ | 
| 762 | 761 |  function sensei_get_the_question_id( ){ | 
| 763 | 762 | |
| 764 | - global $sensei_question_loop; | |
| 765 | -    if( isset( $sensei_question_loop['current_question']->ID ) ){ | |
| 763 | + global $sensei_question_loop; | |
| 764 | +	if( isset( $sensei_question_loop['current_question']->ID ) ){ | |
| 766 | 765 | |
| 767 | - return $sensei_question_loop['current_question']->ID; | |
| 766 | + return $sensei_question_loop['current_question']->ID; | |
| 768 | 767 | |
| 769 | - } | |
| 768 | + } | |
| 770 | 769 | |
| 771 | 770 | }// end sensei_the_question_id | 
| 772 | 771 | |
| @@ -793,63 +792,63 @@ discard block | ||
| 793 | 792 | */ | 
| 794 | 793 |  function sensei_can_user_view_lesson( $lesson_id = '', $user_id = ''  ){ | 
| 795 | 794 | |
| 796 | -    if( empty( $lesson_id ) ){ | |
| 795 | +	if( empty( $lesson_id ) ){ | |
| 797 | 796 | |
| 798 | - $lesson_id = get_the_ID(); | |
| 797 | + $lesson_id = get_the_ID(); | |
| 799 | 798 | |
| 800 | - } | |
| 799 | + } | |
| 801 | 800 | |
| 802 | -    if( empty( $user_id ) ){ | |
| 801 | +	if( empty( $user_id ) ){ | |
| 803 | 802 | |
| 804 | - $user_id = get_current_user_id(); | |
| 803 | + $user_id = get_current_user_id(); | |
| 805 | 804 | |
| 806 | - } | |
| 805 | + } | |
| 807 | 806 | |
| 808 | - // Check for prerequisite lesson completions | |
| 809 | - $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); | |
| 810 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); | |
| 811 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); | |
| 807 | + // Check for prerequisite lesson completions | |
| 808 | + $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); | |
| 809 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); | |
| 810 | + $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); | |
| 812 | 811 | |
| 813 | - $is_preview = false; | |
| 814 | -    if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { | |
| 812 | + $is_preview = false; | |
| 813 | +	if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { | |
| 815 | 814 | |
| 816 | - $is_preview = true; | |
| 817 | - $pre_requisite_complete = true; | |
| 815 | + $is_preview = true; | |
| 816 | + $pre_requisite_complete = true; | |
| 818 | 817 | |
| 819 | - }; | |
| 818 | + }; | |
| 820 | 819 | |
| 821 | 820 | |
| 822 | - $user_can_access_lesson = false; | |
| 821 | + $user_can_access_lesson = false; | |
| 823 | 822 | |
| 824 | -    if( is_user_logged_in() && $user_taking_course ){ | |
| 823 | +	if( is_user_logged_in() && $user_taking_course ){ | |
| 825 | 824 | |
| 826 | - $user_can_access_lesson = true; | |
| 825 | + $user_can_access_lesson = true; | |
| 827 | 826 | |
| 828 | - } | |
| 827 | + } | |
| 829 | 828 | |
| 830 | 829 | |
| 831 | - $access_permission = false; | |
| 830 | + $access_permission = false; | |
| 832 | 831 | |
| 833 | -    if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) { | |
| 832 | +	if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) { | |
| 834 | 833 | |
| 835 | - $access_permission = true; | |
| 834 | + $access_permission = true; | |
| 836 | 835 | |
| 837 | - } | |
| 836 | + } | |
| 838 | 837 | |
| 839 | - $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; | |
| 838 | + $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; | |
| 840 | 839 | |
| 841 | - /** | |
| 842 | - * Filter the can user view lesson function | |
| 843 | - * | |
| 844 | - * @since 1.9.0 | |
| 845 | - * | |
| 846 | - * @hooked Sensei_WC::alter_can_user_view_lesson | |
| 847 | - * | |
| 848 | - * @param bool $can_user_view_lesson | |
| 849 | - * @param string $lesson_id | |
| 850 | - * @param string $user_id | |
| 851 | - */ | |
| 852 | - return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); | |
| 840 | + /** | |
| 841 | + * Filter the can user view lesson function | |
| 842 | + * | |
| 843 | + * @since 1.9.0 | |
| 844 | + * | |
| 845 | + * @hooked Sensei_WC::alter_can_user_view_lesson | |
| 846 | + * | |
| 847 | + * @param bool $can_user_view_lesson | |
| 848 | + * @param string $lesson_id | |
| 849 | + * @param string $user_id | |
| 850 | + */ | |
| 851 | + return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); | |
| 853 | 852 | |
| 854 | 853 | } // end sensei_can_current_user_view_lesson | 
| 855 | 854 | |
| @@ -861,49 +860,49 @@ discard block | ||
| 861 | 860 | */ | 
| 862 | 861 |  function sensei_the_single_lesson_meta(){ | 
| 863 | 862 | |
| 864 | - // if the lesson meta is included within theme load that instead of the function content | |
| 865 | - $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); | |
| 866 | -    if( ! empty( $template ) ){ | |
| 867 | - | |
| 868 | - Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); | |
| 869 | - return; | |
| 863 | + // if the lesson meta is included within theme load that instead of the function content | |
| 864 | + $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); | |
| 865 | +	if( ! empty( $template ) ){ | |
| 870 | 866 | |
| 871 | - } | |
| 867 | + Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); | |
| 868 | + return; | |
| 872 | 869 | |
| 873 | - // Get the meta info | |
| 874 | - $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); | |
| 875 | - $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); | |
| 870 | + } | |
| 876 | 871 | |
| 877 | - // Complete Lesson Logic | |
| 878 | - do_action( 'sensei_complete_lesson' ); | |
| 879 | - // Check that the course has been started | |
| 880 | - if ( Sensei()->access_settings() | |
| 881 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) | |
| 882 | -        || $is_preview ) { | |
| 883 | - ?> | |
| 872 | + // Get the meta info | |
| 873 | + $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); | |
| 874 | + $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); | |
| 875 | + | |
| 876 | + // Complete Lesson Logic | |
| 877 | + do_action( 'sensei_complete_lesson' ); | |
| 878 | + // Check that the course has been started | |
| 879 | + if ( Sensei()->access_settings() | |
| 880 | + || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) | |
| 881 | +		|| $is_preview ) { | |
| 882 | + ?> | |
| 884 | 883 | <section class="lesson-meta"> | 
| 885 | 884 | <?php | 
| 886 | -            if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { | |
| 885 | +			if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { | |
| 887 | 886 | |
| 888 | - do_action( 'sensei_lesson_video', get_the_ID() ); | |
| 887 | + do_action( 'sensei_lesson_video', get_the_ID() ); | |
| 889 | 888 | |
| 890 | - } | |
| 891 | - ?> | |
| 889 | + } | |
| 890 | + ?> | |
| 892 | 891 | <?php do_action( 'sensei_frontend_messages' ); ?> | 
| 893 | 892 | |
| 894 | 893 | <?php if ( ! $is_preview | 
| 895 | -                || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { | |
| 894 | +				|| Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { | |
| 896 | 895 | |
| 897 | - sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); | |
| 896 | + sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); | |
| 898 | 897 | |
| 899 | - } ?> | |
| 898 | + } ?> | |
| 900 | 899 | </section> | 
| 901 | 900 | |
| 902 | 901 | <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?> | 
| 903 | 902 | |
| 904 | 903 | <?php } | 
| 905 | 904 | |
| 906 | - do_action( 'sensei_lesson_meta_extra', get_the_ID() ); | |
| 905 | + do_action( 'sensei_lesson_meta_extra', get_the_ID() ); | |
| 907 | 906 | |
| 908 | 907 | } // end the_single_lesson_meta | 
| 909 | 908 | |
| @@ -919,16 +918,16 @@ discard block | ||
| 919 | 918 | */ | 
| 920 | 919 |  function get_sensei_header(){ | 
| 921 | 920 | |
| 922 | - if ( ! defined( 'ABSPATH' ) ) exit; | |
| 921 | + if ( ! defined( 'ABSPATH' ) ) exit; | |
| 923 | 922 | |
| 924 | - get_header(); | |
| 923 | + get_header(); | |
| 925 | 924 | |
| 926 | - /** | |
| 927 | - * sensei_before_main_content hook | |
| 928 | - * | |
| 929 | - * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) | |
| 930 | - */ | |
| 931 | - do_action( 'sensei_before_main_content' ); | |
| 925 | + /** | |
| 926 | + * sensei_before_main_content hook | |
| 927 | + * | |
| 928 | + * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) | |
| 929 | + */ | |
| 930 | + do_action( 'sensei_before_main_content' ); | |
| 932 | 931 | |
| 933 | 932 | }// end get_sensei_header | 
| 934 | 933 | |
| @@ -944,28 +943,28 @@ discard block | ||
| 944 | 943 | */ | 
| 945 | 944 |  function get_sensei_footer(){ | 
| 946 | 945 | |
| 947 | - /** | |
| 948 | - * sensei_pagination hook | |
| 949 | - * | |
| 950 | - * @hooked sensei_pagination - 10 (outputs pagination) | |
| 951 | - */ | |
| 952 | - do_action( 'sensei_pagination' ); | |
| 953 | - | |
| 954 | - /** | |
| 955 | - * sensei_after_main_content hook | |
| 956 | - * | |
| 957 | - * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) | |
| 958 | - */ | |
| 959 | - do_action( 'sensei_after_main_content' ); | |
| 960 | - | |
| 961 | - /** | |
| 962 | - * sensei_sidebar hook | |
| 963 | - * | |
| 964 | - * @hooked sensei_get_sidebar - 10 | |
| 965 | - */ | |
| 966 | - do_action( 'sensei_sidebar' ); | |
| 967 | - | |
| 968 | - get_footer(); | |
| 946 | + /** | |
| 947 | + * sensei_pagination hook | |
| 948 | + * | |
| 949 | + * @hooked sensei_pagination - 10 (outputs pagination) | |
| 950 | + */ | |
| 951 | + do_action( 'sensei_pagination' ); | |
| 952 | + | |
| 953 | + /** | |
| 954 | + * sensei_after_main_content hook | |
| 955 | + * | |
| 956 | + * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) | |
| 957 | + */ | |
| 958 | + do_action( 'sensei_after_main_content' ); | |
| 959 | + | |
| 960 | + /** | |
| 961 | + * sensei_sidebar hook | |
| 962 | + * | |
| 963 | + * @hooked sensei_get_sidebar - 10 | |
| 964 | + */ | |
| 965 | + do_action( 'sensei_sidebar' ); | |
| 966 | + | |
| 967 | + get_footer(); | |
| 969 | 968 | |
| 970 | 969 | }// end get_sensei_header | 
| 971 | 970 | |
| @@ -977,14 +976,14 @@ discard block | ||
| 977 | 976 | */ | 
| 978 | 977 |  function the_no_permissions_title(){ | 
| 979 | 978 | |
| 980 | - /** | |
| 981 | - * Filter the no permissions title just before it is echo'd on the | |
| 982 | - * no-permissions.php file. | |
| 983 | - * | |
| 984 | - * @since 1.9.0 | |
| 985 | - * @param $no_permissions_title | |
| 986 | - */ | |
| 987 | - echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); | |
| 979 | + /** | |
| 980 | + * Filter the no permissions title just before it is echo'd on the | |
| 981 | + * no-permissions.php file. | |
| 982 | + * | |
| 983 | + * @since 1.9.0 | |
| 984 | + * @param $no_permissions_title | |
| 985 | + */ | |
| 986 | + echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); | |
| 988 | 987 | |
| 989 | 988 | } | 
| 990 | 989 | |
| @@ -995,14 +994,14 @@ discard block | ||
| 995 | 994 | */ | 
| 996 | 995 |  function the_no_permissions_message( $post_id ){ | 
| 997 | 996 | |
| 998 | - /** | |
| 999 | - * Filter the no permissions message just before it is echo'd on the | |
| 1000 | - * no-permissions.php file. | |
| 1001 | - * | |
| 1002 | - * @since 1.9.0 | |
| 1003 | - * @param $no_permissions_message | |
| 1004 | - */ | |
| 1005 | - echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); | |
| 997 | + /** | |
| 998 | + * Filter the no permissions message just before it is echo'd on the | |
| 999 | + * no-permissions.php file. | |
| 1000 | + * | |
| 1001 | + * @since 1.9.0 | |
| 1002 | + * @param $no_permissions_message | |
| 1003 | + */ | |
| 1004 | + echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); | |
| 1006 | 1005 | |
| 1007 | 1006 | } | 
| 1008 | 1007 | |
| @@ -1013,8 +1012,8 @@ discard block | ||
| 1013 | 1012 | */ | 
| 1014 | 1013 |  function sensei_the_excerpt( $post_id ){ | 
| 1015 | 1014 | |
| 1016 | - global $post; | |
| 1017 | - the_excerpt( $post ); | |
| 1015 | + global $post; | |
| 1016 | + the_excerpt( $post ); | |
| 1018 | 1017 | |
| 1019 | 1018 | } | 
| 1020 | 1019 | |
| @@ -1028,9 +1027,9 @@ discard block | ||
| 1028 | 1027 | */ | 
| 1029 | 1028 |   function sensei_get_current_page_url(){ | 
| 1030 | 1029 | |
| 1031 | - global $wp; | |
| 1032 | - $current_page_url = home_url( $wp->request ); | |
| 1033 | - return $current_page_url; | |
| 1030 | + global $wp; | |
| 1031 | + $current_page_url = home_url( $wp->request ); | |
| 1032 | + return $current_page_url; | |
| 1034 | 1033 | |
| 1035 | 1034 | } | 
| 1036 | 1035 | |
| @@ -1042,7 +1041,7 @@ discard block | ||
| 1042 | 1041 | */ | 
| 1043 | 1042 |  function sensei_the_my_courses_content(){ | 
| 1044 | 1043 | |
| 1045 | - echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); | |
| 1044 | + echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); | |
| 1046 | 1045 | |
| 1047 | 1046 | } // sensei_the_my_courses_content | 
| 1048 | 1047 | |
| @@ -1057,7 +1056,7 @@ discard block | ||
| 1057 | 1056 | */ | 
| 1058 | 1057 |  function sensei_load_template( $template_name ){ | 
| 1059 | 1058 | |
| 1060 | - Sensei_Templates::get_template( $template_name ); | |
| 1059 | + Sensei_Templates::get_template( $template_name ); | |
| 1061 | 1060 | |
| 1062 | 1061 | } | 
| 1063 | 1062 | |
| @@ -1071,7 +1070,7 @@ discard block | ||
| 1071 | 1070 | */ | 
| 1072 | 1071 |  function sensei_load_template_part( $slug, $name ){ | 
| 1073 | 1072 | |
| 1074 | - Sensei_Templates::get_part( $slug, $name ); | |
| 1073 | + Sensei_Templates::get_part( $slug, $name ); | |
| 1075 | 1074 | |
| 1076 | 1075 | } | 
| 1077 | 1076 | |
| @@ -1090,17 +1089,17 @@ discard block | ||
| 1090 | 1089 | */ | 
| 1091 | 1090 |  function sensei_the_lesson_excerpt( $lesson_id = '' ) { | 
| 1092 | 1091 | |
| 1093 | -    if( empty( $lesson_id )){ | |
| 1092 | +	if( empty( $lesson_id )){ | |
| 1094 | 1093 | |
| 1095 | - $lesson_id = get_the_ID(); | |
| 1094 | + $lesson_id = get_the_ID(); | |
| 1096 | 1095 | |
| 1097 | - } | |
| 1096 | + } | |
| 1098 | 1097 | |
| 1099 | -    if( 'lesson' != get_post_type( $lesson_id ) ){ | |
| 1100 | - return; | |
| 1101 | - } | |
| 1098 | +	if( 'lesson' != get_post_type( $lesson_id ) ){ | |
| 1099 | + return; | |
| 1100 | + } | |
| 1102 | 1101 | |
| 1103 | - echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); | |
| 1102 | + echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); | |
| 1104 | 1103 | |
| 1105 | 1104 | }// End lesson_excerpt() | 
| 1106 | 1105 | |
| @@ -1110,16 +1109,16 @@ discard block | ||
| 1110 | 1109 | * @since 1.9.0 | 
| 1111 | 1110 | */ | 
| 1112 | 1111 |  function sensei_the_course_results_lessons(){ | 
| 1113 | - // load backwards compatible template name if it exists in the users theme | |
| 1114 | - $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); | |
| 1115 | -    if( $located_template ){ | |
| 1112 | + // load backwards compatible template name if it exists in the users theme | |
| 1113 | + $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); | |
| 1114 | +	if( $located_template ){ | |
| 1116 | 1115 | |
| 1117 | - Sensei_Templates::get_template( 'course-results/course-lessons.php' ); | |
| 1118 | - return; | |
| 1116 | + Sensei_Templates::get_template( 'course-results/course-lessons.php' ); | |
| 1117 | + return; | |
| 1119 | 1118 | |
| 1120 | - } | |
| 1119 | + } | |
| 1121 | 1120 | |
| 1122 | - Sensei_Templates::get_template( 'course-results/lessons.php' ); | |
| 1121 | + Sensei_Templates::get_template( 'course-results/lessons.php' ); | |
| 1123 | 1122 | } | 
| 1124 | 1123 | |
| 1125 | 1124 | /** | 
| @@ -1131,7 +1130,7 @@ discard block | ||
| 1131 | 1130 | */ | 
| 1132 | 1131 |  function sensei_courses_per_row(){ | 
| 1133 | 1132 | |
| 1134 | - echo Sensei_Course::get_loop_number_of_columns(); | |
| 1133 | + echo Sensei_Course::get_loop_number_of_columns(); | |
| 1135 | 1134 | |
| 1136 | 1135 | } | 
| 1137 | 1136 | |
| @@ -1145,7 +1144,7 @@ discard block | ||
| 1145 | 1144 | */ | 
| 1146 | 1145 |  function sensei_get_template( $template_name, $args, $path ){ | 
| 1147 | 1146 | |
| 1148 | - Sensei_Templates::get_template( $template_name, $args, $path ); | |
| 1147 | + Sensei_Templates::get_template( $template_name, $args, $path ); | |
| 1149 | 1148 | |
| 1150 | 1149 | } | 
| 1151 | 1150 | |
| @@ -1159,14 +1158,14 @@ discard block | ||
| 1159 | 1158 | */ | 
| 1160 | 1159 |  function get_the_lesson_status_class(){ | 
| 1161 | 1160 | |
| 1162 | - $status_class = ''; | |
| 1163 | - $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); | |
| 1161 | + $status_class = ''; | |
| 1162 | + $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); | |
| 1164 | 1163 | |
| 1165 | -    if ( $lesson_completed ) { | |
| 1166 | - $status_class = 'completed'; | |
| 1167 | - } | |
| 1164 | +	if ( $lesson_completed ) { | |
| 1165 | + $status_class = 'completed'; | |
| 1166 | + } | |
| 1168 | 1167 | |
| 1169 | - return $status_class; | |
| 1168 | + return $status_class; | |
| 1170 | 1169 | |
| 1171 | 1170 | }// end get_the_lesson_status_class | 
| 1172 | 1171 | /** | 
| @@ -1178,5 +1177,5 @@ discard block | ||
| 1178 | 1177 | */ | 
| 1179 | 1178 |  function sensei_the_lesson_status_class(){ | 
| 1180 | 1179 | |
| 1181 | - echo get_the_lesson_status_class(); | |
| 1180 | + echo get_the_lesson_status_class(); | |
| 1182 | 1181 | } | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined( 'ABSPATH' ) ){ exit; } // Exit if accessed directly | |
| 2 | +if ( ! defined('ABSPATH')) { exit; } // Exit if accessed directly | |
| 3 | 3 | |
| 4 | 4 | /*************************************************************************************************** | 
| 5 | 5 | * Output tags. | 
| @@ -12,9 +12,9 @@ discard block | ||
| 12 | 12 | * @param string $type (default: 'newcourses') | 
| 13 | 13 | * @return void | 
| 14 | 14 | */ | 
| 15 | -    function sensei_course_archive_next_link( $type = 'newcourses' ) { | |
| 15 | +    function sensei_course_archive_next_link($type = 'newcourses') { | |
| 16 | 16 | |
| 17 | -        _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); | |
| 17 | +        _deprecated_function('sensei_course_archive_next_link', '1.9.0', 'This is no longer used or required in Sensei.'); | |
| 18 | 18 | |
| 19 | 19 | } // End sensei_course_archive_next_link() | 
| 20 | 20 | |
| @@ -27,15 +27,15 @@ discard block | ||
| 27 | 27 |  	 function course_single_lessons() { | 
| 28 | 28 | |
| 29 | 29 | // load backwards compatible template name if it exists in the users theme | 
| 30 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); | |
| 31 | -         if( $located_template ){ | |
| 30 | + $located_template = locate_template(Sensei()->template_url.'single-course/course-lessons.php'); | |
| 31 | +         if ($located_template) { | |
| 32 | 32 | |
| 33 | - Sensei_Templates::get_template( 'single-course/course-lessons.php' ); | |
| 33 | +             Sensei_Templates::get_template('single-course/course-lessons.php'); | |
| 34 | 34 | return; | 
| 35 | 35 | |
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | - Sensei_Templates::get_template( 'single-course/lessons.php' ); | |
| 38 | +		Sensei_Templates::get_template('single-course/lessons.php'); | |
| 39 | 39 | |
| 40 | 40 | } // End course_single_lessons() | 
| 41 | 41 | |
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | */ | 
| 49 | 49 |  	 function lesson_single_meta() { | 
| 50 | 50 | |
| 51 | -         _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); | |
| 51 | +         _deprecated_function('lesson_single_meta', '1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta'); | |
| 52 | 52 | sensei_the_single_lesson_meta(); | 
| 53 | 53 | |
| 54 | 54 | } // End lesson_single_meta() | 
| @@ -62,9 +62,9 @@ discard block | ||
| 62 | 62 | * @return void | 
| 63 | 63 | * @deprecated since 1.9.0 | 
| 64 | 64 | */ | 
| 65 | -	 function quiz_questions( $return = false ) { | |
| 65 | +	 function quiz_questions($return = false) { | |
| 66 | 66 | |
| 67 | - Sensei_Templates::get_template( 'single-quiz/quiz-questions.php' ); | |
| 67 | +	 	Sensei_Templates::get_template('single-quiz/quiz-questions.php'); | |
| 68 | 68 | |
| 69 | 69 | } // End quiz_questions() | 
| 70 | 70 | |
| @@ -76,9 +76,9 @@ discard block | ||
| 76 | 76 | * @return void | 
| 77 | 77 | * @deprecated | 
| 78 | 78 | */ | 
| 79 | -	 function quiz_question_type( $question_type = 'multiple-choice' ) { | |
| 79 | +	 function quiz_question_type($question_type = 'multiple-choice') { | |
| 80 | 80 | |
| 81 | - Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); | |
| 81 | +         Sensei_Templates::get_template('single-quiz/question_type-'.$question_type.'.php'); | |
| 82 | 82 | |
| 83 | 83 | } // End lesson_single_meta() | 
| 84 | 84 | |
| @@ -94,9 +94,9 @@ discard block | ||
| 94 | 94 | * @param mixed $course_id | 
| 95 | 95 | * @return bool | 
| 96 | 96 | */ | 
| 97 | -	function sensei_check_prerequisite_course( $course_id ) { | |
| 97 | +	function sensei_check_prerequisite_course($course_id) { | |
| 98 | 98 | |
| 99 | - return Sensei_Course::is_prerequisite_complete( $course_id ); | |
| 99 | + return Sensei_Course::is_prerequisite_complete($course_id); | |
| 100 | 100 | |
| 101 | 101 | } // End sensei_check_prerequisite_course() | 
| 102 | 102 | |
| @@ -108,16 +108,16 @@ discard block | ||
| 108 | 108 | * @param mixed $course_id | 
| 109 | 109 | * @return void | 
| 110 | 110 | */ | 
| 111 | -	function sensei_start_course_form( $course_id ) { | |
| 111 | +	function sensei_start_course_form($course_id) { | |
| 112 | 112 | |
| 113 | - $prerequisite_complete = sensei_check_prerequisite_course( $course_id ); | |
| 113 | + $prerequisite_complete = sensei_check_prerequisite_course($course_id); | |
| 114 | 114 | |
| 115 | -		if ( $prerequisite_complete ) { | |
| 116 | - ?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> | |
| 115 | +		if ($prerequisite_complete) { | |
| 116 | + ?><form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> | |
| 117 | 117 | |
| 118 | - <input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" /> | |
| 118 | +    			<input type="hidden" name="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" id="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_start_course_noonce')); ?>" /> | |
| 119 | 119 | |
| 120 | - <span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span> | |
| 120 | +    			<span><input name="course_start" type="submit" class="course-start" value="<?php _e('Start taking this Course', 'woothemes-sensei'); ?>"/></span> | |
| 121 | 121 | |
| 122 | 122 | </form><?php | 
| 123 | 123 | } // End If Statement | 
| @@ -132,9 +132,9 @@ discard block | ||
| 132 | 132 | * @param mixed $course_id | 
| 133 | 133 | * @return void | 
| 134 | 134 | */ | 
| 135 | -	function sensei_wc_add_to_cart( $course_id ) { | |
| 135 | +	function sensei_wc_add_to_cart($course_id) { | |
| 136 | 136 | |
| 137 | - Sensei_WC::the_add_to_cart_button_html( $course_id ); | |
| 137 | + Sensei_WC::the_add_to_cart_button_html($course_id); | |
| 138 | 138 | |
| 139 | 139 | } // End sensei_wc_add_to_cart() | 
| 140 | 140 | |
| @@ -146,8 +146,8 @@ discard block | ||
| 146 | 146 | * @param int $wc_post_id (default: 0) | 
| 147 | 147 | * @return bool | 
| 148 | 148 | */ | 
| 149 | -	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { | |
| 150 | - return Sensei_WC::is_product_in_cart( $wc_product_id ); | |
| 149 | +	function sensei_check_if_product_is_in_cart($wc_product_id = 0) { | |
| 150 | + return Sensei_WC::is_product_in_cart($wc_product_id); | |
| 151 | 151 | } // End sensei_check_if_product_is_in_cart() | 
| 152 | 152 | |
| 153 | 153 | /** | 
| @@ -157,16 +157,16 @@ discard block | ||
| 157 | 157 | * @param mixed $post_id | 
| 158 | 158 | * @return void | 
| 159 | 159 | */ | 
| 160 | -	function sensei_simple_course_price( $post_id ) { | |
| 160 | +	function sensei_simple_course_price($post_id) { | |
| 161 | 161 | |
| 162 | 162 | //WooCommerce Pricing | 
| 163 | -        if ( Sensei_WC::is_woocommerce_active() ) { | |
| 164 | - $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); | |
| 165 | -    	    if ( 0 < $wc_post_id ) { | |
| 163 | +        if (Sensei_WC::is_woocommerce_active()) { | |
| 164 | + $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true); | |
| 165 | +    	    if (0 < $wc_post_id) { | |
| 166 | 166 | // Get the product | 
| 167 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); | |
| 167 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); | |
| 168 | 168 | |
| 169 | -    	    	if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> | |
| 169 | +    	    	if (isset($product) && ! empty($product) && $product->is_purchasable() && $product->is_in_stock() && ! sensei_check_if_product_is_in_cart($wc_post_id)) { ?> | |
| 170 | 170 | <span class="course-price"><?php echo $product->get_price_html(); ?></span> | 
| 171 | 171 | <?php } // End If Statement | 
| 172 | 172 | } // End If Statement | 
| @@ -180,11 +180,11 @@ discard block | ||
| 180 | 180 | * @param array $widget_args (default: array()) | 
| 181 | 181 | * @return array | 
| 182 | 182 | */ | 
| 183 | -	function sensei_recent_comments_widget_filter( $widget_args = array() ) { | |
| 184 | - if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' ); | |
| 183 | +	function sensei_recent_comments_widget_filter($widget_args = array()) { | |
| 184 | +		if ( ! isset($widget_args['post_type'])) $widget_args['post_type'] = array('post', 'page'); | |
| 185 | 185 | return $widget_args; | 
| 186 | 186 | } // End sensei_recent_comments_widget_filter() | 
| 187 | - add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 ); | |
| 187 | +	add_filter('widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1); | |
| 188 | 188 | |
| 189 | 189 | /** | 
| 190 | 190 | * sensei_course_archive_filter function. | 
| @@ -193,26 +193,26 @@ discard block | ||
| 193 | 193 | * @param WP_Query $query ( default: array ( ) ) | 
| 194 | 194 | * @return void | 
| 195 | 195 | */ | 
| 196 | -	function sensei_course_archive_filter( $query ) { | |
| 196 | +	function sensei_course_archive_filter($query) { | |
| 197 | 197 | |
| 198 | 198 | |
| 199 | - if ( ! $query->is_main_query() ) | |
| 199 | + if ( ! $query->is_main_query()) | |
| 200 | 200 | return; | 
| 201 | 201 | |
| 202 | 202 | // Apply Filter only if on frontend and when course archive is running | 
| 203 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); | |
| 203 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); | |
| 204 | 204 | |
| 205 | -		if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) { | |
| 205 | +		if ( ! is_admin() && 0 < $course_page_id && 0 < intval($query->get('page_id')) && $query->get('page_id') == $course_page_id) { | |
| 206 | 206 | // Check for pagination settings | 
| 207 | -   			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { | |
| 208 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); | |
| 207 | +   			if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { | |
| 208 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); | |
| 209 | 209 |      		} else { | 
| 210 | - $amount = $query->get( 'posts_per_page' ); | |
| 210 | +    			$amount = $query->get('posts_per_page'); | |
| 211 | 211 | } // End If Statement | 
| 212 | - $query->set( 'posts_per_page', $amount ); | |
| 212 | +    		$query->set('posts_per_page', $amount); | |
| 213 | 213 | } // End If Statement | 
| 214 | 214 | } // End sensei_course_archive_filter() | 
| 215 | - add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 ); | |
| 215 | +	add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1); | |
| 216 | 216 | |
| 217 | 217 | /** | 
| 218 | 218 | * sensei_complete_lesson_button description | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | * @return html | 
| 221 | 221 | */ | 
| 222 | 222 |  	function sensei_complete_lesson_button() { | 
| 223 | - do_action( 'sensei_complete_lesson_button' ); | |
| 223 | +		do_action('sensei_complete_lesson_button'); | |
| 224 | 224 | } // End sensei_complete_lesson_button() | 
| 225 | 225 | |
| 226 | 226 | /** | 
| @@ -229,7 +229,7 @@ discard block | ||
| 229 | 229 | * @return html | 
| 230 | 230 | */ | 
| 231 | 231 |  	function sensei_reset_lesson_button() { | 
| 232 | - do_action( 'sensei_reset_lesson_button' ); | |
| 232 | +		do_action('sensei_reset_lesson_button'); | |
| 233 | 233 | } // End sensei_reset_lesson_button() | 
| 234 | 234 | |
| 235 | 235 | /** | 
| @@ -238,19 +238,19 @@ discard block | ||
| 238 | 238 | * @param integer $lesson_id | 
| 239 | 239 | * @return array $return_values | 
| 240 | 240 | */ | 
| 241 | -	function sensei_get_prev_next_lessons( $lesson_id = 0 ) { | |
| 241 | +	function sensei_get_prev_next_lessons($lesson_id = 0) { | |
| 242 | 242 | |
| 243 | 243 | $return_values = array(); | 
| 244 | 244 | $return_values['prev_lesson'] = 0; | 
| 245 | 245 | $return_values['next_lesson'] = 0; | 
| 246 | -		if ( 0 < $lesson_id ) { | |
| 246 | +		if (0 < $lesson_id) { | |
| 247 | 247 | // Get the List of Lessons in the Course | 
| 248 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); | |
| 248 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); | |
| 249 | 249 | $all_lessons = array(); | 
| 250 | 250 | |
| 251 | - $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); | |
| 251 | + $modules = Sensei()->modules->get_course_modules(intval($lesson_course_id)); | |
| 252 | 252 | |
| 253 | -            foreach( (array) $modules as $module ) { | |
| 253 | +            foreach ((array) $modules as $module) { | |
| 254 | 254 | |
| 255 | 255 | $args = array( | 
| 256 | 256 | 'post_type' => 'lesson', | 
| @@ -259,7 +259,7 @@ discard block | ||
| 259 | 259 | 'meta_query' => array( | 
| 260 | 260 | array( | 
| 261 | 261 | 'key' => '_lesson_course', | 
| 262 | - 'value' => intval( $lesson_course_id ), | |
| 262 | + 'value' => intval($lesson_course_id), | |
| 263 | 263 | 'compare' => '=' | 
| 264 | 264 | ) | 
| 265 | 265 | ), | 
| @@ -267,18 +267,18 @@ discard block | ||
| 267 | 267 | array( | 
| 268 | 268 | 'taxonomy' => Sensei()->modules->taxonomy, | 
| 269 | 269 | 'field' => 'id', | 
| 270 | - 'terms' => intval( $module->term_id ) | |
| 270 | + 'terms' => intval($module->term_id) | |
| 271 | 271 | ) | 
| 272 | 272 | ), | 
| 273 | - 'meta_key' => '_order_module_' . $module->term_id, | |
| 273 | + 'meta_key' => '_order_module_'.$module->term_id, | |
| 274 | 274 | 'orderby' => 'meta_value_num date', | 
| 275 | 275 | 'order' => 'ASC', | 
| 276 | 276 | 'suppress_filters' => 0 | 
| 277 | 277 | ); | 
| 278 | 278 | |
| 279 | - $lessons = get_posts( $args ); | |
| 280 | -                if ( 0 < count( $lessons ) ) { | |
| 281 | -                    foreach ($lessons as $lesson_item){ | |
| 279 | + $lessons = get_posts($args); | |
| 280 | +                if (0 < count($lessons)) { | |
| 281 | +                    foreach ($lessons as $lesson_item) { | |
| 282 | 282 | $all_lessons[] = $lesson_item->ID; | 
| 283 | 283 | } // End For Loop | 
| 284 | 284 | } // End If Statement | 
| @@ -288,36 +288,36 @@ discard block | ||
| 288 | 288 | 'post_type' => 'lesson', | 
| 289 | 289 | 'posts_per_page' => -1, | 
| 290 | 290 | 'suppress_filters' => 0, | 
| 291 | - 'meta_key' => '_order_' . $lesson_course_id, | |
| 291 | + 'meta_key' => '_order_'.$lesson_course_id, | |
| 292 | 292 | 'orderby' => 'meta_value_num date', | 
| 293 | 293 | 'order' => 'ASC', | 
| 294 | 294 | 'meta_query' => array( | 
| 295 | 295 | array( | 
| 296 | 296 | 'key' => '_lesson_course', | 
| 297 | - 'value' => intval( $lesson_course_id ), | |
| 297 | + 'value' => intval($lesson_course_id), | |
| 298 | 298 | ), | 
| 299 | 299 | ), | 
| 300 | 300 | 'post__not_in' => $all_lessons, | 
| 301 | 301 | ); | 
| 302 | 302 | |
| 303 | - $other_lessons = get_posts( $args ); | |
| 304 | -            if ( 0 < count( $other_lessons ) ) { | |
| 305 | -				foreach ($other_lessons as $lesson_item){ | |
| 303 | + $other_lessons = get_posts($args); | |
| 304 | +            if (0 < count($other_lessons)) { | |
| 305 | +				foreach ($other_lessons as $lesson_item) { | |
| 306 | 306 | $all_lessons[] = $lesson_item->ID; | 
| 307 | 307 | } // End For Loop | 
| 308 | 308 | } // End If Statement | 
| 309 | 309 | |
| 310 | -            if ( 0 < count( $all_lessons ) ) { | |
| 310 | +            if (0 < count($all_lessons)) { | |
| 311 | 311 | $found_index = false; | 
| 312 | -				foreach ( $all_lessons as $lesson ){ | |
| 313 | -					if ( $found_index && $return_values['next_lesson'] == 0 ) { | |
| 312 | +				foreach ($all_lessons as $lesson) { | |
| 313 | +					if ($found_index && $return_values['next_lesson'] == 0) { | |
| 314 | 314 | $return_values['next_lesson'] = $lesson; | 
| 315 | 315 | } // End If Statement | 
| 316 | -					if ( $lesson == $lesson_id ) { | |
| 316 | +					if ($lesson == $lesson_id) { | |
| 317 | 317 | // Is the current post | 
| 318 | 318 | $found_index = true; | 
| 319 | 319 | } // End If Statement | 
| 320 | -					if ( !$found_index ) { | |
| 320 | +					if ( ! $found_index) { | |
| 321 | 321 | $return_values['prev_lesson'] = $lesson; | 
| 322 | 322 | } // End If Statement | 
| 323 | 323 | } // End For Loop | 
| @@ -336,7 +336,7 @@ discard block | ||
| 336 | 336 | * @param int|WP_Post $post_id Optional. Defaults to current post | 
| 337 | 337 | * @return string $excerpt | 
| 338 | 338 | */ | 
| 339 | -  function sensei_get_excerpt( $post_id = '' ) { | |
| 339 | +  function sensei_get_excerpt($post_id = '') { | |
| 340 | 340 | |
| 341 | 341 | global $post; | 
| 342 | 342 |        _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); | 
| @@ -344,14 +344,14 @@ discard block | ||
| 344 | 344 | |
| 345 | 345 | } | 
| 346 | 346 | |
| 347 | -	function sensei_has_user_started_course( $post_id = 0, $user_id = 0 ) { | |
| 348 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()" ); | |
| 349 | - return Sensei_Utils::user_started_course( $post_id, $user_id ); | |
| 347 | +	function sensei_has_user_started_course($post_id = 0, $user_id = 0) { | |
| 348 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()"); | |
| 349 | + return Sensei_Utils::user_started_course($post_id, $user_id); | |
| 350 | 350 | } // End sensei_has_user_started_course() | 
| 351 | 351 | |
| 352 | -	function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { | |
| 353 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); | |
| 354 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); | |
| 352 | +	function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { | |
| 353 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); | |
| 354 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); | |
| 355 | 355 | } // End sensei_has_user_completed_lesson() | 
| 356 | 356 | |
| 357 | 357 | /** | 
| @@ -363,9 +363,9 @@ discard block | ||
| 363 | 363 | * @param int $user_id | 
| 364 | 364 | * @return bool | 
| 365 | 365 | */ | 
| 366 | -function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) { | |
| 366 | +function sensei_has_user_completed_prerequisite_lesson($current_lesson_id, $user_id) { | |
| 367 | 367 | |
| 368 | - return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); | |
| 368 | + return WooThemes_Sensei_Lesson::is_pre_requisite_complete($current_lesson_id, $user_id); | |
| 369 | 369 | |
| 370 | 370 | } // End sensei_has_user_completed_prerequisite_lesson() | 
| 371 | 371 | |
| @@ -388,7 +388,7 @@ discard block | ||
| 388 | 388 | * @return bool | 
| 389 | 389 | * | 
| 390 | 390 | */ | 
| 391 | -function sensei_have_modules( $course_post_id = '' ){ | |
| 391 | +function sensei_have_modules($course_post_id = '') { | |
| 392 | 392 | |
| 393 | 393 | global $post, $wp_query, $sensei_modules_loop; | 
| 394 | 394 | |
| @@ -396,23 +396,23 @@ discard block | ||
| 396 | 396 | wp_reset_query(); | 
| 397 | 397 | $post = $wp_query->post; | 
| 398 | 398 | |
| 399 | -	if( empty( $course_post_id ) ){ | |
| 399 | +	if (empty($course_post_id)) { | |
| 400 | 400 | |
| 401 | 401 | $course_id = $post->ID; | 
| 402 | 402 | |
| 403 | 403 | } | 
| 404 | 404 | |
| 405 | 405 | // doesn't apply to none course post types | 
| 406 | -	if( ! sensei_is_a_course( $course_id )  ){ | |
| 406 | +	if ( ! sensei_is_a_course($course_id)) { | |
| 407 | 407 | return false; | 
| 408 | 408 | } | 
| 409 | 409 | |
| 410 | 410 | // check the current item compared to the total number of modules | 
| 411 | -	if( $sensei_modules_loop[ 'current' ] + 1 > $sensei_modules_loop[ 'total' ]  ){ | |
| 411 | +	if ($sensei_modules_loop['current'] + 1 > $sensei_modules_loop['total']) { | |
| 412 | 412 | |
| 413 | 413 | return false; | 
| 414 | 414 | |
| 415 | -	}else{ | |
| 415 | +	} else { | |
| 416 | 416 | |
| 417 | 417 | return true; | 
| 418 | 418 | |
| @@ -426,27 +426,27 @@ discard block | ||
| 426 | 426 | * | 
| 427 | 427 | * @since 1.9.0 | 
| 428 | 428 | */ | 
| 429 | -function sensei_setup_module(){ | |
| 429 | +function sensei_setup_module() { | |
| 430 | 430 | |
| 431 | 431 | global $sensei_modules_loop, $wp_query; | 
| 432 | 432 | |
| 433 | 433 | // increment the index | 
| 434 | - $sensei_modules_loop[ 'current' ]++; | |
| 435 | - $index = $sensei_modules_loop[ 'current' ]; | |
| 436 | -	if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { | |
| 434 | + $sensei_modules_loop['current']++; | |
| 435 | + $index = $sensei_modules_loop['current']; | |
| 436 | +	if (isset($sensei_modules_loop['modules'][$index])) { | |
| 437 | 437 | |
| 438 | 438 | $sensei_modules_loop['current_module'] = $sensei_modules_loop['modules'][$index]; | 
| 439 | 439 | // setup the query for the module lessons | 
| 440 | 440 | $course_id = $sensei_modules_loop['course_id']; | 
| 441 | 441 | $module_term_id = $sensei_modules_loop['current_module']->term_id; | 
| 442 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); | |
| 442 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); | |
| 443 | 443 | |
| 444 | 444 | // setup the global wp-query only if the lessons | 
| 445 | -		if( $modules_query->have_posts() ){ | |
| 445 | +		if ($modules_query->have_posts()) { | |
| 446 | 446 | |
| 447 | 447 | $wp_query = $modules_query; | 
| 448 | 448 | |
| 449 | -		}else{ | |
| 449 | +		} else { | |
| 450 | 450 | |
| 451 | 451 | wp_reset_query(); | 
| 452 | 452 | |
| @@ -470,30 +470,30 @@ discard block | ||
| 470 | 470 | * | 
| 471 | 471 | * @return bool | 
| 472 | 472 | */ | 
| 473 | -function sensei_module_has_lessons(){ | |
| 473 | +function sensei_module_has_lessons() { | |
| 474 | 474 | |
| 475 | 475 | global $wp_query, $sensei_modules_loop; | 
| 476 | 476 | |
| 477 | -	if( 'lesson' == $wp_query->get('post_type') ){ | |
| 477 | +	if ('lesson' == $wp_query->get('post_type')) { | |
| 478 | 478 | |
| 479 | 479 | return have_posts(); | 
| 480 | 480 | |
| 481 | -	}else{ | |
| 481 | +	} else { | |
| 482 | 482 | |
| 483 | 483 | // if the loop has not been initiated check the first module has lessons | 
| 484 | -        if( -1 == $sensei_modules_loop[ 'current' ]  ){ | |
| 484 | +        if ( -1 == $sensei_modules_loop['current']  ) { | |
| 485 | 485 | |
| 486 | 486 | $index = 0; | 
| 487 | 487 | |
| 488 | -            if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { | |
| 488 | +            if (isset($sensei_modules_loop['modules'][$index])) { | |
| 489 | 489 | // setup the query for the module lessons | 
| 490 | 490 | $course_id = $sensei_modules_loop['course_id']; | 
| 491 | 491 | |
| 492 | - $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; | |
| 493 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); | |
| 492 | + $module_term_id = $sensei_modules_loop['modules'][$index] ->term_id; | |
| 493 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); | |
| 494 | 494 | |
| 495 | 495 | // setup the global wp-query only if the lessons | 
| 496 | -                if( $modules_query->have_posts() ){ | |
| 496 | +                if ($modules_query->have_posts()) { | |
| 497 | 497 | |
| 498 | 498 | return true; | 
| 499 | 499 | |
| @@ -517,9 +517,9 @@ discard block | ||
| 517 | 517 | * @uses sensei_the_module_title | 
| 518 | 518 | * @return string | 
| 519 | 519 | */ | 
| 520 | -function sensei_the_module_title_attribute(){ | |
| 520 | +function sensei_the_module_title_attribute() { | |
| 521 | 521 | |
| 522 | - esc_attr_e( sensei_get_the_module_title() ); | |
| 522 | + esc_attr_e(sensei_get_the_module_title()); | |
| 523 | 523 | |
| 524 | 524 | } | 
| 525 | 525 | |
| @@ -530,11 +530,11 @@ discard block | ||
| 530 | 530 | * | 
| 531 | 531 | * @return string | 
| 532 | 532 | */ | 
| 533 | -function sensei_the_module_permalink(){ | |
| 533 | +function sensei_the_module_permalink() { | |
| 534 | 534 | |
| 535 | 535 | global $sensei_modules_loop; | 
| 536 | 536 | $course_id = $sensei_modules_loop['course_id']; | 
| 537 | -	$module_url = add_query_arg('course_id', $course_id, get_term_link( $sensei_modules_loop['current_module'], 'module' ) ); | |
| 537 | +	$module_url = add_query_arg('course_id', $course_id, get_term_link($sensei_modules_loop['current_module'], 'module')); | |
| 538 | 538 | $module_term_id = $sensei_modules_loop['current_module']->term_id; | 
| 539 | 539 | |
| 540 | 540 | /** | 
| @@ -546,7 +546,7 @@ discard block | ||
| 546 | 546 | * @param int $module_term_id | 
| 547 | 547 | * @param string $course_id | 
| 548 | 548 | */ | 
| 549 | - echo esc_url_raw( apply_filters( 'sensei_the_module_permalink', $module_url, $module_term_id ,$course_id ) ); | |
| 549 | +	 echo esc_url_raw(apply_filters('sensei_the_module_permalink', $module_url, $module_term_id, $course_id)); | |
| 550 | 550 | |
| 551 | 551 | }// end sensei_the_module_permalink | 
| 552 | 552 | |
| @@ -558,7 +558,7 @@ discard block | ||
| 558 | 558 | * | 
| 559 | 559 | * @return string | 
| 560 | 560 | */ | 
| 561 | -function sensei_get_the_module_title(){ | |
| 561 | +function sensei_get_the_module_title() { | |
| 562 | 562 | |
| 563 | 563 | global $sensei_modules_loop; | 
| 564 | 564 | |
| @@ -577,7 +577,7 @@ discard block | ||
| 577 | 577 | * @param $module_term_id | 
| 578 | 578 | * @param $course_id | 
| 579 | 579 | */ | 
| 580 | - return apply_filters( 'sensei_the_module_title', $module_title , $module_term_id, $course_id ); | |
| 580 | +	return apply_filters('sensei_the_module_title', $module_title, $module_term_id, $course_id); | |
| 581 | 581 | |
| 582 | 582 | } | 
| 583 | 583 | |
| @@ -589,7 +589,7 @@ discard block | ||
| 589 | 589 | * @uses sensei_get_the_module_title | 
| 590 | 590 | * @return string | 
| 591 | 591 | */ | 
| 592 | -function sensei_the_module_title(){ | |
| 592 | +function sensei_the_module_title() { | |
| 593 | 593 | |
| 594 | 594 | echo sensei_get_the_module_title(); | 
| 595 | 595 | |
| @@ -602,16 +602,16 @@ discard block | ||
| 602 | 602 | * @since 1.9.0 | 
| 603 | 603 | * @return string | 
| 604 | 604 | */ | 
| 605 | -function sensei_get_the_module_status(){ | |
| 605 | +function sensei_get_the_module_status() { | |
| 606 | 606 | |
| 607 | 607 | global $sensei_modules_loop; | 
| 608 | 608 | $module_title = $sensei_modules_loop['current_module']->name; | 
| 609 | 609 | $module_term_id = $sensei_modules_loop['current_module']->term_id; | 
| 610 | 610 | $course_id = $sensei_modules_loop['course_id']; | 
| 611 | - $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() ); | |
| 611 | + $module_progress = Sensei()->modules->get_user_module_progress($module_term_id, $course_id, get_current_user_id()); | |
| 612 | 612 | |
| 613 | - $module_status = ''; | |
| 614 | -    if ( $module_progress && $module_progress > 0) { | |
| 613 | + $module_status = ''; | |
| 614 | +    if ($module_progress && $module_progress > 0) { | |
| 615 | 615 | |
| 616 | 616 |          $module_status = __('Completed', 'woothemes-sensei'); | 
| 617 | 617 | |
| @@ -624,7 +624,7 @@ discard block | ||
| 624 | 624 | } | 
| 625 | 625 | |
| 626 | 626 | $module_status_html = '<p class="status module-status completed">' | 
| 627 | - . strtolower( str_replace( ' ', '-', $module_status ) ) | |
| 627 | +                            . strtolower(str_replace(' ', '-', $module_status)) | |
| 628 | 628 | . '</p>'; | 
| 629 | 629 | |
| 630 | 630 | /** | 
| @@ -638,7 +638,7 @@ discard block | ||
| 638 | 638 | * @param $module_term_id | 
| 639 | 639 | * @param $course_id | 
| 640 | 640 | */ | 
| 641 | - return apply_filters( 'sensei_the_module_status_html', $module_status_html , $module_term_id, $course_id ); | |
| 641 | +    return apply_filters('sensei_the_module_status_html', $module_status_html, $module_term_id, $course_id); | |
| 642 | 642 | |
| 643 | 643 | } | 
| 644 | 644 | |
| @@ -646,7 +646,7 @@ discard block | ||
| 646 | 646 | * Print out the current module status | 
| 647 | 647 | * @since 1.9.0 | 
| 648 | 648 | */ | 
| 649 | -function sensei_the_module_status(){ | |
| 649 | +function sensei_the_module_status() { | |
| 650 | 650 | |
| 651 | 651 | echo sensei_get_the_module_status(); | 
| 652 | 652 | |
| @@ -667,19 +667,19 @@ discard block | ||
| 667 | 667 | * | 
| 668 | 668 | * @return bool | 
| 669 | 669 | */ | 
| 670 | -function sensei_quiz_has_questions(){ | |
| 670 | +function sensei_quiz_has_questions() { | |
| 671 | 671 | |
| 672 | 672 | global $sensei_question_loop; | 
| 673 | 673 | |
| 674 | -    if( !isset( $sensei_question_loop['total'] ) ){ | |
| 674 | +    if ( ! isset($sensei_question_loop['total'])) { | |
| 675 | 675 | return false; | 
| 676 | 676 | } | 
| 677 | 677 | |
| 678 | -    if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){ | |
| 678 | +    if ($sensei_question_loop['current'] + 1 < $sensei_question_loop['total']) { | |
| 679 | 679 | |
| 680 | 680 | return true; | 
| 681 | 681 | |
| 682 | -    }else{ | |
| 682 | +    } else { | |
| 683 | 683 | |
| 684 | 684 | return false; | 
| 685 | 685 | |
| @@ -696,13 +696,13 @@ discard block | ||
| 696 | 696 | * @since 1.9.0 | 
| 697 | 697 | |
| 698 | 698 | */ | 
| 699 | -function sensei_setup_the_question(){ | |
| 699 | +function sensei_setup_the_question() { | |
| 700 | 700 | |
| 701 | 701 | global $sensei_question_loop; | 
| 702 | 702 | |
| 703 | 703 | $sensei_question_loop['current']++; | 
| 704 | 704 | $index = $sensei_question_loop['current']; | 
| 705 | - $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; | |
| 705 | + $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][$index]; | |
| 706 | 706 | |
| 707 | 707 | |
| 708 | 708 | }// end sensei_setup_the_question | 
| @@ -713,14 +713,14 @@ discard block | ||
| 713 | 713 | * This function gets the type and loads the template that will handle it. | 
| 714 | 714 | * | 
| 715 | 715 | */ | 
| 716 | -function sensei_the_question_content(){ | |
| 716 | +function sensei_the_question_content() { | |
| 717 | 717 | |
| 718 | 718 | global $sensei_question_loop; | 
| 719 | 719 | |
| 720 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); | |
| 720 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); | |
| 721 | 721 | |
| 722 | 722 | // load the template that displays the question information. | 
| 723 | - WooThemes_Sensei_Question::load_question_template( $question_type ); | |
| 723 | + WooThemes_Sensei_Question::load_question_template($question_type); | |
| 724 | 724 | |
| 725 | 725 | }// end sensei_the_question_content | 
| 726 | 726 | |
| @@ -729,11 +729,11 @@ discard block | ||
| 729 | 729 | * | 
| 730 | 730 | * @since 1.9.0 | 
| 731 | 731 | */ | 
| 732 | -function sensei_the_question_class(){ | |
| 732 | +function sensei_the_question_class() { | |
| 733 | 733 | |
| 734 | 734 | global $sensei_question_loop; | 
| 735 | 735 | |
| 736 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); | |
| 736 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); | |
| 737 | 737 | |
| 738 | 738 | /** | 
| 739 | 739 | * filter the sensei question class within | 
| @@ -741,16 +741,16 @@ discard block | ||
| 741 | 741 | * | 
| 742 | 742 | * @since 1.9.0 | 
| 743 | 743 | */ | 
| 744 | - $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); | |
| 744 | +     $classes = apply_filters('sensei_question_classes', array($question_type)); | |
| 745 | 745 | |
| 746 | 746 | $html_classes = ''; | 
| 747 | -    foreach( $classes as $class ){ | |
| 747 | +    foreach ($classes as $class) { | |
| 748 | 748 | |
| 749 | - $html_classes .= $class . ' '; | |
| 749 | + $html_classes .= $class.' '; | |
| 750 | 750 | |
| 751 | 751 | }// end foreach | 
| 752 | 752 | |
| 753 | - esc_attr_e( trim( $html_classes ) ); | |
| 753 | + esc_attr_e(trim($html_classes)); | |
| 754 | 754 | |
| 755 | 755 | } | 
| 756 | 756 | |
| @@ -759,10 +759,10 @@ discard block | ||
| 759 | 759 | * | 
| 760 | 760 | * @since 1.9.0 | 
| 761 | 761 | */ | 
| 762 | -function sensei_get_the_question_id( ){ | |
| 762 | +function sensei_get_the_question_id( ) { | |
| 763 | 763 | |
| 764 | 764 | global $sensei_question_loop; | 
| 765 | -    if( isset( $sensei_question_loop['current_question']->ID ) ){ | |
| 765 | +    if (isset($sensei_question_loop['current_question']->ID)) { | |
| 766 | 766 | |
| 767 | 767 | return $sensei_question_loop['current_question']->ID; | 
| 768 | 768 | |
| @@ -791,27 +791,27 @@ discard block | ||
| 791 | 791 | * @param string $lesson_id | 
| 792 | 792 | * @return bool | 
| 793 | 793 | */ | 
| 794 | -function sensei_can_user_view_lesson( $lesson_id = '', $user_id = ''  ){ | |
| 794 | +function sensei_can_user_view_lesson($lesson_id = '', $user_id = '') { | |
| 795 | 795 | |
| 796 | -    if( empty( $lesson_id ) ){ | |
| 796 | +    if (empty($lesson_id)) { | |
| 797 | 797 | |
| 798 | 798 | $lesson_id = get_the_ID(); | 
| 799 | 799 | |
| 800 | 800 | } | 
| 801 | 801 | |
| 802 | -    if( empty( $user_id ) ){ | |
| 802 | +    if (empty($user_id)) { | |
| 803 | 803 | |
| 804 | 804 | $user_id = get_current_user_id(); | 
| 805 | 805 | |
| 806 | 806 | } | 
| 807 | 807 | |
| 808 | 808 | // Check for prerequisite lesson completions | 
| 809 | - $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); | |
| 810 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); | |
| 811 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); | |
| 809 | + $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id); | |
| 810 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); | |
| 811 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, $user_id); | |
| 812 | 812 | |
| 813 | 813 | $is_preview = false; | 
| 814 | -    if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { | |
| 814 | +    if (Sensei_Utils::is_preview_lesson($lesson_id)) { | |
| 815 | 815 | |
| 816 | 816 | $is_preview = true; | 
| 817 | 817 | $pre_requisite_complete = true; | 
| @@ -819,24 +819,24 @@ discard block | ||
| 819 | 819 | }; | 
| 820 | 820 | |
| 821 | 821 | |
| 822 | - $user_can_access_lesson = false; | |
| 822 | + $user_can_access_lesson = false; | |
| 823 | 823 | |
| 824 | -    if( is_user_logged_in() && $user_taking_course ){ | |
| 824 | +    if (is_user_logged_in() && $user_taking_course) { | |
| 825 | 825 | |
| 826 | - $user_can_access_lesson = true; | |
| 826 | + $user_can_access_lesson = true; | |
| 827 | 827 | |
| 828 | 828 | } | 
| 829 | 829 | |
| 830 | 830 | |
| 831 | 831 | $access_permission = false; | 
| 832 | 832 | |
| 833 | -    if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) { | |
| 833 | +    if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) { | |
| 834 | 834 | |
| 835 | 835 | $access_permission = true; | 
| 836 | 836 | |
| 837 | 837 | } | 
| 838 | 838 | |
| 839 | - $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; | |
| 839 | + $can_user_view_lesson = $access_permission || ($user_can_access_lesson && $pre_requisite_complete) || $is_preview; | |
| 840 | 840 | |
| 841 | 841 | /** | 
| 842 | 842 | * Filter the can user view lesson function | 
| @@ -849,7 +849,7 @@ discard block | ||
| 849 | 849 | * @param string $lesson_id | 
| 850 | 850 | * @param string $user_id | 
| 851 | 851 | */ | 
| 852 | - return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); | |
| 852 | +    return apply_filters('sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id); | |
| 853 | 853 | |
| 854 | 854 | } // end sensei_can_current_user_view_lesson | 
| 855 | 855 | |
| @@ -859,51 +859,51 @@ discard block | ||
| 859 | 859 | * The function should only be called on the single lesson | 
| 860 | 860 | * | 
| 861 | 861 | */ | 
| 862 | -function sensei_the_single_lesson_meta(){ | |
| 862 | +function sensei_the_single_lesson_meta() { | |
| 863 | 863 | |
| 864 | 864 | // if the lesson meta is included within theme load that instead of the function content | 
| 865 | - $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); | |
| 866 | -    if( ! empty( $template ) ){ | |
| 865 | +    $template = Sensei_Templates::locate_template('single-lesson/lesson-meta.php'); | |
| 866 | +    if ( ! empty($template)) { | |
| 867 | 867 | |
| 868 | - Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); | |
| 868 | +        Sensei_Templates::get_template('single-lesson/lesson-meta.php'); | |
| 869 | 869 | return; | 
| 870 | 870 | |
| 871 | 871 | } | 
| 872 | 872 | |
| 873 | 873 | // Get the meta info | 
| 874 | - $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); | |
| 875 | - $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); | |
| 874 | + $lesson_course_id = absint(get_post_meta(get_the_ID(), '_lesson_course', true)); | |
| 875 | + $is_preview = Sensei_Utils::is_preview_lesson(get_the_ID()); | |
| 876 | 876 | |
| 877 | 877 | // Complete Lesson Logic | 
| 878 | - do_action( 'sensei_complete_lesson' ); | |
| 878 | +    do_action('sensei_complete_lesson'); | |
| 879 | 879 | // Check that the course has been started | 
| 880 | - if ( Sensei()->access_settings() | |
| 881 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) | |
| 882 | -        || $is_preview ) { | |
| 880 | + if (Sensei()->access_settings() | |
| 881 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()) | |
| 882 | +        || $is_preview) { | |
| 883 | 883 | ?> | 
| 884 | 884 | <section class="lesson-meta"> | 
| 885 | 885 | <?php | 
| 886 | -            if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { | |
| 886 | +            if (apply_filters('sensei_video_position', 'top', get_the_ID()) == 'bottom') { | |
| 887 | 887 | |
| 888 | - do_action( 'sensei_lesson_video', get_the_ID() ); | |
| 888 | +                do_action('sensei_lesson_video', get_the_ID()); | |
| 889 | 889 | |
| 890 | 890 | } | 
| 891 | 891 | ?> | 
| 892 | - <?php do_action( 'sensei_frontend_messages' ); ?> | |
| 892 | +            <?php do_action('sensei_frontend_messages'); ?> | |
| 893 | 893 | |
| 894 | 894 | <?php if ( ! $is_preview | 
| 895 | -                || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { | |
| 895 | +                || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())) { | |
| 896 | 896 | |
| 897 | - sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); | |
| 897 | +                sensei_do_deprecated_action('sensei_lesson_quiz_meta', '1.9.0', 'sensei_single_lesson_content_inside_before', array(get_the_ID(), get_current_user_id())); | |
| 898 | 898 | |
| 899 | 899 | } ?> | 
| 900 | 900 | </section> | 
| 901 | 901 | |
| 902 | - <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?> | |
| 902 | +        <?php do_action('sensei_lesson_back_link', $lesson_course_id); ?> | |
| 903 | 903 | |
| 904 | 904 | <?php } | 
| 905 | 905 | |
| 906 | - do_action( 'sensei_lesson_meta_extra', get_the_ID() ); | |
| 906 | +    do_action('sensei_lesson_meta_extra', get_the_ID()); | |
| 907 | 907 | |
| 908 | 908 | } // end the_single_lesson_meta | 
| 909 | 909 | |
| @@ -917,9 +917,9 @@ discard block | ||
| 917 | 917 | * | 
| 918 | 918 | * @since 1.9.0 | 
| 919 | 919 | */ | 
| 920 | -function get_sensei_header(){ | |
| 920 | +function get_sensei_header() { | |
| 921 | 921 | |
| 922 | - if ( ! defined( 'ABSPATH' ) ) exit; | |
| 922 | +    if ( ! defined('ABSPATH')) exit; | |
| 923 | 923 | |
| 924 | 924 | get_header(); | 
| 925 | 925 | |
| @@ -928,7 +928,7 @@ discard block | ||
| 928 | 928 | * | 
| 929 | 929 | * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) | 
| 930 | 930 | */ | 
| 931 | - do_action( 'sensei_before_main_content' ); | |
| 931 | +    do_action('sensei_before_main_content'); | |
| 932 | 932 | |
| 933 | 933 | }// end get_sensei_header | 
| 934 | 934 | |
| @@ -942,28 +942,28 @@ discard block | ||
| 942 | 942 | * | 
| 943 | 943 | * @since 1.9.0 | 
| 944 | 944 | */ | 
| 945 | -function get_sensei_footer(){ | |
| 945 | +function get_sensei_footer() { | |
| 946 | 946 | |
| 947 | 947 | /** | 
| 948 | 948 | * sensei_pagination hook | 
| 949 | 949 | * | 
| 950 | 950 | * @hooked sensei_pagination - 10 (outputs pagination) | 
| 951 | 951 | */ | 
| 952 | - do_action( 'sensei_pagination' ); | |
| 952 | +    do_action('sensei_pagination'); | |
| 953 | 953 | |
| 954 | 954 | /** | 
| 955 | 955 | * sensei_after_main_content hook | 
| 956 | 956 | * | 
| 957 | 957 | * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) | 
| 958 | 958 | */ | 
| 959 | - do_action( 'sensei_after_main_content' ); | |
| 959 | +    do_action('sensei_after_main_content'); | |
| 960 | 960 | |
| 961 | 961 | /** | 
| 962 | 962 | * sensei_sidebar hook | 
| 963 | 963 | * | 
| 964 | 964 | * @hooked sensei_get_sidebar - 10 | 
| 965 | 965 | */ | 
| 966 | - do_action( 'sensei_sidebar' ); | |
| 966 | +    do_action('sensei_sidebar'); | |
| 967 | 967 | |
| 968 | 968 | get_footer(); | 
| 969 | 969 | |
| @@ -975,7 +975,7 @@ discard block | ||
| 975 | 975 | * | 
| 976 | 976 | * @since 1.9.0 | 
| 977 | 977 | */ | 
| 978 | -function the_no_permissions_title(){ | |
| 978 | +function the_no_permissions_title() { | |
| 979 | 979 | |
| 980 | 980 | /** | 
| 981 | 981 | * Filter the no permissions title just before it is echo'd on the | 
| @@ -984,7 +984,7 @@ discard block | ||
| 984 | 984 | * @since 1.9.0 | 
| 985 | 985 | * @param $no_permissions_title | 
| 986 | 986 | */ | 
| 987 | - echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); | |
| 987 | +    echo apply_filters('sensei_the_no_permissions_title', Sensei()->permissions_message['title']); | |
| 988 | 988 | |
| 989 | 989 | } | 
| 990 | 990 | |
| @@ -993,7 +993,7 @@ discard block | ||
| 993 | 993 | * | 
| 994 | 994 | * @since 1.9.0 | 
| 995 | 995 | */ | 
| 996 | -function the_no_permissions_message( $post_id ){ | |
| 996 | +function the_no_permissions_message($post_id) { | |
| 997 | 997 | |
| 998 | 998 | /** | 
| 999 | 999 | * Filter the no permissions message just before it is echo'd on the | 
| @@ -1002,7 +1002,7 @@ discard block | ||
| 1002 | 1002 | * @since 1.9.0 | 
| 1003 | 1003 | * @param $no_permissions_message | 
| 1004 | 1004 | */ | 
| 1005 | - echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); | |
| 1005 | +    echo apply_filters('sensei_the_no_permissions_message', Sensei()->permissions_message['message'], $post_id); | |
| 1006 | 1006 | |
| 1007 | 1007 | } | 
| 1008 | 1008 | |
| @@ -1011,10 +1011,10 @@ discard block | ||
| 1011 | 1011 | * | 
| 1012 | 1012 | * @since 1.9.0 | 
| 1013 | 1013 | */ | 
| 1014 | -function sensei_the_excerpt( $post_id ){ | |
| 1014 | +function sensei_the_excerpt($post_id) { | |
| 1015 | 1015 | |
| 1016 | 1016 | global $post; | 
| 1017 | - the_excerpt( $post ); | |
| 1017 | + the_excerpt($post); | |
| 1018 | 1018 | |
| 1019 | 1019 | } | 
| 1020 | 1020 | |
| @@ -1026,10 +1026,10 @@ discard block | ||
| 1026 | 1026 | * @global WP $wp | 
| 1027 | 1027 | * @return string $current_page_url | 
| 1028 | 1028 | */ | 
| 1029 | - function sensei_get_current_page_url(){ | |
| 1029 | + function sensei_get_current_page_url() { | |
| 1030 | 1030 | |
| 1031 | 1031 | global $wp; | 
| 1032 | - $current_page_url = home_url( $wp->request ); | |
| 1032 | + $current_page_url = home_url($wp->request); | |
| 1033 | 1033 | return $current_page_url; | 
| 1034 | 1034 | |
| 1035 | 1035 | } | 
| @@ -1040,9 +1040,9 @@ discard block | ||
| 1040 | 1040 | * | 
| 1041 | 1041 | * @since 1.9.0 | 
| 1042 | 1042 | */ | 
| 1043 | -function sensei_the_my_courses_content(){ | |
| 1043 | +function sensei_the_my_courses_content() { | |
| 1044 | 1044 | |
| 1045 | - echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); | |
| 1045 | + echo Sensei()->course->load_user_courses_content(wp_get_current_user()); | |
| 1046 | 1046 | |
| 1047 | 1047 | } // sensei_the_my_courses_content | 
| 1048 | 1048 | |
| @@ -1055,9 +1055,9 @@ discard block | ||
| 1055 | 1055 | * | 
| 1056 | 1056 | * @since 1.9.0 | 
| 1057 | 1057 | */ | 
| 1058 | -function sensei_load_template( $template_name ){ | |
| 1058 | +function sensei_load_template($template_name) { | |
| 1059 | 1059 | |
| 1060 | - Sensei_Templates::get_template( $template_name ); | |
| 1060 | + Sensei_Templates::get_template($template_name); | |
| 1061 | 1061 | |
| 1062 | 1062 | } | 
| 1063 | 1063 | |
| @@ -1069,9 +1069,9 @@ discard block | ||
| 1069 | 1069 | * @param string $name the name of the template. | 
| 1070 | 1070 | * @since 1.9.0 | 
| 1071 | 1071 | */ | 
| 1072 | -function sensei_load_template_part( $slug, $name ){ | |
| 1072 | +function sensei_load_template_part($slug, $name) { | |
| 1073 | 1073 | |
| 1074 | - Sensei_Templates::get_part( $slug, $name ); | |
| 1074 | + Sensei_Templates::get_part($slug, $name); | |
| 1075 | 1075 | |
| 1076 | 1076 | } | 
| 1077 | 1077 | |
| @@ -1088,19 +1088,19 @@ discard block | ||
| 1088 | 1088 | * @access public | 
| 1089 | 1089 | * @param string $lesson_id | 
| 1090 | 1090 | */ | 
| 1091 | -function sensei_the_lesson_excerpt( $lesson_id = '' ) { | |
| 1091 | +function sensei_the_lesson_excerpt($lesson_id = '') { | |
| 1092 | 1092 | |
| 1093 | -    if( empty( $lesson_id )){ | |
| 1093 | +    if (empty($lesson_id)) { | |
| 1094 | 1094 | |
| 1095 | 1095 | $lesson_id = get_the_ID(); | 
| 1096 | 1096 | |
| 1097 | 1097 | } | 
| 1098 | 1098 | |
| 1099 | -    if( 'lesson' != get_post_type( $lesson_id ) ){ | |
| 1099 | +    if ('lesson' != get_post_type($lesson_id)) { | |
| 1100 | 1100 | return; | 
| 1101 | 1101 | } | 
| 1102 | 1102 | |
| 1103 | - echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); | |
| 1103 | + echo Sensei_Lesson::lesson_excerpt(get_post($lesson_id), false); | |
| 1104 | 1104 | |
| 1105 | 1105 | }// End lesson_excerpt() | 
| 1106 | 1106 | |
| @@ -1109,17 +1109,17 @@ discard block | ||
| 1109 | 1109 | * | 
| 1110 | 1110 | * @since 1.9.0 | 
| 1111 | 1111 | */ | 
| 1112 | -function sensei_the_course_results_lessons(){ | |
| 1112 | +function sensei_the_course_results_lessons() { | |
| 1113 | 1113 | // load backwards compatible template name if it exists in the users theme | 
| 1114 | - $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); | |
| 1115 | -    if( $located_template ){ | |
| 1114 | + $located_template = locate_template(Sensei()->template_url.'course-results/course-lessons.php'); | |
| 1115 | +    if ($located_template) { | |
| 1116 | 1116 | |
| 1117 | - Sensei_Templates::get_template( 'course-results/course-lessons.php' ); | |
| 1117 | +        Sensei_Templates::get_template('course-results/course-lessons.php'); | |
| 1118 | 1118 | return; | 
| 1119 | 1119 | |
| 1120 | 1120 | } | 
| 1121 | 1121 | |
| 1122 | - Sensei_Templates::get_template( 'course-results/lessons.php' ); | |
| 1122 | +    Sensei_Templates::get_template('course-results/lessons.php'); | |
| 1123 | 1123 | } | 
| 1124 | 1124 | |
| 1125 | 1125 | /** | 
| @@ -1129,7 +1129,7 @@ discard block | ||
| 1129 | 1129 | * @uses Sensei_Course::get_loop_number_of_columns | 
| 1130 | 1130 | * @since 1.9.0 | 
| 1131 | 1131 | */ | 
| 1132 | -function sensei_courses_per_row(){ | |
| 1132 | +function sensei_courses_per_row() { | |
| 1133 | 1133 | |
| 1134 | 1134 | echo Sensei_Course::get_loop_number_of_columns(); | 
| 1135 | 1135 | |
| @@ -1143,9 +1143,9 @@ discard block | ||
| 1143 | 1143 | * @param $args | 
| 1144 | 1144 | * @param $path | 
| 1145 | 1145 | */ | 
| 1146 | -function sensei_get_template( $template_name, $args, $path ){ | |
| 1146 | +function sensei_get_template($template_name, $args, $path) { | |
| 1147 | 1147 | |
| 1148 | - Sensei_Templates::get_template( $template_name, $args, $path ); | |
| 1148 | + Sensei_Templates::get_template($template_name, $args, $path); | |
| 1149 | 1149 | |
| 1150 | 1150 | } | 
| 1151 | 1151 | |
| @@ -1157,12 +1157,12 @@ discard block | ||
| 1157 | 1157 | * | 
| 1158 | 1158 | * @return string $status_class | 
| 1159 | 1159 | */ | 
| 1160 | -function get_the_lesson_status_class(){ | |
| 1160 | +function get_the_lesson_status_class() { | |
| 1161 | 1161 | |
| 1162 | 1162 | $status_class = ''; | 
| 1163 | - $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); | |
| 1163 | + $lesson_completed = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id()); | |
| 1164 | 1164 | |
| 1165 | -    if ( $lesson_completed ) { | |
| 1165 | +    if ($lesson_completed) { | |
| 1166 | 1166 | $status_class = 'completed'; | 
| 1167 | 1167 | } | 
| 1168 | 1168 | |
| @@ -1176,7 +1176,7 @@ discard block | ||
| 1176 | 1176 | * | 
| 1177 | 1177 | * @since 1.9.0 | 
| 1178 | 1178 | */ | 
| 1179 | -function sensei_the_lesson_status_class(){ | |
| 1179 | +function sensei_the_lesson_status_class() { | |
| 1180 | 1180 | |
| 1181 | 1181 | echo get_the_lesson_status_class(); | 
| 1182 | 1182 | } |