| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
** Use Custom Templates |
| 5 |
*/ |
| 6 |
|
| 7 |
add_filter( 'template_include', 'wpc_single_lesson_page_template', 99 ); |
| 8 |
function wpc_single_lesson_page_template( $template ) |
| 9 |
{ |
| 10 |
if ( get_post_type() == 'lesson' && is_single() ) { |
| 11 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/single-lesson.php'; |
| 12 |
if ( !empty( $new_template ) ) { |
| 13 |
return $new_template; |
| 14 |
} |
| 15 |
} else { |
| 16 |
return $template; |
| 17 |
} |
| 18 |
} |
| 19 |
add_filter( 'template_include', 'wpc_archive_lesson_page_template', 99 ); |
| 20 |
function wpc_archive_lesson_page_template( $template ) |
| 21 |
{ |
| 22 |
if ( is_post_type_archive( 'lesson' ) && get_post_type() == 'lesson' ) { |
| 23 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/archive-lesson.php'; |
| 24 |
if ( !empty( $new_template ) ) { |
| 25 |
return $new_template; |
| 26 |
} |
| 27 |
} else { |
| 28 |
return $template; |
| 29 |
} |
| 30 |
} |
| 31 |
add_filter( 'template_include', 'wpc_archive_course_page_template', 99 ); |
| 32 |
function wpc_archive_course_page_template( $template ) |
| 33 |
{ |
| 34 |
if ( is_post_type_archive( 'course' ) && get_post_type() == 'course') { |
| 35 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/archive-course.php'; |
| 36 |
if ( !empty( $new_template ) ) { |
| 37 |
return $new_template; |
| 38 |
} |
| 39 |
} else { |
| 40 |
return $template; |
| 41 |
} |
| 42 |
} |
| 43 |
add_filter( 'template_include', 'wpc_single_course_page_template', 99 ); |
| 44 |
function wpc_single_course_page_template( $template ) |
| 45 |
{ |
| 46 |
if ( is_single() && get_post_type() == 'course') { |
| 47 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/single-course.php'; |
| 48 |
if ( !empty( $new_template ) ) { |
| 49 |
return $new_template; |
| 50 |
} |
| 51 |
} else { |
| 52 |
return $template; |
| 53 |
} |
| 54 |
} |
| 55 |
add_filter( 'template_include', 'wpc_archive_teacher_page_template', 99 ); |
| 56 |
function wpc_archive_teacher_page_template( $template ) |
| 57 |
{ |
| 58 |
if ( is_post_type_archive( 'teacher' )) { |
| 59 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/archive-teacher.php'; |
| 60 |
//$new_template = locate_template( array( '/templates/wpc-single-lesson.php' ) ); |
| 61 |
if ( !empty( $new_template ) ) { |
| 62 |
return $new_template; |
| 63 |
} |
| 64 |
} else { |
| 65 |
return $template; |
| 66 |
} |
| 67 |
} |
| 68 |
add_filter( 'template_include', 'wpc_course_category_page_template', 9 ); |
| 69 |
function wpc_course_category_page_template( $template ) |
| 70 |
{ |
| 71 |
if ( is_tax() == 'course-category' && get_post_type() == 'course') { |
| 72 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/category-course.php'; |
| 73 |
//$new_template = locate_template( array( '/templates/wpc-single-lesson.php' ) ); |
| 74 |
if ( !empty( $new_template ) ) { |
| 75 |
return $new_template; |
| 76 |
} |
| 77 |
} else { |
| 78 |
return $template; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
add_filter( 'template_include', 'wpc_single_quiz_page_template_shim', 100 ); |
| 83 |
function wpc_single_quiz_page_template_shim( $template ) |
| 84 |
{ |
| 85 |
if ( get_post_type() == 'wpc-quiz' && is_single() ) { |
| 86 |
$new_template = wpc_dirname_r( __FILE__, 2 ) . '/templates/single-quiz.php'; |
| 87 |
if ( !empty( $new_template ) ) { |
| 88 |
return $new_template; |
| 89 |
} |
| 90 |
} else { |
| 91 |
return $template; |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
?> |