@@ -13,137 +13,137 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Sensei_Autoloader { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var path to the includes directory within Sensei. |
|
| 18 | - */ |
|
| 19 | - private $include_path = 'includes'; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @var array $class_file_map. List of classes mapped to their files |
|
| 23 | - */ |
|
| 24 | - private $class_file_map = array(); |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Constructor |
|
| 28 | - * @since 1.9.0 |
|
| 29 | - */ |
|
| 30 | - public function __construct(){ |
|
| 31 | - |
|
| 32 | - // make sure we do not override an existing autoload function |
|
| 33 | - if( function_exists('__autoload') ){ |
|
| 34 | - spl_autoload_register( '__autoload' ); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - // setup a relative path for the current autoload instance |
|
| 38 | - $this->include_path = trailingslashit( untrailingslashit( dirname( __FILE__ ) ) ); |
|
| 39 | - |
|
| 40 | - //setup the class file map |
|
| 41 | - $this->initialize_class_file_map(); |
|
| 42 | - |
|
| 43 | - // add Sensei custom auto loader |
|
| 44 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
| 45 | - |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Generate a list of Sensei class and map them the their respective |
|
| 50 | - * files within the includes directory |
|
| 51 | - * |
|
| 52 | - * @since 1.9.0 |
|
| 53 | - */ |
|
| 54 | - public function initialize_class_file_map(){ |
|
| 55 | - |
|
| 56 | - $this->class_file_map = array( |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Main Sensei class |
|
| 60 | - */ |
|
| 61 | - 'Sensei_Main' => 'class-sensei.php', |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Admin |
|
| 65 | - */ |
|
| 66 | - 'Sensei_Welcome' => 'admin/class-sensei-welcome.php' , |
|
| 67 | - 'Sensei_Learner_Management' => 'admin/class-sensei-learner-management.php' , |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Shortcodes |
|
| 71 | - */ |
|
| 72 | - 'Sensei_Shortcode_Loader' => 'shortcodes/class-sensei-shortcode-loader.php', |
|
| 73 | - 'Sensei_Shortcode_Interface' => 'shortcodes/interface-sensei-shortcode.php', |
|
| 74 | - 'Sensei_Shortcode_Featured_Courses' => 'shortcodes/class-sensei-shortcode-featured-courses.php', |
|
| 75 | - 'Sensei_Shortcode_User_Courses' => 'shortcodes/class-sensei-shortcode-user-courses.php', |
|
| 76 | - 'Sensei_Shortcode_Courses' => 'shortcodes/class-sensei-shortcode-courses.php', |
|
| 77 | - 'Sensei_Shortcode_Teachers' => 'shortcodes/class-sensei-shortcode-teachers.php', |
|
| 78 | - 'Sensei_Shortcode_User_Messages' => 'shortcodes/class-sensei-shortcode-user-messages.php', |
|
| 79 | - 'Sensei_Shortcode_Course_Page' => 'shortcodes/class-sensei-shortcode-course-page.php', |
|
| 80 | - 'Sensei_Shortcode_Lesson_Page' => 'shortcodes/class-sensei-shortcode-lesson-page.php', |
|
| 81 | - 'Sensei_Shortcode_Course_Categories' => 'shortcodes/class-sensei-shortcode-course-categories.php', |
|
| 82 | - 'Sensei_Shortcode_Unpurchased_Courses' => 'shortcodes/class-sensei-shortcode-unpurchased-courses.php', |
|
| 83 | - 'Sensei_Legacy_Shortcodes' => 'shortcodes/class-sensei-legacy-shortcodes.php', |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Built in theme integration support |
|
| 87 | - */ |
|
| 88 | - 'Sensei_Theme_Integration_Loader' => 'theme-integrations/theme-integration-loader.php', |
|
| 89 | - 'Sensei__S' => 'theme-integrations/_s.php', |
|
| 90 | - 'Sensei_Twentyeleven' => 'theme-integrations/twentyeleven.php', |
|
| 91 | - 'Sensei_Twentytwelve' => 'theme-integrations/twentytwelve.php', |
|
| 92 | - 'Sensei_Twentythirteen' => 'theme-integrations/Twentythirteen.php', |
|
| 93 | - 'Sensei_Twentyfourteen' => 'theme-integrations/Twentyfourteen.php', |
|
| 94 | - 'Sensei_Twentyfifteen' => 'theme-integrations/Twentyfifteen.php', |
|
| 95 | - 'Sensei_Twentysixteen' => 'theme-integrations/Twentysixteen.php', |
|
| 96 | - 'Sensei_Storefront' => 'theme-integrations/Storefront.php', |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * WooCommerce |
|
| 100 | - */ |
|
| 101 | - 'Sensei_WC' => 'class-sensei-wc.php', |
|
| 102 | - |
|
| 103 | - ); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Autoload all sensei files as the class names are used. |
|
| 108 | - */ |
|
| 109 | - public function autoload( $class ){ |
|
| 110 | - |
|
| 111 | - // only handle classes with the word `sensei` in it |
|
| 112 | - if( ! is_numeric( strpos ( strtolower( $class ), 'sensei') ) ){ |
|
| 113 | - |
|
| 114 | - return; |
|
| 115 | - |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // exit if we didn't provide mapping for this class |
|
| 119 | - if( isset( $this->class_file_map[ $class ] ) ){ |
|
| 120 | - |
|
| 121 | - $file_location = $this->include_path . $this->class_file_map[ $class ]; |
|
| 122 | - require_once( $file_location); |
|
| 123 | - return; |
|
| 124 | - |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // check for file in the main includes directory |
|
| 128 | - $class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $class ) ) . '.php'; |
|
| 129 | - if( file_exists( $class_file_path ) ){ |
|
| 130 | - |
|
| 131 | - require_once( $class_file_path ); |
|
| 132 | - return; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // lastly check legacy types |
|
| 136 | - $stripped_woothemes_from_class = str_replace( 'woothemes_','', strtolower( $class ) ); // remove woothemes |
|
| 137 | - $legacy_class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $stripped_woothemes_from_class ) ) . '.php'; |
|
| 138 | - if( file_exists( $legacy_class_file_path ) ){ |
|
| 139 | - |
|
| 140 | - require_once( $legacy_class_file_path ); |
|
| 141 | - return; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - return; |
|
| 145 | - |
|
| 146 | - }// end autoload |
|
| 16 | + /** |
|
| 17 | + * @var path to the includes directory within Sensei. |
|
| 18 | + */ |
|
| 19 | + private $include_path = 'includes'; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @var array $class_file_map. List of classes mapped to their files |
|
| 23 | + */ |
|
| 24 | + private $class_file_map = array(); |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Constructor |
|
| 28 | + * @since 1.9.0 |
|
| 29 | + */ |
|
| 30 | + public function __construct(){ |
|
| 31 | + |
|
| 32 | + // make sure we do not override an existing autoload function |
|
| 33 | + if( function_exists('__autoload') ){ |
|
| 34 | + spl_autoload_register( '__autoload' ); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + // setup a relative path for the current autoload instance |
|
| 38 | + $this->include_path = trailingslashit( untrailingslashit( dirname( __FILE__ ) ) ); |
|
| 39 | + |
|
| 40 | + //setup the class file map |
|
| 41 | + $this->initialize_class_file_map(); |
|
| 42 | + |
|
| 43 | + // add Sensei custom auto loader |
|
| 44 | + spl_autoload_register( array( $this, 'autoload' ) ); |
|
| 45 | + |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Generate a list of Sensei class and map them the their respective |
|
| 50 | + * files within the includes directory |
|
| 51 | + * |
|
| 52 | + * @since 1.9.0 |
|
| 53 | + */ |
|
| 54 | + public function initialize_class_file_map(){ |
|
| 55 | + |
|
| 56 | + $this->class_file_map = array( |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Main Sensei class |
|
| 60 | + */ |
|
| 61 | + 'Sensei_Main' => 'class-sensei.php', |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Admin |
|
| 65 | + */ |
|
| 66 | + 'Sensei_Welcome' => 'admin/class-sensei-welcome.php' , |
|
| 67 | + 'Sensei_Learner_Management' => 'admin/class-sensei-learner-management.php' , |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Shortcodes |
|
| 71 | + */ |
|
| 72 | + 'Sensei_Shortcode_Loader' => 'shortcodes/class-sensei-shortcode-loader.php', |
|
| 73 | + 'Sensei_Shortcode_Interface' => 'shortcodes/interface-sensei-shortcode.php', |
|
| 74 | + 'Sensei_Shortcode_Featured_Courses' => 'shortcodes/class-sensei-shortcode-featured-courses.php', |
|
| 75 | + 'Sensei_Shortcode_User_Courses' => 'shortcodes/class-sensei-shortcode-user-courses.php', |
|
| 76 | + 'Sensei_Shortcode_Courses' => 'shortcodes/class-sensei-shortcode-courses.php', |
|
| 77 | + 'Sensei_Shortcode_Teachers' => 'shortcodes/class-sensei-shortcode-teachers.php', |
|
| 78 | + 'Sensei_Shortcode_User_Messages' => 'shortcodes/class-sensei-shortcode-user-messages.php', |
|
| 79 | + 'Sensei_Shortcode_Course_Page' => 'shortcodes/class-sensei-shortcode-course-page.php', |
|
| 80 | + 'Sensei_Shortcode_Lesson_Page' => 'shortcodes/class-sensei-shortcode-lesson-page.php', |
|
| 81 | + 'Sensei_Shortcode_Course_Categories' => 'shortcodes/class-sensei-shortcode-course-categories.php', |
|
| 82 | + 'Sensei_Shortcode_Unpurchased_Courses' => 'shortcodes/class-sensei-shortcode-unpurchased-courses.php', |
|
| 83 | + 'Sensei_Legacy_Shortcodes' => 'shortcodes/class-sensei-legacy-shortcodes.php', |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Built in theme integration support |
|
| 87 | + */ |
|
| 88 | + 'Sensei_Theme_Integration_Loader' => 'theme-integrations/theme-integration-loader.php', |
|
| 89 | + 'Sensei__S' => 'theme-integrations/_s.php', |
|
| 90 | + 'Sensei_Twentyeleven' => 'theme-integrations/twentyeleven.php', |
|
| 91 | + 'Sensei_Twentytwelve' => 'theme-integrations/twentytwelve.php', |
|
| 92 | + 'Sensei_Twentythirteen' => 'theme-integrations/Twentythirteen.php', |
|
| 93 | + 'Sensei_Twentyfourteen' => 'theme-integrations/Twentyfourteen.php', |
|
| 94 | + 'Sensei_Twentyfifteen' => 'theme-integrations/Twentyfifteen.php', |
|
| 95 | + 'Sensei_Twentysixteen' => 'theme-integrations/Twentysixteen.php', |
|
| 96 | + 'Sensei_Storefront' => 'theme-integrations/Storefront.php', |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * WooCommerce |
|
| 100 | + */ |
|
| 101 | + 'Sensei_WC' => 'class-sensei-wc.php', |
|
| 102 | + |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Autoload all sensei files as the class names are used. |
|
| 108 | + */ |
|
| 109 | + public function autoload( $class ){ |
|
| 110 | + |
|
| 111 | + // only handle classes with the word `sensei` in it |
|
| 112 | + if( ! is_numeric( strpos ( strtolower( $class ), 'sensei') ) ){ |
|
| 113 | + |
|
| 114 | + return; |
|
| 115 | + |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // exit if we didn't provide mapping for this class |
|
| 119 | + if( isset( $this->class_file_map[ $class ] ) ){ |
|
| 120 | + |
|
| 121 | + $file_location = $this->include_path . $this->class_file_map[ $class ]; |
|
| 122 | + require_once( $file_location); |
|
| 123 | + return; |
|
| 124 | + |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // check for file in the main includes directory |
|
| 128 | + $class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $class ) ) . '.php'; |
|
| 129 | + if( file_exists( $class_file_path ) ){ |
|
| 130 | + |
|
| 131 | + require_once( $class_file_path ); |
|
| 132 | + return; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // lastly check legacy types |
|
| 136 | + $stripped_woothemes_from_class = str_replace( 'woothemes_','', strtolower( $class ) ); // remove woothemes |
|
| 137 | + $legacy_class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $stripped_woothemes_from_class ) ) . '.php'; |
|
| 138 | + if( file_exists( $legacy_class_file_path ) ){ |
|
| 139 | + |
|
| 140 | + require_once( $legacy_class_file_path ); |
|
| 141 | + return; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + return; |
|
| 145 | + |
|
| 146 | + }// end autoload |
|
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | new Sensei_Autoloader(); |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | 3 | /** |
| 4 | - * The Template for displaying all course lessons on the course results page. |
|
| 5 | - * |
|
| 6 | - * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php |
|
| 7 | - * |
|
| 8 | - * @author Automattic |
|
| 9 | - * @package Sensei |
|
| 10 | - * @category Templates |
|
| 11 | - * @version 1.9.0 |
|
| 12 | - */ |
|
| 4 | + * The Template for displaying all course lessons on the course results page. |
|
| 5 | + * |
|
| 6 | + * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php |
|
| 7 | + * |
|
| 8 | + * @author Automattic |
|
| 9 | + * @package Sensei |
|
| 10 | + * @category Templates |
|
| 11 | + * @version 1.9.0 |
|
| 12 | + */ |
|
| 13 | 13 | |
| 14 | 14 | global $course; |
| 15 | 15 | ?> |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | <?php if ( is_user_logged_in() ): ?> |
| 18 | 18 | |
| 19 | 19 | <?php |
| 20 | - /** |
|
| 21 | - * Fires inside course-results/lessons.php after the |
|
| 22 | - * is uer logged check, just above the lessons header. |
|
| 23 | - * @since 1.4.0 |
|
| 24 | - */ |
|
| 25 | - do_action( 'sensei_course_results_before_lessons', $course->ID ); |
|
| 26 | - ?> |
|
| 20 | + /** |
|
| 21 | + * Fires inside course-results/lessons.php after the |
|
| 22 | + * is uer logged check, just above the lessons header. |
|
| 23 | + * @since 1.4.0 |
|
| 24 | + */ |
|
| 25 | + do_action( 'sensei_course_results_before_lessons', $course->ID ); |
|
| 26 | + ?> |
|
| 27 | 27 | |
| 28 | 28 | <header> |
| 29 | 29 | |
@@ -36,33 +36,33 @@ discard block |
||
| 36 | 36 | <?php |
| 37 | 37 | |
| 38 | 38 | $displayed_lessons = array(); |
| 39 | - $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) ); |
|
| 39 | + $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) ); |
|
| 40 | 40 | |
| 41 | - // List modules with lessons |
|
| 42 | - foreach( $modules as $module ) { |
|
| 41 | + // List modules with lessons |
|
| 42 | + foreach( $modules as $module ) { |
|
| 43 | 43 | |
| 44 | - $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id ); |
|
| 45 | - $lessons = $lessons_query->get_posts(); |
|
| 44 | + $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id ); |
|
| 45 | + $lessons = $lessons_query->get_posts(); |
|
| 46 | 46 | |
| 47 | - if( count( $lessons ) > 0 ) { ?> |
|
| 47 | + if( count( $lessons ) > 0 ) { ?> |
|
| 48 | 48 | |
| 49 | 49 | <h3> <?php echo $module->name; ?></h3> |
| 50 | 50 | |
| 51 | 51 | <?php |
| 52 | - $count = 0; |
|
| 53 | - foreach( $lessons as $lesson ) { |
|
| 54 | - |
|
| 55 | - $lesson_grade = 'n/a'; |
|
| 56 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
| 57 | - if ( $has_questions ) { |
|
| 58 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() ); |
|
| 59 | - // Get user quiz grade |
|
| 60 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
| 61 | - if ( $lesson_grade ) { |
|
| 62 | - $lesson_grade .= '%'; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - ?> |
|
| 52 | + $count = 0; |
|
| 53 | + foreach( $lessons as $lesson ) { |
|
| 54 | + |
|
| 55 | + $lesson_grade = 'n/a'; |
|
| 56 | + $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
| 57 | + if ( $has_questions ) { |
|
| 58 | + $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() ); |
|
| 59 | + // Get user quiz grade |
|
| 60 | + $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
| 61 | + if ( $lesson_grade ) { |
|
| 62 | + $lesson_grade .= '%'; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + ?> |
|
| 66 | 66 | <h2> |
| 67 | 67 | |
| 68 | 68 | <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>" |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | <?php |
| 82 | 82 | |
| 83 | - }// end for each |
|
| 83 | + }// end for each |
|
| 84 | 84 | |
| 85 | - }// end if count lesson |
|
| 85 | + }// end if count lesson |
|
| 86 | 86 | |
| 87 | - } // end for each module |
|
| 88 | - ?> |
|
| 87 | + } // end for each module |
|
| 88 | + ?> |
|
| 89 | 89 | |
| 90 | 90 | <?php |
| 91 | 91 | |
| 92 | - $lessons = Sensei()->modules->get_none_module_lessons( $course->ID ); |
|
| 93 | - if( 0 < count( $lessons ) ): ?> |
|
| 92 | + $lessons = Sensei()->modules->get_none_module_lessons( $course->ID ); |
|
| 93 | + if( 0 < count( $lessons ) ): ?> |
|
| 94 | 94 | |
| 95 | 95 | <h3> |
| 96 | 96 | |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | <?php foreach ( $lessons as $lesson ): ?> |
| 102 | 102 | |
| 103 | 103 | <?php |
| 104 | - $lesson_grade = 'n/a'; |
|
| 105 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
| 106 | - if ( $has_questions ) { |
|
| 107 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id()); |
|
| 108 | - // Get user quiz grade |
|
| 109 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
| 110 | - if ( $lesson_grade ) { |
|
| 111 | - $lesson_grade .= '%'; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - ?> |
|
| 104 | + $lesson_grade = 'n/a'; |
|
| 105 | + $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
| 106 | + if ( $has_questions ) { |
|
| 107 | + $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id()); |
|
| 108 | + // Get user quiz grade |
|
| 109 | + $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
| 110 | + if ( $lesson_grade ) { |
|
| 111 | + $lesson_grade .= '%'; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + ?> |
|
| 115 | 115 | |
| 116 | 116 | <h2> |
| 117 | 117 | |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | <?php |
| 139 | 139 | |
| 140 | - $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() ); |
|
| 141 | - echo $course_user_grade . '%'; |
|
| 140 | + $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() ); |
|
| 141 | + echo $course_user_grade . '%'; |
|
| 142 | 142 | |
| 143 | - ?> |
|
| 143 | + ?> |
|
| 144 | 144 | |
| 145 | 145 | </span> |
| 146 | 146 | |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | </article> |
| 150 | 150 | |
| 151 | 151 | <?php |
| 152 | - /** |
|
| 153 | - * Fires inside course-results/lessons.php after the |
|
| 154 | - * is uer logged check, at the bottom of all lessons. |
|
| 155 | - * |
|
| 156 | - * @since 1.4.0 |
|
| 157 | - */ |
|
| 152 | + /** |
|
| 153 | + * Fires inside course-results/lessons.php after the |
|
| 154 | + * is uer logged check, at the bottom of all lessons. |
|
| 155 | + * |
|
| 156 | + * @since 1.4.0 |
|
| 157 | + */ |
|
| 158 | 158 | do_action( 'sensei_course_results_after_lessons', $course->ID ); |
| 159 | - ?> |
|
| 159 | + ?> |
|
| 160 | 160 | |
| 161 | 161 | <?php endif; //user logged in ?> |
| 162 | 162 | \ No newline at end of file |
@@ -9,24 +9,24 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | Class Sensei_Twentythirteen { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Output opening wrappers |
|
| 14 | - * @since 1.9.0 |
|
| 15 | - */ |
|
| 16 | - public function wrapper_start(){ |
|
| 17 | - ?> |
|
| 12 | + /** |
|
| 13 | + * Output opening wrappers |
|
| 14 | + * @since 1.9.0 |
|
| 15 | + */ |
|
| 16 | + public function wrapper_start(){ |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div id="primary" class="site-content"> |
| 20 | 20 | <div id="content" role="main" class="entry-content"> |
| 21 | 21 | |
| 22 | 22 | <?php } |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Output closing wrappers |
|
| 26 | - * |
|
| 27 | - * @since 1.9.0 |
|
| 28 | - */ |
|
| 29 | - public function wrapper_end(){ ?> |
|
| 24 | + /** |
|
| 25 | + * Output closing wrappers |
|
| 26 | + * |
|
| 27 | + * @since 1.9.0 |
|
| 28 | + */ |
|
| 29 | + public function wrapper_end(){ ?> |
|
| 30 | 30 | |
| 31 | 31 | </div> |
| 32 | 32 | </div> |
@@ -9,24 +9,24 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | Class Sensei_Twentythirteen { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Output opening wrappers |
|
| 14 | - * @since 1.9.0 |
|
| 15 | - */ |
|
| 16 | - public function wrapper_start(){ |
|
| 17 | - ?> |
|
| 12 | + /** |
|
| 13 | + * Output opening wrappers |
|
| 14 | + * @since 1.9.0 |
|
| 15 | + */ |
|
| 16 | + public function wrapper_start(){ |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div id="primary" class="site-content"> |
| 20 | 20 | <div id="content" role="main" class="entry-content"> |
| 21 | 21 | |
| 22 | 22 | <?php } |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Output closing wrappers |
|
| 26 | - * |
|
| 27 | - * @since 1.9.0 |
|
| 28 | - */ |
|
| 29 | - public function wrapper_end(){ ?> |
|
| 24 | + /** |
|
| 25 | + * Output closing wrappers |
|
| 26 | + * |
|
| 27 | + * @since 1.9.0 |
|
| 28 | + */ |
|
| 29 | + public function wrapper_end(){ ?> |
|
| 30 | 30 | |
| 31 | 31 | </div> |
| 32 | 32 | </div> |
@@ -16,28 +16,28 @@ discard block |
||
| 16 | 16 | class Sensei_Notices{ |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * @var $notices |
|
| 20 | - */ |
|
| 19 | + * @var $notices |
|
| 20 | + */ |
|
| 21 | 21 | protected $notices; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * constructor |
|
| 25 | - */ |
|
| 24 | + * constructor |
|
| 25 | + */ |
|
| 26 | 26 | public function __construct(){ |
| 27 | 27 | //initialize the notices variable |
| 28 | 28 | $this->notices = array(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * Add a notice to the array of notices for display at a later stage. |
|
| 33 | - * |
|
| 34 | - * |
|
| 35 | - * |
|
| 36 | - * @param string $message |
|
| 37 | - * @param string $type defaults to alert options( alert, tick , download , info ) |
|
| 38 | - * |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 32 | + * Add a notice to the array of notices for display at a later stage. |
|
| 33 | + * |
|
| 34 | + * |
|
| 35 | + * |
|
| 36 | + * @param string $message |
|
| 37 | + * @param string $type defaults to alert options( alert, tick , download , info ) |
|
| 38 | + * |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | 41 | |
| 42 | 42 | public function add_notice( $content , $type = 'alert' ){ |
| 43 | 43 | // append the new notice |
@@ -45,13 +45,13 @@ discard block |
||
| 45 | 45 | } // end add_notice() |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Output all notices added |
|
| 49 | - * |
|
| 50 | - * @param string $message |
|
| 51 | - * @param string $type |
|
| 52 | - * |
|
| 53 | - * @return void |
|
| 54 | - */ |
|
| 48 | + * Output all notices added |
|
| 49 | + * |
|
| 50 | + * @param string $message |
|
| 51 | + * @param string $type |
|
| 52 | + * |
|
| 53 | + * @return void |
|
| 54 | + */ |
|
| 55 | 55 | |
| 56 | 56 | public function print_notices(){ |
| 57 | 57 | if( count( $this->notices ) > 0 ){ |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | } // end print_notice() |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Clear all notices |
|
| 72 | - * |
|
| 73 | - * @return void |
|
| 74 | - */ |
|
| 71 | + * Clear all notices |
|
| 72 | + * |
|
| 73 | + * @return void |
|
| 74 | + */ |
|
| 75 | 75 | |
| 76 | 76 | public function clear_notices(){ |
| 77 | 77 | // assign an empty array to clear all existing notices |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | function sensei_all_access() { |
| 47 | 47 | |
| 48 | - $access = current_user_can( 'manage_sensei' ) || current_user_can( 'manage_sensei_grades' ); |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Filter sensei_all_access function result |
|
| 52 | - * which determinse if the current user |
|
| 53 | - * can access all of Sensei without restrictions |
|
| 54 | - * |
|
| 55 | - * @since 1.4.0 |
|
| 56 | - * @param bool $access |
|
| 57 | - */ |
|
| 48 | + $access = current_user_can( 'manage_sensei' ) || current_user_can( 'manage_sensei_grades' ); |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Filter sensei_all_access function result |
|
| 52 | + * which determinse if the current user |
|
| 53 | + * can access all of Sensei without restrictions |
|
| 54 | + * |
|
| 55 | + * @since 1.4.0 |
|
| 56 | + * @param bool $access |
|
| 57 | + */ |
|
| 58 | 58 | return apply_filters( 'sensei_all_access', $access ); |
| 59 | 59 | |
| 60 | 60 | } // End sensei_all_access() |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function sensei_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
| 74 | 74 | |
| 75 | - $hex = str_replace( '#', '', $color ); |
|
| 75 | + $hex = str_replace( '#', '', $color ); |
|
| 76 | 76 | |
| 77 | 77 | $c_r = hexdec( substr( $hex, 0, 2 ) ); |
| 78 | 78 | $c_g = hexdec( substr( $hex, 2, 2 ) ); |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | $color = '#'; |
| 120 | 120 | |
| 121 | 121 | foreach ($base as $k => $v) : |
| 122 | - $amount = $v / 100; |
|
| 123 | - $amount = round($amount * $factor); |
|
| 124 | - $new_decimal = $v - $amount; |
|
| 125 | - |
|
| 126 | - $new_hex_component = dechex($new_decimal); |
|
| 127 | - if(strlen($new_hex_component) < 2) : |
|
| 128 | - $new_hex_component = "0".$new_hex_component; |
|
| 129 | - endif; |
|
| 130 | - $color .= $new_hex_component; |
|
| 122 | + $amount = $v / 100; |
|
| 123 | + $amount = round($amount * $factor); |
|
| 124 | + $new_decimal = $v - $amount; |
|
| 125 | + |
|
| 126 | + $new_hex_component = dechex($new_decimal); |
|
| 127 | + if(strlen($new_hex_component) < 2) : |
|
| 128 | + $new_hex_component = "0".$new_hex_component; |
|
| 129 | + endif; |
|
| 130 | + $color .= $new_hex_component; |
|
| 131 | 131 | endforeach; |
| 132 | 132 | |
| 133 | 133 | return $color; |
@@ -148,17 +148,17 @@ discard block |
||
| 148 | 148 | $base = sensei_rgb_from_hex( $color ); |
| 149 | 149 | $color = '#'; |
| 150 | 150 | |
| 151 | - foreach ($base as $k => $v) : |
|
| 152 | - $amount = 255 - $v; |
|
| 153 | - $amount = $amount / 100; |
|
| 154 | - $amount = round($amount * $factor); |
|
| 155 | - $new_decimal = $v + $amount; |
|
| 156 | - |
|
| 157 | - $new_hex_component = dechex($new_decimal); |
|
| 158 | - if(strlen($new_hex_component) < 2) : |
|
| 159 | - $new_hex_component = "0".$new_hex_component; |
|
| 160 | - endif; |
|
| 161 | - $color .= $new_hex_component; |
|
| 151 | + foreach ($base as $k => $v) : |
|
| 152 | + $amount = 255 - $v; |
|
| 153 | + $amount = $amount / 100; |
|
| 154 | + $amount = round($amount * $factor); |
|
| 155 | + $new_decimal = $v + $amount; |
|
| 156 | + |
|
| 157 | + $new_hex_component = dechex($new_decimal); |
|
| 158 | + if(strlen($new_hex_component) < 2) : |
|
| 159 | + $new_hex_component = "0".$new_hex_component; |
|
| 160 | + endif; |
|
| 161 | + $color .= $new_hex_component; |
|
| 162 | 162 | endforeach; |
| 163 | 163 | |
| 164 | 164 | return $color; |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active() |
| 173 | 173 | */ |
| 174 | 174 | if ( ! function_exists( 'is_woocommerce_active' ) ) { |
| 175 | - function is_woocommerce_active() { |
|
| 176 | - // calling is present instead of is active here |
|
| 177 | - // as this function can override other is_woocommerce_active |
|
| 178 | - // function in other woo plugins and Sensei_WC::is_woocommerce_active |
|
| 179 | - // also check the sensei settings for enable WooCommerce support, which |
|
| 180 | - // other plugins should not check against. |
|
| 181 | - return Sensei_WC::is_woocommerce_present(); |
|
| 182 | - } |
|
| 175 | + function is_woocommerce_active() { |
|
| 176 | + // calling is present instead of is active here |
|
| 177 | + // as this function can override other is_woocommerce_active |
|
| 178 | + // function in other woo plugins and Sensei_WC::is_woocommerce_active |
|
| 179 | + // also check the sensei settings for enable WooCommerce support, which |
|
| 180 | + // other plugins should not check against. |
|
| 181 | + return Sensei_WC::is_woocommerce_present(); |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -195,20 +195,20 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | function sensei_do_deprecated_action( $hook_tag, $version, $alternative="" , $args = array() ){ |
| 197 | 197 | |
| 198 | - if( has_action( $hook_tag ) ){ |
|
| 198 | + if( has_action( $hook_tag ) ){ |
|
| 199 | 199 | |
| 200 | - $error_message = sprintf( __( "SENSEI: The hook '%s', has been deprecated since '%s'." , 'woothemes-sensei'), $hook_tag ,$version ); |
|
| 200 | + $error_message = sprintf( __( "SENSEI: The hook '%s', has been deprecated since '%s'." , 'woothemes-sensei'), $hook_tag ,$version ); |
|
| 201 | 201 | |
| 202 | - if( !empty( $alternative ) ){ |
|
| 202 | + if( !empty( $alternative ) ){ |
|
| 203 | 203 | |
| 204 | - $error_message .= sprintf( __("Please use '%s' instead.", 'woothemes-sensei'), $alternative ) ; |
|
| 204 | + $error_message .= sprintf( __("Please use '%s' instead.", 'woothemes-sensei'), $alternative ) ; |
|
| 205 | 205 | |
| 206 | - } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - trigger_error( $error_message ); |
|
| 209 | - do_action( $hook_tag , $args ); |
|
| 208 | + trigger_error( $error_message ); |
|
| 209 | + do_action( $hook_tag , $args ); |
|
| 210 | 210 | |
| 211 | - } |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | }// end sensei_do_deprecated_action |
| 214 | 214 | |
@@ -238,18 +238,18 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function sensei_user_login_url(){ |
| 240 | 240 | |
| 241 | - $my_courses_page_id = intval( Sensei()->settings->get( 'my_course_page' ) ); |
|
| 242 | - $page = get_post( $my_courses_page_id ); |
|
| 241 | + $my_courses_page_id = intval( Sensei()->settings->get( 'my_course_page' ) ); |
|
| 242 | + $page = get_post( $my_courses_page_id ); |
|
| 243 | 243 | |
| 244 | - if ( $my_courses_page_id && isset( $page->ID ) && 'page' == get_post_type( $page->ID ) ){ |
|
| 244 | + if ( $my_courses_page_id && isset( $page->ID ) && 'page' == get_post_type( $page->ID ) ){ |
|
| 245 | 245 | |
| 246 | - return get_permalink( $page->ID ); |
|
| 246 | + return get_permalink( $page->ID ); |
|
| 247 | 247 | |
| 248 | - } else { |
|
| 248 | + } else { |
|
| 249 | 249 | |
| 250 | - return wp_login_url(); |
|
| 250 | + return wp_login_url(); |
|
| 251 | 251 | |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | 254 | }// end sensei_user_login_link |
| 255 | 255 | |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function sensei_is_login_required(){ |
| 264 | 264 | |
| 265 | - $login_required = isset( Sensei()->settings->settings['access_permission'] ) && ( true == Sensei()->settings->settings['access_permission'] ); |
|
| 265 | + $login_required = isset( Sensei()->settings->settings['access_permission'] ) && ( true == Sensei()->settings->settings['access_permission'] ); |
|
| 266 | 266 | |
| 267 | - return $login_required; |
|
| 267 | + return $login_required; |
|
| 268 | 268 | |
| 269 | 269 | } |
| 270 | 270 | \ No newline at end of file |
@@ -15,172 +15,172 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class Sensei_Shortcode_Loader{ |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @var array { |
|
| 20 | - * type string $shortcode |
|
| 21 | - * type Sensei_Shortcode |
|
| 22 | - * } all the shortcodes and which class to instantiate when they are called from |
|
| 23 | - * WordPress's do_shortcode() function. |
|
| 24 | - * |
|
| 25 | - */ |
|
| 26 | - protected $shortcode_classes; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Run all the functions that needs to be hooked into WordPress |
|
| 30 | - * |
|
| 31 | - * @since 1.9.0 |
|
| 32 | - */ |
|
| 33 | - public function __construct(){ |
|
| 34 | - |
|
| 35 | - // create a list of shortcodes and the class that handles them |
|
| 36 | - $this->setup_shortcode_class_map(); |
|
| 37 | - |
|
| 38 | - // setup all the shortcodes and load the listener into WP |
|
| 39 | - $this->initialize_shortcodes(); |
|
| 40 | - |
|
| 41 | - // add sensei body class for shortcodes |
|
| 42 | - add_filter( 'body_class', array( $this, 'possibly_add_body_class' )); |
|
| 43 | - |
|
| 44 | - // array( $this, 'add_body_class') |
|
| 45 | - |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Array of shortcode classes that should be instantiated when WordPress loads |
|
| 50 | - * a Sensei specific shortcode. |
|
| 51 | - * This list contains: |
|
| 52 | - * $shortcode => $class_name |
|
| 53 | - * |
|
| 54 | - * $shortcode is the actual shortcode the user will add to the editor |
|
| 55 | - * $class_name is the name of the class that will be instantiated to handle |
|
| 56 | - * the rendering of the shortcode. |
|
| 57 | - * |
|
| 58 | - * NOTE: When adding a new shortcode here be sure to load your shortcodes class |
|
| 59 | - * in class-sensei-autoloader class_file_map function |
|
| 60 | - */ |
|
| 61 | - public function setup_shortcode_class_map(){ |
|
| 62 | - |
|
| 63 | - $this->shortcode_classes = array( |
|
| 64 | - 'sensei_featured_courses' => 'Sensei_Shortcode_Featured_Courses', |
|
| 65 | - 'sensei_user_courses' => 'Sensei_Shortcode_User_Courses', |
|
| 66 | - 'sensei_courses' => 'Sensei_Shortcode_Courses', |
|
| 67 | - 'sensei_teachers' => 'Sensei_Shortcode_Teachers', |
|
| 68 | - 'sensei_user_messages' => 'Sensei_Shortcode_User_Messages', |
|
| 69 | - 'sensei_course_page' => 'Sensei_Shortcode_Course_Page', |
|
| 70 | - 'sensei_lesson_page' => 'Sensei_Shortcode_Lesson_Page', |
|
| 71 | - 'sensei_course_categories' => 'Sensei_Shortcode_Course_Categories', |
|
| 72 | - 'sensei_unpurchased_courses' => 'Sensei_Shortcode_Unpurchased_Courses', |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - // legacy shortcode handling: |
|
| 76 | - Sensei_Legacy_Shortcodes::init(); |
|
| 77 | - |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Add all shortcodes here |
|
| 82 | - * |
|
| 83 | - * This function adds shortcodes to WP that links to other functionality. |
|
| 84 | - * @since 1.9.0 |
|
| 85 | - */ |
|
| 86 | - public function initialize_shortcodes(){ |
|
| 87 | - |
|
| 88 | - // shortcodes should only respond to front end calls |
|
| 89 | - if( is_admin() || defined( 'DOING_AJAX' ) ){ |
|
| 90 | - return; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Tell WP to run this classes load_shortcode function for all the |
|
| 95 | - * shortcodes registered here in. |
|
| 96 | - * |
|
| 97 | - * With this method we only load shortcode classes when we need them. |
|
| 98 | - */ |
|
| 99 | - foreach( $this->shortcode_classes as $shortcode => $class ){ |
|
| 100 | - |
|
| 101 | - // all Sensei shortcodes are rendered by this loader class |
|
| 102 | - // it acts as an interface between wp and the shortcodes registered |
|
| 103 | - // above |
|
| 104 | - add_shortcode( $shortcode, array( $this,'render_shortcode' ) ); |
|
| 105 | - |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Respond to WordPress do_shortcode calls |
|
| 112 | - * for shortcodes registered in the initialize_shortcodes function. |
|
| 113 | - * |
|
| 114 | - * @since 1.9.0 |
|
| 115 | - * |
|
| 116 | - * @param $attributes |
|
| 117 | - * @param $content |
|
| 118 | - * @param $code the shortcode that is being requested |
|
| 119 | - * |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function render_shortcode( $attributes='', $content='', $code ){ |
|
| 123 | - |
|
| 124 | - // only respond if the shortcode that we've added shortcode |
|
| 125 | - // classes for. |
|
| 126 | - if( ! isset( $this->shortcode_classes[ $code ] ) ){ |
|
| 127 | - return ''; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // create an instances of the current requested shortcode |
|
| 131 | - $shortcode_handling_class = $this->shortcode_classes[ $code ]; |
|
| 132 | - $shortcode = new $shortcode_handling_class( $attributes, $content, $code ); |
|
| 133 | - |
|
| 134 | - // we expect the sensei class instantiated to implement the Sensei_Shortcode interface |
|
| 135 | - if( ! in_array( 'Sensei_Shortcode_Interface', class_implements( $shortcode) ) ){ |
|
| 136 | - |
|
| 137 | - $message = "The rendering class for your shortcode: $code, must implement the Sensei_Shortcode interface"; |
|
| 138 | - _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode',$message, '1.9.0' ); |
|
| 139 | - |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - return $shortcode->render(); |
|
| 143 | - |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Add the Sensei body class if |
|
| 148 | - * the current page has a Sensei shortcode. |
|
| 149 | - * |
|
| 150 | - * Note: legacy shortcodes not supported here. |
|
| 151 | - * |
|
| 152 | - * @since 1.9.0 |
|
| 153 | - * |
|
| 154 | - * @param array $classes |
|
| 155 | - * @return array |
|
| 156 | - */ |
|
| 157 | - public function possibly_add_body_class ( $classes ) { |
|
| 158 | - |
|
| 159 | - global $post; |
|
| 160 | - |
|
| 161 | - $has_sensei_shortcode = false; |
|
| 162 | - |
|
| 163 | - if ( is_a( $post, 'WP_Post' ) ) { |
|
| 164 | - |
|
| 165 | - // check all registered Sensei shortcodes (not legacy shortcodes) |
|
| 166 | - foreach ( $this->shortcode_classes as $shortcode => $class ){ |
|
| 167 | - |
|
| 168 | - if ( has_shortcode( $post->post_content, $shortcode ) ) { |
|
| 18 | + /** |
|
| 19 | + * @var array { |
|
| 20 | + * type string $shortcode |
|
| 21 | + * type Sensei_Shortcode |
|
| 22 | + * } all the shortcodes and which class to instantiate when they are called from |
|
| 23 | + * WordPress's do_shortcode() function. |
|
| 24 | + * |
|
| 25 | + */ |
|
| 26 | + protected $shortcode_classes; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Run all the functions that needs to be hooked into WordPress |
|
| 30 | + * |
|
| 31 | + * @since 1.9.0 |
|
| 32 | + */ |
|
| 33 | + public function __construct(){ |
|
| 34 | + |
|
| 35 | + // create a list of shortcodes and the class that handles them |
|
| 36 | + $this->setup_shortcode_class_map(); |
|
| 37 | + |
|
| 38 | + // setup all the shortcodes and load the listener into WP |
|
| 39 | + $this->initialize_shortcodes(); |
|
| 40 | + |
|
| 41 | + // add sensei body class for shortcodes |
|
| 42 | + add_filter( 'body_class', array( $this, 'possibly_add_body_class' )); |
|
| 43 | + |
|
| 44 | + // array( $this, 'add_body_class') |
|
| 45 | + |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Array of shortcode classes that should be instantiated when WordPress loads |
|
| 50 | + * a Sensei specific shortcode. |
|
| 51 | + * This list contains: |
|
| 52 | + * $shortcode => $class_name |
|
| 53 | + * |
|
| 54 | + * $shortcode is the actual shortcode the user will add to the editor |
|
| 55 | + * $class_name is the name of the class that will be instantiated to handle |
|
| 56 | + * the rendering of the shortcode. |
|
| 57 | + * |
|
| 58 | + * NOTE: When adding a new shortcode here be sure to load your shortcodes class |
|
| 59 | + * in class-sensei-autoloader class_file_map function |
|
| 60 | + */ |
|
| 61 | + public function setup_shortcode_class_map(){ |
|
| 62 | + |
|
| 63 | + $this->shortcode_classes = array( |
|
| 64 | + 'sensei_featured_courses' => 'Sensei_Shortcode_Featured_Courses', |
|
| 65 | + 'sensei_user_courses' => 'Sensei_Shortcode_User_Courses', |
|
| 66 | + 'sensei_courses' => 'Sensei_Shortcode_Courses', |
|
| 67 | + 'sensei_teachers' => 'Sensei_Shortcode_Teachers', |
|
| 68 | + 'sensei_user_messages' => 'Sensei_Shortcode_User_Messages', |
|
| 69 | + 'sensei_course_page' => 'Sensei_Shortcode_Course_Page', |
|
| 70 | + 'sensei_lesson_page' => 'Sensei_Shortcode_Lesson_Page', |
|
| 71 | + 'sensei_course_categories' => 'Sensei_Shortcode_Course_Categories', |
|
| 72 | + 'sensei_unpurchased_courses' => 'Sensei_Shortcode_Unpurchased_Courses', |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + // legacy shortcode handling: |
|
| 76 | + Sensei_Legacy_Shortcodes::init(); |
|
| 77 | + |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Add all shortcodes here |
|
| 82 | + * |
|
| 83 | + * This function adds shortcodes to WP that links to other functionality. |
|
| 84 | + * @since 1.9.0 |
|
| 85 | + */ |
|
| 86 | + public function initialize_shortcodes(){ |
|
| 87 | + |
|
| 88 | + // shortcodes should only respond to front end calls |
|
| 89 | + if( is_admin() || defined( 'DOING_AJAX' ) ){ |
|
| 90 | + return; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Tell WP to run this classes load_shortcode function for all the |
|
| 95 | + * shortcodes registered here in. |
|
| 96 | + * |
|
| 97 | + * With this method we only load shortcode classes when we need them. |
|
| 98 | + */ |
|
| 99 | + foreach( $this->shortcode_classes as $shortcode => $class ){ |
|
| 100 | + |
|
| 101 | + // all Sensei shortcodes are rendered by this loader class |
|
| 102 | + // it acts as an interface between wp and the shortcodes registered |
|
| 103 | + // above |
|
| 104 | + add_shortcode( $shortcode, array( $this,'render_shortcode' ) ); |
|
| 105 | + |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Respond to WordPress do_shortcode calls |
|
| 112 | + * for shortcodes registered in the initialize_shortcodes function. |
|
| 113 | + * |
|
| 114 | + * @since 1.9.0 |
|
| 115 | + * |
|
| 116 | + * @param $attributes |
|
| 117 | + * @param $content |
|
| 118 | + * @param $code the shortcode that is being requested |
|
| 119 | + * |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function render_shortcode( $attributes='', $content='', $code ){ |
|
| 123 | + |
|
| 124 | + // only respond if the shortcode that we've added shortcode |
|
| 125 | + // classes for. |
|
| 126 | + if( ! isset( $this->shortcode_classes[ $code ] ) ){ |
|
| 127 | + return ''; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // create an instances of the current requested shortcode |
|
| 131 | + $shortcode_handling_class = $this->shortcode_classes[ $code ]; |
|
| 132 | + $shortcode = new $shortcode_handling_class( $attributes, $content, $code ); |
|
| 133 | + |
|
| 134 | + // we expect the sensei class instantiated to implement the Sensei_Shortcode interface |
|
| 135 | + if( ! in_array( 'Sensei_Shortcode_Interface', class_implements( $shortcode) ) ){ |
|
| 136 | + |
|
| 137 | + $message = "The rendering class for your shortcode: $code, must implement the Sensei_Shortcode interface"; |
|
| 138 | + _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode',$message, '1.9.0' ); |
|
| 139 | + |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + return $shortcode->render(); |
|
| 143 | + |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Add the Sensei body class if |
|
| 148 | + * the current page has a Sensei shortcode. |
|
| 149 | + * |
|
| 150 | + * Note: legacy shortcodes not supported here. |
|
| 151 | + * |
|
| 152 | + * @since 1.9.0 |
|
| 153 | + * |
|
| 154 | + * @param array $classes |
|
| 155 | + * @return array |
|
| 156 | + */ |
|
| 157 | + public function possibly_add_body_class ( $classes ) { |
|
| 158 | + |
|
| 159 | + global $post; |
|
| 160 | + |
|
| 161 | + $has_sensei_shortcode = false; |
|
| 162 | + |
|
| 163 | + if ( is_a( $post, 'WP_Post' ) ) { |
|
| 164 | + |
|
| 165 | + // check all registered Sensei shortcodes (not legacy shortcodes) |
|
| 166 | + foreach ( $this->shortcode_classes as $shortcode => $class ){ |
|
| 167 | + |
|
| 168 | + if ( has_shortcode( $post->post_content, $shortcode ) ) { |
|
| 169 | 169 | |
| 170 | - $has_sensei_shortcode = true; |
|
| 171 | - } |
|
| 170 | + $has_sensei_shortcode = true; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - } |
|
| 174 | - } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - if( $has_sensei_shortcode ) { |
|
| 177 | - $classes[] = 'sensei' ; |
|
| 178 | - } |
|
| 176 | + if( $has_sensei_shortcode ) { |
|
| 177 | + $classes[] = 'sensei' ; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | - return $classes; |
|
| 182 | - |
|
| 183 | - } |
|
| 181 | + return $classes; |
|
| 182 | + |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | 185 | } // end class Sensei_Shortcodes |
| 186 | 186 | new Sensei_Shortcode_Loader(); |
@@ -14,148 +14,148 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Sensei_Shortcode_Unpurchased_Courses implements Sensei_Shortcode_Interface { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @var WP_Query to help setup the query needed by the render method. |
|
| 19 | - */ |
|
| 20 | - protected $query; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var string number of items to show on the current page |
|
| 24 | - * Default: all. |
|
| 25 | - */ |
|
| 26 | - protected $number; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var string ordery by course field |
|
| 30 | - * Default: date |
|
| 31 | - */ |
|
| 32 | - protected $orderby; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var string ASC or DESC |
|
| 36 | - * Default: 'DESC' |
|
| 37 | - */ |
|
| 38 | - protected $order; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Setup the shortcode object |
|
| 42 | - * |
|
| 43 | - * @since 1.9.0 |
|
| 44 | - * @param array $attributes |
|
| 45 | - * @param string $content |
|
| 46 | - * @param string $shortcode the shortcode that was called for this instance |
|
| 47 | - */ |
|
| 48 | - public function __construct( $attributes, $content, $shortcode ){ |
|
| 49 | - |
|
| 50 | - // set up all argument need for constructing the course query |
|
| 51 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
| 52 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title'; |
|
| 53 | - |
|
| 54 | - // set the default for menu_order to be ASC |
|
| 55 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
| 56 | - |
|
| 57 | - $this->order = 'ASC'; |
|
| 17 | + /** |
|
| 18 | + * @var WP_Query to help setup the query needed by the render method. |
|
| 19 | + */ |
|
| 20 | + protected $query; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var string number of items to show on the current page |
|
| 24 | + * Default: all. |
|
| 25 | + */ |
|
| 26 | + protected $number; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var string ordery by course field |
|
| 30 | + * Default: date |
|
| 31 | + */ |
|
| 32 | + protected $orderby; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var string ASC or DESC |
|
| 36 | + * Default: 'DESC' |
|
| 37 | + */ |
|
| 38 | + protected $order; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Setup the shortcode object |
|
| 42 | + * |
|
| 43 | + * @since 1.9.0 |
|
| 44 | + * @param array $attributes |
|
| 45 | + * @param string $content |
|
| 46 | + * @param string $shortcode the shortcode that was called for this instance |
|
| 47 | + */ |
|
| 48 | + public function __construct( $attributes, $content, $shortcode ){ |
|
| 49 | + |
|
| 50 | + // set up all argument need for constructing the course query |
|
| 51 | + $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
| 52 | + $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title'; |
|
| 53 | + |
|
| 54 | + // set the default for menu_order to be ASC |
|
| 55 | + if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
| 56 | + |
|
| 57 | + $this->order = 'ASC'; |
|
| 58 | 58 | |
| 59 | - }else{ |
|
| 59 | + }else{ |
|
| 60 | 60 | |
| 61 | - // for everything else use the value passed or the default DESC |
|
| 62 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
| 61 | + // for everything else use the value passed or the default DESC |
|
| 62 | + $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
| 63 | 63 | |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // setup the course query that will be used when rendering |
|
| 67 | - $this->setup_course_query(); |
|
| 68 | - } |
|
| 66 | + // setup the course query that will be used when rendering |
|
| 67 | + $this->setup_course_query(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Sets up the object course query |
|
| 72 | - * that will be used int he render method. |
|
| 73 | - * |
|
| 74 | - * @since 1.9.0 |
|
| 75 | - */ |
|
| 76 | - protected function setup_course_query(){ |
|
| 70 | + /** |
|
| 71 | + * Sets up the object course query |
|
| 72 | + * that will be used int he render method. |
|
| 73 | + * |
|
| 74 | + * @since 1.9.0 |
|
| 75 | + */ |
|
| 76 | + protected function setup_course_query(){ |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | - // course query parameters to be used for all courses |
|
| 80 | - $query_args = array( |
|
| 81 | - 'post_type' => 'course', |
|
| 82 | - 'post_status' => 'publish', |
|
| 83 | - // the number specified by the user will be used later in this function |
|
| 84 | - 'posts_per_page' => 1000, |
|
| 85 | - 'orderby' => $this->orderby, |
|
| 86 | - 'order' => $this->order |
|
| 87 | - ); |
|
| 79 | + // course query parameters to be used for all courses |
|
| 80 | + $query_args = array( |
|
| 81 | + 'post_type' => 'course', |
|
| 82 | + 'post_status' => 'publish', |
|
| 83 | + // the number specified by the user will be used later in this function |
|
| 84 | + 'posts_per_page' => 1000, |
|
| 85 | + 'orderby' => $this->orderby, |
|
| 86 | + 'order' => $this->order |
|
| 87 | + ); |
|
| 88 | 88 | |
| 89 | - // get all the courses that has a product attached |
|
| 90 | - $all_courses_query = new WP_Query( $query_args ); |
|
| 89 | + // get all the courses that has a product attached |
|
| 90 | + $all_courses_query = new WP_Query( $query_args ); |
|
| 91 | 91 | |
| 92 | - $paid_courses_not_taken = array(); |
|
| 93 | - // look through all course and find the purchasable ones that user has not purchased |
|
| 94 | - foreach( $all_courses_query->posts as $course ){ |
|
| 92 | + $paid_courses_not_taken = array(); |
|
| 93 | + // look through all course and find the purchasable ones that user has not purchased |
|
| 94 | + foreach( $all_courses_query->posts as $course ){ |
|
| 95 | 95 | |
| 96 | - // only keep the courses with a product including only courses that the user not taking |
|
| 97 | - $course_product_id = get_post_meta( $course->ID, '_course_woocommerce_product',true ); |
|
| 98 | - if( is_numeric( $course_product_id ) |
|
| 99 | - && |
|
| 100 | - ! Sensei_Utils::user_started_course( $course->ID , get_current_user_id() ) |
|
| 101 | - ){ |
|
| 96 | + // only keep the courses with a product including only courses that the user not taking |
|
| 97 | + $course_product_id = get_post_meta( $course->ID, '_course_woocommerce_product',true ); |
|
| 98 | + if( is_numeric( $course_product_id ) |
|
| 99 | + && |
|
| 100 | + ! Sensei_Utils::user_started_course( $course->ID , get_current_user_id() ) |
|
| 101 | + ){ |
|
| 102 | 102 | |
| 103 | - $paid_courses_not_taken[] = $course->ID; |
|
| 103 | + $paid_courses_not_taken[] = $course->ID; |
|
| 104 | 104 | |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - } // end foreach |
|
| 107 | + } // end foreach |
|
| 108 | 108 | |
| 109 | - // setup the course query again and only use the course the user has not purchased. |
|
| 110 | - // this query will be loaded into the global WP_Query in the render function. |
|
| 111 | - $query_args[ 'post__in' ] = $paid_courses_not_taken; |
|
| 112 | - $query_args[ 'posts_per_page' ] = $this->number; |
|
| 109 | + // setup the course query again and only use the course the user has not purchased. |
|
| 110 | + // this query will be loaded into the global WP_Query in the render function. |
|
| 111 | + $query_args[ 'post__in' ] = $paid_courses_not_taken; |
|
| 112 | + $query_args[ 'posts_per_page' ] = $this->number; |
|
| 113 | 113 | |
| 114 | - $this->query = new WP_Query( $query_args ); |
|
| 114 | + $this->query = new WP_Query( $query_args ); |
|
| 115 | 115 | |
| 116 | - }// end setup _course_query |
|
| 116 | + }// end setup _course_query |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Rendering the shortcode this class is responsible for. |
|
| 120 | - * |
|
| 121 | - * @return string $content |
|
| 122 | - */ |
|
| 123 | - public function render(){ |
|
| 118 | + /** |
|
| 119 | + * Rendering the shortcode this class is responsible for. |
|
| 120 | + * |
|
| 121 | + * @return string $content |
|
| 122 | + */ |
|
| 123 | + public function render(){ |
|
| 124 | 124 | |
| 125 | - global $wp_query; |
|
| 125 | + global $wp_query; |
|
| 126 | 126 | |
| 127 | - if ( ! is_user_logged_in() ) { |
|
| 127 | + if ( ! is_user_logged_in() ) { |
|
| 128 | 128 | |
| 129 | - $anchor_before = '<a href="' . esc_url( sensei_user_login_url() ) . '" >'; |
|
| 130 | - $anchor_after = '</a>'; |
|
| 131 | - $notice = sprintf( |
|
| 132 | - __('You must be logged in to view the non-purchased courses. Click here to %slogin%s.'), |
|
| 133 | - $anchor_before, |
|
| 134 | - $anchor_after |
|
| 135 | - ); |
|
| 129 | + $anchor_before = '<a href="' . esc_url( sensei_user_login_url() ) . '" >'; |
|
| 130 | + $anchor_after = '</a>'; |
|
| 131 | + $notice = sprintf( |
|
| 132 | + __('You must be logged in to view the non-purchased courses. Click here to %slogin%s.'), |
|
| 133 | + $anchor_before, |
|
| 134 | + $anchor_after |
|
| 135 | + ); |
|
| 136 | 136 | |
| 137 | - Sensei()->notices->add_notice( $notice, 'info' ); |
|
| 138 | - Sensei()->notices->print_notices(); |
|
| 137 | + Sensei()->notices->add_notice( $notice, 'info' ); |
|
| 138 | + Sensei()->notices->print_notices(); |
|
| 139 | 139 | |
| 140 | - return ''; |
|
| 140 | + return ''; |
|
| 141 | 141 | |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - // keep a reference to old query |
|
| 145 | - $current_global_query = $wp_query; |
|
| 146 | - // assign the query setup in $this-> setup_course_query |
|
| 147 | - $wp_query = $this->query; |
|
| 144 | + // keep a reference to old query |
|
| 145 | + $current_global_query = $wp_query; |
|
| 146 | + // assign the query setup in $this-> setup_course_query |
|
| 147 | + $wp_query = $this->query; |
|
| 148 | 148 | |
| 149 | - ob_start(); |
|
| 150 | - Sensei()->notices->print_notices(); |
|
| 151 | - Sensei_Templates::get_template('loop-course.php'); |
|
| 152 | - $shortcode_output = ob_get_clean(); |
|
| 149 | + ob_start(); |
|
| 150 | + Sensei()->notices->print_notices(); |
|
| 151 | + Sensei_Templates::get_template('loop-course.php'); |
|
| 152 | + $shortcode_output = ob_get_clean(); |
|
| 153 | 153 | |
| 154 | - //restore old query |
|
| 155 | - $wp_query = $current_global_query; |
|
| 154 | + //restore old query |
|
| 155 | + $wp_query = $current_global_query; |
|
| 156 | 156 | |
| 157 | - return $shortcode_output; |
|
| 157 | + return $shortcode_output; |
|
| 158 | 158 | |
| 159 | - }// end render |
|
| 159 | + }// end render |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | \ No newline at end of file |
@@ -1,15 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | 3 | /** |
| 4 | - * Content wrappers |
|
| 5 | - * |
|
| 6 | - * All support theme wrappers can be found in includes/theme-integrations |
|
| 7 | - * |
|
| 8 | - * @author Automattic |
|
| 9 | - * @package Sensei |
|
| 10 | - * @category Templates |
|
| 11 | - * @version 1.9.0 |
|
| 12 | - */ |
|
| 4 | + * Content wrappers |
|
| 5 | + * |
|
| 6 | + * All support theme wrappers can be found in includes/theme-integrations |
|
| 7 | + * |
|
| 8 | + * @author Automattic |
|
| 9 | + * @package Sensei |
|
| 10 | + * @category Templates |
|
| 11 | + * @version 1.9.0 |
|
| 12 | + */ |
|
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | </main> |