1 | <?php |
||
16 | class LSX_Sensei_Course { |
||
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 | } // End __construct() |
||
31 | |||
32 | /** |
||
33 | * Fetches an instance of the class. |
||
34 | * |
||
35 | * @return self |
||
36 | */ |
||
37 | public static function instance() { |
||
38 | if ( ! self::$instance ) { |
||
39 | self::$instance = new self(); |
||
40 | } |
||
41 | return self::$instance; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Run our changes. |
||
46 | */ |
||
47 | public function init() { |
||
48 | global $sensei; |
||
49 | global $woothemes_sensei; |
||
50 | |||
51 | // Switching the course filters and the headers around. |
||
52 | remove_action( 'sensei_archive_before_course_loop', array( 'Sensei_Course', 'archive_header' ), 10, 0 ); |
||
|
|||
53 | remove_action( 'sensei_archive_before_course_loop', array( 'Sensei_Course', 'course_archive_sorting' ) ); |
||
54 | remove_action( 'sensei_archive_before_course_loop', array( 'Sensei_Course', 'course_archive_filters' ) ); |
||
55 | add_action( 'sensei_archive_before_course_loop', array( 'Sensei_Course', 'archive_header' ), 11, 0 ); |
||
56 | add_action( 'sensei_archive_before_course_loop', array( 'Sensei_Course', 'course_archive_sorting' ), 12 ); |
||
57 | add_action( 'sensei_archive_before_course_loop', array( 'Sensei_Course', 'course_archive_filters' ), 12 ); |
||
58 | |||
59 | // First add the thumbnail. |
||
60 | add_action( 'sensei_course_content_inside_before', array( $this, 'get_course_thumbnail' ), 1 ); |
||
61 | |||
62 | // This is for our wrapper, we run it on 2, after the thumbnail we added. |
||
63 | add_action( 'sensei_course_content_inside_before', array( $this, 'course_body_div_open' ), 1 ); |
||
64 | add_action( 'sensei_course_content_inside_after', array( $this, 'course_body_div_close' ), 50 ); |
||
65 | |||
66 | // This is for our wrapper, we run it on 2, after the thumbnail we added. |
||
67 | add_action( 'sensei_course_content_inside_before', array( $this, 'course_body_div_results_open' ), 20 ); |
||
68 | add_action( 'sensei_course_content_inside_after', array( $this, 'course_body_div_results_close' ), 49 ); |
||
69 | |||
70 | add_action( 'sensei_single_course_content_inside_before', array( $this, 'display_course_amount' ), 20 ); |
||
71 | |||
72 | // removes the course image above the content. |
||
73 | remove_action( 'sensei_course_content_inside_before', array( $woothemes_sensei->course, 'course_image' ), 30, 1 ); |
||
74 | // add the course image to the left of the content. |
||
75 | add_action( 'lsx_sensei_course_content_inside_before', array( $woothemes_sensei->course, 'course_image' ), 30, 1 ); |
||
76 | |||
77 | add_filter( 'attach_shortcode_hooks', 'lsx_attach_shortcode_hooks', 10, 1 ); |
||
78 | |||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Gets the current courses thumbnail for content-course.php |
||
83 | * |
||
84 | * @return void |
||
85 | */ |
||
86 | public function get_course_thumbnail() { |
||
87 | ?> |
||
88 | <div class="course-thumbnail"> |
||
89 | <?php do_action( 'lsx_sensei_course_content_inside_before', get_the_ID() ); ?> |
||
90 | </div> |
||
91 | <?php |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * <div class="course-body"> for content-course.php |
||
96 | * |
||
97 | * @return void |
||
98 | */ |
||
99 | public function course_body_div_open() { |
||
100 | global $post, $current_user; |
||
101 | $is_user_taking_course = Sensei_Utils::has_started_course( $post->ID, $current_user->ID ); |
||
102 | $user_taking_course_class = ''; |
||
103 | if ( ! empty( $is_user_taking_course ) ) { |
||
104 | $user_taking_course_class = 'currently-in-course'; |
||
105 | } |
||
106 | ?> |
||
107 | <div class="course-body <?php echo esc_html( $user_taking_course_class ); ?>"> |
||
108 | <?php |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * The closing </div> for <div class="course-body"> content-course.php |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | public function course_body_div_close() { |
||
119 | <?php |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * <div class="course-details-info"> for content-course.php, just for the info after the meta |
||
124 | * |
||
125 | * @return void |
||
126 | */ |
||
127 | public function course_body_div_results_open() { |
||
130 | <?php |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * The closing </div> for <div class="course-details-info"> content-course.php, just for the info after the meta |
||
135 | * |
||
136 | * @return void |
||
137 | */ |
||
138 | public function course_body_div_results_close() { |
||
139 | ?> |
||
140 | </div> |
||
141 | <?php |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Display the course price on a single course. |
||
146 | * |
||
147 | * @return void |
||
148 | */ |
||
149 | public function display_course_amount() { |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 | |||
167 | } // End Class |
||
168 | new LSX_Sensei_Course(); |
||
169 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.