@@ -25,167 +25,167 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class Sensei_Shortcode_User_Courses implements Sensei_Shortcode_Interface { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var WP_Query to help setup the query needed by the render method. |
|
| 30 | - */ |
|
| 31 | - protected $query; |
|
| 28 | + /** |
|
| 29 | + * @var WP_Query to help setup the query needed by the render method. |
|
| 30 | + */ |
|
| 31 | + protected $query; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var string number of items to show on the current page |
|
| 35 | - * Default: -1. |
|
| 36 | - */ |
|
| 37 | - protected $number; |
|
| 33 | + /** |
|
| 34 | + * @var string number of items to show on the current page |
|
| 35 | + * Default: -1. |
|
| 36 | + */ |
|
| 37 | + protected $number; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var string ordery by course field |
|
| 41 | - * Default: date |
|
| 42 | - */ |
|
| 43 | - protected $orderby; |
|
| 39 | + /** |
|
| 40 | + * @var string ordery by course field |
|
| 41 | + * Default: date |
|
| 42 | + */ |
|
| 43 | + protected $orderby; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string ASC or DESC |
|
| 47 | - * Default: 'DESC' |
|
| 48 | - */ |
|
| 49 | - protected $order; |
|
| 45 | + /** |
|
| 46 | + * @var string ASC or DESC |
|
| 47 | + * Default: 'DESC' |
|
| 48 | + */ |
|
| 49 | + protected $order; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var status can be completed or active. If none is specified all will be shown |
|
| 53 | - */ |
|
| 54 | - protected $status; |
|
| 51 | + /** |
|
| 52 | + * @var status can be completed or active. If none is specified all will be shown |
|
| 53 | + */ |
|
| 54 | + protected $status; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Setup the shortcode object |
|
| 58 | - * |
|
| 59 | - * @since 1.9.0 |
|
| 60 | - * @param array $attributes |
|
| 61 | - * @param string $content |
|
| 62 | - * @param string $shortcode the shortcode that was called for this instance |
|
| 63 | - */ |
|
| 64 | - public function __construct( $attributes, $content, $shortcode ){ |
|
| 56 | + /** |
|
| 57 | + * Setup the shortcode object |
|
| 58 | + * |
|
| 59 | + * @since 1.9.0 |
|
| 60 | + * @param array $attributes |
|
| 61 | + * @param string $content |
|
| 62 | + * @param string $shortcode the shortcode that was called for this instance |
|
| 63 | + */ |
|
| 64 | + public function __construct( $attributes, $content, $shortcode ){ |
|
| 65 | 65 | |
| 66 | - if(! is_user_logged_in() ) { |
|
| 67 | - // show the login form |
|
| 68 | - Sensei()->frontend->sensei_login_form(); |
|
| 69 | - return; |
|
| 70 | - } |
|
| 66 | + if(! is_user_logged_in() ) { |
|
| 67 | + // show the login form |
|
| 68 | + Sensei()->frontend->sensei_login_form(); |
|
| 69 | + return; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - // set up all argument need for constructing the course query |
|
| 73 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
| 74 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title'; |
|
| 75 | - $this->status = isset( $attributes['status'] ) ? $attributes['status'] : 'all'; |
|
| 72 | + // set up all argument need for constructing the course query |
|
| 73 | + $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
| 74 | + $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title'; |
|
| 75 | + $this->status = isset( $attributes['status'] ) ? $attributes['status'] : 'all'; |
|
| 76 | 76 | |
| 77 | - // set the default for menu_order to be ASC |
|
| 78 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
| 77 | + // set the default for menu_order to be ASC |
|
| 78 | + if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
| 79 | 79 | |
| 80 | - $this->order = 'ASC'; |
|
| 80 | + $this->order = 'ASC'; |
|
| 81 | 81 | |
| 82 | - }else{ |
|
| 82 | + }else{ |
|
| 83 | 83 | |
| 84 | - // for everything else use the value passed or the default DESC |
|
| 85 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC'; |
|
| 84 | + // for everything else use the value passed or the default DESC |
|
| 85 | + $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC'; |
|
| 86 | 86 | |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - // setup the course query that will be used when rendering |
|
| 90 | - $this->setup_course_query(); |
|
| 91 | - } |
|
| 89 | + // setup the course query that will be used when rendering |
|
| 90 | + $this->setup_course_query(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Sets up the object course query |
|
| 95 | - * that will be used in the render method. |
|
| 96 | - * |
|
| 97 | - * @since 1.9.0 |
|
| 98 | - */ |
|
| 99 | - protected function setup_course_query(){ |
|
| 93 | + /** |
|
| 94 | + * Sets up the object course query |
|
| 95 | + * that will be used in the render method. |
|
| 96 | + * |
|
| 97 | + * @since 1.9.0 |
|
| 98 | + */ |
|
| 99 | + protected function setup_course_query(){ |
|
| 100 | 100 | |
| 101 | - $status_query = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status' ); |
|
| 102 | - $user_courses_logs = Sensei_Utils::sensei_check_for_activity( $status_query , true ); |
|
| 103 | - if ( !is_array($user_courses_logs) ) { |
|
| 101 | + $status_query = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status' ); |
|
| 102 | + $user_courses_logs = Sensei_Utils::sensei_check_for_activity( $status_query , true ); |
|
| 103 | + if ( !is_array($user_courses_logs) ) { |
|
| 104 | 104 | |
| 105 | - $user_courses_logs = array( $user_courses_logs ); |
|
| 105 | + $user_courses_logs = array( $user_courses_logs ); |
|
| 106 | 106 | |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - $completed_ids = $active_ids = array(); |
|
| 110 | - foreach( $user_courses_logs as $course_status ) { |
|
| 109 | + $completed_ids = $active_ids = array(); |
|
| 110 | + foreach( $user_courses_logs as $course_status ) { |
|
| 111 | 111 | |
| 112 | - if ( Sensei_Utils::user_completed_course( $course_status, get_current_user_id() ) ) { |
|
| 112 | + if ( Sensei_Utils::user_completed_course( $course_status, get_current_user_id() ) ) { |
|
| 113 | 113 | |
| 114 | - $completed_ids[] = $course_status->comment_post_ID; |
|
| 114 | + $completed_ids[] = $course_status->comment_post_ID; |
|
| 115 | 115 | |
| 116 | - } else { |
|
| 116 | + } else { |
|
| 117 | 117 | |
| 118 | - $active_ids[] = $course_status->comment_post_ID; |
|
| 118 | + $active_ids[] = $course_status->comment_post_ID; |
|
| 119 | 119 | |
| 120 | - } |
|
| 121 | - } |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - if( 'completed' == $this->status ){ |
|
| 123 | + if( 'completed' == $this->status ){ |
|
| 124 | 124 | |
| 125 | - $included_courses = $completed_ids; |
|
| 125 | + $included_courses = $completed_ids; |
|
| 126 | 126 | |
| 127 | 127 | |
| 128 | - }elseif( 'active'==$this->status ){ |
|
| 128 | + }elseif( 'active'==$this->status ){ |
|
| 129 | 129 | |
| 130 | - $included_courses = $active_ids; |
|
| 130 | + $included_courses = $active_ids; |
|
| 131 | 131 | |
| 132 | - }else{ // all courses |
|
| 132 | + }else{ // all courses |
|
| 133 | 133 | |
| 134 | - if( empty( $completed_ids ) ){ |
|
| 134 | + if( empty( $completed_ids ) ){ |
|
| 135 | 135 | |
| 136 | - add_action( 'sensei_loop_course_inside_before', array( $this, 'completed_no_course_message_output' ) ); |
|
| 137 | - } |
|
| 136 | + add_action( 'sensei_loop_course_inside_before', array( $this, 'completed_no_course_message_output' ) ); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - if( empty( $active_ids ) ){ |
|
| 139 | + if( empty( $active_ids ) ){ |
|
| 140 | 140 | |
| 141 | - add_action( 'sensei_loop_course_inside_before', array( $this, 'active_no_course_message_output' ) ); |
|
| 141 | + add_action( 'sensei_loop_course_inside_before', array( $this, 'active_no_course_message_output' ) ); |
|
| 142 | 142 | |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if( empty( $completed_ids ) && empty( $active_ids ) ){ |
|
| 145 | + if( empty( $completed_ids ) && empty( $active_ids ) ){ |
|
| 146 | 146 | |
| 147 | - $included_courses = array('-1000'); // don't show any courses |
|
| 147 | + $included_courses = array('-1000'); // don't show any courses |
|
| 148 | 148 | |
| 149 | - }else{ |
|
| 150 | - $included_courses = Sensei_Utils::array_zip_merge( (array)$active_ids, (array)$completed_ids ); |
|
| 151 | - } |
|
| 149 | + }else{ |
|
| 150 | + $included_courses = Sensei_Utils::array_zip_merge( (array)$active_ids, (array)$completed_ids ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + // temporary work around to hide pagination on the courses page |
|
| 157 | + // this is in place until we can load the course for each tab via ajax |
|
| 158 | + // if the shortcode is not active or in active and the active and completed |
|
| 159 | + // tabs show up. |
|
| 160 | + $number_of_posts = $this->number; |
|
| 161 | + if( 'active' != $this->status && 'complete' != $this->status ){ |
|
| 162 | + $number_of_posts = 1000; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // course query parameters |
|
| 166 | + $query_var_paged = get_query_var('paged'); |
|
| 167 | + $query_args = array( |
|
| 168 | + 'post_type' => 'course', |
|
| 169 | + 'post_status' => 'publish', |
|
| 170 | + 'orderby' => $this->orderby, |
|
| 171 | + 'order' => $this->order, |
|
| 172 | + 'paged' => empty( $query_var_paged )? 1 : $query_var_paged, |
|
| 173 | + 'posts_per_page' => $number_of_posts, |
|
| 174 | + 'post__in' => $included_courses, |
|
| 175 | + ); |
|
| 176 | + |
|
| 177 | + $this->query = new WP_Query( $query_args ); |
|
| 152 | 178 | |
| 179 | + }// end setup _course_query |
|
| 153 | 180 | |
| 154 | - } |
|
| 155 | - |
|
| 156 | - // temporary work around to hide pagination on the courses page |
|
| 157 | - // this is in place until we can load the course for each tab via ajax |
|
| 158 | - // if the shortcode is not active or in active and the active and completed |
|
| 159 | - // tabs show up. |
|
| 160 | - $number_of_posts = $this->number; |
|
| 161 | - if( 'active' != $this->status && 'complete' != $this->status ){ |
|
| 162 | - $number_of_posts = 1000; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // course query parameters |
|
| 166 | - $query_var_paged = get_query_var('paged'); |
|
| 167 | - $query_args = array( |
|
| 168 | - 'post_type' => 'course', |
|
| 169 | - 'post_status' => 'publish', |
|
| 170 | - 'orderby' => $this->orderby, |
|
| 171 | - 'order' => $this->order, |
|
| 172 | - 'paged' => empty( $query_var_paged )? 1 : $query_var_paged, |
|
| 173 | - 'posts_per_page' => $number_of_posts, |
|
| 174 | - 'post__in' => $included_courses, |
|
| 175 | - ); |
|
| 176 | - |
|
| 177 | - $this->query = new WP_Query( $query_args ); |
|
| 178 | - |
|
| 179 | - }// end setup _course_query |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Output the message that tells the user they have |
|
| 183 | - * no completed courses. |
|
| 184 | - * |
|
| 185 | - * @since 1.9.0 |
|
| 186 | - */ |
|
| 187 | - public function completed_no_course_message_output(){ |
|
| 188 | - ?> |
|
| 181 | + /** |
|
| 182 | + * Output the message that tells the user they have |
|
| 183 | + * no completed courses. |
|
| 184 | + * |
|
| 185 | + * @since 1.9.0 |
|
| 186 | + */ |
|
| 187 | + public function completed_no_course_message_output(){ |
|
| 188 | + ?> |
|
| 189 | 189 | <li class="user-completed"> |
| 190 | 190 | <div class="sensei-message info"> |
| 191 | 191 | |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | </div> |
| 195 | 195 | </li> |
| 196 | 196 | <?php |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Output the message that tells the user they have |
|
| 201 | - * no active courses. |
|
| 202 | - * |
|
| 203 | - * @since 1.9.0 |
|
| 204 | - */ |
|
| 205 | - public function active_no_course_message_output(){ |
|
| 206 | - ?> |
|
| 199 | + /** |
|
| 200 | + * Output the message that tells the user they have |
|
| 201 | + * no active courses. |
|
| 202 | + * |
|
| 203 | + * @since 1.9.0 |
|
| 204 | + */ |
|
| 205 | + public function active_no_course_message_output(){ |
|
| 206 | + ?> |
|
| 207 | 207 | |
| 208 | 208 | <li class="user-active"> |
| 209 | 209 | <div class="sensei-message info"> |
@@ -219,141 +219,141 @@ discard block |
||
| 219 | 219 | </div> |
| 220 | 220 | </li> |
| 221 | 221 | <?php |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * Rendering the shortcode this class is responsible for. |
|
| 226 | - * |
|
| 227 | - * @return string $content |
|
| 228 | - */ |
|
| 229 | - public function render(){ |
|
| 224 | + /** |
|
| 225 | + * Rendering the shortcode this class is responsible for. |
|
| 226 | + * |
|
| 227 | + * @return string $content |
|
| 228 | + */ |
|
| 229 | + public function render(){ |
|
| 230 | 230 | |
| 231 | - global $wp_query; |
|
| 231 | + global $wp_query; |
|
| 232 | 232 | |
| 233 | - if(! is_user_logged_in() ) { |
|
| 234 | - return ''; |
|
| 235 | - } |
|
| 233 | + if(! is_user_logged_in() ) { |
|
| 234 | + return ''; |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - // keep a reference to old query |
|
| 238 | - $current_global_query = $wp_query; |
|
| 237 | + // keep a reference to old query |
|
| 238 | + $current_global_query = $wp_query; |
|
| 239 | 239 | |
| 240 | - // assign the query setup in $this-> setup_course_query |
|
| 241 | - $wp_query = $this->query; |
|
| 240 | + // assign the query setup in $this-> setup_course_query |
|
| 241 | + $wp_query = $this->query; |
|
| 242 | 242 | |
| 243 | - $this->attach_shortcode_hooks(); |
|
| 243 | + $this->attach_shortcode_hooks(); |
|
| 244 | 244 | |
| 245 | - ob_start(); |
|
| 246 | - echo '<section id="sensei-user-courses">'; |
|
| 247 | - Sensei_Messages::the_my_messages_link(); |
|
| 248 | - Sensei_Templates::get_template('loop-course.php'); |
|
| 249 | - Sensei_Templates::get_template('globals/pagination.php'); |
|
| 250 | - echo '</section>'; |
|
| 245 | + ob_start(); |
|
| 246 | + echo '<section id="sensei-user-courses">'; |
|
| 247 | + Sensei_Messages::the_my_messages_link(); |
|
| 248 | + Sensei_Templates::get_template('loop-course.php'); |
|
| 249 | + Sensei_Templates::get_template('globals/pagination.php'); |
|
| 250 | + echo '</section>'; |
|
| 251 | 251 | |
| 252 | - $shortcode_output = ob_get_clean(); |
|
| 252 | + $shortcode_output = ob_get_clean(); |
|
| 253 | 253 | |
| 254 | - $this->detach_shortcode_hooks(); |
|
| 254 | + $this->detach_shortcode_hooks(); |
|
| 255 | 255 | |
| 256 | - //restore old query |
|
| 257 | - $wp_query = $current_global_query; |
|
| 256 | + //restore old query |
|
| 257 | + $wp_query = $current_global_query; |
|
| 258 | 258 | |
| 259 | - return $shortcode_output; |
|
| 259 | + return $shortcode_output; |
|
| 260 | 260 | |
| 261 | - }// end render |
|
| 261 | + }// end render |
|
| 262 | 262 | |
| 263 | - /** |
|
| 264 | - * Add hooks for the shortcode |
|
| 265 | - * |
|
| 266 | - * @since 1.9.0 |
|
| 267 | - */ |
|
| 268 | - public function attach_shortcode_hooks(){ |
|
| 263 | + /** |
|
| 264 | + * Add hooks for the shortcode |
|
| 265 | + * |
|
| 266 | + * @since 1.9.0 |
|
| 267 | + */ |
|
| 268 | + public function attach_shortcode_hooks(){ |
|
| 269 | 269 | |
| 270 | - // attach the toggle functionality |
|
| 271 | - // don't show the toggle action if the user specified complete or active for this shortcode |
|
| 272 | - if( ! in_array( $this->status, array( 'active', 'complete' ) ) ){ |
|
| 270 | + // attach the toggle functionality |
|
| 271 | + // don't show the toggle action if the user specified complete or active for this shortcode |
|
| 272 | + if( ! in_array( $this->status, array( 'active', 'complete' ) ) ){ |
|
| 273 | 273 | |
| 274 | - add_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) ); |
|
| 275 | - add_action( 'wp_footer', array( $this, 'print_course_toggle_actions_inline_script' ), 90 ); |
|
| 274 | + add_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) ); |
|
| 275 | + add_action( 'wp_footer', array( $this, 'print_course_toggle_actions_inline_script' ), 90 ); |
|
| 276 | 276 | |
| 277 | - } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - // add extra classes to distinguish the course based on user completed or active |
|
| 280 | - add_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 ); |
|
| 279 | + // add extra classes to distinguish the course based on user completed or active |
|
| 280 | + add_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 ); |
|
| 281 | 281 | |
| 282 | - // attach progress meter below course |
|
| 283 | - add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) ); |
|
| 284 | - add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) ); |
|
| 282 | + // attach progress meter below course |
|
| 283 | + add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) ); |
|
| 284 | + add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) ); |
|
| 285 | 285 | |
| 286 | - } |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - /** |
|
| 289 | - * Remove hooks for the shortcode |
|
| 290 | - * |
|
| 291 | - * @since 1.9.0 |
|
| 292 | - */ |
|
| 293 | - public function detach_shortcode_hooks(){ |
|
| 288 | + /** |
|
| 289 | + * Remove hooks for the shortcode |
|
| 290 | + * |
|
| 291 | + * @since 1.9.0 |
|
| 292 | + */ |
|
| 293 | + public function detach_shortcode_hooks(){ |
|
| 294 | 294 | |
| 295 | - //remove all hooks after the output is generated |
|
| 296 | - remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) ); |
|
| 297 | - remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) ); |
|
| 298 | - remove_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 ); |
|
| 299 | - remove_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) ); |
|
| 300 | - } |
|
| 295 | + //remove all hooks after the output is generated |
|
| 296 | + remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) ); |
|
| 297 | + remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) ); |
|
| 298 | + remove_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 ); |
|
| 299 | + remove_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) ); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - /** |
|
| 303 | - * Hooks into sensei_course_content_inside_after |
|
| 304 | - * |
|
| 305 | - * @param $course |
|
| 306 | - */ |
|
| 307 | - public function attach_course_progress( $course_id ){ |
|
| 302 | + /** |
|
| 303 | + * Hooks into sensei_course_content_inside_after |
|
| 304 | + * |
|
| 305 | + * @param $course |
|
| 306 | + */ |
|
| 307 | + public function attach_course_progress( $course_id ){ |
|
| 308 | 308 | |
| 309 | - $percentage = Sensei()->course->get_completion_percentage( $course_id, get_current_user_id() ); |
|
| 310 | - echo Sensei()->course->get_progress_meter( $percentage ); |
|
| 309 | + $percentage = Sensei()->course->get_completion_percentage( $course_id, get_current_user_id() ); |
|
| 310 | + echo Sensei()->course->get_progress_meter( $percentage ); |
|
| 311 | 311 | |
| 312 | - }// attach_course_progress |
|
| 312 | + }// attach_course_progress |
|
| 313 | 313 | |
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * Hooked into sensei_course_content_inside_after |
|
| 317 | - * |
|
| 318 | - * Prints out the course action buttons |
|
| 319 | - * |
|
| 320 | - * @param integer $course_id |
|
| 321 | - */ |
|
| 322 | - public function attach_course_buttons( $course_id ){ |
|
| 315 | + /** |
|
| 316 | + * Hooked into sensei_course_content_inside_after |
|
| 317 | + * |
|
| 318 | + * Prints out the course action buttons |
|
| 319 | + * |
|
| 320 | + * @param integer $course_id |
|
| 321 | + */ |
|
| 322 | + public function attach_course_buttons( $course_id ){ |
|
| 323 | 323 | |
| 324 | - Sensei()->course->the_course_action_buttons( get_post( $course_id ) ); |
|
| 324 | + Sensei()->course->the_course_action_buttons( get_post( $course_id ) ); |
|
| 325 | 325 | |
| 326 | - }// attach_course_buttons |
|
| 326 | + }// attach_course_buttons |
|
| 327 | 327 | |
| 328 | - /** |
|
| 329 | - * Add a the user status class for the given course. |
|
| 330 | - * |
|
| 331 | - * @since 1.9 |
|
| 332 | - * |
|
| 333 | - * @param array $classes |
|
| 334 | - * @param WP_Post $course |
|
| 335 | - * @return array $classes |
|
| 336 | - */ |
|
| 337 | - public function course_status_class_tagging($classes, $course){ |
|
| 328 | + /** |
|
| 329 | + * Add a the user status class for the given course. |
|
| 330 | + * |
|
| 331 | + * @since 1.9 |
|
| 332 | + * |
|
| 333 | + * @param array $classes |
|
| 334 | + * @param WP_Post $course |
|
| 335 | + * @return array $classes |
|
| 336 | + */ |
|
| 337 | + public function course_status_class_tagging($classes, $course){ |
|
| 338 | 338 | |
| 339 | - if ( Sensei_Utils::user_completed_course( $course, get_current_user_id() ) ) { |
|
| 339 | + if ( Sensei_Utils::user_completed_course( $course, get_current_user_id() ) ) { |
|
| 340 | 340 | |
| 341 | - $classes[] = 'user-completed'; |
|
| 341 | + $classes[] = 'user-completed'; |
|
| 342 | 342 | |
| 343 | - } else { |
|
| 343 | + } else { |
|
| 344 | 344 | |
| 345 | - $classes[] = 'user-active'; |
|
| 345 | + $classes[] = 'user-active'; |
|
| 346 | 346 | |
| 347 | - } |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | - return $classes; |
|
| 349 | + return $classes; |
|
| 350 | 350 | |
| 351 | - }// end course_status_class_tagging |
|
| 351 | + }// end course_status_class_tagging |
|
| 352 | 352 | |
| 353 | - /** |
|
| 354 | - * Output the course toggle functionality |
|
| 355 | - */ |
|
| 356 | - public function course_toggle_actions(){ ?> |
|
| 353 | + /** |
|
| 354 | + * Output the course toggle functionality |
|
| 355 | + */ |
|
| 356 | + public function course_toggle_actions(){ ?> |
|
| 357 | 357 | |
| 358 | 358 | <section id="user-course-status-toggle"> |
| 359 | 359 | <a id="sensei-user-courses-active-action" href=""><?php _e('Active Courses'); ?></a> |
@@ -363,12 +363,12 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | <?php } |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * Load the javascript for the toggle functionality |
|
| 368 | - * |
|
| 369 | - * @since 1.9.0 |
|
| 370 | - */ |
|
| 371 | - function print_course_toggle_actions_inline_script() { ?> |
|
| 366 | + /** |
|
| 367 | + * Load the javascript for the toggle functionality |
|
| 368 | + * |
|
| 369 | + * @since 1.9.0 |
|
| 370 | + */ |
|
| 371 | + function print_course_toggle_actions_inline_script() { ?> |
|
| 372 | 372 | |
| 373 | 373 | <script type="text/javascript"> |
| 374 | 374 | var buttonContainer = jQuery('#user-course-status-toggle'); |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | 'order' => $order, |
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | - // Handle search |
|
| 163 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 164 | - $args['search'] = esc_html( $_GET['s'] ); |
|
| 165 | - } |
|
| 162 | + // Handle search |
|
| 163 | + if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 164 | + $args['search'] = esc_html( $_GET['s'] ); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | switch ( $this->type ) { |
| 168 | 168 | case 'courses': |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | 221 | |
| 222 | - // Handle search |
|
| 223 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 224 | - $args['search'] = esc_html( $_GET['s'] ); |
|
| 225 | - } |
|
| 222 | + // Handle search |
|
| 223 | + if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 224 | + $args['search'] = esc_html( $_GET['s'] ); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | |
| 228 | 228 | // Start the csv with the column headings |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * Generates the overall array for a single item in the display |
| 261 | 261 | * @since 1.7.0 |
| 262 | 262 | * @param object $item The current item |
| 263 | - * @return array $column_data; |
|
| 263 | + * @return array $column_data; |
|
| 264 | 264 | */ |
| 265 | 265 | protected function get_row_data( $item ) { |
| 266 | 266 | |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | $percent_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_percentage', $grade_args, $item ), true ) ); |
| 297 | 297 | $percent_total = Sensei_Grading::get_course_users_grades_sum( $item->ID ); |
| 298 | 298 | |
| 299 | - $course_average_percent = 0; |
|
| 300 | - if( $percent_count > 0 && $percent_total > 0 ){ |
|
| 301 | - $course_average_percent = abs( round( doubleval( $percent_total / $percent_count ), 2 ) ); |
|
| 302 | - } |
|
| 299 | + $course_average_percent = 0; |
|
| 300 | + if( $percent_count > 0 && $percent_total > 0 ){ |
|
| 301 | + $course_average_percent = abs( round( doubleval( $percent_total / $percent_count ), 2 ) ); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | // Output course data |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | $grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true )); |
| 356 | 356 | $grade_total = Sensei_Grading::get_lessons_users_grades_sum( $item->ID ); |
| 357 | 357 | |
| 358 | - $lesson_average_grade = 0; |
|
| 359 | - if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 360 | - $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 361 | - } |
|
| 358 | + $lesson_average_grade = 0; |
|
| 359 | + if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 360 | + $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - } |
|
| 363 | + } |
|
| 364 | 364 | // Output lesson data |
| 365 | 365 | if ( $this->csv_output ) { |
| 366 | 366 | $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
@@ -417,15 +417,15 @@ discard block |
||
| 417 | 417 | $grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_lesson_grades', $grade_args, $item ), true )); |
| 418 | 418 | $grade_total = Sensei_Grading::get_user_graded_lessons_sum( $item->ID ); |
| 419 | 419 | |
| 420 | - $user_average_grade = 0; |
|
| 421 | - if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 422 | - $user_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 423 | - } |
|
| 420 | + $user_average_grade = 0; |
|
| 421 | + if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 422 | + $user_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | 425 | // Output the users data |
| 426 | 426 | if ( $this->csv_output ) { |
| 427 | - $user_name = Sensei_Learner::get_full_name( $item->ID ); |
|
| 428 | - } |
|
| 427 | + $user_name = Sensei_Learner::get_full_name( $item->ID ); |
|
| 428 | + } |
|
| 429 | 429 | else { |
| 430 | 430 | $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->ID ), admin_url( 'admin.php' ) ); |
| 431 | 431 | $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $item->display_name . '</a></strong>'; |
@@ -519,17 +519,17 @@ discard block |
||
| 519 | 519 | // This stops the full meta data of each user being loaded |
| 520 | 520 | $args['fields'] = array( 'ID', 'user_login', 'user_email', 'user_registered', 'display_name' ); |
| 521 | 521 | |
| 522 | - /** |
|
| 523 | - * Filter the WP_User_Query arguments |
|
| 524 | - * @since 1.6.0 |
|
| 525 | - * @param $args |
|
| 526 | - */ |
|
| 527 | - $args = apply_filters( 'sensei_analysis_overview_filter_users', $args ); |
|
| 522 | + /** |
|
| 523 | + * Filter the WP_User_Query arguments |
|
| 524 | + * @since 1.6.0 |
|
| 525 | + * @param $args |
|
| 526 | + */ |
|
| 527 | + $args = apply_filters( 'sensei_analysis_overview_filter_users', $args ); |
|
| 528 | 528 | $wp_user_search = new WP_User_Query( $args ); |
| 529 | - $learners = $wp_user_search->get_results(); |
|
| 529 | + $learners = $wp_user_search->get_results(); |
|
| 530 | 530 | $this->total_items = $wp_user_search->get_total(); |
| 531 | 531 | |
| 532 | - return $learners; |
|
| 532 | + return $learners; |
|
| 533 | 533 | |
| 534 | 534 | } // End get_learners() |
| 535 | 535 | |
@@ -546,15 +546,15 @@ discard block |
||
| 546 | 546 | $total_courses = Sensei()->course->course_count( array('publish', 'private') ); |
| 547 | 547 | $total_lessons = Sensei()->lesson->lesson_count( array('publish', 'private') ); |
| 548 | 548 | |
| 549 | - /** |
|
| 550 | - * filter the analysis tot grades query args |
|
| 551 | - */ |
|
| 549 | + /** |
|
| 550 | + * filter the analysis tot grades query args |
|
| 551 | + */ |
|
| 552 | 552 | $grade_args = apply_filters( 'sensei_analysis_total_quiz_grades', array( |
| 553 | 553 | 'type' => 'sensei_lesson_status', |
| 554 | 554 | 'status' => 'any', |
| 555 | 555 | |
| 556 | - 'meta_key' => 'grade' |
|
| 557 | - )); |
|
| 556 | + 'meta_key' => 'grade' |
|
| 557 | + )); |
|
| 558 | 558 | |
| 559 | 559 | $total_grade_count = Sensei_Grading::get_graded_lessons_count(); |
| 560 | 560 | $total_grade_total = Sensei_Grading::get_graded_lessons_sum(); |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * The Template for displaying course archives, including the course page template. |
|
| 4 | - * |
|
| 5 | - * Override this template by copying it to yourtheme/sensei/archive-course.php |
|
| 6 | - * |
|
| 7 | - * @author Automattic |
|
| 8 | - * @package Sensei |
|
| 9 | - * @category Templates |
|
| 10 | - * @version 1.9.0 |
|
| 11 | - */ |
|
| 3 | + * The Template for displaying course archives, including the course page template. |
|
| 4 | + * |
|
| 5 | + * Override this template by copying it to yourtheme/sensei/archive-course.php |
|
| 6 | + * |
|
| 7 | + * @author Automattic |
|
| 8 | + * @package Sensei |
|
| 9 | + * @category Templates |
|
| 10 | + * @version 1.9.0 |
|
| 11 | + */ |
|
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <?php get_sensei_header(); ?> |
| 15 | 15 | |
| 16 | 16 | <?php |
| 17 | 17 | /** |
| 18 | - * This hook fire inside learner-profile.php before the content |
|
| 19 | - * |
|
| 20 | - * @since 1.9.0 |
|
| 21 | - * |
|
| 22 | - * @hooked Sensei_Course_Results::deprecate_sensei_course_results_content_hook() - 20 |
|
| 23 | - */ |
|
| 18 | + * This hook fire inside learner-profile.php before the content |
|
| 19 | + * |
|
| 20 | + * @since 1.9.0 |
|
| 21 | + * |
|
| 22 | + * @hooked Sensei_Course_Results::deprecate_sensei_course_results_content_hook() - 20 |
|
| 23 | + */ |
|
| 24 | 24 | do_action( 'sensei_course_results_content_before' ); |
| 25 | 25 | ?> |
| 26 | 26 | |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | <section class="entry fix"> |
| 35 | 35 | |
| 36 | 36 | <?php |
| 37 | - /** |
|
| 38 | - * This hook fire inside learner-profile.php inside directly before the content |
|
| 39 | - * |
|
| 40 | - * @since 1.9.0 |
|
| 41 | - * |
|
| 42 | - * @param integer $course_id |
|
| 43 | - * |
|
| 44 | - */ |
|
| 45 | - do_action( 'sensei_course_results_content_inside_before', $course->ID ); |
|
| 46 | - ?> |
|
| 37 | + /** |
|
| 38 | + * This hook fire inside learner-profile.php inside directly before the content |
|
| 39 | + * |
|
| 40 | + * @since 1.9.0 |
|
| 41 | + * |
|
| 42 | + * @param integer $course_id |
|
| 43 | + * |
|
| 44 | + */ |
|
| 45 | + do_action( 'sensei_course_results_content_inside_before', $course->ID ); |
|
| 46 | + ?> |
|
| 47 | 47 | |
| 48 | 48 | <header> |
| 49 | 49 | |
@@ -56,44 +56,44 @@ discard block |
||
| 56 | 56 | <?php if ( is_user_logged_in() ):?> |
| 57 | 57 | |
| 58 | 58 | <?php |
| 59 | - /** |
|
| 60 | - * This hook fire inside learner-profile.php inside directly before the content |
|
| 61 | - * |
|
| 62 | - * @since 1.9.0 |
|
| 63 | - * |
|
| 64 | - * @param integer $course_id |
|
| 65 | - * |
|
| 66 | - * @hooked Sensei_Course_Results::course_info() - 20 |
|
| 67 | - */ |
|
| 68 | - do_action( 'sensei_course_results_content_inside_before_lessons', $course->ID ); |
|
| 69 | - ?> |
|
| 59 | + /** |
|
| 60 | + * This hook fire inside learner-profile.php inside directly before the content |
|
| 61 | + * |
|
| 62 | + * @since 1.9.0 |
|
| 63 | + * |
|
| 64 | + * @param integer $course_id |
|
| 65 | + * |
|
| 66 | + * @hooked Sensei_Course_Results::course_info() - 20 |
|
| 67 | + */ |
|
| 68 | + do_action( 'sensei_course_results_content_inside_before_lessons', $course->ID ); |
|
| 69 | + ?> |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | <section class="course-results-lessons"> |
| 73 | 73 | <?php |
| 74 | - $started_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 75 | - if( $started_course ) { |
|
| 74 | + $started_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 75 | + if( $started_course ) { |
|
| 76 | 76 | |
| 77 | - sensei_the_course_results_lessons(); |
|
| 77 | + sensei_the_course_results_lessons(); |
|
| 78 | 78 | |
| 79 | - } |
|
| 80 | - ?> |
|
| 79 | + } |
|
| 80 | + ?> |
|
| 81 | 81 | </section> |
| 82 | 82 | |
| 83 | 83 | <?php endif; ?> |
| 84 | 84 | |
| 85 | 85 | <?php |
| 86 | - /** |
|
| 87 | - * This hook fire inside learner-profile.php inside directly after the content |
|
| 88 | - * |
|
| 89 | - * @since 1.9.0 |
|
| 90 | - * |
|
| 91 | - * @param integer $course_id |
|
| 92 | - * |
|
| 93 | - * @hooked Sensei()->course_results->course_info - 20 |
|
| 94 | - */ |
|
| 95 | - do_action( 'sensei_course_results_content_inside_after', $course->ID ); |
|
| 96 | - ?> |
|
| 86 | + /** |
|
| 87 | + * This hook fire inside learner-profile.php inside directly after the content |
|
| 88 | + * |
|
| 89 | + * @since 1.9.0 |
|
| 90 | + * |
|
| 91 | + * @param integer $course_id |
|
| 92 | + * |
|
| 93 | + * @hooked Sensei()->course_results->course_info - 20 |
|
| 94 | + */ |
|
| 95 | + do_action( 'sensei_course_results_content_inside_after', $course->ID ); |
|
| 96 | + ?> |
|
| 97 | 97 | |
| 98 | 98 | </section> |
| 99 | 99 | |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | <?php |
| 103 | 103 | /** |
| 104 | - * This hook fire inside course-results.php before the content |
|
| 105 | - * |
|
| 106 | - * @since 1.9.0 |
|
| 107 | - * |
|
| 108 | - */ |
|
| 104 | + * This hook fire inside course-results.php before the content |
|
| 105 | + * |
|
| 106 | + * @since 1.9.0 |
|
| 107 | + * |
|
| 108 | + */ |
|
| 109 | 109 | do_action( 'sensei_course_results_content_after' ); |
| 110 | 110 | ?> |
| 111 | 111 | |
@@ -1,42 +1,42 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Class Sensei__S |
|
| 4 | - * |
|
| 5 | - * Responsible for wrapping for the underscores theme |
|
| 6 | - * with the correct markup |
|
| 7 | - * |
|
| 8 | - * |
|
| 9 | - * @package Views |
|
| 10 | - * @subpackage Theme-Integration |
|
| 11 | - * @author Automattic |
|
| 12 | - * |
|
| 13 | - * @since 1.9.0 |
|
| 3 | + * Class Sensei__S |
|
| 4 | + * |
|
| 5 | + * Responsible for wrapping for the underscores theme |
|
| 6 | + * with the correct markup |
|
| 7 | + * |
|
| 8 | + * |
|
| 9 | + * @package Views |
|
| 10 | + * @subpackage Theme-Integration |
|
| 11 | + * @author Automattic |
|
| 12 | + * |
|
| 13 | + * @since 1.9.0 |
|
| 14 | 14 | */ |
| 15 | 15 | Class Sensei__S { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Output opening wrappers |
|
| 19 | - * @since 1.9.0 |
|
| 20 | - */ |
|
| 21 | - public function wrapper_start(){ ?> |
|
| 17 | + /** |
|
| 18 | + * Output opening wrappers |
|
| 19 | + * @since 1.9.0 |
|
| 20 | + */ |
|
| 21 | + public function wrapper_start(){ ?> |
|
| 22 | 22 | <div id="primary" class="content-area"> |
| 23 | 23 | <main id="main" class="site-main" role="main"> |
| 24 | 24 | |
| 25 | 25 | <?php } |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Output closing wrappers |
|
| 29 | - * |
|
| 30 | - * @since 1.9.0 |
|
| 31 | - */ |
|
| 32 | - public function wrapper_end(){ ?> |
|
| 27 | + /** |
|
| 28 | + * Output closing wrappers |
|
| 29 | + * |
|
| 30 | + * @since 1.9.0 |
|
| 31 | + */ |
|
| 32 | + public function wrapper_end(){ ?> |
|
| 33 | 33 | |
| 34 | 34 | </main> <!-- main-site --> |
| 35 | 35 | </div> <!-- content-area --> |
| 36 | 36 | |
| 37 | 37 | <?php |
| 38 | 38 | |
| 39 | - get_sidebar(); |
|
| 39 | + get_sidebar(); |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | } // end class |
@@ -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' ) ); |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $screen = get_current_screen(); |
| 130 | 130 | |
| 131 | - if( empty( $screen ) ){ |
|
| 132 | - return; |
|
| 133 | - } |
|
| 131 | + if( empty( $screen ) ){ |
|
| 132 | + return; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | if ( $screen->base == 'post' && $post_type == 'course' ) { |
| 136 | 136 | |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; |
| 142 | 142 | $parent_file = 'edit.php?post_type=course'; |
| 143 | 143 | |
| 144 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
| 144 | + } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
| 145 | 145 | |
| 146 | - $submenu_file = 'edit-tags.php?taxonomy=module'; |
|
| 147 | - $parent_file = 'edit.php?post_type=course'; |
|
| 146 | + $submenu_file = 'edit-tags.php?taxonomy=module'; |
|
| 147 | + $parent_file = 'edit.php?post_type=course'; |
|
| 148 | 148 | |
| 149 | 149 | } elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { |
| 150 | 150 | |
| 151 | - $submenu_file = 'edit.php?post_type=sensei_message'; |
|
| 151 | + $submenu_file = 'edit.php?post_type=sensei_message'; |
|
| 152 | 152 | $parent_file = 'sensei'; |
| 153 | 153 | |
| 154 | 154 | } |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | function install_pages_output() { |
| 178 | 178 | |
| 179 | - if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
| 179 | + if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
| 180 | 180 | |
| 181 | - ?> |
|
| 181 | + ?> |
|
| 182 | 182 | <div id="message" class="updated sensei-message sensei-connect"> |
| 183 | 183 | <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> |
| 184 | 184 | <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a> |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | </div> |
| 187 | 187 | <?php |
| 188 | 188 | |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | } // End install_pages_output() |
| 192 | 192 | |
@@ -205,25 +205,25 @@ discard block |
||
| 205 | 205 | function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) { |
| 206 | 206 | global $wpdb; |
| 207 | 207 | |
| 208 | - $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); |
|
| 208 | + $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); |
|
| 209 | 209 | if ( $page_id ) : |
| 210 | 210 | return $page_id; |
| 211 | 211 | endif; |
| 212 | 212 | |
| 213 | 213 | $page_data = array( |
| 214 | - 'post_status' => 'publish', |
|
| 215 | - 'post_type' => 'page', |
|
| 216 | - 'post_author' => 1, |
|
| 217 | - 'post_name' => $slug, |
|
| 218 | - 'post_title' => $page_title, |
|
| 219 | - 'post_content' => $page_content, |
|
| 220 | - 'post_parent' => $post_parent, |
|
| 221 | - 'comment_status' => 'closed' |
|
| 222 | - ); |
|
| 214 | + 'post_status' => 'publish', |
|
| 215 | + 'post_type' => 'page', |
|
| 216 | + 'post_author' => 1, |
|
| 217 | + 'post_name' => $slug, |
|
| 218 | + 'post_title' => $page_title, |
|
| 219 | + 'post_content' => $page_content, |
|
| 220 | + 'post_parent' => $post_parent, |
|
| 221 | + 'comment_status' => 'closed' |
|
| 222 | + ); |
|
| 223 | 223 | |
| 224 | - $page_id = wp_insert_post( $page_data ); |
|
| 224 | + $page_id = wp_insert_post( $page_data ); |
|
| 225 | 225 | |
| 226 | - return $page_id; |
|
| 226 | + return $page_id; |
|
| 227 | 227 | |
| 228 | 228 | } // End create_page() |
| 229 | 229 | |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | function create_pages() { |
| 238 | 238 | |
| 239 | 239 | // Courses page |
| 240 | - $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), __('Courses', 'woothemes-sensei'), '' ); |
|
| 241 | - Sensei()->settings->set( 'course_page', $new_course_page_id ); |
|
| 240 | + $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), __('Courses', 'woothemes-sensei'), '' ); |
|
| 241 | + Sensei()->settings->set( 'course_page', $new_course_page_id ); |
|
| 242 | 242 | |
| 243 | - // User Dashboard page |
|
| 244 | - $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); |
|
| 245 | - Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); |
|
| 243 | + // User Dashboard page |
|
| 244 | + $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); |
|
| 245 | + Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); |
|
| 246 | 246 | |
| 247 | 247 | } // End create_pages() |
| 248 | 248 | |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); |
| 264 | 264 | wp_enqueue_style( 'woothemes-sensei-global' ); |
| 265 | 265 | |
| 266 | - // Select 2 styles |
|
| 267 | - wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
| 266 | + // Select 2 styles |
|
| 267 | + wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
| 268 | 268 | |
| 269 | 269 | // Test for Write Panel Pages |
| 270 | 270 | if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) { |
@@ -277,32 +277,32 @@ discard block |
||
| 277 | 277 | } // End admin_styles_global() |
| 278 | 278 | |
| 279 | 279 | |
| 280 | - /** |
|
| 281 | - * Globally register all scripts needed in admin. |
|
| 282 | - * |
|
| 283 | - * The script users should enqueue the script when needed. |
|
| 284 | - * |
|
| 285 | - * @since 1.8.2 |
|
| 286 | - * @access public |
|
| 287 | - */ |
|
| 288 | - public function register_scripts( $hook ){ |
|
| 280 | + /** |
|
| 281 | + * Globally register all scripts needed in admin. |
|
| 282 | + * |
|
| 283 | + * The script users should enqueue the script when needed. |
|
| 284 | + * |
|
| 285 | + * @since 1.8.2 |
|
| 286 | + * @access public |
|
| 287 | + */ |
|
| 288 | + public function register_scripts( $hook ){ |
|
| 289 | 289 | |
| 290 | - $screen = get_current_screen(); |
|
| 290 | + $screen = get_current_screen(); |
|
| 291 | 291 | |
| 292 | - // Allow developers to load non-minified versions of scripts |
|
| 293 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 292 | + // Allow developers to load non-minified versions of scripts |
|
| 293 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 294 | 294 | |
| 295 | - // Select2 script used to enhance all select boxes |
|
| 296 | - wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
| 295 | + // Select2 script used to enhance all select boxes |
|
| 296 | + wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
| 297 | 297 | |
| 298 | - // load edit module scripts |
|
| 299 | - if( 'edit-module' == $screen->id ){ |
|
| 298 | + // load edit module scripts |
|
| 299 | + if( 'edit-module' == $screen->id ){ |
|
| 300 | 300 | |
| 301 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
| 301 | + wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
| 302 | 302 | |
| 303 | - } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | 314 | function admin_install_notice() { |
| 315 | - ?> |
|
| 315 | + ?> |
|
| 316 | 316 | <div id="message" class="updated sensei-message sensei-connect"> |
| 317 | 317 | |
| 318 | 318 | <p> |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @return void |
| 348 | 348 | */ |
| 349 | 349 | function admin_installed_notice() { |
| 350 | - ?> |
|
| 350 | + ?> |
|
| 351 | 351 | <div id="message" class="updated sensei-message sensei-connect"> |
| 352 | 352 | |
| 353 | 353 | <p> |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | </div> |
| 376 | 376 | <?php |
| 377 | 377 | |
| 378 | - // Set installed option |
|
| 379 | - update_option('sensei_installed', 0); |
|
| 378 | + // Set installed option |
|
| 379 | + update_option('sensei_installed', 0); |
|
| 380 | 380 | } // End admin_installed_notice() |
| 381 | 381 | |
| 382 | 382 | |
@@ -408,21 +408,21 @@ discard block |
||
| 408 | 408 | function admin_notices_styles() { |
| 409 | 409 | |
| 410 | 410 | // Installed notices |
| 411 | - if ( 1 == get_option( 'sensei_installed' ) ) { |
|
| 411 | + if ( 1 == get_option( 'sensei_installed' ) ) { |
|
| 412 | 412 | |
| 413 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
| 413 | + wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
| 414 | 414 | |
| 415 | - if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) { |
|
| 416 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
| 417 | - } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
| 418 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
| 419 | - } // End If Statement |
|
| 415 | + if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) { |
|
| 416 | + add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
| 417 | + } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
| 418 | + add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
| 419 | + } // End If Statement |
|
| 420 | 420 | |
| 421 | - } // End If Statement |
|
| 421 | + } // End If Statement |
|
| 422 | 422 | |
| 423 | - if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
| 424 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
| 425 | - } |
|
| 423 | + if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
| 424 | + add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | } // End admin_notices_styles() |
| 428 | 428 | |
@@ -538,30 +538,30 @@ discard block |
||
| 538 | 538 | */ |
| 539 | 539 | private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { |
| 540 | 540 | |
| 541 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
| 542 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
| 541 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
| 542 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
| 543 | 543 | |
| 544 | - // duplicate the generic wp post information |
|
| 544 | + // duplicate the generic wp post information |
|
| 545 | 545 | $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); |
| 546 | 546 | |
| 547 | 547 | //update the new lesson data |
| 548 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
| 548 | + add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
| 549 | 549 | |
| 550 | 550 | //update the new quiz data |
| 551 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
| 552 | - wp_update_post( |
|
| 553 | - array( |
|
| 554 | - 'ID' => $new_quiz->ID, |
|
| 555 | - 'post_parent' => $new_lesson_id |
|
| 556 | - ) |
|
| 557 | - ); |
|
| 551 | + add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
| 552 | + wp_update_post( |
|
| 553 | + array( |
|
| 554 | + 'ID' => $new_quiz->ID, |
|
| 555 | + 'post_parent' => $new_lesson_id |
|
| 556 | + ) |
|
| 557 | + ); |
|
| 558 | 558 | |
| 559 | 559 | foreach( $old_quiz_questions as $question ) { |
| 560 | 560 | |
| 561 | 561 | // copy the question order over to the new quiz |
| 562 | 562 | $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); |
| 563 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
| 564 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
| 563 | + $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
| 564 | + add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
| 565 | 565 | |
| 566 | 566 | // Add question to quiz |
| 567 | 567 | add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); |
@@ -883,21 +883,21 @@ discard block |
||
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case 'checkbox': |
| 886 | - //backwards compatibility |
|
| 887 | - if( empty( $data ) || 'on' == $data ){ |
|
| 888 | - $checked_value = 'on'; |
|
| 889 | - }elseif( 'yes' == $data ) { |
|
| 886 | + //backwards compatibility |
|
| 887 | + if( empty( $data ) || 'on' == $data ){ |
|
| 888 | + $checked_value = 'on'; |
|
| 889 | + }elseif( 'yes' == $data ) { |
|
| 890 | 890 | |
| 891 | - $checked_value = 'yes'; |
|
| 891 | + $checked_value = 'yes'; |
|
| 892 | 892 | |
| 893 | - }elseif( 'auto' == $data ) { |
|
| 893 | + }elseif( 'auto' == $data ) { |
|
| 894 | 894 | |
| 895 | - $checked_value = 'auto'; |
|
| 895 | + $checked_value = 'auto'; |
|
| 896 | 896 | |
| 897 | - } else { |
|
| 898 | - $checked_value = 1; |
|
| 899 | - $data = intval( $data ); |
|
| 900 | - } |
|
| 897 | + } else { |
|
| 898 | + $checked_value = 1; |
|
| 899 | + $data = intval( $data ); |
|
| 900 | + } |
|
| 901 | 901 | $checked = checked( $checked_value, $data, false ); |
| 902 | 902 | $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; |
| 903 | 903 | break; |
@@ -1001,26 +1001,26 @@ discard block |
||
| 1001 | 1001 | |
| 1002 | 1002 | if( 0 < count( $courses ) ) { |
| 1003 | 1003 | |
| 1004 | - // order the courses as set by the users |
|
| 1005 | - $all_course_ids = array(); |
|
| 1006 | - foreach( $courses as $course ){ |
|
| 1004 | + // order the courses as set by the users |
|
| 1005 | + $all_course_ids = array(); |
|
| 1006 | + foreach( $courses as $course ){ |
|
| 1007 | 1007 | |
| 1008 | - $all_course_ids[] = (string)$course->ID; |
|
| 1008 | + $all_course_ids[] = (string)$course->ID; |
|
| 1009 | 1009 | |
| 1010 | - } |
|
| 1011 | - $order_string = $this->get_course_order(); |
|
| 1010 | + } |
|
| 1011 | + $order_string = $this->get_course_order(); |
|
| 1012 | 1012 | |
| 1013 | - if( !empty( $order_string ) ){ |
|
| 1014 | - $ordered_course_ids = explode(',' , $order_string ); |
|
| 1015 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
| 1016 | - } |
|
| 1013 | + if( !empty( $order_string ) ){ |
|
| 1014 | + $ordered_course_ids = explode(',' , $order_string ); |
|
| 1015 | + $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
| 1016 | + } |
|
| 1017 | 1017 | |
| 1018 | 1018 | |
| 1019 | 1019 | $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
| 1020 | 1020 | $html .= '<ul class="sortable-course-list">' . "\n"; |
| 1021 | 1021 | $count = 0; |
| 1022 | 1022 | foreach ( $all_course_ids as $course_id ) { |
| 1023 | - $course = get_post( $course_id ); |
|
| 1023 | + $course = get_post( $course_id ); |
|
| 1024 | 1024 | $count++; |
| 1025 | 1025 | $class = 'course'; |
| 1026 | 1026 | if ( $count == 1 ) { $class .= ' first'; } |
@@ -1135,73 +1135,73 @@ discard block |
||
| 1135 | 1135 | |
| 1136 | 1136 | $displayed_lessons = array(); |
| 1137 | 1137 | |
| 1138 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1139 | - |
|
| 1140 | - foreach( $modules as $module ) { |
|
| 1141 | - |
|
| 1142 | - $args = array( |
|
| 1143 | - 'post_type' => 'lesson', |
|
| 1144 | - 'post_status' => 'publish', |
|
| 1145 | - 'posts_per_page' => -1, |
|
| 1146 | - 'meta_query' => array( |
|
| 1147 | - array( |
|
| 1148 | - 'key' => '_lesson_course', |
|
| 1149 | - 'value' => intval( $course_id ), |
|
| 1150 | - 'compare' => '=' |
|
| 1151 | - ) |
|
| 1152 | - ), |
|
| 1153 | - 'tax_query' => array( |
|
| 1154 | - array( |
|
| 1155 | - 'taxonomy' => Sensei()->modules->taxonomy, |
|
| 1156 | - 'field' => 'id', |
|
| 1157 | - 'terms' => intval( $module->term_id ) |
|
| 1158 | - ) |
|
| 1159 | - ), |
|
| 1160 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
| 1161 | - 'orderby' => 'meta_value_num date', |
|
| 1162 | - 'order' => 'ASC', |
|
| 1163 | - 'suppress_filters' => 0 |
|
| 1164 | - ); |
|
| 1165 | - |
|
| 1166 | - $lessons = get_posts( $args ); |
|
| 1167 | - |
|
| 1168 | - if( count( $lessons ) > 0 ) { |
|
| 1169 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
| 1170 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
| 1171 | - |
|
| 1172 | - $count = 0; |
|
| 1173 | - foreach( $lessons as $lesson ) { |
|
| 1174 | - $count++; |
|
| 1175 | - $class = 'lesson'; |
|
| 1176 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1177 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
| 1178 | - if ( $count % 2 != 0 ) { |
|
| 1179 | - $class .= ' alternate'; |
|
| 1180 | - } |
|
| 1181 | - |
|
| 1182 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
| 1183 | - |
|
| 1184 | - $displayed_lessons[] = $lesson->ID; |
|
| 1185 | - } |
|
| 1186 | - |
|
| 1187 | - $html .= '</ul>' . "\n"; |
|
| 1188 | - |
|
| 1189 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
| 1190 | - } |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - |
|
| 1194 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
| 1138 | + $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1139 | + |
|
| 1140 | + foreach( $modules as $module ) { |
|
| 1141 | + |
|
| 1142 | + $args = array( |
|
| 1143 | + 'post_type' => 'lesson', |
|
| 1144 | + 'post_status' => 'publish', |
|
| 1145 | + 'posts_per_page' => -1, |
|
| 1146 | + 'meta_query' => array( |
|
| 1147 | + array( |
|
| 1148 | + 'key' => '_lesson_course', |
|
| 1149 | + 'value' => intval( $course_id ), |
|
| 1150 | + 'compare' => '=' |
|
| 1151 | + ) |
|
| 1152 | + ), |
|
| 1153 | + 'tax_query' => array( |
|
| 1154 | + array( |
|
| 1155 | + 'taxonomy' => Sensei()->modules->taxonomy, |
|
| 1156 | + 'field' => 'id', |
|
| 1157 | + 'terms' => intval( $module->term_id ) |
|
| 1158 | + ) |
|
| 1159 | + ), |
|
| 1160 | + 'meta_key' => '_order_module_' . $module->term_id, |
|
| 1161 | + 'orderby' => 'meta_value_num date', |
|
| 1162 | + 'order' => 'ASC', |
|
| 1163 | + 'suppress_filters' => 0 |
|
| 1164 | + ); |
|
| 1165 | + |
|
| 1166 | + $lessons = get_posts( $args ); |
|
| 1167 | + |
|
| 1168 | + if( count( $lessons ) > 0 ) { |
|
| 1169 | + $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
| 1170 | + $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
| 1171 | + |
|
| 1172 | + $count = 0; |
|
| 1173 | + foreach( $lessons as $lesson ) { |
|
| 1174 | + $count++; |
|
| 1175 | + $class = 'lesson'; |
|
| 1176 | + if ( $count == 1 ) { $class .= ' first'; } |
|
| 1177 | + if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
| 1178 | + if ( $count % 2 != 0 ) { |
|
| 1179 | + $class .= ' alternate'; |
|
| 1180 | + } |
|
| 1181 | + |
|
| 1182 | + $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
| 1183 | + |
|
| 1184 | + $displayed_lessons[] = $lesson->ID; |
|
| 1185 | + } |
|
| 1186 | + |
|
| 1187 | + $html .= '</ul>' . "\n"; |
|
| 1188 | + |
|
| 1189 | + $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
| 1190 | + } |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + |
|
| 1194 | + $lessons = Sensei()->course->course_lessons( $course_id ); |
|
| 1195 | 1195 | |
| 1196 | 1196 | if( 0 < count( $lessons ) ) { |
| 1197 | 1197 | |
| 1198 | - //get module term ids, will be used to exclude lessons |
|
| 1199 | - $module_items_ids = array(); |
|
| 1200 | - if( ! empty( $modules ) ) { |
|
| 1201 | - foreach ($modules as $module) { |
|
| 1202 | - $module_items_ids[] = $module->term_id; |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1198 | + //get module term ids, will be used to exclude lessons |
|
| 1199 | + $module_items_ids = array(); |
|
| 1200 | + if( ! empty( $modules ) ) { |
|
| 1201 | + foreach ($modules as $module) { |
|
| 1202 | + $module_items_ids[] = $module->term_id; |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | 1205 | |
| 1206 | 1206 | if( 0 < count( $displayed_lessons ) ) { |
| 1207 | 1207 | $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; |
@@ -1211,13 +1211,13 @@ discard block |
||
| 1211 | 1211 | $count = 0; |
| 1212 | 1212 | foreach ( $lessons as $lesson ) { |
| 1213 | 1213 | |
| 1214 | - // if lesson belongs to one fo the course modules then exclude it here |
|
| 1215 | - // as it is listed above |
|
| 1216 | - if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
| 1214 | + // if lesson belongs to one fo the course modules then exclude it here |
|
| 1215 | + // as it is listed above |
|
| 1216 | + if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
| 1217 | 1217 | |
| 1218 | - continue; |
|
| 1218 | + continue; |
|
| 1219 | 1219 | |
| 1220 | - } |
|
| 1220 | + } |
|
| 1221 | 1221 | |
| 1222 | 1222 | $count++; |
| 1223 | 1223 | $class = 'lesson'; |
@@ -1261,28 +1261,28 @@ discard block |
||
| 1261 | 1261 | |
| 1262 | 1262 | if( $course_id ) { |
| 1263 | 1263 | |
| 1264 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1264 | + $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1265 | 1265 | |
| 1266 | - foreach( $modules as $module ) { |
|
| 1266 | + foreach( $modules as $module ) { |
|
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | - if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) |
|
| 1270 | - && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { |
|
| 1269 | + if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) |
|
| 1270 | + && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { |
|
| 1271 | 1271 | |
| 1272 | - $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); |
|
| 1273 | - $i = 1; |
|
| 1274 | - foreach( $order as $lesson_id ) { |
|
| 1272 | + $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); |
|
| 1273 | + $i = 1; |
|
| 1274 | + foreach( $order as $lesson_id ) { |
|
| 1275 | 1275 | |
| 1276 | - if( $lesson_id ) { |
|
| 1277 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
| 1278 | - ++$i; |
|
| 1279 | - } |
|
| 1276 | + if( $lesson_id ) { |
|
| 1277 | + update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
| 1278 | + ++$i; |
|
| 1279 | + } |
|
| 1280 | 1280 | |
| 1281 | - }// end for each order |
|
| 1281 | + }// end for each order |
|
| 1282 | 1282 | |
| 1283 | - }// end if |
|
| 1283 | + }// end if |
|
| 1284 | 1284 | |
| 1285 | - } // end for each modules |
|
| 1285 | + } // end for each modules |
|
| 1286 | 1286 | |
| 1287 | 1287 | |
| 1288 | 1288 | if( $order_string ) { |
@@ -1365,47 +1365,47 @@ discard block |
||
| 1365 | 1365 | |
| 1366 | 1366 | /** |
| 1367 | 1367 | * Adding admin notice if the current |
| 1368 | - * installed theme is not compatible |
|
| 1369 | - * |
|
| 1368 | + * installed theme is not compatible |
|
| 1369 | + * |
|
| 1370 | 1370 | * @return void |
| 1371 | 1371 | */ |
| 1372 | 1372 | public function theme_compatibility_notices() { |
| 1373 | 1373 | |
| 1374 | - if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
| 1375 | - switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
| 1374 | + if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
| 1375 | + switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
| 1376 | 1376 | case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; |
| 1377 | 1377 | case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; |
| 1378 | 1378 | } |
| 1379 | - } |
|
| 1379 | + } |
|
| 1380 | 1380 | |
| 1381 | - // white list templates that are already support by default and do not show notice for them |
|
| 1382 | - $template = get_option( 'template' ); |
|
| 1381 | + // white list templates that are already support by default and do not show notice for them |
|
| 1382 | + $template = get_option( 'template' ); |
|
| 1383 | 1383 | |
| 1384 | - $white_list = array( 'twentyeleven', |
|
| 1385 | - 'twentytwelve', |
|
| 1386 | - 'twentyfourteen', |
|
| 1387 | - 'twentyfifteen', |
|
| 1388 | - 'twentysixteen', |
|
| 1389 | - 'storefront', |
|
| 1390 | - ); |
|
| 1384 | + $white_list = array( 'twentyeleven', |
|
| 1385 | + 'twentytwelve', |
|
| 1386 | + 'twentyfourteen', |
|
| 1387 | + 'twentyfifteen', |
|
| 1388 | + 'twentysixteen', |
|
| 1389 | + 'storefront', |
|
| 1390 | + ); |
|
| 1391 | 1391 | |
| 1392 | - if ( in_array( $template, $white_list ) ) { |
|
| 1392 | + if ( in_array( $template, $white_list ) ) { |
|
| 1393 | 1393 | |
| 1394 | - return; |
|
| 1394 | + return; |
|
| 1395 | 1395 | |
| 1396 | - } |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | - // don't show the notice if the user chose to hide it |
|
| 1399 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
| 1400 | - if( $hide_theme_check_notice ) { |
|
| 1398 | + // don't show the notice if the user chose to hide it |
|
| 1399 | + $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
| 1400 | + if( $hide_theme_check_notice ) { |
|
| 1401 | 1401 | |
| 1402 | - return; |
|
| 1402 | + return; |
|
| 1403 | 1403 | |
| 1404 | - } |
|
| 1404 | + } |
|
| 1405 | 1405 | |
| 1406 | - // show the notice for themes not supporting sensei |
|
| 1407 | - if ( ! current_theme_supports( 'sensei' ) ) { |
|
| 1408 | - ?> |
|
| 1406 | + // show the notice for themes not supporting sensei |
|
| 1407 | + if ( ! current_theme_supports( 'sensei' ) ) { |
|
| 1408 | + ?> |
|
| 1409 | 1409 | |
| 1410 | 1410 | <div id="message" class="error sensei-message sensei-connect"> |
| 1411 | 1411 | <p> |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | public function reset_theme_check_notices() { |
| 1442 | 1442 | global $current_user; |
| 1443 | 1443 | wp_get_current_user(); |
| 1444 | - $user_id = $current_user->ID; |
|
| 1444 | + $user_id = $current_user->ID; |
|
| 1445 | 1445 | |
| 1446 | 1446 | delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); |
| 1447 | 1447 | } |
@@ -1461,62 +1461,62 @@ discard block |
||
| 1461 | 1461 | return $prevent_access; |
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | - /** |
|
| 1465 | - * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args |
|
| 1466 | - * on the sensei settings page. |
|
| 1467 | - * |
|
| 1468 | - * The function |
|
| 1469 | - * |
|
| 1470 | - * @since 1.8.7 |
|
| 1471 | - */ |
|
| 1472 | - public static function install_pages(){ |
|
| 1464 | + /** |
|
| 1465 | + * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args |
|
| 1466 | + * on the sensei settings page. |
|
| 1467 | + * |
|
| 1468 | + * The function |
|
| 1469 | + * |
|
| 1470 | + * @since 1.8.7 |
|
| 1471 | + */ |
|
| 1472 | + public static function install_pages(){ |
|
| 1473 | 1473 | |
| 1474 | - // only fire on the settings page |
|
| 1475 | - if( ! isset( $_GET['page'] ) |
|
| 1476 | - || 'woothemes-sensei-settings' != $_GET['page'] |
|
| 1477 | - || 1 == get_option('skip_install_sensei_pages') ){ |
|
| 1474 | + // only fire on the settings page |
|
| 1475 | + if( ! isset( $_GET['page'] ) |
|
| 1476 | + || 'woothemes-sensei-settings' != $_GET['page'] |
|
| 1477 | + || 1 == get_option('skip_install_sensei_pages') ){ |
|
| 1478 | 1478 | |
| 1479 | - return; |
|
| 1479 | + return; |
|
| 1480 | 1480 | |
| 1481 | - } |
|
| 1481 | + } |
|
| 1482 | 1482 | |
| 1483 | - // Install/page installer |
|
| 1484 | - $install_complete = false; |
|
| 1483 | + // Install/page installer |
|
| 1484 | + $install_complete = false; |
|
| 1485 | 1485 | |
| 1486 | - // Add pages button |
|
| 1487 | - $settings_url = ''; |
|
| 1488 | - if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) { |
|
| 1486 | + // Add pages button |
|
| 1487 | + $settings_url = ''; |
|
| 1488 | + if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) { |
|
| 1489 | 1489 | |
| 1490 | - Sensei()->admin->create_pages(); |
|
| 1490 | + Sensei()->admin->create_pages(); |
|
| 1491 | 1491 | |
| 1492 | - update_option('skip_install_sensei_pages', 1); |
|
| 1492 | + update_option('skip_install_sensei_pages', 1); |
|
| 1493 | 1493 | |
| 1494 | - $install_complete = true; |
|
| 1495 | - $settings_url = remove_query_arg('install_sensei_pages'); |
|
| 1494 | + $install_complete = true; |
|
| 1495 | + $settings_url = remove_query_arg('install_sensei_pages'); |
|
| 1496 | 1496 | |
| 1497 | - // Skip button |
|
| 1498 | - } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) { |
|
| 1497 | + // Skip button |
|
| 1498 | + } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) { |
|
| 1499 | 1499 | |
| 1500 | - update_option('skip_install_sensei_pages', 1); |
|
| 1501 | - $install_complete = true; |
|
| 1502 | - $settings_url = remove_query_arg('skip_install_sensei_pages'); |
|
| 1500 | + update_option('skip_install_sensei_pages', 1); |
|
| 1501 | + $install_complete = true; |
|
| 1502 | + $settings_url = remove_query_arg('skip_install_sensei_pages'); |
|
| 1503 | 1503 | |
| 1504 | - } |
|
| 1504 | + } |
|
| 1505 | 1505 | |
| 1506 | - if ($install_complete) { |
|
| 1506 | + if ($install_complete) { |
|
| 1507 | 1507 | |
| 1508 | - // refresh the rewrite rules on init |
|
| 1509 | - update_option('sensei_flush_rewrite_rules', '1'); |
|
| 1508 | + // refresh the rewrite rules on init |
|
| 1509 | + update_option('sensei_flush_rewrite_rules', '1'); |
|
| 1510 | 1510 | |
| 1511 | - // Set installed option |
|
| 1512 | - update_option('sensei_installed', 0); |
|
| 1511 | + // Set installed option |
|
| 1512 | + update_option('sensei_installed', 0); |
|
| 1513 | 1513 | |
| 1514 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
| 1515 | - wp_redirect( $complete_url ); |
|
| 1514 | + $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
| 1515 | + wp_redirect( $complete_url ); |
|
| 1516 | 1516 | |
| 1517 | - } |
|
| 1517 | + } |
|
| 1518 | 1518 | |
| 1519 | - }// end install_pages |
|
| 1519 | + }// end install_pages |
|
| 1520 | 1520 | |
| 1521 | 1521 | } // End Class |
| 1522 | 1522 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function register_hook_listener() { |
| 59 | 59 | |
| 60 | - add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 60 | + add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 61 | 61 | add_action( 'admin_init', array( $this, 'settings_fields' ) ); |
| 62 | - add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 62 | + add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 63 | 63 | |
| 64 | 64 | } // End setup_settings() |
| 65 | 65 | |
@@ -293,14 +293,14 @@ discard block |
||
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | 295 | public function settings_screen () |
| 296 | - { |
|
| 296 | + { |
|
| 297 | 297 | |
| 298 | - ?> |
|
| 298 | + ?> |
|
| 299 | 299 | <div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>"> |
| 300 | 300 | <?php screen_icon('woothemes-sensei'); ?> |
| 301 | 301 | <h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) { |
| 302 | - echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 303 | - } ?></h2> |
|
| 302 | + echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 303 | + } ?></h2> |
|
| 304 | 304 | <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" |
| 305 | 305 | title="WooThemes"><img |
| 306 | 306 | src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes"/></a></p> |
@@ -308,26 +308,26 @@ discard block |
||
| 308 | 308 | <form action="options.php" method="post"> |
| 309 | 309 | |
| 310 | 310 | <?php |
| 311 | - $this->settings_tabs(); |
|
| 312 | - settings_fields($this->token); |
|
| 313 | - $page = 'woothemes-sensei-settings'; |
|
| 314 | - foreach ($this->sections as $section_id => $section) { |
|
| 311 | + $this->settings_tabs(); |
|
| 312 | + settings_fields($this->token); |
|
| 313 | + $page = 'woothemes-sensei-settings'; |
|
| 314 | + foreach ($this->sections as $section_id => $section) { |
|
| 315 | 315 | |
| 316 | - echo '<section id="' . $section_id . '">'; |
|
| 316 | + echo '<section id="' . $section_id . '">'; |
|
| 317 | 317 | |
| 318 | - if ($section['name']) |
|
| 319 | - echo "<h2>{$section['name']}</h2>\n"; |
|
| 318 | + if ($section['name']) |
|
| 319 | + echo "<h2>{$section['name']}</h2>\n"; |
|
| 320 | 320 | |
| 321 | - echo '<table class="form-table">'; |
|
| 322 | - do_settings_fields($page, $section_id ); |
|
| 323 | - echo '</table>'; |
|
| 321 | + echo '<table class="form-table">'; |
|
| 322 | + do_settings_fields($page, $section_id ); |
|
| 323 | + echo '</table>'; |
|
| 324 | 324 | |
| 325 | - echo '</section>'; |
|
| 325 | + echo '</section>'; |
|
| 326 | 326 | |
| 327 | - } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - submit_button(); |
|
| 330 | - ?> |
|
| 329 | + submit_button(); |
|
| 330 | + ?> |
|
| 331 | 331 | </form> |
| 332 | 332 | <?php do_action( 'settings_after_form' ); ?> |
| 333 | 333 | </div><!--/#woothemes-sensei--> |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function get_settings () { |
| 344 | 344 | |
| 345 | - $this->settings = get_option( $this->token, array() ); |
|
| 345 | + $this->settings = get_option( $this->token, array() ); |
|
| 346 | 346 | |
| 347 | 347 | foreach ( $this->fields as $k => $v ) { |
| 348 | 348 | if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) { |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @return void |
| 376 | 376 | */ |
| 377 | 377 | public function settings_errors () { |
| 378 | - settings_errors( $this->token . '-errors' ); |
|
| 378 | + settings_errors( $this->token . '-errors' ); |
|
| 379 | 379 | } // End settings_errors() |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n"; |
| 442 | 442 | if ( $has_description ) { |
| 443 | 443 | echo wp_kses( $args['data']['description'], array( 'a' => array( |
| 444 | - 'href' => array(), |
|
| 445 | - 'title' => array() |
|
| 446 | - ) |
|
| 444 | + 'href' => array(), |
|
| 445 | + 'title' => array() |
|
| 446 | + ) |
|
| 447 | 447 | ) |
| 448 | 448 | ) . '</label>' . "\n"; |
| 449 | 449 | } |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | public function enqueue_scripts () { |
| 834 | 834 | |
| 835 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 835 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 836 | 836 | |
| 837 | 837 | wp_enqueue_script( 'farbtastic' ); |
| 838 | 838 | wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version ); |
@@ -16,25 +16,25 @@ discard block |
||
| 16 | 16 | public $slider_labels; |
| 17 | 17 | public $role_caps; |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var Sensei_Course |
|
| 21 | - */ |
|
| 22 | - public $course; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var Sensei_Lesson |
|
| 26 | - */ |
|
| 27 | - public $lesson; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var Sensei_Question |
|
| 31 | - */ |
|
| 32 | - public $question; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var Sensei_Quiz |
|
| 36 | - */ |
|
| 37 | - public $quiz; |
|
| 19 | + /** |
|
| 20 | + * @var Sensei_Course |
|
| 21 | + */ |
|
| 22 | + public $course; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var Sensei_Lesson |
|
| 26 | + */ |
|
| 27 | + public $lesson; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var Sensei_Question |
|
| 31 | + */ |
|
| 32 | + public $question; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var Sensei_Quiz |
|
| 36 | + */ |
|
| 37 | + public $quiz; |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Constructor |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // Setup Post Types |
| 46 | 46 | $this->labels = array(); |
| 47 | - $this->token = 'woothemes-sensei-posttypes'; |
|
| 47 | + $this->token = 'woothemes-sensei-posttypes'; |
|
| 48 | 48 | |
| 49 | 49 | $this->setup_post_type_labels_base(); |
| 50 | 50 | add_action( 'init', array( $this, 'setup_course_post_type' ), 100 ); |
@@ -103,94 +103,94 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * Setup the "course" post type, it's admin menu item and the appropriate labels and permissions. |
| 105 | 105 | * @since 1.0.0 |
| 106 | - * @uses Sensei() |
|
| 106 | + * @uses Sensei() |
|
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | 109 | public function setup_course_post_type () { |
| 110 | 110 | |
| 111 | 111 | $args = array( |
| 112 | - 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ), |
|
| 113 | - 'public' => true, |
|
| 114 | - 'publicly_queryable' => true, |
|
| 115 | - 'show_ui' => true, |
|
| 116 | - 'show_in_menu' => true, |
|
| 117 | - 'show_in_admin_bar' => true, |
|
| 118 | - 'query_var' => true, |
|
| 119 | - 'rewrite' => array( |
|
| 120 | - 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) , |
|
| 121 | - 'with_front' => true, |
|
| 122 | - 'feeds' => true, |
|
| 123 | - 'pages' => true |
|
| 124 | - ), |
|
| 125 | - 'map_meta_cap' => true, |
|
| 126 | - 'capability_type' => 'course', |
|
| 127 | - 'has_archive' => $this->get_course_post_type_archive_slug(), |
|
| 128 | - 'hierarchical' => false, |
|
| 129 | - 'menu_position' => 51, |
|
| 130 | - 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) |
|
| 112 | + 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ), |
|
| 113 | + 'public' => true, |
|
| 114 | + 'publicly_queryable' => true, |
|
| 115 | + 'show_ui' => true, |
|
| 116 | + 'show_in_menu' => true, |
|
| 117 | + 'show_in_admin_bar' => true, |
|
| 118 | + 'query_var' => true, |
|
| 119 | + 'rewrite' => array( |
|
| 120 | + 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) , |
|
| 121 | + 'with_front' => true, |
|
| 122 | + 'feeds' => true, |
|
| 123 | + 'pages' => true |
|
| 124 | + ), |
|
| 125 | + 'map_meta_cap' => true, |
|
| 126 | + 'capability_type' => 'course', |
|
| 127 | + 'has_archive' => $this->get_course_post_type_archive_slug(), |
|
| 128 | + 'hierarchical' => false, |
|
| 129 | + 'menu_position' => 51, |
|
| 130 | + 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Filter the arguments passed in when registering the Sensei Course post type. |
|
| 135 | - * |
|
| 136 | - * @since 1.9.0 |
|
| 137 | - * @param array $args |
|
| 138 | - */ |
|
| 133 | + /** |
|
| 134 | + * Filter the arguments passed in when registering the Sensei Course post type. |
|
| 135 | + * |
|
| 136 | + * @since 1.9.0 |
|
| 137 | + * @param array $args |
|
| 138 | + */ |
|
| 139 | 139 | register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) ); |
| 140 | 140 | |
| 141 | 141 | } // End setup_course_post_type() |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Figure out of the course post type has an archive and what it should be. |
|
| 145 | - * |
|
| 146 | - * This function should return 'courses' or the page_uri for the course page setting. |
|
| 147 | - * |
|
| 148 | - * For backward compatibility sake ( pre 1.9 )If the course page set in settings |
|
| 149 | - * still has any of the old shortcodes: [newcourses][featuredcourses][freecourses][paidcourses] the |
|
| 150 | - * page slug will not be returned. For any other pages without it the page URI will be returned. |
|
| 151 | - * |
|
| 152 | - * |
|
| 153 | - * @sine 1.9.0 |
|
| 154 | - * |
|
| 155 | - * |
|
| 156 | - * @return false|string |
|
| 157 | - */ |
|
| 158 | - public function get_course_post_type_archive_slug(){ |
|
| 143 | + /** |
|
| 144 | + * Figure out of the course post type has an archive and what it should be. |
|
| 145 | + * |
|
| 146 | + * This function should return 'courses' or the page_uri for the course page setting. |
|
| 147 | + * |
|
| 148 | + * For backward compatibility sake ( pre 1.9 )If the course page set in settings |
|
| 149 | + * still has any of the old shortcodes: [newcourses][featuredcourses][freecourses][paidcourses] the |
|
| 150 | + * page slug will not be returned. For any other pages without it the page URI will be returned. |
|
| 151 | + * |
|
| 152 | + * |
|
| 153 | + * @sine 1.9.0 |
|
| 154 | + * |
|
| 155 | + * |
|
| 156 | + * @return false|string |
|
| 157 | + */ |
|
| 158 | + public function get_course_post_type_archive_slug(){ |
|
| 159 | 159 | |
| 160 | - $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) ); |
|
| 160 | + $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) ); |
|
| 161 | 161 | |
| 162 | - // for a valid post that doesn't have any of the old short codes set the archive the same |
|
| 163 | - // as the page URI |
|
| 164 | - if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){ |
|
| 162 | + // for a valid post that doesn't have any of the old short codes set the archive the same |
|
| 163 | + // as the page URI |
|
| 164 | + if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){ |
|
| 165 | 165 | |
| 166 | - return get_page_uri( $settings_course_page->ID ); |
|
| 166 | + return get_page_uri( $settings_course_page->ID ); |
|
| 167 | 167 | |
| 168 | - }else{ |
|
| 168 | + }else{ |
|
| 169 | 169 | |
| 170 | - return 'courses'; |
|
| 170 | + return 'courses'; |
|
| 171 | 171 | |
| 172 | - } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - }// end course_post_type_determine_archive |
|
| 174 | + }// end course_post_type_determine_archive |
|
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Check if given content has any of these old shortcodes: |
|
| 178 | - * [newcourses][featuredcourses][freecourses][paidcourses] |
|
| 179 | - * |
|
| 180 | - * @since 1.9.0 |
|
| 181 | - * |
|
| 182 | - * @param string $content |
|
| 183 | - * |
|
| 184 | - * @return bool |
|
| 185 | - */ |
|
| 186 | - public function has_old_shortcodes( $content ){ |
|
| 176 | + /** |
|
| 177 | + * Check if given content has any of these old shortcodes: |
|
| 178 | + * [newcourses][featuredcourses][freecourses][paidcourses] |
|
| 179 | + * |
|
| 180 | + * @since 1.9.0 |
|
| 181 | + * |
|
| 182 | + * @param string $content |
|
| 183 | + * |
|
| 184 | + * @return bool |
|
| 185 | + */ |
|
| 186 | + public function has_old_shortcodes( $content ){ |
|
| 187 | 187 | |
| 188 | - return ( has_shortcode( $content, 'newcourses') |
|
| 189 | - || has_shortcode( $content, 'featuredcourses') |
|
| 190 | - || has_shortcode( $content, 'freecourses') |
|
| 191 | - || has_shortcode( $content, 'paidcourses') ); |
|
| 188 | + return ( has_shortcode( $content, 'newcourses') |
|
| 189 | + || has_shortcode( $content, 'featuredcourses') |
|
| 190 | + || has_shortcode( $content, 'freecourses') |
|
| 191 | + || has_shortcode( $content, 'paidcourses') ); |
|
| 192 | 192 | |
| 193 | - }// end has old shortcodes |
|
| 193 | + }// end has old shortcodes |
|
| 194 | 194 | |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -211,32 +211,32 @@ discard block |
||
| 211 | 211 | } // End If Statement |
| 212 | 212 | |
| 213 | 213 | $args = array( |
| 214 | - 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ), |
|
| 215 | - 'public' => true, |
|
| 216 | - 'publicly_queryable' => true, |
|
| 217 | - 'show_ui' => true, |
|
| 218 | - 'show_in_menu' => true, |
|
| 219 | - 'query_var' => true, |
|
| 220 | - 'rewrite' => array( |
|
| 221 | - 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 222 | - 'with_front' => true, |
|
| 223 | - 'feeds' => true, |
|
| 224 | - 'pages' => true |
|
| 225 | - ), |
|
| 226 | - 'map_meta_cap' => true, |
|
| 227 | - 'capability_type' => 'lesson', |
|
| 228 | - 'has_archive' => true, |
|
| 229 | - 'hierarchical' => false, |
|
| 230 | - 'menu_position' => 52, |
|
| 231 | - 'supports' => $supports_array |
|
| 214 | + 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ), |
|
| 215 | + 'public' => true, |
|
| 216 | + 'publicly_queryable' => true, |
|
| 217 | + 'show_ui' => true, |
|
| 218 | + 'show_in_menu' => true, |
|
| 219 | + 'query_var' => true, |
|
| 220 | + 'rewrite' => array( |
|
| 221 | + 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 222 | + 'with_front' => true, |
|
| 223 | + 'feeds' => true, |
|
| 224 | + 'pages' => true |
|
| 225 | + ), |
|
| 226 | + 'map_meta_cap' => true, |
|
| 227 | + 'capability_type' => 'lesson', |
|
| 228 | + 'has_archive' => true, |
|
| 229 | + 'hierarchical' => false, |
|
| 230 | + 'menu_position' => 52, |
|
| 231 | + 'supports' => $supports_array |
|
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Filter the arguments passed in when registering the Sensei Lesson post type. |
|
| 236 | - * |
|
| 237 | - * @since 1.9.0 |
|
| 238 | - * @param array $args |
|
| 239 | - */ |
|
| 234 | + /** |
|
| 235 | + * Filter the arguments passed in when registering the Sensei Lesson post type. |
|
| 236 | + * |
|
| 237 | + * @since 1.9.0 |
|
| 238 | + * @param array $args |
|
| 239 | + */ |
|
| 240 | 240 | register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) ); |
| 241 | 241 | |
| 242 | 242 | } // End setup_lesson_post_type() |
@@ -244,44 +244,44 @@ discard block |
||
| 244 | 244 | /** |
| 245 | 245 | * Setup the "quiz" post type, it's admin menu item and the appropriate labels and permissions. |
| 246 | 246 | * @since 1.0.0 |
| 247 | - * @uses Sensei() |
|
| 247 | + * @uses Sensei() |
|
| 248 | 248 | * @return void |
| 249 | 249 | */ |
| 250 | 250 | public function setup_quiz_post_type () { |
| 251 | 251 | |
| 252 | 252 | $args = array( |
| 253 | - 'labels' => $this->create_post_type_labels( |
|
| 254 | - $this->labels['quiz']['singular'], |
|
| 255 | - $this->labels['quiz']['plural'], |
|
| 256 | - $this->labels['quiz']['menu'] |
|
| 257 | - ), |
|
| 258 | - 'public' => true, |
|
| 259 | - 'publicly_queryable' => true, |
|
| 260 | - 'show_ui' => true, |
|
| 261 | - 'show_in_menu' => false, |
|
| 262 | - 'show_in_nav_menus' => false, |
|
| 263 | - 'query_var' => true, |
|
| 264 | - 'exclude_from_search' => true, |
|
| 265 | - 'rewrite' => array( |
|
| 266 | - 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 267 | - 'with_front' => true, |
|
| 268 | - 'feeds' => true, |
|
| 269 | - 'pages' => true |
|
| 270 | - ), |
|
| 271 | - 'map_meta_cap' => true, |
|
| 272 | - 'capability_type' => 'quiz', |
|
| 273 | - 'has_archive' => false, |
|
| 274 | - 'hierarchical' => false, |
|
| 275 | - 'menu_position' => 20, // Below "Pages" |
|
| 276 | - 'supports' => array( '' ) |
|
| 253 | + 'labels' => $this->create_post_type_labels( |
|
| 254 | + $this->labels['quiz']['singular'], |
|
| 255 | + $this->labels['quiz']['plural'], |
|
| 256 | + $this->labels['quiz']['menu'] |
|
| 257 | + ), |
|
| 258 | + 'public' => true, |
|
| 259 | + 'publicly_queryable' => true, |
|
| 260 | + 'show_ui' => true, |
|
| 261 | + 'show_in_menu' => false, |
|
| 262 | + 'show_in_nav_menus' => false, |
|
| 263 | + 'query_var' => true, |
|
| 264 | + 'exclude_from_search' => true, |
|
| 265 | + 'rewrite' => array( |
|
| 266 | + 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 267 | + 'with_front' => true, |
|
| 268 | + 'feeds' => true, |
|
| 269 | + 'pages' => true |
|
| 270 | + ), |
|
| 271 | + 'map_meta_cap' => true, |
|
| 272 | + 'capability_type' => 'quiz', |
|
| 273 | + 'has_archive' => false, |
|
| 274 | + 'hierarchical' => false, |
|
| 275 | + 'menu_position' => 20, // Below "Pages" |
|
| 276 | + 'supports' => array( '' ) |
|
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Filter the arguments passed in when registering the Sensei Quiz post type. |
|
| 281 | - * |
|
| 282 | - * @since 1.9.0 |
|
| 283 | - * @param array $args |
|
| 284 | - */ |
|
| 279 | + /** |
|
| 280 | + * Filter the arguments passed in when registering the Sensei Quiz post type. |
|
| 281 | + * |
|
| 282 | + * @since 1.9.0 |
|
| 283 | + * @param array $args |
|
| 284 | + */ |
|
| 285 | 285 | register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) ); |
| 286 | 286 | |
| 287 | 287 | } // End setup_quiz_post_type() |
@@ -295,34 +295,34 @@ discard block |
||
| 295 | 295 | public function setup_question_post_type () { |
| 296 | 296 | |
| 297 | 297 | $args = array( |
| 298 | - 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ), |
|
| 299 | - 'public' => false, |
|
| 300 | - 'publicly_queryable' => true, |
|
| 301 | - 'show_ui' => true, |
|
| 302 | - 'show_in_menu' => true, |
|
| 303 | - 'show_in_nav_menus' => false, |
|
| 304 | - 'query_var' => true, |
|
| 305 | - 'exclude_from_search' => true, |
|
| 306 | - 'rewrite' => array( |
|
| 307 | - 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 308 | - 'with_front' => true, |
|
| 309 | - 'feeds' => true, |
|
| 310 | - 'pages' => true |
|
| 311 | - ), |
|
| 312 | - 'map_meta_cap' => true, |
|
| 313 | - 'capability_type' => 'question', |
|
| 314 | - 'has_archive' => true, |
|
| 315 | - 'hierarchical' => false, |
|
| 316 | - 'menu_position' => 51, |
|
| 317 | - 'supports' => array( 'title' ) |
|
| 298 | + 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ), |
|
| 299 | + 'public' => false, |
|
| 300 | + 'publicly_queryable' => true, |
|
| 301 | + 'show_ui' => true, |
|
| 302 | + 'show_in_menu' => true, |
|
| 303 | + 'show_in_nav_menus' => false, |
|
| 304 | + 'query_var' => true, |
|
| 305 | + 'exclude_from_search' => true, |
|
| 306 | + 'rewrite' => array( |
|
| 307 | + 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 308 | + 'with_front' => true, |
|
| 309 | + 'feeds' => true, |
|
| 310 | + 'pages' => true |
|
| 311 | + ), |
|
| 312 | + 'map_meta_cap' => true, |
|
| 313 | + 'capability_type' => 'question', |
|
| 314 | + 'has_archive' => true, |
|
| 315 | + 'hierarchical' => false, |
|
| 316 | + 'menu_position' => 51, |
|
| 317 | + 'supports' => array( 'title' ) |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | - /** |
|
| 321 | - * Filter the arguments passed in when registering the Sensei Question post type. |
|
| 322 | - * |
|
| 323 | - * @since 1.9.0 |
|
| 324 | - * @param array $args |
|
| 325 | - */ |
|
| 320 | + /** |
|
| 321 | + * Filter the arguments passed in when registering the Sensei Question post type. |
|
| 322 | + * |
|
| 323 | + * @since 1.9.0 |
|
| 324 | + * @param array $args |
|
| 325 | + */ |
|
| 326 | 326 | register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) ); |
| 327 | 327 | |
| 328 | 328 | } // End setup_question_post_type() |
@@ -335,26 +335,26 @@ discard block |
||
| 335 | 335 | public function setup_multiple_question_post_type () { |
| 336 | 336 | |
| 337 | 337 | $args = array( |
| 338 | - 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ), |
|
| 339 | - 'public' => false, |
|
| 340 | - 'publicly_queryable' => false, |
|
| 341 | - 'show_ui' => false, |
|
| 342 | - 'show_in_menu' => false, |
|
| 343 | - 'show_in_nav_menus' => false, |
|
| 344 | - 'query_var' => false, |
|
| 345 | - 'exclude_from_search' => true, |
|
| 346 | - 'rewrite' => array( |
|
| 347 | - 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 348 | - 'with_front' => false, |
|
| 349 | - 'feeds' => false, |
|
| 350 | - 'pages' => false |
|
| 351 | - ), |
|
| 352 | - 'map_meta_cap' => true, |
|
| 353 | - 'capability_type' => 'question', |
|
| 354 | - 'has_archive' => false, |
|
| 355 | - 'hierarchical' => false, |
|
| 356 | - 'menu_position' => 51, |
|
| 357 | - 'supports' => array( 'title', 'custom-fields' ) |
|
| 338 | + 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ), |
|
| 339 | + 'public' => false, |
|
| 340 | + 'publicly_queryable' => false, |
|
| 341 | + 'show_ui' => false, |
|
| 342 | + 'show_in_menu' => false, |
|
| 343 | + 'show_in_nav_menus' => false, |
|
| 344 | + 'query_var' => false, |
|
| 345 | + 'exclude_from_search' => true, |
|
| 346 | + 'rewrite' => array( |
|
| 347 | + 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 348 | + 'with_front' => false, |
|
| 349 | + 'feeds' => false, |
|
| 350 | + 'pages' => false |
|
| 351 | + ), |
|
| 352 | + 'map_meta_cap' => true, |
|
| 353 | + 'capability_type' => 'question', |
|
| 354 | + 'has_archive' => false, |
|
| 355 | + 'hierarchical' => false, |
|
| 356 | + 'menu_position' => 51, |
|
| 357 | + 'supports' => array( 'title', 'custom-fields' ) |
|
| 358 | 358 | ); |
| 359 | 359 | |
| 360 | 360 | register_post_type( 'multiple_question', $args ); |
@@ -370,34 +370,34 @@ discard block |
||
| 370 | 370 | if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) { |
| 371 | 371 | |
| 372 | 372 | $args = array( |
| 373 | - 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ), |
|
| 374 | - 'public' => true, |
|
| 375 | - 'publicly_queryable' => true, |
|
| 376 | - 'show_ui' => true, |
|
| 377 | - 'show_in_menu' => 'admin.php?page=sensei', |
|
| 378 | - 'show_in_nav_menus' => true, |
|
| 379 | - 'query_var' => true, |
|
| 380 | - 'exclude_from_search' => true, |
|
| 381 | - 'rewrite' => array( |
|
| 382 | - 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 383 | - 'with_front' => false, |
|
| 384 | - 'feeds' => false, |
|
| 385 | - 'pages' => true |
|
| 386 | - ), |
|
| 387 | - 'map_meta_cap' => true, |
|
| 388 | - 'capability_type' => 'question', |
|
| 389 | - 'has_archive' => true, |
|
| 390 | - 'hierarchical' => false, |
|
| 391 | - 'menu_position' => 50, |
|
| 392 | - 'supports' => array( 'title', 'editor', 'comments' ), |
|
| 373 | + 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ), |
|
| 374 | + 'public' => true, |
|
| 375 | + 'publicly_queryable' => true, |
|
| 376 | + 'show_ui' => true, |
|
| 377 | + 'show_in_menu' => 'admin.php?page=sensei', |
|
| 378 | + 'show_in_nav_menus' => true, |
|
| 379 | + 'query_var' => true, |
|
| 380 | + 'exclude_from_search' => true, |
|
| 381 | + 'rewrite' => array( |
|
| 382 | + 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 383 | + 'with_front' => false, |
|
| 384 | + 'feeds' => false, |
|
| 385 | + 'pages' => true |
|
| 386 | + ), |
|
| 387 | + 'map_meta_cap' => true, |
|
| 388 | + 'capability_type' => 'question', |
|
| 389 | + 'has_archive' => true, |
|
| 390 | + 'hierarchical' => false, |
|
| 391 | + 'menu_position' => 50, |
|
| 392 | + 'supports' => array( 'title', 'editor', 'comments' ), |
|
| 393 | 393 | ); |
| 394 | 394 | |
| 395 | - /** |
|
| 396 | - * Filter the arguments passed in when registering the Sensei sensei_message post type. |
|
| 397 | - * |
|
| 398 | - * @since 1.9.0 |
|
| 399 | - * @param array $args |
|
| 400 | - */ |
|
| 395 | + /** |
|
| 396 | + * Filter the arguments passed in when registering the Sensei sensei_message post type. |
|
| 397 | + * |
|
| 398 | + * @since 1.9.0 |
|
| 399 | + * @param array $args |
|
| 400 | + */ |
|
| 401 | 401 | register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args ) ); |
| 402 | 402 | } |
| 403 | 403 | } // End setup_sensei_message_post_type() |
@@ -430,11 +430,11 @@ discard block |
||
| 430 | 430 | 'show_ui' => true, |
| 431 | 431 | 'query_var' => true, |
| 432 | 432 | 'show_in_nav_menus' => true, |
| 433 | - 'capabilities' => array( |
|
| 434 | - 'manage_terms' => 'manage_categories', |
|
| 435 | - 'edit_terms' => 'edit_courses', |
|
| 436 | - 'delete_terms' => 'manage_categories', |
|
| 437 | - 'assign_terms' => 'edit_courses',), |
|
| 433 | + 'capabilities' => array( |
|
| 434 | + 'manage_terms' => 'manage_categories', |
|
| 435 | + 'edit_terms' => 'edit_courses', |
|
| 436 | + 'delete_terms' => 'manage_categories', |
|
| 437 | + 'assign_terms' => 'edit_courses',), |
|
| 438 | 438 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
| 439 | 439 | ); |
| 440 | 440 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | 'show_ui' => true, /* TO DO - future releases */ |
| 472 | 472 | 'query_var' => true, |
| 473 | 473 | 'show_in_nav_menus' => false, |
| 474 | - 'public' => false, |
|
| 474 | + 'public' => false, |
|
| 475 | 475 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
| 476 | 476 | ); |
| 477 | 477 | |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | 'query_var' => false, |
| 545 | 545 | 'show_in_nav_menus' => false, |
| 546 | 546 | 'show_admin_column' => true, |
| 547 | - 'capabilities' => array( |
|
| 548 | - 'manage_terms' => 'manage_categories', |
|
| 549 | - 'edit_terms' => 'edit_questions', |
|
| 550 | - 'delete_terms' => 'manage_categories', |
|
| 551 | - 'assign_terms' => 'edit_questions',), |
|
| 547 | + 'capabilities' => array( |
|
| 548 | + 'manage_terms' => 'manage_categories', |
|
| 549 | + 'edit_terms' => 'edit_questions', |
|
| 550 | + 'delete_terms' => 'manage_categories', |
|
| 551 | + 'assign_terms' => 'edit_questions',), |
|
| 552 | 552 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
| 553 | 553 | ); |
| 554 | 554 | |
@@ -582,11 +582,11 @@ discard block |
||
| 582 | 582 | 'show_ui' => true, |
| 583 | 583 | 'query_var' => true, |
| 584 | 584 | 'show_in_nav_menus' => true, |
| 585 | - 'capabilities' => array( |
|
| 586 | - 'manage_terms' => 'manage_categories', |
|
| 587 | - 'edit_terms' => 'edit_lessons', |
|
| 588 | - 'delete_terms' => 'manage_categories', |
|
| 589 | - 'assign_terms' => 'edit_lessons',), |
|
| 585 | + 'capabilities' => array( |
|
| 586 | + 'manage_terms' => 'manage_categories', |
|
| 587 | + 'edit_terms' => 'edit_lessons', |
|
| 588 | + 'delete_terms' => 'manage_categories', |
|
| 589 | + 'assign_terms' => 'edit_lessons',), |
|
| 590 | 590 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
| 591 | 591 | ); |
| 592 | 592 | |
@@ -623,19 +623,19 @@ discard block |
||
| 623 | 623 | $lower_case_plural = function_exists( 'mb_strtolower' ) ? mb_strtolower( $plural, 'UTF-8') : strtolower( $plural ); |
| 624 | 624 | |
| 625 | 625 | $labels = array( |
| 626 | - 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ), |
|
| 627 | - 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ), |
|
| 628 | - 'add_new' => __( 'Add New', 'woothemes-sensei' ), |
|
| 629 | - 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ), |
|
| 630 | - 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ), |
|
| 631 | - 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ), |
|
| 632 | - 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ), |
|
| 633 | - 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ), |
|
| 634 | - 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ), |
|
| 635 | - 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), $lower_case_plural ) , |
|
| 636 | - 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), $lower_case_plural ), |
|
| 637 | - 'parent_item_colon' => '', |
|
| 638 | - 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu ) |
|
| 626 | + 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ), |
|
| 627 | + 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ), |
|
| 628 | + 'add_new' => __( 'Add New', 'woothemes-sensei' ), |
|
| 629 | + 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ), |
|
| 630 | + 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ), |
|
| 631 | + 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ), |
|
| 632 | + 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ), |
|
| 633 | + 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ), |
|
| 634 | + 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ), |
|
| 635 | + 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), $lower_case_plural ) , |
|
| 636 | + 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), $lower_case_plural ), |
|
| 637 | + 'parent_item_colon' => '', |
|
| 638 | + 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu ) |
|
| 639 | 639 | ); |
| 640 | 640 | |
| 641 | 641 | return $labels; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | * Assigns the defaults for each user role capabilities. |
| 709 | 709 | * |
| 710 | 710 | * @since 1.1.0 |
| 711 | - * |
|
| 711 | + * |
|
| 712 | 712 | * @param array $post_types |
| 713 | 713 | * @return void |
| 714 | 714 | */ |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | * Adds a 'Edit Quiz' link to the admin bar when viewing a Quiz linked to a corresponding Lesson |
| 777 | 777 | * |
| 778 | 778 | * @since 1.7.0 |
| 779 | - * @param WP_Admin_Bar $bar |
|
| 779 | + * @param WP_Admin_Bar $bar |
|
| 780 | 780 | * @return void |
| 781 | 781 | */ |
| 782 | 782 | public function quiz_admin_bar_menu( $bar ) { |
@@ -1,23 +1,23 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | 3 | /** |
| 4 | - * The Template for displaying True/False ( Boolean ) Question type. |
|
| 5 | - * |
|
| 6 | - * @author Automattic |
|
| 7 | - * @package Sensei |
|
| 8 | - * @category Templates |
|
| 9 | - * @version 1.9.0 |
|
| 10 | - */ |
|
| 4 | + * The Template for displaying True/False ( Boolean ) Question type. |
|
| 5 | + * |
|
| 6 | + * @author Automattic |
|
| 7 | + * @package Sensei |
|
| 8 | + * @category Templates |
|
| 9 | + * @version 1.9.0 |
|
| 10 | + */ |
|
| 11 | 11 | ?> |
| 12 | 12 | |
| 13 | 13 | <?php |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Get the question data with the current quiz id |
|
| 17 | - * All data is loaded in this array to keep the template clean. |
|
| 18 | - */ |
|
| 19 | - $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() ); |
|
| 20 | - $boolean_options = array( 'true', 'false' ); |
|
| 15 | + /** |
|
| 16 | + * Get the question data with the current quiz id |
|
| 17 | + * All data is loaded in this array to keep the template clean. |
|
| 18 | + */ |
|
| 19 | + $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() ); |
|
| 20 | + $boolean_options = array( 'true', 'false' ); |
|
| 21 | 21 | |
| 22 | 22 | ?> |
| 23 | 23 | |
@@ -25,44 +25,44 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | <?php |
| 27 | 27 | |
| 28 | - // setup the options the right answer set by the admin/teacher |
|
| 29 | - // will be compared to. |
|
| 30 | - $boolean_options = array( true, false ); |
|
| 28 | + // setup the options the right answer set by the admin/teacher |
|
| 29 | + // will be compared to. |
|
| 30 | + $boolean_options = array( true, false ); |
|
| 31 | 31 | |
| 32 | - //loop through the 2 boolean options and compare them with |
|
| 33 | - // the selected right answer |
|
| 34 | - foreach ( $boolean_options as $option ){ |
|
| 32 | + //loop through the 2 boolean options and compare them with |
|
| 33 | + // the selected right answer |
|
| 34 | + foreach ( $boolean_options as $option ){ |
|
| 35 | 35 | |
| 36 | - $answer_class = ''; |
|
| 36 | + $answer_class = ''; |
|
| 37 | 37 | |
| 38 | - // Add classes to indicate correctness, only if there is a grade |
|
| 39 | - if( isset( $question_data[ 'user_correct' ] ) && 0 < $question_data['question_grade'] ) { |
|
| 38 | + // Add classes to indicate correctness, only if there is a grade |
|
| 39 | + if( isset( $question_data[ 'user_correct' ] ) && 0 < $question_data['question_grade'] ) { |
|
| 40 | 40 | |
| 41 | - if( $question_right_answer == $question_data[ 'question_right_answer' ] ) { |
|
| 41 | + if( $question_right_answer == $question_data[ 'question_right_answer' ] ) { |
|
| 42 | 42 | |
| 43 | - if( $question_data[ 'user_correct' ] ) { |
|
| 43 | + if( $question_data[ 'user_correct' ] ) { |
|
| 44 | 44 | |
| 45 | - $answer_class = 'user_right'; |
|
| 45 | + $answer_class = 'user_right'; |
|
| 46 | 46 | |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $answer_class .= ' right_answer'; |
|
| 49 | + $answer_class .= ' right_answer'; |
|
| 50 | 50 | |
| 51 | - } else { |
|
| 51 | + } else { |
|
| 52 | 52 | |
| 53 | - if( ! $question_data[ 'user_correct' ] ) { |
|
| 53 | + if( ! $question_data[ 'user_correct' ] ) { |
|
| 54 | 54 | |
| 55 | - $answer_class = 'user_wrong'; |
|
| 55 | + $answer_class = 'user_wrong'; |
|
| 56 | 56 | |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - } // end if right answer == current booloean options |
|
| 59 | + } // end if right answer == current booloean options |
|
| 60 | 60 | |
| 61 | - }// end if $user_correct .. $question_grade |
|
| 61 | + }// end if $user_correct .. $question_grade |
|
| 62 | 62 | |
| 63 | - $option_value = $option ? 'true' : 'false'; |
|
| 63 | + $option_value = $option ? 'true' : 'false'; |
|
| 64 | 64 | |
| 65 | - ?> |
|
| 65 | + ?> |
|
| 66 | 66 | |
| 67 | 67 | <li class="<?php esc_attr_e( $answer_class ); ?>"> |
| 68 | 68 | |
@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | <label for="<?php echo esc_attr( 'question_' . $question_data[ 'ID' ] ) . '-option-' . $option_value; ?>"> |
| 77 | 77 | <?php |
| 78 | 78 | |
| 79 | - if( 'true' == $option ){ |
|
| 79 | + if( 'true' == $option ){ |
|
| 80 | 80 | |
| 81 | - _e( 'True', 'woothemes-sensei' ); |
|
| 81 | + _e( 'True', 'woothemes-sensei' ); |
|
| 82 | 82 | |
| 83 | - }else{ |
|
| 83 | + }else{ |
|
| 84 | 84 | |
| 85 | - _e( 'False', 'woothemes-sensei' ); |
|
| 85 | + _e( 'False', 'woothemes-sensei' ); |
|
| 86 | 86 | |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - ?> |
|
| 89 | + ?> |
|
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | </label> |
@@ -30,80 +30,80 @@ |
||
| 30 | 30 | |
| 31 | 31 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 32 | 32 | |
| 33 | - require_once( 'includes/class-sensei-autoloader.php' ); |
|
| 34 | - require_once( 'includes/lib/woo-functions.php' ); |
|
| 35 | - require_once( 'includes/sensei-functions.php' ); |
|
| 33 | + require_once( 'includes/class-sensei-autoloader.php' ); |
|
| 34 | + require_once( 'includes/lib/woo-functions.php' ); |
|
| 35 | + require_once( 'includes/sensei-functions.php' ); |
|
| 36 | 36 | |
| 37 | - if ( ! is_admin() ) {
|
|
| 38 | - require_once( 'includes/template-functions.php' ); |
|
| 39 | - } |
|
| 37 | + if ( ! is_admin() ) {
|
|
| 38 | + require_once( 'includes/template-functions.php' ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Returns the global Sensei Instance. |
|
| 43 | - * |
|
| 44 | - * @since 1.8.0 |
|
| 45 | - */ |
|
| 46 | - function Sensei(){
|
|
| 41 | + /** |
|
| 42 | + * Returns the global Sensei Instance. |
|
| 43 | + * |
|
| 44 | + * @since 1.8.0 |
|
| 45 | + */ |
|
| 46 | + function Sensei(){
|
|
| 47 | 47 | |
| 48 | - return Sensei_Main::instance(); |
|
| 48 | + return Sensei_Main::instance(); |
|
| 49 | 49 | |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | // set the sensei version number |
| 53 | 53 | Sensei()->version = '1.9.1'; |
| 54 | 54 | |
| 55 | - //backwards compatibility |
|
| 56 | - global $woothemes_sensei; |
|
| 57 | - $woothemes_sensei = Sensei(); |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Hook in WooCommerce functionality |
|
| 61 | - */ |
|
| 62 | - if( Sensei_WC::is_woocommerce_active() ){
|
|
| 63 | - add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) );
|
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Load all Template hooks |
|
| 68 | - */ |
|
| 69 | - if(! is_admin() ){
|
|
| 70 | - |
|
| 71 | - require_once( 'includes/hooks/template.php' ); |
|
| 72 | - |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Plugin updates |
|
| 77 | - * @since 1.0.1 |
|
| 78 | - */ |
|
| 79 | - woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 ); |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Sensei Activation Hook registration |
|
| 83 | - * @since 1.8.0 |
|
| 84 | - */ |
|
| 85 | - register_activation_hook( __FILE__, 'activate_sensei' ); |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Activate_sensei |
|
| 89 | - * |
|
| 90 | - * All the activation checks needed to ensure Sensei is ready for use |
|
| 91 | - * @since 1.8.0 |
|
| 92 | - */ |
|
| 93 | - function activate_sensei () {
|
|
| 94 | - |
|
| 95 | - // create the teacher role on activation and ensure that it has all the needed capabilities |
|
| 96 | - Sensei()->teacher->create_role(); |
|
| 97 | - |
|
| 98 | - //Setup all the role capabilities needed |
|
| 99 | - Sensei()->updates->add_sensei_caps(); |
|
| 100 | - Sensei()->updates->add_editor_caps(); |
|
| 101 | - Sensei()->updates->assign_role_caps(); |
|
| 102 | - |
|
| 103 | - //Flush rules |
|
| 104 | - add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 ); |
|
| 105 | - |
|
| 106 | - //Load the Welcome Screen |
|
| 107 | - add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 ); |
|
| 108 | - |
|
| 109 | - }// end activate_sensei |
|
| 55 | + //backwards compatibility |
|
| 56 | + global $woothemes_sensei; |
|
| 57 | + $woothemes_sensei = Sensei(); |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Hook in WooCommerce functionality |
|
| 61 | + */ |
|
| 62 | + if( Sensei_WC::is_woocommerce_active() ){
|
|
| 63 | + add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) );
|
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Load all Template hooks |
|
| 68 | + */ |
|
| 69 | + if(! is_admin() ){
|
|
| 70 | + |
|
| 71 | + require_once( 'includes/hooks/template.php' ); |
|
| 72 | + |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Plugin updates |
|
| 77 | + * @since 1.0.1 |
|
| 78 | + */ |
|
| 79 | + woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 ); |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Sensei Activation Hook registration |
|
| 83 | + * @since 1.8.0 |
|
| 84 | + */ |
|
| 85 | + register_activation_hook( __FILE__, 'activate_sensei' ); |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Activate_sensei |
|
| 89 | + * |
|
| 90 | + * All the activation checks needed to ensure Sensei is ready for use |
|
| 91 | + * @since 1.8.0 |
|
| 92 | + */ |
|
| 93 | + function activate_sensei () {
|
|
| 94 | + |
|
| 95 | + // create the teacher role on activation and ensure that it has all the needed capabilities |
|
| 96 | + Sensei()->teacher->create_role(); |
|
| 97 | + |
|
| 98 | + //Setup all the role capabilities needed |
|
| 99 | + Sensei()->updates->add_sensei_caps(); |
|
| 100 | + Sensei()->updates->add_editor_caps(); |
|
| 101 | + Sensei()->updates->assign_role_caps(); |
|
| 102 | + |
|
| 103 | + //Flush rules |
|
| 104 | + add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 ); |
|
| 105 | + |
|
| 106 | + //Load the Welcome Screen |
|
| 107 | + add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 ); |
|
| 108 | + |
|
| 109 | + }// end activate_sensei |
|