1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* LSX Sensei Class |
4
|
|
|
* |
5
|
|
|
* @package lsx |
6
|
|
|
* @subpackage sensei |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
10
|
|
|
exit; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
if ( ! class_exists( 'LSX_Sensei' ) ) : |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The LSX Sensei integration class |
17
|
|
|
*/ |
18
|
|
|
class LSX_Sensei { |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Holds class instance |
22
|
|
|
* |
23
|
|
|
* @since 1.0.0 |
24
|
|
|
* @var object |
25
|
|
|
*/ |
26
|
|
|
protected static $instance = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Holds the LSX_Sensei_Course() variable. |
30
|
|
|
* |
31
|
|
|
* @var LSX_Sensei_Course() |
32
|
|
|
*/ |
33
|
|
|
public $lsx_sensei_course = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Holds the LSX_Sensei_Lesson() variable. |
37
|
|
|
* |
38
|
|
|
* @var LSX_Sensei_Lesson() |
39
|
|
|
*/ |
40
|
|
|
public $lsx_sensei_lesson = false; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Setup class. |
44
|
|
|
* |
45
|
|
|
* @since 1.0 |
46
|
|
|
*/ |
47
|
|
|
public function __construct() { |
48
|
|
|
$this->lsx_sensei_course = require_once get_template_directory() . '/includes/sensei/class-lsx-sensei-course.php'; |
49
|
|
|
$this->lsx_sensei_lesson = require_once get_template_directory() . '/includes/sensei/class-lsx-sensei-lesson.php'; |
50
|
|
|
|
51
|
|
|
global $woothemes_sensei; |
52
|
|
|
|
53
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'lsx_sensei_scripts_add_styles' ) ); |
54
|
|
|
|
55
|
|
|
remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 ); |
56
|
|
|
add_action( 'sensei_before_main_content', array( $this, 'lsx_sensei_theme_wrapper_start' ) ); |
57
|
|
|
|
58
|
|
|
remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 ); |
59
|
|
|
add_action( 'sensei_after_main_content', array( $this, 'lsx_sensei_theme_wrapper_end' ) ); |
60
|
|
|
|
61
|
|
|
add_filter( 'get_the_archive_title', array( $this, 'lsx_sensei_modify_archive_title' ), 99, 1 ); |
62
|
|
|
|
63
|
|
|
// LSX |
64
|
|
|
add_filter( 'lsx_global_header_disable', array( $this, 'lsx_sensei_disable_lsx_banner' ) ); |
65
|
|
|
// LSX Banners - Plugin, Placeholders |
66
|
|
|
add_filter( 'lsx_banner_plugin_disable', array( $this, 'lsx_sensei_disable_lsx_banner' ) ); |
67
|
|
|
// LSX Banners - Banner |
68
|
|
|
add_filter( 'lsx_banner_disable', array( $this, 'lsx_sensei_disable_lsx_banner' ) ); |
69
|
|
|
|
70
|
|
|
add_filter( 'course_archive_title', array( $this, 'lsx_sensei_archive_title' ), 10, 1 ); |
71
|
|
|
add_filter( 'sensei_lesson_archive_title', array( $this, 'lsx_sensei_archive_title' ), 10, 1 ); |
72
|
|
|
|
73
|
|
|
add_filter( 'course_category_title', array( $this, 'lsx_sensei_category_title' ), 10, 1 ); |
74
|
|
|
|
75
|
|
|
add_action( 'sensei_course_content_inside_after', array( $this, 'lsx_sensei_add_buttons' ), 9 ); |
76
|
|
|
|
77
|
|
|
add_filter( 'sensei_wc_single_add_to_cart_button_text', array( $this, 'lsx_sensei_add_to_cart_text' ) ); |
78
|
|
|
|
79
|
|
|
add_action( 'lsx_content_wrap_before', array( $this, 'lsx_sensei_results_header' ) ); |
80
|
|
|
|
81
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_course_breadcrumb_filter' ), 40, 1 ); |
82
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_course_breadcrumb_filter' ), 40, 1 ); |
83
|
|
|
|
84
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_lesson_breadcrumb_filter' ), 40, 1 ); |
85
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_lesson_breadcrumb_filter' ), 40, 1 ); |
86
|
|
|
|
87
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_module_breadcrumb_filter' ), 40, 1 ); |
88
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_module_breadcrumb_filter' ), 40, 1 ); |
89
|
|
|
|
90
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_learner_breadcrumb_filter' ), 40, 1 ); |
91
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_learner_breadcrumb_filter' ), 40, 1 ); |
92
|
|
|
|
93
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_quiz_breadcrumb_filter' ), 40, 1 ); |
94
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_quiz_breadcrumb_filter' ), 40, 1 ); |
95
|
|
|
|
96
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_messages_breadcrumb_filter' ), 40, 1 ); |
97
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_messages_breadcrumb_filter' ), 40, 1 ); |
98
|
|
|
|
99
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'lsx_sensei_results_breadcrumb_filter' ), 40, 1 ); |
100
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'lsx_sensei_results_breadcrumb_filter' ), 40, 1 ); |
101
|
|
|
|
102
|
|
|
add_action( 'sensei_archive_before_message_loop', array( $this, 'lsx_sensei_back_message_button' ) ); |
103
|
|
|
add_action( 'sensei_content_message_after', array( $this, 'lsx_sensei_view_message_button' ) ); |
104
|
|
|
|
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Return an instance of this class. |
109
|
|
|
* |
110
|
|
|
* @since 1.0.0 |
111
|
|
|
* @return object A single instance of this class. |
112
|
|
|
*/ |
113
|
|
|
public static function get_instance() { |
114
|
|
|
// If the single instance hasn't been set, set it now. |
115
|
|
|
if ( null === self::$instance ) { |
116
|
|
|
self::$instance = new self; |
117
|
|
|
} |
118
|
|
|
return self::$instance; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Sensei enqueue styles. |
123
|
|
|
* |
124
|
|
|
* @package lsx |
125
|
|
|
* @subpackage sensei |
126
|
|
|
*/ |
127
|
|
|
public function lsx_sensei_scripts_add_styles() { |
128
|
|
|
wp_enqueue_style( 'sensei-lsx', get_template_directory_uri() . '/assets/css/sensei/sensei.css', array( 'lsx_main' ), LSX_VERSION ); |
129
|
|
|
wp_style_add_data( 'sensei-lsx', 'rtl', 'replace' ); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Sensei wrapper start. |
134
|
|
|
* |
135
|
|
|
* @package lsx |
136
|
|
|
* @subpackage sensei |
137
|
|
|
*/ |
138
|
|
|
public function lsx_sensei_theme_wrapper_start() { |
139
|
|
|
lsx_content_wrap_before(); |
140
|
|
|
echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">'; |
141
|
|
|
lsx_content_before(); |
142
|
|
|
echo '<main id="main" class="site-main" role="main">'; |
143
|
|
|
lsx_content_top(); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Sensei wrapper end. |
148
|
|
|
* |
149
|
|
|
* @package lsx |
150
|
|
|
* @subpackage sensei |
151
|
|
|
*/ |
152
|
|
|
public function lsx_sensei_theme_wrapper_end() { |
153
|
|
|
lsx_content_bottom(); |
154
|
|
|
echo '</main>'; |
155
|
|
|
lsx_content_after(); |
156
|
|
|
echo '</div>'; |
157
|
|
|
lsx_content_wrap_after(); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Remove "Archives:" from the courses archive title. |
162
|
|
|
* |
163
|
|
|
* @param [type] $title |
|
|
|
|
164
|
|
|
* @return void |
165
|
|
|
*/ |
166
|
|
|
public function lsx_sensei_modify_archive_title( $title ) { |
167
|
|
|
if ( is_archive() && is_post_type_archive( 'course' ) ) { |
168
|
|
|
$title = __( 'Courses', 'lsx' ); |
169
|
|
|
} |
170
|
|
|
if ( is_archive() && is_post_type_archive( 'sensei_message' ) ) { |
171
|
|
|
$title = __( 'Messages', 'lsx' ); |
172
|
|
|
} |
173
|
|
|
if ( is_archive() && is_post_type_archive( 'lesson' ) ) { |
174
|
|
|
$title = __( 'Lessons', 'lsx' ); |
175
|
|
|
} |
176
|
|
|
if ( is_archive() && is_tax() ) { |
177
|
|
|
$title = single_term_title( '', false ); |
178
|
|
|
} |
179
|
|
|
return $title; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Disable LSX Banners in some Sensei pages. |
184
|
|
|
* |
185
|
|
|
* @package lsx |
186
|
|
|
* @subpackage sensei |
187
|
|
|
*/ |
188
|
|
|
public function lsx_sensei_disable_lsx_banner( $disabled ) { |
189
|
|
|
if ( is_sensei() ) { |
190
|
|
|
$disabled = true; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
return $disabled; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Filters the archive title. |
198
|
|
|
* |
199
|
|
|
* @package lsx |
200
|
|
|
* @subpackage sensei |
201
|
|
|
*/ |
202
|
|
|
public function lsx_sensei_archive_title( $html ) { |
203
|
|
|
$html = preg_replace( '/<header class="archive-header"><h1>([^<]+)<\/h1><\/header>/i', '<h1>$1</h1>', $html ); |
204
|
|
|
return $html; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Filters the archive title. |
209
|
|
|
* |
210
|
|
|
* @package lsx |
211
|
|
|
* @subpackage sensei |
212
|
|
|
*/ |
213
|
|
|
public function lsx_sensei_category_title( $html ) { |
214
|
|
|
$html = str_replace( 'h2', 'h1', $html ); |
215
|
|
|
return $html; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Add extra buttons to the single view on lists. |
220
|
|
|
* |
221
|
|
|
* @package lsx |
222
|
|
|
* @subpackage sensei |
223
|
|
|
*/ |
224
|
|
|
public function lsx_sensei_add_buttons( $course_id ) { |
|
|
|
|
225
|
|
|
global $post, $current_user; |
226
|
|
|
$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
227
|
|
|
if ( class_exists( 'Sensei_WC' ) ) { |
228
|
|
|
$course_purchasable = Sensei_WC::is_course_purchasable( $post->ID ); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
?> |
232
|
|
|
<section class="entry-actions"> |
233
|
|
|
<?php |
234
|
|
|
if ( ( ! $is_user_taking_course ) && $course_purchasable ) { |
|
|
|
|
235
|
|
|
Sensei_WC::the_add_to_cart_button_html( $post->ID ); |
236
|
|
|
} |
237
|
|
|
?> |
238
|
|
|
</section> |
239
|
|
|
<?php |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* Change add to cart button text. |
244
|
|
|
* |
245
|
|
|
* @package lsx |
246
|
|
|
* @subpackage sensei |
247
|
|
|
*/ |
248
|
|
|
public function lsx_sensei_add_to_cart_text( $text ) { |
|
|
|
|
249
|
|
|
$text = esc_html__( 'Add to cart', 'lsx' ); |
250
|
|
|
return $text; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Displays the Results header. |
255
|
|
|
* |
256
|
|
|
* @package lsx |
257
|
|
|
* @subpackage layout |
258
|
|
|
*/ |
259
|
|
|
public function lsx_sensei_results_header( $user ) { |
|
|
|
|
260
|
|
|
|
261
|
|
|
$default_size = 'sm'; |
262
|
|
|
$size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
263
|
|
|
global $wp_query; |
264
|
|
|
if ( isset( $wp_query->query_vars['course_results'] ) ) { |
265
|
|
|
$is_results = $wp_query->query_vars['course_results']; |
266
|
|
|
} else { |
267
|
|
|
$is_results = false; |
268
|
|
|
} |
269
|
|
View Code Duplication |
if ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
|
|
|
270
|
|
|
$is_profile = $wp_query->query_vars['learner_profile']; |
271
|
|
|
} else { |
272
|
|
|
$is_profile = false; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
if ( is_sticky() && $is_results ) : |
276
|
|
|
$course_for_results = get_page_by_path( $is_results, OBJECT, 'course' ); |
277
|
|
|
|
278
|
|
|
$course_title = esc_html( $course_for_results->post_title ); |
279
|
|
|
?> |
280
|
|
|
<div class="archive-header-wrapper banner-single col-<?php echo esc_attr( $size ); ?>-12"> |
281
|
|
|
<?php lsx_global_header_inner_bottom(); ?> |
282
|
|
|
<header class="archive-header"> |
283
|
|
|
<h1 class="archive-title"><?php echo wp_kses_post( $course_title ); ?></h1> |
284
|
|
|
</header> |
285
|
|
|
|
286
|
|
|
</div> |
287
|
|
|
<?php |
288
|
|
|
endif; |
289
|
|
|
|
290
|
|
|
if ( is_sticky() && $is_profile ) : |
291
|
|
|
$query_var = $wp_query->query_vars['learner_profile']; |
292
|
|
|
$learner_user = Sensei_Learner::find_by_query_var( $query_var ); |
293
|
|
|
$learner_name = $learner_user->display_name; |
294
|
|
|
?> |
295
|
|
|
<div class="archive-header-wrapper banner-single col-<?php echo esc_attr( $size ); ?>-12"> |
296
|
|
|
<?php lsx_global_header_inner_bottom(); ?> |
297
|
|
|
<header class="archive-header"> |
298
|
|
|
<h1 class="archive-title"><?php echo esc_html( $learner_name ); ?></h1> |
299
|
|
|
</header> |
300
|
|
|
|
301
|
|
|
</div> |
302
|
|
|
<?php |
303
|
|
|
endif; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Add the Parent Course link to the course breadcrumbs |
308
|
|
|
* @param $crumbs |
309
|
|
|
* @return array |
310
|
|
|
*/ |
311
|
|
|
public function lsx_sensei_course_breadcrumb_filter( $crumbs, $id = 0 ) { |
|
|
|
|
312
|
|
|
if ( is_single() && ( is_singular( 'course' ) ) ) { |
313
|
|
|
global $course; |
314
|
|
|
$lesson = get_the_title(); |
315
|
|
|
$course_page_url = intval( Sensei()->settings->settings['course_page'] ); |
316
|
|
|
$course_page_url = get_permalink( $course_page_url ); |
317
|
|
|
|
318
|
|
|
if ( $lesson ) { |
319
|
|
|
|
320
|
|
|
$new_crumbs = array(); |
321
|
|
|
$new_crumbs[0] = $crumbs[0]; |
322
|
|
|
|
323
|
|
View Code Duplication |
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
324
|
|
|
$new_crumbs[1] = array( |
325
|
|
|
0 => __( 'All Courses', 'lsx' ), |
326
|
|
|
1 => $course_page_url, |
327
|
|
|
); |
328
|
|
|
$new_crumbs[2] = array( |
329
|
|
|
0 => $lesson, |
330
|
|
|
); |
331
|
|
|
} else { |
332
|
|
|
$new_crumbs[1] = array( |
333
|
|
|
'text' => __( 'All Courses', 'lsx' ), |
334
|
|
|
'url' => $course_page_url, |
335
|
|
|
); |
336
|
|
|
$new_crumbs[2] = array( |
337
|
|
|
'text' => $lesson, |
338
|
|
|
); |
339
|
|
|
} |
340
|
|
|
$crumbs = $new_crumbs; |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
return $crumbs; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Add the Parent Course link to the lessons breadcrumbs |
348
|
|
|
* @param $crumbs |
349
|
|
|
* @return array |
350
|
|
|
*/ |
351
|
|
|
public function lsx_sensei_lesson_breadcrumb_filter( $crumbs, $id = 0 ) { |
352
|
|
View Code Duplication |
if ( is_sensei() && is_single() && ( is_singular( 'lesson' ) ) ) { |
|
|
|
|
353
|
|
|
global $course; |
354
|
|
|
$lesson = get_the_title(); |
355
|
|
|
$course_page_url = intval( Sensei()->settings->settings['course_page'] ); |
356
|
|
|
$course_page_url = get_permalink( $course_page_url ); |
357
|
|
|
|
358
|
|
|
if ( empty( $id ) ) { |
359
|
|
|
$id = get_the_ID(); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
if ( 0 < intval( $id ) ) { |
363
|
|
|
$course = intval( get_post_meta( $id, '_lesson_course', true ) ); |
364
|
|
|
$course_id = esc_url( get_permalink( $course ) ); |
365
|
|
|
$course_title = esc_html( get_the_title( $course ) ); |
366
|
|
|
if ( ! $course ) { |
367
|
|
|
return; |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
if ( $course_id ) { |
372
|
|
|
|
373
|
|
|
$new_crumbs = array(); |
374
|
|
|
$new_crumbs[0] = $crumbs[0]; |
375
|
|
|
|
376
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
377
|
|
|
$new_crumbs[1] = array( |
378
|
|
|
0 => __( 'Courses', 'lsx' ), |
379
|
|
|
1 => $course_page_url, |
380
|
|
|
); |
381
|
|
|
$new_crumbs[2] = array( |
382
|
|
|
0 => $course_title, |
|
|
|
|
383
|
|
|
1 => $course_id, |
|
|
|
|
384
|
|
|
); |
385
|
|
|
$new_crumbs[3] = array( |
386
|
|
|
0 => $lesson, |
387
|
|
|
); |
388
|
|
|
} else { |
389
|
|
|
$new_crumbs[1] = array( |
390
|
|
|
'text' => __( 'Courses', 'lsx' ), |
391
|
|
|
'url' => $course_page_url, |
392
|
|
|
); |
393
|
|
|
$new_crumbs[2] = array( |
394
|
|
|
'text' => $course_title, |
395
|
|
|
'url' => $course_id, |
396
|
|
|
); |
397
|
|
|
$new_crumbs[3] = array( |
398
|
|
|
'text' => $lesson, |
399
|
|
|
); |
400
|
|
|
} |
401
|
|
|
$crumbs = $new_crumbs; |
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
return $crumbs; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* Add the Parent Course link to the module breadcrumbs |
409
|
|
|
* @param $crumbs |
410
|
|
|
* @return array |
411
|
|
|
*/ |
412
|
|
|
public function lsx_sensei_module_breadcrumb_filter( $crumbs, $id = 0 ) { |
413
|
|
|
if ( ! empty( get_queried_object()->name ) ) { |
414
|
|
|
$title = apply_filters( 'sensei_module_archive_title', get_queried_object()->name ); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
if ( is_sensei() && is_tax() && is_archive() && ( ! empty( $title ) ) ) { |
418
|
|
|
|
419
|
|
|
$lesson = get_the_archive_title(); |
420
|
|
|
$course_page_url = intval( Sensei()->settings->settings['course_page'] ); |
421
|
|
|
$course_page_url = get_permalink( $course_page_url ); |
422
|
|
|
|
423
|
|
|
if ( empty( $id ) ) { |
424
|
|
|
$id = get_the_ID(); |
|
|
|
|
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
$new_crumbs = array(); |
428
|
|
|
$new_crumbs[0] = $crumbs[0]; |
429
|
|
|
|
430
|
|
View Code Duplication |
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
431
|
|
|
$new_crumbs[1] = array( |
432
|
|
|
0 => __( 'Courses', 'lsx' ), |
433
|
|
|
1 => $course_page_url, |
434
|
|
|
); |
435
|
|
|
$new_crumbs[2] = array( |
436
|
|
|
0 => $lesson, |
437
|
|
|
); |
438
|
|
|
} else { |
439
|
|
|
$new_crumbs[1] = array( |
440
|
|
|
'text' => __( 'Courses', 'lsx' ), |
441
|
|
|
'url' => $course_page_url, |
442
|
|
|
); |
443
|
|
|
$new_crumbs[2] = array( |
444
|
|
|
'text' => $lesson, |
445
|
|
|
); |
446
|
|
|
} |
447
|
|
|
$crumbs = $new_crumbs; |
448
|
|
|
} |
449
|
|
|
return $crumbs; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Add the Parent Course link to the Learner breadcrumbs |
454
|
|
|
* @param $crumbs |
455
|
|
|
* @return array |
456
|
|
|
*/ |
457
|
|
|
public function lsx_sensei_learner_breadcrumb_filter( $crumbs, $id = 0 ) { |
458
|
|
|
global $wp_query; |
459
|
|
|
|
460
|
|
View Code Duplication |
if ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
|
|
|
461
|
|
|
$is_profile = $wp_query->query_vars['learner_profile']; |
462
|
|
|
} else { |
463
|
|
|
$is_profile = false; |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
if ( is_sticky() && $is_profile ) { |
467
|
|
|
|
468
|
|
|
if ( empty( $id ) ) { |
469
|
|
|
$id = get_the_ID(); |
|
|
|
|
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
$query_var = $wp_query->query_vars['learner_profile']; |
473
|
|
|
$learner_user = Sensei_Learner::find_by_query_var( $query_var ); |
474
|
|
|
$learner_name = $learner_user->display_name; |
475
|
|
|
|
476
|
|
|
$new_crumbs = array(); |
477
|
|
|
$new_crumbs[0] = $crumbs[0]; |
478
|
|
|
|
479
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
480
|
|
|
$new_crumbs[1] = array( |
481
|
|
|
0 => __( 'Learners', 'lsx' ), |
482
|
|
|
); |
483
|
|
|
$new_crumbs[2] = array( |
484
|
|
|
0 => $learner_name, |
485
|
|
|
); |
486
|
|
|
} else { |
487
|
|
|
$new_crumbs[1] = array( |
488
|
|
|
'text' => __( 'Learners', 'lsx' ), |
489
|
|
|
); |
490
|
|
|
$new_crumbs[2] = array( |
491
|
|
|
'text' => $learner_name, |
492
|
|
|
); |
493
|
|
|
} |
494
|
|
|
$crumbs = $new_crumbs; |
495
|
|
|
} |
496
|
|
|
return $crumbs; |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* Add the Parent Course link to the messages breadcrumbs |
501
|
|
|
* @param $crumbs |
502
|
|
|
* @return array |
503
|
|
|
*/ |
504
|
|
|
public function lsx_sensei_messages_breadcrumb_filter( $crumbs, $id = 0 ) { |
505
|
|
|
if ( is_archive() && ( is_post_type_archive( 'sensei_message' ) ) ) { |
506
|
|
|
|
507
|
|
|
$course_page_url = intval( Sensei()->settings->settings['course_page'] ); |
508
|
|
|
$course_page_url = get_permalink( $course_page_url ); |
509
|
|
|
|
510
|
|
|
if ( empty( $id ) ) { |
511
|
|
|
$id = get_the_ID(); |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
if ( $id ) { |
515
|
|
|
|
516
|
|
|
$new_crumbs = array(); |
517
|
|
|
$new_crumbs[0] = $crumbs[0]; |
518
|
|
|
|
519
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
520
|
|
|
$new_crumbs[1] = array( |
521
|
|
|
0 => __( 'Courses', 'lsx' ), |
522
|
|
|
1 => $course_page_url, |
523
|
|
|
); |
524
|
|
|
$new_crumbs[2] = array( |
525
|
|
|
0 => __( 'Messages', 'lsx' ), |
526
|
|
|
); |
527
|
|
|
} else { |
528
|
|
|
$new_crumbs[1] = array( |
529
|
|
|
'text' => __( 'Courses', 'lsx' ), |
530
|
|
|
'url' => $course_page_url, |
531
|
|
|
); |
532
|
|
|
$new_crumbs[2] = array( |
533
|
|
|
'text' => __( 'Messages', 'lsx' ), |
534
|
|
|
); |
535
|
|
|
} |
536
|
|
|
$crumbs = $new_crumbs; |
537
|
|
|
} |
538
|
|
|
} |
539
|
|
|
return $crumbs; |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* Add the Parent Course link to the quiz breadcrumbs |
544
|
|
|
* @param $crumbs |
545
|
|
|
* @return array |
546
|
|
|
*/ |
547
|
|
|
public function lsx_sensei_quiz_breadcrumb_filter( $crumbs, $id = 0 ) { |
548
|
|
View Code Duplication |
if ( ( is_single() && ( is_singular( 'quiz' ) ) ) ) { |
|
|
|
|
549
|
|
|
global $course; |
550
|
|
|
$course_page_url = intval( Sensei()->settings->settings['course_page'] ); |
551
|
|
|
$course_page_url = get_permalink( $course_page_url ); |
552
|
|
|
$lesson = get_the_title(); |
553
|
|
|
|
554
|
|
|
if ( empty( $id ) ) { |
555
|
|
|
$id = get_the_ID(); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
if ( 0 < intval( $id ) ) { |
559
|
|
|
|
560
|
|
|
$course = intval( get_post_meta( $id, '_quiz_lesson', true ) ); |
561
|
|
|
$course_id = esc_url( get_permalink( $course ) ); |
562
|
|
|
$course_title = esc_html( get_the_title( $course ) ); |
563
|
|
|
if ( ! $course ) { |
564
|
|
|
return; |
565
|
|
|
} |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
if ( $course_id ) { |
569
|
|
|
|
570
|
|
|
$new_crumbs = array(); |
571
|
|
|
$new_crumbs[0] = $crumbs[0]; |
572
|
|
|
|
573
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
574
|
|
|
$new_crumbs[1] = array( |
575
|
|
|
0 => __( 'Courses', 'lsx' ), |
576
|
|
|
1 => $course_page_url, |
577
|
|
|
); |
578
|
|
|
$new_crumbs[2] = array( |
579
|
|
|
0 => $course_title, |
|
|
|
|
580
|
|
|
1 => $course_id, |
|
|
|
|
581
|
|
|
); |
582
|
|
|
$new_crumbs[3] = array( |
583
|
|
|
0 => $lesson, |
584
|
|
|
); |
585
|
|
|
} else { |
586
|
|
|
$new_crumbs[1] = array( |
587
|
|
|
'text' => __( 'Courses', 'lsx' ), |
588
|
|
|
'url' => $course_page_url, |
589
|
|
|
); |
590
|
|
|
$new_crumbs[2] = array( |
591
|
|
|
'text' => $course_title, |
592
|
|
|
'url' => $course_id, |
593
|
|
|
); |
594
|
|
|
$new_crumbs[3] = array( |
595
|
|
|
'text' => $lesson, |
596
|
|
|
); |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
$crumbs = $new_crumbs; |
600
|
|
|
} |
601
|
|
|
} |
602
|
|
|
return $crumbs; |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
/** |
606
|
|
|
* Add the Parent Course link to the results breadcrumbs |
607
|
|
|
* @param $crumbs |
608
|
|
|
* @return array |
609
|
|
|
*/ |
610
|
|
|
public function lsx_sensei_results_breadcrumb_filter( $crumbs, $id = 0 ) { |
611
|
|
|
if ( is_sticky() ) { |
612
|
|
|
global $wp_query; |
613
|
|
|
$course_id = ''; |
614
|
|
|
if ( isset( $wp_query->query_vars['course_results'] ) ) { |
615
|
|
|
$is_results = $wp_query->query_vars['course_results']; |
616
|
|
|
} |
617
|
|
|
$course_page_url = intval( Sensei()->settings->settings['course_page'] ); |
618
|
|
|
$course_page_url = get_permalink( $course_page_url ); |
619
|
|
|
|
620
|
|
|
if ( empty( $id ) ) { |
621
|
|
|
$id = get_the_ID(); |
|
|
|
|
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
if ( isset( $is_results ) ) { |
625
|
|
|
$course_for_results = get_page_by_path( $is_results, OBJECT, 'course' ); |
626
|
|
|
|
627
|
|
|
$course_id = esc_url( get_permalink( $course_for_results ) ); |
628
|
|
|
$course_title = esc_html( $course_for_results->post_title ); |
629
|
|
|
|
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
if ( $course_id ) { |
633
|
|
|
$new_crumbs = array(); |
634
|
|
|
$new_crumbs[0] = $crumbs[0]; |
635
|
|
|
|
636
|
|
|
if ( $is_results ) { |
|
|
|
|
637
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
638
|
|
|
$new_crumbs[1] = array( |
639
|
|
|
0 => __( 'Courses', 'lsx' ), |
640
|
|
|
1 => $course_page_url, |
641
|
|
|
); |
642
|
|
|
$new_crumbs[2] = array( |
643
|
|
|
0 => $course_title, |
|
|
|
|
644
|
|
|
1 => $course_id, |
645
|
|
|
); |
646
|
|
|
$new_crumbs[3] = array( |
647
|
|
|
0 => __( 'Results', 'lsx' ), |
648
|
|
|
); |
649
|
|
|
} else { |
650
|
|
|
$new_crumbs[1] = array( |
651
|
|
|
'text' => __( 'Courses', 'lsx' ), |
652
|
|
|
'url' => $course_page_url, |
653
|
|
|
); |
654
|
|
|
$new_crumbs[2] = array( |
655
|
|
|
'text' => __( 'Results', 'lsx' ), |
656
|
|
|
); |
657
|
|
|
} |
658
|
|
|
} |
659
|
|
|
$crumbs = $new_crumbs; |
660
|
|
|
} |
661
|
|
|
} |
662
|
|
|
return $crumbs; |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* Show the 'View Message' button on messages. |
667
|
|
|
* |
668
|
|
|
* @param [type] $message_post_id |
|
|
|
|
669
|
|
|
* @return void |
670
|
|
|
*/ |
671
|
|
|
public function lsx_sensei_view_message_button( $message_post_id ) { |
672
|
|
|
$message_link = get_the_permalink( $message_post_id ); |
673
|
|
|
echo '<a href="' . esc_url_raw( $message_link ) . '" class="btn view-msg-btn">' . wp_kses_post( 'View Message', 'lsx' ) . '</a>'; |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* Show the 'Back to My Courses' button on messages. |
678
|
|
|
* |
679
|
|
|
* @param [type] $message_post_id |
|
|
|
|
680
|
|
|
* @return void |
681
|
|
|
*/ |
682
|
|
|
public function lsx_sensei_back_message_button( $courses_link ) { |
|
|
|
|
683
|
|
|
$courses_link = '/my-courses/'; |
684
|
|
|
echo '<a href="' . esc_url_raw( $courses_link ) . '" class="btn border-btn my-courses-btn">' . wp_kses_post( 'My Courses', 'lsx' ) . '</a>'; |
685
|
|
|
} |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
endif; |
689
|
|
|
|
690
|
|
|
LSX_Sensei::get_instance(); |
691
|
|
|
|
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.