@@ 352-403 (lines=52) @@ | ||
349 | * @return array |
|
350 | */ |
|
351 | public function lsx_sensei_lesson_breadcrumb_filter( $crumbs, $id = 0 ) { |
|
352 | 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 | ||
@@ 548-601 (lines=54) @@ | ||
545 | * @return array |
|
546 | */ |
|
547 | public function lsx_sensei_quiz_breadcrumb_filter( $crumbs, $id = 0 ) { |
|
548 | 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 |