Issues (896)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/class-sensei-templates.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
3
/**
4
 * Sensei Template Class
5
 *
6
 * Handles all Template loading and redirecting functionality.
7
 *
8
 * @package Views
9
 * @author Automattic
10
 *
11
 * @since 1.9.0
12
 */
13
class Sensei_Templates {
14
15
    /**
16
     *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
17
     *
18
     * @since 1.9.0
19
     * @param string $slug
20
     * @param string $name default: ''
21
     *
22
     * @return void
23
     */
24
    public static function get_part(  $slug, $name = ''  ){
25
26
        $template = '';
27
        $plugin_template_url = Sensei()->template_url;
28
        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
29
30
        // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
        if ( $name ){
32
33
            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
34
35
        }
36
37
        // Get default slug-name.php
38
        if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
39
40
            $template = $plugin_template_path . "{$slug}-{$name}.php";
41
42
        }
43
44
45
        // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
        if ( !$template ){
47
48
            $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
49
50
        }
51
52
53
        if ( $template ){
54
55
            load_template( $template, false );
56
57
        }
58
59
    } // end get part
60
61
    /**
62
     * Get the template.
63
     *
64
     * @since 1.9.0
65
     *
66
     * @param $template_name
67
     * @param array $args
68
     * @param string $template_path
69
     * @param string $default_path
70
     */
71
    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
72
73
        if ( $args && is_array($args) )
0 ignored issues
show
Bug Best Practice introduced by
The expression $args of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
74
            extract( $args );
75
76
        $located = self::locate_template( $template_name, $template_path, $default_path );
77
78
        if( ! empty( $located ) ){
79
80
            do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
81
82
            include( $located );
83
84
            do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
85
86
        }
87
88
    } // end get template
89
90
    /**
91
     * Check if the template file exists. A wrapper for WP locate_template.
92
     *
93
     * @since 1.9.0
94
     *
95
     * @param $template_name
96
     * @param string $template_path
97
     * @param string $default_path
98
     *
99
     * @return mixed|void
100
     */
101
    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
102
103
        if ( ! $template_path ) $template_path = Sensei()->template_url;
104
        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
105
106
        // Look within passed path within the theme - this is priority
107
        $template = locate_template(
108
            array(
109
                $template_path . $template_name,
110
                $template_name
111
            )
112
        );
113
114
        // Get default template
115
        if ( ! $template ){
116
117
            $template = $default_path . $template_name;
118
119
        }
120
        // return nothing for file that do not exist
121
        if( !file_exists( $template ) ){
122
            $template = '';
123
        }
124
125
        // Return what we found
126
        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
127
128
    } // end locate
129
130
    /**
131
     * Determine which Sensei template to load based on the
132
     * current page context.
133
     *
134
     * @since 1.0
135
     *
136
     * @param string $template
137
     * @return string $template
138
     */
139
    public static function template_loader ( $template = '' ) {
140
141
        global $wp_query, $email_template;
142
143
        $find = array( 'woothemes-sensei.php' );
144
        $file = '';
145
146
        if ( isset( $email_template ) && $email_template ) {
147
148
            $file 	= 'emails/' . $email_template;
149
            $find[] = $file;
150
            $find[] = Sensei()->template_url . $file;
151
152 View Code Duplication
        } elseif ( is_single() && get_post_type() == 'course' ) {
153
154
            // possible backward compatible template include if theme overrides content-single-course.php
155
            // this template was removed in 1.9.0 and code all moved into the main single-course.php file
156
            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
157
158
            $file 	= 'single-course.php';
159
            $find[] = $file;
160
            $find[] = Sensei()->template_url . $file;
161
162
163
        } elseif ( is_single() && get_post_type() == 'lesson' ) {  // check
164
165
            // possible backward compatible template include if theme overrides content-single-lesson.php
166
            // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
167
            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
168
169
            $file 	= 'single-lesson.php';
170
            $find[] = $file;
171
            $find[] = Sensei()->template_url . $file;
172
173 View Code Duplication
        } elseif ( is_single() && get_post_type() == 'quiz' ) {  // check
174
175
            // possible backward compatible template include if theme overrides content-single-quiz.php
176
            // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
177
            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
178
179
            $file 	= 'single-quiz.php';
180
            $find[] = $file;
181
            $find[] = Sensei()->template_url . $file;
182
183
184
        } elseif ( is_single() && get_post_type() == 'sensei_message' ) { //// check
185
186
            // possible backward compatible template include if theme overrides content-single-message.php
187
            // this template was removed in 1.9.0 and code all moved into the main single-message.php file
188
            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
189
190
            $file 	= 'single-message.php';
191
            $find[] = $file;
192
            $find[] = Sensei()->template_url . $file;
193
194
        } elseif ( is_post_type_archive( 'course' )
195
                    || is_page( Sensei()->get_page_id( 'courses' ) )
196
                    || is_tax( 'course-category' )) {
197
198
            // possible backward compatible template include if theme overrides 'taxonomy-course-category'
199
            // this template was removed in 1.9.0 and replaced by archive-course.php
200
            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
201
202
            $file 	= 'archive-course.php';
203
            $find[] = $file;
204
            $find[] = Sensei()->template_url . $file;
205
206
        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
207
208
            $file 	= 'archive-message.php';
209
            $find[] = $file;
210
            $find[] = Sensei()->template_url . $file;
211
212
        } elseif( is_tax( 'lesson-tag' ) ) {
213
214
            // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
215
            // this template was removed in 1.9.0 and replaced by archive-lesson.php
216
            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
217
218
            $file 	= 'archive-lesson.php';
219
            $find[] = $file;
220
            $find[] = Sensei()->template_url . $file;
221
222
        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
223
224
            // Override for sites with static home page
225
            $wp_query->is_home = false;
226
227
            $file 	= 'learner-profile.php';
228
            $find[] = $file;
229
            $find[] = Sensei()->template_url . $file;
230
231
        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
232
233
            // Override for sites with static home page
234
            $wp_query->is_home = false;
235
236
            $file = 'course-results.php';
237
            $find[] = $file;
238
            $find[] = Sensei()->template_url . $file;
239
240
        }elseif( is_author()
241
                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
242
                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
243
244
            $file = 'teacher-archive.php';
245
            $find[] = $file;
246
            $find[] = Sensei()->template_url . $file;
247
248
        } // Load the template file
249
250
	    // if file is present set it to be loaded otherwise continue with the initial template given by WP
251
        if ( $file ) {
252
253
            $template = locate_template( $find );
254
            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
255
256
        } // End If Statement
257
258
        return $template;
259
260
    } // End template_loader()
261
262
    /**
263
     * This function loads the no-permissions template for users with no access
264
     * if a Sensei template was loaded.
265
     *
266
     * This function doesn't determine the permissions. Permissions must be determined
267
     * before loading this function as it only gets the template.
268
     *
269
     * This function also checks the user theme for overrides to ensure the right template
270
     * file is returned.
271
     *
272
     * @since 1.9.0
273
     */
274
    public static function get_no_permission_template( ){
275
276
        // possible backward compatible template loading
277
        // this template was removed in 1.9.0 and code all moved into the no-permissions.php file
278
        self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
279
280
        $file 	= 'no-permissions.php';
281
        $find[] = $file;
282
        $find[] = Sensei()->template_url . $file;
283
284
        $template = locate_template( $find );
285
        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
286
287
	    // set a global constant so that we know that we're in this template
288
	    define('SENSEI_NO_PERMISSION', true );
289
290
        return $template;
291
292
    }
293
294
    /**
295
     * This function is specifically created for loading template files from the theme.
296
     *
297
     * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
298
     * around the singular content file from their theme and exit.
299
     *
300
     * If none is found this function will do nothing. If a template is found this funciton
301
     * will exit execution of the script an not continue.
302
     *
303
     * @since 1.9.0
304
     * @param string $template
305
     * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
306
     */
307
    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
308
309
        $found_template = locate_template( array( $template ) );
310
        if( $found_template ){
311
312
            if( $load_header_footer ){
313
314
                get_sensei_header();
315
                include( $found_template );
316
                get_sensei_footer();
317
318
            }else{
319
320
                include( $found_template );
321
322
            }
323
324
            exit;
325
326
        }
327
328
    }
329
330
331
    /**
332
     * Hooks the deprecated archive content hook into the hook again just in
333
     * case other developers have used it.
334
     *
335
     * @deprecated since 1.9.0
336
     */
337
    public static function deprecated_archive_course_content_hook(){
338
339
        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
340
341
    }// end deprecated_archive_hook
342
343
    /**
344
     * A generic function for echoing the post title
345
     *
346
     * @since 1.9.0
347
     * @param  WP_Post $post
348
     */
349
    public static function the_title( $post ){
350
351
        // ID passed in
352
        if( is_numeric( $post ) ){
353
            $post = get_post( $post );
354
        }
355
356
        /**
357
         * Filter the template html tag for the title
358
         *
359
         * @since 1.9.0
360
         *
361
         * @param $title_html_tag default is 'h3'
362
         */
363
        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
364
365
        /**
366
         * Filter the title classes
367
         *
368
         * @since 1.9.0
369
         * @param string $title_classes defaults to $post_type-title
370
         */
371
        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
372
373
        $html= '';
374
        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
375
        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
376
        $html .= $post->post_title ;
377
        $html .= '</a>';
378
        $html .= '</'. $title_html_tag. '>';
379
        echo $html;
380
381
    }// end the title
382
383
    /**
384
     * This function adds the hooks inside and above the single course content for
385
     * backwards compatibility sake.
386
     *
387
     * @since 1.9.0
388
     * @deprecated 1.9.0
389
     */
390
    public static function deprecated_single_course_inside_before_hooks(){
391
392
        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
393
        sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
394
        sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
395
396
    }// end deprecated_single_course_inside_before_hooks
397
398
    /**
399
     * This function adds the hooks to sensei_course_single_lessons for
400
     * backwards compatibility sake.  and provides developers with an alternative.
401
     *
402
     * @since 1.9.0
403
     * @deprecated 1.9.0
404
     */
405
    public static function deprecate_sensei_course_single_lessons_hook(){
406
407
        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
408
409
    }// deprecate_sensei_course_single_lessons_hook
410
411
    /**
412
     * Deprecated all deprecated_single_main_content_hook hooked actions.
413
     *
414
     * The content must be dealt with inside the respective templates.
415
     *
416
     * @since 1.9.0
417
     * @deprecated 1.9.0
418
     */
419
    public static function deprecated_single_main_content_hook(){
420
421
            if( is_singular( 'course' ) ) {
422
423
                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
424
425
            } elseif( is_singular( 'message' ) ){
426
427
                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
428
            }
429
430
    }// end deprecated_single_course_single_main_content_hook
431
432
    /**
433
     * Deprecate the  old sensei modules
434
     * @since 1.9.0
435
     * @deprecated since 1.9.0
436
     */
437
    public static function deprecate_module_before_hook(){
438
439
        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
440
441
    }
442
443
    /**
444
     * Deprecate the  old sensei modules after hooks
445
     * @since 1.9.0
446
     * @deprecated since 1.9.0
447
     */
448
    public static function deprecate_module_after_hook(){
449
450
        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
451
452
    }
453
454
    /**
455
     * Deprecate the single message hooks for post types.
456
     *
457
     * @since 1.9.0
458
     * @deprecated since 1.9.0
459
     */
460
    public static function deprecate_all_post_type_single_title_hooks(){
461
462
        if( is_singular( 'sensei_message' ) ){
463
464
            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
465
466
        }
467
468
    }
469
470
    /**
471
     * course_single_meta function.
472
     *
473
     * @access public
474
     * @return void
475
     * @deprecated since 1.9.0
476
     */
477
    public static function deprecate_course_single_meta_hooks() {
478
479
        // deprecate all these hooks
480
        sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
481
        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
482
        sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
483
        sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
484
485
    } // End deprecate_course_single_meta_hooks
486
487
    /**
488
     * Run the deprecated hooks on the single lesson page
489
     * @deprecated since 1.9.0
490
     */
491
    public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
492
493
        if( is_singular( 'lesson' ) ){
494
495
            sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
496
            sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
497
498
        }
499
500
    }// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
501
502
    /**
503
     * Deprecate the hook sensei_lesson_course_signup.
504
     *
505
     * The hook content will be linked directly on the recommended
506
     * sensei_single_lesson_content_inside_after
507
     *
508
     * @deprecated since 1.9.0
509
     */
510
    public static function deprecate_sensei_lesson_course_signup_hook(){
511
512
        $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
513
        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
514
515
        if(  !$user_taking_course ) {
516
517
            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
518
519
        }
520
    }// end deprecate_sensei_lesson_course_signup_hook
521
522
    /**
523
     * Running the deprecated hook: sensei_lesson_single_meta
524
     *
525
     * @since 1.9.0
526
     * @deprecated since 1.9.0
527
     */
528
    public static function deprecate_sensei_lesson_single_meta_hook(){
529
530
        if ( sensei_can_user_view_lesson()  ) {
531
532
            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
533
534
535
        }
536
537
    }// end deprecate_sensei_lesson_single_meta_hook
538
539
    /**
540
     * Deprecate the sensei lesson single title hook
541
     * @deprecated since 1.9.0
542
     */
543
    public static function deprecate_sensei_lesson_single_title(){
544
545
        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
546
547
    }// end deprecate_sensei_lesson_single_title
548
549
    /**
550
     * hook in the deperecated single main content to the lesson
551
     * @deprecated since 1.9.0
552
     */
553
    public  static function deprecate_lesson_single_main_content_hook(){
554
555
        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
556
557
    }// end sensei_deprecate_lesson_single_main_content_hook
558
559
    /**
560
     * hook in the deperecated single main content to the lesson
561
     * @deprecated since 1.9.0
562
     */
563
    public  static function deprecate_lesson_image_hook(){
564
565
        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
566
567
    }// end sensei_deprecate_lesson_single_main_content_hook
568
569
    /**
570
     * hook in the deprecated sensei_login_form hook for backwards
571
     * compatibility
572
     *
573
     * @since 1.9.0
574
     * @deprecated since 1.9.0
575
     */
576
    public static function deprecate_sensei_login_form_hook(){
577
578
        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
579
580
    } // end deprecate_sensei_login_form_hook
581
582
    /**
583
     * Fire the sensei_complete_course action.
584
     *
585
     * This is just a backwards compatible function to add the action
586
     * to a template. This should not be used as the function from this
587
     * hook will be added directly to my-courses page via one of the hooks there.
588
     *
589
     * @since 1.9.0
590
     */
591
    public static function  fire_sensei_complete_course_hook(){
592
593
        do_action( 'sensei_complete_course' );
594
595
    } //fire_sensei_complete_course_hook
596
597
    /**
598
     * Fire the frontend message hook
599
     *
600
     * @since 1.9.0
601
     */
602
    public static function  fire_frontend_messages_hook(){
603
604
        do_action( 'sensei_frontend_messages' );
605
606
    }// end sensei_complete_course_action
607
608
    /**
609
     * deprecate the sensei_before_user_course_content hook in favor
610
     * of sensei_my_courses_content_inside_before.
611
     *
612
     * @deprected since 1.9.0
613
     */
614
    public static function  deprecate_sensei_before_user_course_content_hook(){
615
616
        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
617
618
    }// deprecate_sensei_before_user_course_content_hook
619
620
    /**
621
     * deprecate the sensei_before_user_course_content hook in favor
622
     * of sensei_my_courses_content_inside_after hook.
623
     *
624
     * @deprected since 1.9.0
625
     */
626
    public static function  deprecate_sensei_after_user_course_content_hook(){
627
628
        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
629
630
    }// deprecate_sensei_after_user_course_content_hook
631
632
    /**
633
     * Deprecate the 2 main hooks on the archive message template
634
     *
635
     * @deprecated since 1.9.0
636
     * @since 1.9.0
637
     */
638
    public static function deprecated_archive_message_hooks (){
639
640
        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
641
        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
642
643
    }
644
645
    /**
646
     * Run the sensei_complete_quiz for those still hooking
647
     * into but deprecated it.
648
     *
649
     * @deprecated since 1.9.0
650
     */
651
    public static function deprecate_sensei_complete_quiz_action(){
652
653
        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
654
655
    }
656
657
    /**
658
     * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
659
     * it to provide user with a better alternative.
660
     *
661
     * @deprecated since 1.9.0
662
     */
663
    public static function deprecate_sensei_quiz_question_type_action(){
664
665
        // Question Type
666
        global $sensei_question_loop;
667
        $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
668
        sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
669
670
    }
671
672
673
	public static function the_register_button( $post_id = "" ){
674
675
		global $current_user, $post;
676
677
		if ( ! get_option('users_can_register')
678
		     || 'course' != get_post_type( $post_id )
679
		     || ! empty( $current_user->caps )
680
		     || ! Sensei()->settings->get('access_permission')  ) {
681
682
			return;
683
684
		}
685
686
		// if user is not logged in skipped for single lesson
687
688
		// show a link to the my_courses page or the WordPress register page if
689
		// not my courses page was set in the settings
690 View Code Duplication
		if( !empty( $my_courses_page_id ) && $my_courses_page_id ){
691
692
			$my_courses_url = get_permalink( $my_courses_page_id  );
693
			$register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
694
			echo '<div class="status register">' . $register_link . '</div>' ;
695
696
		} else{
697
698
			wp_register( '<div class="status register">', '</div>' );
699
700
		}
701
702
	}
703
}//end class
704