lightspeeddevelopment /
lsx
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * LSX Sensei Lesson Class |
||
| 4 | * |
||
| 5 | * @package lsx |
||
| 6 | * @subpackage sensei |
||
| 7 | */ |
||
| 8 | |||
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
||
| 10 | exit; // Exit if accessed directly. |
||
| 11 | } |
||
| 12 | |||
| 13 | /** |
||
| 14 | * LSX Sensei Lesson Class |
||
| 15 | */ |
||
| 16 | class LSX_Sensei_Lesson { |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Instance of class. |
||
| 20 | * |
||
| 21 | * @var self |
||
| 22 | */ |
||
| 23 | private static $instance; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Constructor. |
||
| 27 | */ |
||
| 28 | public function __construct() { |
||
| 29 | add_action( 'init', array( $this, 'init' ) ); |
||
| 30 | add_action( 'widgets_init', array( $this, 'lsx_widget_area_sensei_init' ), 100 ); |
||
| 31 | add_filter( 'body_class', array( $this, 'lsx_widget_area_sensei_is_active' ) ); |
||
| 32 | } // End __construct() |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Fetches an instance of the class. |
||
| 36 | * |
||
| 37 | * @return self |
||
| 38 | */ |
||
| 39 | public static function instance() { |
||
| 40 | if ( ! self::$instance ) { |
||
| 41 | self::$instance = new self(); |
||
| 42 | } |
||
| 43 | return self::$instance; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Run our changes. |
||
| 48 | */ |
||
| 49 | public function init() { |
||
| 50 | add_action( 'lsx_content_top', array( $this, 'lsx_sensei_lesson_sidebar' ) ); |
||
| 51 | |||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Register a sidebar when Sensei Participants or Sensei Progress plugins are active. |
||
| 56 | * |
||
| 57 | * @return void |
||
| 58 | */ |
||
| 59 | public function lsx_widget_area_sensei_init() { |
||
| 60 | View Code Duplication | if ( class_exists( 'Sensei_Course_Participants' ) || class_exists( 'Sensei_Course_Progress' ) ) { |
|
| 61 | register_sidebar( array( |
||
| 62 | 'name' => esc_html__( 'LSX Sensei Sidebar', 'lsx' ), |
||
| 63 | 'id' => 'lsx-sensei-sidebar', |
||
| 64 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
||
| 65 | 'after_widget' => '</aside>', |
||
| 66 | 'before_title' => '<h3 class="widget-title">', |
||
| 67 | 'after_title' => '</h3>', |
||
| 68 | ) ); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Widget Area for sensei. |
||
| 74 | * |
||
| 75 | * @param [type] $classes |
||
|
0 ignored issues
–
show
|
|||
| 76 | * @return classes |
||
| 77 | */ |
||
| 78 | public function lsx_widget_area_sensei_is_active( $classes ) { |
||
| 79 | |||
| 80 | if ( class_exists( 'Sensei_Lesson' ) && is_active_sidebar( 'lsx-sensei-sidebar' ) ) { |
||
| 81 | $classes[] = 'lsx-sensei-sidebar-active'; |
||
| 82 | } |
||
| 83 | |||
| 84 | return $classes; |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Adds the widget content to the lesson template if the lsx-sensei-sidebar is active. |
||
| 89 | * |
||
| 90 | * @return void |
||
| 91 | */ |
||
| 92 | public function lsx_sensei_lesson_sidebar() { |
||
| 93 | if ( class_exists( 'Sensei_Lesson' ) && ( class_exists( 'Sensei_Course_Participants' ) || class_exists( 'Sensei_Course_Progress' ) ) ) { |
||
| 94 | if ( ( is_single() && ( is_singular( 'lesson' ) ) ) || ( is_single() && ( is_singular( 'quiz' ) ) ) ) { |
||
| 95 | if ( is_active_sidebar( 'lsx-sensei-sidebar' ) ) { |
||
| 96 | echo '<div id="secondary" class="widget-area lsx-sensei-sidebar">'; |
||
| 97 | dynamic_sidebar( 'lsx-sensei-sidebar' ); |
||
| 98 | echo '</div>'; |
||
| 99 | } |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | } // End Class |
||
| 105 | new LSX_Sensei_Lesson(); |
||
| 106 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.