theme-compatibility
5 years ago
tinymce_translate.php
4 years ago
tutor-general-functions.php
4 years ago
tutor-template-functions.php
4 years ago
tutor-template-hook.php
5 years ago
tutor-template-functions.php
1639 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * @param null $template |
| 9 | * @param bool $tutor_pro |
| 10 | * |
| 11 | * @return bool|string |
| 12 | * |
| 13 | * Load template with override file system |
| 14 | * |
| 15 | * @since v.1.0.0 |
| 16 | * @updated v.1.4.2 |
| 17 | * @updated v.1.4.3 |
| 18 | */ |
| 19 | |
| 20 | if ( ! function_exists( 'tutor_get_template' ) ) { |
| 21 | function tutor_get_template( $template = null, $tutor_pro = false ) { |
| 22 | if ( ! $template ) { |
| 23 | return false; |
| 24 | } |
| 25 | $template = str_replace( '.', DIRECTORY_SEPARATOR, $template ); |
| 26 | |
| 27 | /** |
| 28 | * Get template first from child-theme if exists |
| 29 | * If child theme not exists, then get template from parent theme |
| 30 | */ |
| 31 | $template_location = trailingslashit( get_stylesheet_directory() ) . "tutor/{$template}.php"; |
| 32 | if ( ! file_exists( $template_location ) ) { |
| 33 | $template_location = trailingslashit( get_template_directory() ) . "tutor/{$template}.php"; |
| 34 | } |
| 35 | $file_in_theme = $template_location; |
| 36 | if ( ! file_exists( $template_location ) ) { |
| 37 | $template_location = trailingslashit( tutor()->path ) . "templates/{$template}.php"; |
| 38 | |
| 39 | if ( $tutor_pro && function_exists( 'tutor_pro' ) ) { |
| 40 | $pro_template_location = trailingslashit( tutor_pro()->path ) . "templates/{$template}.php"; |
| 41 | if ( file_exists( $pro_template_location ) ) { |
| 42 | $template_location = trailingslashit( tutor_pro()->path ) . "templates/{$template}.php"; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if ( ! file_exists( $template_location ) ) { |
| 47 | echo '<div class="tutor-notice-warning"> ' . __( sprintf( 'The file you are trying to load does not exist in your theme or Tutor LMS plugin location. If you are extending the Tutor LMS plugin, please create a php file here: %s ', '<code>' . $file_in_theme . '</code>' ), 'tutor' ) . ' </div>'; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return apply_filters( 'tutor_get_template_path', $template_location, $template ); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @param null $template |
| 57 | * @param bool $tutor_pro |
| 58 | * |
| 59 | * @return bool|mixed|void |
| 60 | * |
| 61 | * Get only template path without any warning... |
| 62 | * |
| 63 | * @since v.1.4.2 |
| 64 | */ |
| 65 | if ( ! function_exists( 'tutor_get_template_path' ) ) { |
| 66 | function tutor_get_template_path( $template = null, $tutor_pro = false ) { |
| 67 | if ( ! $template ) { |
| 68 | return false; |
| 69 | } |
| 70 | $template = str_replace( '.', DIRECTORY_SEPARATOR, $template ); |
| 71 | |
| 72 | /** |
| 73 | * Get template first from child-theme if exists |
| 74 | * If child theme not exists, then get template from parent theme |
| 75 | */ |
| 76 | $template_location = trailingslashit( get_stylesheet_directory() ) . "tutor/{$template}.php"; |
| 77 | if ( ! file_exists( $template_location ) ) { |
| 78 | $template_location = trailingslashit( get_template_directory() ) . "tutor/{$template}.php"; |
| 79 | } |
| 80 | if ( ! file_exists( $template_location ) ) { |
| 81 | $template_location = trailingslashit( tutor()->path ) . "templates/{$template}.php"; |
| 82 | } |
| 83 | if ( ! file_exists( $template_location ) && $tutor_pro && function_exists( 'tutor_pro' ) ) { |
| 84 | $template_location = trailingslashit( tutor_pro()->path ) . "templates/{$template}.php"; |
| 85 | } |
| 86 | |
| 87 | return apply_filters( 'tutor_get_template_path', $template_location, $template ); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param null $template |
| 93 | * |
| 94 | * @param array $variables |
| 95 | * |
| 96 | * Load template for TUTOR |
| 97 | * |
| 98 | * @since v.1.0.0 |
| 99 | * |
| 100 | * @updated v.1.1.2 |
| 101 | */ |
| 102 | |
| 103 | if ( ! function_exists( 'tutor_load_template' ) ) { |
| 104 | function tutor_load_template( $template = null, $variables = array(), $tutor_pro = false ) { |
| 105 | $variables = (array) $variables; |
| 106 | $variables = apply_filters( 'get_tutor_load_template_variables', $variables ); |
| 107 | extract( $variables ); |
| 108 | |
| 109 | $isLoad = apply_filters( 'should_tutor_load_template', true, $template, $variables ); |
| 110 | if ( ! $isLoad ) { |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | do_action( 'tutor_load_template_before', $template, $variables ); |
| 115 | include tutor_get_template( $template, $tutor_pro ); |
| 116 | do_action( 'tutor_load_template_after', $template, $variables ); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @param null $template |
| 122 | * @param array $variables |
| 123 | * @param bool $tutor_pro |
| 124 | * |
| 125 | * @since v.1.4.3 |
| 126 | */ |
| 127 | |
| 128 | if ( ! function_exists( 'tutor_load_template_part' ) ) { |
| 129 | function tutor_load_template_part( $template = null, $variables = array(), $tutor_pro = false ) { |
| 130 | $variables = (array) $variables; |
| 131 | $variables = apply_filters( 'get_tutor_load_template_variables', $variables ); |
| 132 | extract( $variables ); |
| 133 | |
| 134 | /** |
| 135 | * Get template first from child-theme if exists |
| 136 | * If child theme not exists, then get template from parent theme |
| 137 | */ |
| 138 | $template_location = trailingslashit( get_stylesheet_directory() ) . 'tutor/template.php'; |
| 139 | if ( ! file_exists( $template_location ) ) { |
| 140 | $template_location = trailingslashit( get_template_directory() ) . 'tutor/template.php'; |
| 141 | } |
| 142 | |
| 143 | if ( ! file_exists( $template_location ) ) { |
| 144 | $template_location = trailingslashit( tutor()->path ) . 'templates/template.php'; |
| 145 | if ( ! file_exists( $template_location ) && $tutor_pro && function_exists( 'tutor_pro' ) ) { |
| 146 | $template_location = trailingslashit( tutor_pro()->path ) . 'templates/template.php'; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | include apply_filters( 'tutor_get_template_part_path', $template_location, $template ); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * @param $template_name |
| 156 | * @param array $variables |
| 157 | * |
| 158 | * @return string |
| 159 | * |
| 160 | * @since v.1.4.3 |
| 161 | */ |
| 162 | |
| 163 | if ( ! function_exists( 'tutor_get_template_html' ) ) { |
| 164 | function tutor_get_template_html( $template_name, $variables = array(), $tutor_pro = false ) { |
| 165 | ob_start(); |
| 166 | tutor_load_template( $template_name, $variables, $tutor_pro ); |
| 167 | |
| 168 | return ob_get_clean(); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | if ( ! function_exists( 'tutor_course_loop_start' ) ) { |
| 173 | function tutor_course_loop_start( $echo = true ) { |
| 174 | ob_start(); |
| 175 | tutor_load_template( 'loop.loop-start' ); |
| 176 | $output = apply_filters( 'tutor_course_loop_start', ob_get_clean() ); |
| 177 | |
| 178 | if ( $echo ) { |
| 179 | echo tutor_kses_html( $output ); |
| 180 | } |
| 181 | return $output; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | if ( ! function_exists( 'tutor_course_loop_end' ) ) { |
| 186 | function tutor_course_loop_end( $echo = true ) { |
| 187 | ob_start(); |
| 188 | tutor_load_template( 'loop.loop-end' ); |
| 189 | |
| 190 | $output = apply_filters( 'tutor_course_loop_end', ob_get_clean() ); |
| 191 | if ( $echo ) { |
| 192 | echo tutor_kses_html( $output ); |
| 193 | } |
| 194 | |
| 195 | return $output; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | if ( ! function_exists( 'tutor_course_archive_pagination' ) ) { |
| 200 | function tutor_course_archive_pagination( $echo = true ) { |
| 201 | ob_start(); |
| 202 | tutor_load_template( 'loop.tutor-pagination' ); |
| 203 | |
| 204 | $output = apply_filters( 'tutor_course_archive_pagination', ob_get_clean() ); |
| 205 | if ( $echo ) { |
| 206 | echo tutor_kses_html( $output ); |
| 207 | } |
| 208 | |
| 209 | return $output; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | function tutor_course_loop_before_content() { |
| 214 | ob_start(); |
| 215 | tutor_load_template( 'loop.loop-before-content' ); |
| 216 | |
| 217 | $output = apply_filters( 'tutor_course_loop_before_content', ob_get_clean() ); |
| 218 | echo tutor_kses_html( $output ); |
| 219 | } |
| 220 | |
| 221 | function tutor_course_loop_after_content() { |
| 222 | ob_start(); |
| 223 | tutor_load_template( 'loop.loop-after-content' ); |
| 224 | |
| 225 | $output = apply_filters( 'tutor_course_loop_after_content', ob_get_clean() ); |
| 226 | echo tutor_kses_html( $output ); |
| 227 | } |
| 228 | |
| 229 | if ( ! function_exists( 'tutor_course_loop_title' ) ) { |
| 230 | function tutor_course_loop_title() { |
| 231 | ob_start(); |
| 232 | tutor_load_template( 'loop.title' ); |
| 233 | $output = apply_filters( 'tutor_course_loop_title', ob_get_clean() ); |
| 234 | |
| 235 | echo tutor_kses_html( $output ); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | |
| 240 | if ( ! function_exists( 'tutor_course_loop_header' ) ) { |
| 241 | function tutor_course_loop_header() { |
| 242 | ob_start(); |
| 243 | tutor_load_template( 'loop.header' ); |
| 244 | $output = apply_filters( 'tutor_course_loop_header', ob_get_clean() ); |
| 245 | |
| 246 | echo tutor_kses_html( $output ); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | if ( ! function_exists( 'tutor_course_loop_footer' ) ) { |
| 251 | function tutor_course_loop_footer() { |
| 252 | ob_start(); |
| 253 | tutor_load_template( 'loop.footer' ); |
| 254 | $output = apply_filters( 'tutor_course_loop_footer', ob_get_clean() ); |
| 255 | |
| 256 | echo tutor_kses_html( $output ); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // tutor_course_loop_footer |
| 261 | |
| 262 | |
| 263 | if ( ! function_exists( 'tutor_course_loop_start_content_wrap' ) ) { |
| 264 | function tutor_course_loop_start_content_wrap() { |
| 265 | ob_start(); |
| 266 | tutor_load_template( 'loop.start_content_wrap' ); |
| 267 | $output = apply_filters( 'tutor_course_loop_start_content_wrap', ob_get_clean() ); |
| 268 | |
| 269 | echo tutor_kses_html( $output ); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | if ( ! function_exists( 'tutor_course_loop_end_content_wrap' ) ) { |
| 274 | function tutor_course_loop_end_content_wrap() { |
| 275 | ob_start(); |
| 276 | tutor_load_template( 'loop.end_content_wrap' ); |
| 277 | $output = apply_filters( 'tutor_course_loop_end_content_wrap', ob_get_clean() ); |
| 278 | |
| 279 | echo tutor_kses_html( $output ); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | if ( ! function_exists( 'tutor_course_loop_thumbnail' ) ) { |
| 284 | function tutor_course_loop_thumbnail( $echo = true ) { |
| 285 | ob_start(); |
| 286 | tutor_load_template( 'loop.thumbnail' ); |
| 287 | $output = apply_filters( 'tutor_course_loop_thumbnail', ob_get_clean() ); |
| 288 | |
| 289 | if ( $echo ) { |
| 290 | echo tutor_kses_html( $output ); |
| 291 | } else { |
| 292 | return $output; |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | if ( ! function_exists( 'tutor_course_loop_wrap_classes' ) ) { |
| 298 | function tutor_course_loop_wrap_classes( $echo = true ) { |
| 299 | $courseID = get_the_ID(); |
| 300 | $classes = apply_filters( |
| 301 | 'tutor_course_loop_wrap_classes', |
| 302 | array( |
| 303 | 'tutor-course', |
| 304 | 'tutor-course-loop', |
| 305 | 'tutor-course-loop-' . $courseID, |
| 306 | ) |
| 307 | ); |
| 308 | |
| 309 | $class = implode( ' ', $classes ); |
| 310 | if ( $echo ) { |
| 311 | echo esc_attr( $class ); |
| 312 | } |
| 313 | |
| 314 | return esc_attr( $class ); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | if ( ! function_exists( 'tutor_course_loop_col_classes' ) ) { |
| 319 | function tutor_course_loop_col_classes( $echo = true ) { |
| 320 | $course_filter = (bool) tutor_utils()->get_option( 'course_archive_filter', false ); |
| 321 | $shortcode_arg = isset( $GLOBALS['tutor_shortcode_arg'] ) ? $GLOBALS['tutor_shortcode_arg']['column_per_row'] : null; |
| 322 | $course_cols = $shortcode_arg === null ? tutor_utils()->get_option( 'courses_col_per_row', 3 ) : $shortcode_arg; |
| 323 | $classes = apply_filters( |
| 324 | 'tutor_course_loop_col_classes', |
| 325 | array( |
| 326 | 'tutor-course-col-' . $course_cols, |
| 327 | ) |
| 328 | ); |
| 329 | |
| 330 | $class = implode( ' ', $classes ); |
| 331 | if ( $echo ) { |
| 332 | echo esc_attr( $class ); |
| 333 | } |
| 334 | |
| 335 | return esc_attr( $class ); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | |
| 340 | if ( ! function_exists( 'tutor_container_classes' ) ) { |
| 341 | function tutor_container_classes( $echo = true ) { |
| 342 | |
| 343 | $classes = apply_filters( |
| 344 | 'tutor_container_classes', |
| 345 | array( |
| 346 | 'tutor-wrap tutor-courses-wrap', |
| 347 | 'tutor-container', |
| 348 | ) |
| 349 | ); |
| 350 | |
| 351 | $class = implode( ' ', $classes ); |
| 352 | |
| 353 | if ( $echo ) { |
| 354 | echo esc_attr( $class ); |
| 355 | } |
| 356 | |
| 357 | return esc_attr( $class ); |
| 358 | } |
| 359 | } |
| 360 | if ( ! function_exists( 'tutor_post_class' ) ) { |
| 361 | function tutor_post_class( $default = '' ) { |
| 362 | $classes = apply_filters( |
| 363 | 'tutor_post_class', |
| 364 | array( |
| 365 | 'tutor-wrap', |
| 366 | $default, |
| 367 | ) |
| 368 | ); |
| 369 | |
| 370 | post_class( $classes ); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | if ( ! function_exists( 'tutor_course_archive_filter_bar' ) ) { |
| 375 | function tutor_course_archive_filter_bar() { |
| 376 | ob_start(); |
| 377 | tutor_load_template( 'global.course-archive-filter-bar' ); |
| 378 | $output = apply_filters( 'tutor_course_archive_filter_bar', ob_get_clean() ); |
| 379 | |
| 380 | echo $output; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * |
| 386 | * Get classes for widget loop single course wrap |
| 387 | * |
| 388 | * @param bool $echo |
| 389 | * |
| 390 | * @return string |
| 391 | * |
| 392 | * @since v.1.3.1 |
| 393 | */ |
| 394 | if ( ! function_exists( 'tutor_widget_course_loop_classes' ) ) { |
| 395 | function tutor_widget_course_loop_classes( $echo = true ) { |
| 396 | |
| 397 | $classes = apply_filters( |
| 398 | 'tutor_widget_course_loop_classes', |
| 399 | array( |
| 400 | 'tutor-widget-course-loop', |
| 401 | 'tutor-widget-course', |
| 402 | 'tutor-widget-course-' . get_the_ID(), |
| 403 | ) |
| 404 | ); |
| 405 | |
| 406 | $class = implode( ' ', $classes ); |
| 407 | if ( $echo ) { |
| 408 | echo esc_attr( $class ); |
| 409 | } |
| 410 | |
| 411 | return esc_attr( $class ); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Get the post thumbnail |
| 417 | */ |
| 418 | if ( ! function_exists( 'get_tutor_course_thumbnail' ) ) { |
| 419 | function get_tutor_course_thumbnail( $size = 'post-thumbnail', $url = false ) { |
| 420 | $post_id = get_the_ID(); |
| 421 | $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id ); |
| 422 | |
| 423 | if ( $post_thumbnail_id ) { |
| 424 | // $size = apply_filters( 'post_thumbnail_size', $size, $post_id ); |
| 425 | $size = apply_filters( 'tutor_course_thumbnail_size', $size, $post_id ); |
| 426 | if ( $url ) { |
| 427 | return wp_get_attachment_image_url( $post_thumbnail_id, $size ); |
| 428 | } |
| 429 | |
| 430 | $html = wp_get_attachment_image( $post_thumbnail_id, $size, false ); |
| 431 | } else { |
| 432 | $placeHolderUrl = tutor()->url . 'assets/images/placeholder.jpg'; |
| 433 | if ( $url ) { |
| 434 | return $placeHolderUrl; |
| 435 | } |
| 436 | $html = sprintf( '<img alt="%s" src="' . $placeHolderUrl . '" />', __( 'Placeholder', 'tutor' ) ); |
| 437 | } |
| 438 | |
| 439 | echo tutor_kses_html( $html ); |
| 440 | } |
| 441 | } |
| 442 | /** |
| 443 | * Get the course/post thumbnail src |
| 444 | */ |
| 445 | if ( ! function_exists( 'get_tutor_course_thumbnail_src' ) ) { |
| 446 | function get_tutor_course_thumbnail_src( $size = 'post-thumbnail' ) { |
| 447 | $post_id = get_the_ID(); |
| 448 | $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id ); |
| 449 | |
| 450 | if ( $post_thumbnail_id ) { |
| 451 | $size = apply_filters( 'tutor_course_thumbnail_size', $size, $post_id ); |
| 452 | $src = wp_get_attachment_image_url( $post_thumbnail_id, $size, false ); |
| 453 | } else { |
| 454 | $src = tutor()->url . 'assets/images/placeholder.jpg'; |
| 455 | } |
| 456 | |
| 457 | return $src; |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | if ( ! function_exists( 'tutor_course_loop_meta' ) ) { |
| 462 | function tutor_course_loop_meta() { |
| 463 | ob_start(); |
| 464 | tutor_load_template( 'loop.meta' ); |
| 465 | $output = apply_filters( 'tutor_course_loop_meta', ob_get_clean() ); |
| 466 | |
| 467 | echo tutor_kses_html( $output ); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * Get course author name in loop |
| 473 | * |
| 474 | * @since: v.1.0.0 |
| 475 | */ |
| 476 | |
| 477 | if ( ! function_exists( 'tutor_course_loop_author' ) ) { |
| 478 | function tutor_course_loop_author() { |
| 479 | ob_start(); |
| 480 | tutor_load_template( 'loop.course-author' ); |
| 481 | $output = apply_filters( 'tutor_course_loop_author', ob_get_clean() ); |
| 482 | |
| 483 | echo $output; |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * Get formatted price with cart form |
| 489 | */ |
| 490 | |
| 491 | if ( ! function_exists( 'tutor_course_loop_price' ) ) { |
| 492 | function tutor_course_loop_price() { |
| 493 | ob_start(); |
| 494 | |
| 495 | if ( tutils()->is_course_added_to_cart( get_the_ID() ) ) { |
| 496 | tutor_load_template( 'loop.course-in-cart' ); |
| 497 | } elseif ( tutils()->is_enrolled( get_the_ID() ) ) { |
| 498 | tutor_load_template( 'loop.course-continue' ); |
| 499 | } else { |
| 500 | $tutor_course_sell_by = apply_filters( 'tutor_course_sell_by', null ); |
| 501 | if ( $tutor_course_sell_by ) { |
| 502 | tutor_load_template( 'loop.course-price-' . $tutor_course_sell_by ); |
| 503 | } else { |
| 504 | tutor_load_template( 'loop.course-price' ); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | echo apply_filters( 'tutor_course_loop_price', ob_get_clean() ); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | /** |
| 513 | * Get Course rating |
| 514 | * |
| 515 | * @since v.1.0.0 |
| 516 | * @updated v.1.4.5 |
| 517 | */ |
| 518 | |
| 519 | if ( ! function_exists( 'tutor_course_loop_rating' ) ) { |
| 520 | function tutor_course_loop_rating() { |
| 521 | |
| 522 | $disable = get_tutor_option( 'disable_course_review' ); |
| 523 | if ( $disable ) { |
| 524 | return; |
| 525 | } |
| 526 | |
| 527 | ob_start(); |
| 528 | tutor_load_template( 'loop.rating' ); |
| 529 | $output = apply_filters( 'tutor_course_loop_rating', ob_get_clean() ); |
| 530 | |
| 531 | echo tutor_kses_html( $output ); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * @param bool $echo |
| 537 | * |
| 538 | * @return mixed|void |
| 539 | * |
| 540 | * Get add to cart form |
| 541 | */ |
| 542 | |
| 543 | if ( ! function_exists( 'tutor_course_loop_add_to_cart' ) ) { |
| 544 | function tutor_course_loop_add_to_cart( $echo = true ) { |
| 545 | ob_start(); |
| 546 | $tutor_course_sell_by = apply_filters( 'tutor_course_sell_by', null ); |
| 547 | |
| 548 | if ( $tutor_course_sell_by ) { |
| 549 | tutor_load_template( 'loop.add-to-cart-' . $tutor_course_sell_by ); |
| 550 | } |
| 551 | |
| 552 | $output = apply_filters( 'tutor_course_loop_add_to_cart_link', ob_get_clean() ); |
| 553 | |
| 554 | if ( $echo ) { |
| 555 | echo wp_kses_post($output); |
| 556 | } |
| 557 | return $output; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | if ( ! function_exists( 'tutor_course_price' ) ) { |
| 562 | function tutor_course_price() { |
| 563 | ob_start(); |
| 564 | tutor_load_template( 'single.course.wc-price-html' ); |
| 565 | $output = apply_filters( 'tutor_course_price', ob_get_clean() ); |
| 566 | |
| 567 | echo $output; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * @param int $post_id |
| 573 | * |
| 574 | * echo the excerpt of TUTOR post type |
| 575 | * |
| 576 | * @since: v.1.0.0 |
| 577 | */ |
| 578 | if ( ! function_exists( 'tutor_the_excerpt' ) ) { |
| 579 | function tutor_the_excerpt( $post_id = 0 ) { |
| 580 | if ( ! $post_id ) { |
| 581 | $post_id = get_the_ID(); |
| 582 | } |
| 583 | echo tutor_get_the_excerpt( $post_id ); |
| 584 | } |
| 585 | } |
| 586 | /** |
| 587 | * @param int $post_id |
| 588 | * |
| 589 | * @return mixed |
| 590 | * |
| 591 | * Return excerpt of TUTOR post type |
| 592 | * |
| 593 | * @since: v.1.0.0 |
| 594 | */ |
| 595 | if ( ! function_exists( 'tutor_get_the_excerpt' ) ) { |
| 596 | function tutor_get_the_excerpt( $post_id = 0 ) { |
| 597 | if ( ! $post_id ) { |
| 598 | $post_id = get_the_ID(); |
| 599 | } |
| 600 | |
| 601 | $get_post = get_post( $post_id ); |
| 602 | return apply_filters( 'tutor_get_the_excerpt', $get_post->post_excerpt ); |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | /** |
| 607 | * @return mixed |
| 608 | * |
| 609 | * return course author |
| 610 | * |
| 611 | * @since: v.1.0.0 |
| 612 | */ |
| 613 | |
| 614 | if ( ! function_exists( 'get_tutor_course_author' ) ) { |
| 615 | function get_tutor_course_author() { |
| 616 | global $post; |
| 617 | return apply_filters( 'get_tutor_course_author', get_the_author_meta( 'display_name', $post->post_author ) ); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | function get_tutor_course_author_id() { |
| 622 | global $post; |
| 623 | return (int) $post->post_author; |
| 624 | } |
| 625 | |
| 626 | /** |
| 627 | * @param int $course_id |
| 628 | * |
| 629 | * @return mixed |
| 630 | * Course benefits return array |
| 631 | * |
| 632 | * @since: v.1.0.0 |
| 633 | */ |
| 634 | |
| 635 | if ( ! function_exists( 'tutor_course_benefits' ) ) { |
| 636 | function tutor_course_benefits( $course_id = 0 ) { |
| 637 | if ( ! $course_id ) { |
| 638 | $course_id = get_the_ID(); |
| 639 | } |
| 640 | $benefits = get_post_meta( $course_id, '_tutor_course_benefits', true ); |
| 641 | |
| 642 | $benefits_array = array(); |
| 643 | if ( $benefits ) { |
| 644 | $benefits_array = explode( "\n", $benefits ); |
| 645 | } |
| 646 | |
| 647 | $array = array_filter( array_map( 'trim', $benefits_array ) ); |
| 648 | |
| 649 | return apply_filters( 'tutor_course/single/benefits', $array, $course_id ); |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | /** |
| 654 | * @param bool $echo |
| 655 | * |
| 656 | * @return mixed |
| 657 | * |
| 658 | * Course single page benefits |
| 659 | * |
| 660 | * @since: v.1.0.0 |
| 661 | */ |
| 662 | |
| 663 | if ( ! function_exists( 'tutor_course_benefits_html' ) ) { |
| 664 | function tutor_course_benefits_html( $echo = true ) { |
| 665 | ob_start(); |
| 666 | tutor_load_template( 'single.course.course-benefits' ); |
| 667 | $output = apply_filters( 'tutor_course/single/benefits_html', ob_get_clean() ); |
| 668 | |
| 669 | if ( $echo ) { |
| 670 | echo wp_kses_post($output); |
| 671 | } |
| 672 | return $output; |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * @param bool $echo |
| 678 | * |
| 679 | * @return mixed|void |
| 680 | * |
| 681 | * Return Topics HTML |
| 682 | * |
| 683 | * @since: v.1.0.0 |
| 684 | */ |
| 685 | if ( ! function_exists( 'tutor_course_topics' ) ) { |
| 686 | function tutor_course_topics( $echo = true ) { |
| 687 | ob_start(); |
| 688 | tutor_load_template( 'single.course.course-topics' ); |
| 689 | $output = apply_filters( 'tutor_course/single/topics', ob_get_clean() ); |
| 690 | wp_reset_postdata(); |
| 691 | |
| 692 | if ( $echo ) { |
| 693 | echo tutor_kses_html( $output ); |
| 694 | } |
| 695 | |
| 696 | return $output; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | * @param int $course_id |
| 702 | * |
| 703 | * @return mixed|void |
| 704 | * |
| 705 | * return course requirements in array |
| 706 | * |
| 707 | * @since: v.1.0.0 |
| 708 | */ |
| 709 | if ( ! function_exists( 'tutor_course_requirements' ) ) { |
| 710 | function tutor_course_requirements( $course_id = 0 ) { |
| 711 | if ( ! $course_id ) { |
| 712 | $course_id = get_the_ID(); |
| 713 | } |
| 714 | $requirements = get_post_meta( $course_id, '_tutor_course_requirements', true ); |
| 715 | |
| 716 | $requirements_array = array(); |
| 717 | if ( $requirements ) { |
| 718 | $requirements_array = explode( "\n", $requirements ); |
| 719 | } |
| 720 | |
| 721 | $array = array_filter( array_map( 'trim', $requirements_array ) ); |
| 722 | return apply_filters( 'tutor_course/single/requirements', $array, $course_id ); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * @param bool $echo |
| 728 | * |
| 729 | * @return mixed|void |
| 730 | * |
| 731 | * Return course requirements in course single page |
| 732 | * |
| 733 | * @since: v.1.0.0 |
| 734 | */ |
| 735 | if ( ! function_exists( 'tutor_course_requirements_html' ) ) { |
| 736 | function tutor_course_requirements_html( $echo = true ) { |
| 737 | ob_start(); |
| 738 | tutor_load_template( 'single.course.course-requirements' ); |
| 739 | $output = apply_filters( 'tutor_course/single/requirements_html', ob_get_clean() ); |
| 740 | |
| 741 | if ( $echo ) { |
| 742 | echo tutor_kses_html( $output ); |
| 743 | } |
| 744 | return $output; |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | |
| 749 | /** |
| 750 | * @param int $course_id |
| 751 | * |
| 752 | * @return mixed|void |
| 753 | * |
| 754 | * Return target audience in course single page |
| 755 | * |
| 756 | * @since: v.1.0.0 |
| 757 | */ |
| 758 | if ( ! function_exists( 'tutor_course_target_audience' ) ) { |
| 759 | function tutor_course_target_audience( $course_id = 0 ) { |
| 760 | if ( ! $course_id ) { |
| 761 | $course_id = get_the_ID(); |
| 762 | } |
| 763 | $target_audience = get_post_meta( $course_id, '_tutor_course_target_audience', true ); |
| 764 | |
| 765 | $target_audience_array = array(); |
| 766 | if ( $target_audience ) { |
| 767 | $target_audience_array = explode( "\n", $target_audience ); |
| 768 | } |
| 769 | |
| 770 | $array = array_filter( array_map( 'trim', $target_audience_array ) ); |
| 771 | return apply_filters( 'tutor_course/single/target_audience', $array, $course_id ); |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * @param bool $echo |
| 777 | * |
| 778 | * @return mixed|void |
| 779 | * |
| 780 | * Return target audience in course single page |
| 781 | * |
| 782 | * @since: v.1.0.0 |
| 783 | */ |
| 784 | if ( ! function_exists( 'tutor_course_target_audience_html' ) ) { |
| 785 | function tutor_course_target_audience_html( $echo = true ) { |
| 786 | ob_start(); |
| 787 | tutor_load_template( 'single.course.course-target-audience' ); |
| 788 | $output = apply_filters( 'tutor_course/single/audience_html', ob_get_clean() ); |
| 789 | |
| 790 | if ( $echo ) { |
| 791 | echo tutor_kses_html( $output ); |
| 792 | } |
| 793 | return $output; |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | |
| 798 | if ( ! function_exists( 'tutor_course_material_includes' ) ) { |
| 799 | function tutor_course_material_includes( $course_id = 0 ) { |
| 800 | if ( ! $course_id ) { |
| 801 | $course_id = get_the_ID(); |
| 802 | } |
| 803 | $target_audience = get_post_meta( $course_id, '_tutor_course_material_includes', true ); |
| 804 | |
| 805 | $target_audience_array = array(); |
| 806 | if ( $target_audience ) { |
| 807 | $target_audience_array = explode( "\n", $target_audience ); |
| 808 | } |
| 809 | |
| 810 | $array = array_filter( array_map( 'trim', $target_audience_array ) ); |
| 811 | return apply_filters( 'tutor_course/single/material_includes', $array, $course_id ); |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | if ( ! function_exists( 'tutor_course_material_includes_html' ) ) { |
| 816 | function tutor_course_material_includes_html( $echo = true ) { |
| 817 | ob_start(); |
| 818 | tutor_load_template( 'single.course.material-includes' ); |
| 819 | $output = apply_filters( 'tutor_course/single/material_includes', ob_get_clean() ); |
| 820 | |
| 821 | if ( $echo ) { |
| 822 | echo tutor_kses_html( $output ); |
| 823 | } |
| 824 | return $output; |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | // tutor_course_material_includes_html |
| 829 | |
| 830 | |
| 831 | if ( ! function_exists( 'tutor_course_instructors_html' ) ) { |
| 832 | function tutor_course_instructors_html( $echo = true ) { |
| 833 | $display_course_instructors = tutor_utils()->get_option( 'display_course_instructors' ); |
| 834 | if ( ! $display_course_instructors ) { |
| 835 | return null; |
| 836 | } |
| 837 | |
| 838 | ob_start(); |
| 839 | tutor_load_template( 'single.course.instructors' ); |
| 840 | $output = apply_filters( 'tutor_course/single/instructors_html', ob_get_clean() ); |
| 841 | |
| 842 | if ( $echo ) { |
| 843 | echo tutor_kses_html( $output ); |
| 844 | } |
| 845 | return $output; |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | if ( ! function_exists( 'tutor_course_target_reviews_html' ) ) { |
| 850 | function tutor_course_target_reviews_html( $echo = true ) { |
| 851 | ob_start(); |
| 852 | tutor_load_template( 'single.course.reviews' ); |
| 853 | $output = apply_filters( 'tutor_course/single/reviews_html', ob_get_clean() ); |
| 854 | |
| 855 | if ( $echo ) { |
| 856 | echo tutor_kses_html( $output ); |
| 857 | } |
| 858 | return $output; |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | if ( ! function_exists( 'tutor_course_target_review_form_html' ) ) { |
| 863 | function tutor_course_target_review_form_html( $echo = true ) { |
| 864 | $isDisableReview = (bool) tutils()->get_option( 'disable_course_review' ); |
| 865 | if ( $isDisableReview ) { |
| 866 | $output = apply_filters( 'tutor_review_disabled_text', '' ); |
| 867 | |
| 868 | if ( $echo ) { |
| 869 | echo tutor_kses_html( $output ); |
| 870 | } |
| 871 | return $output; |
| 872 | } |
| 873 | |
| 874 | ob_start(); |
| 875 | tutor_load_template( 'single.course.review-form' ); |
| 876 | $output = apply_filters( 'tutor_course/single/reviews_form', ob_get_clean() ); |
| 877 | |
| 878 | if ( $echo ) { |
| 879 | echo tutor_kses_html( $output ); |
| 880 | } |
| 881 | return $output; |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * @param bool $echo |
| 887 | * |
| 888 | * @return mixed |
| 889 | * |
| 890 | * Course single page main content / description |
| 891 | * |
| 892 | * @since: v.1.0.0 |
| 893 | */ |
| 894 | if ( ! function_exists( 'tutor_course_content' ) ) { |
| 895 | function tutor_course_content( $echo = true ) { |
| 896 | ob_start(); |
| 897 | tutor_load_template( 'single.course.course-content' ); |
| 898 | $output = apply_filters( 'tutor_course/single/content', ob_get_clean() ); |
| 899 | |
| 900 | if ( $echo ) { |
| 901 | echo tutor_kses_html( $output ); |
| 902 | } |
| 903 | |
| 904 | return $output; |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | /** |
| 909 | * Course single page lead info |
| 910 | * |
| 911 | * @since: v.1.0.0 |
| 912 | */ |
| 913 | if ( ! function_exists( 'tutor_course_lead_info' ) ) { |
| 914 | function tutor_course_lead_info( $echo = true ) { |
| 915 | ob_start(); |
| 916 | |
| 917 | // exit('failed'); |
| 918 | |
| 919 | $course_id = get_the_ID(); |
| 920 | $course_post_type = tutor()->course_post_type; |
| 921 | $queryCourse = new WP_Query( |
| 922 | array( |
| 923 | 'p' => $course_id, |
| 924 | 'post_type' => $course_post_type, |
| 925 | ) |
| 926 | ); |
| 927 | |
| 928 | if ( $queryCourse->have_posts() ) { |
| 929 | while ( $queryCourse->have_posts() ) { |
| 930 | $queryCourse->the_post(); |
| 931 | tutor_load_template( 'single.course.lead-info' ); |
| 932 | } |
| 933 | wp_reset_postdata(); |
| 934 | } |
| 935 | |
| 936 | $output = apply_filters( 'tutor_course/single/lead_info', ob_get_clean() ); |
| 937 | |
| 938 | if ( $echo ) { |
| 939 | echo tutor_kses_html( $output ); |
| 940 | } |
| 941 | return $output; |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | /** |
| 946 | * @param bool $echo |
| 947 | * |
| 948 | * @return mixed|void |
| 949 | */ |
| 950 | |
| 951 | if ( ! function_exists( 'tutor_course_enrolled_lead_info' ) ) { |
| 952 | function tutor_course_enrolled_lead_info( $echo = true ) { |
| 953 | ob_start(); |
| 954 | |
| 955 | $course_id = get_the_ID(); |
| 956 | $course_post_type = tutor()->course_post_type; |
| 957 | $queryCourse = new WP_Query( |
| 958 | array( |
| 959 | 'p' => $course_id, |
| 960 | 'post_type' => $course_post_type, |
| 961 | ) |
| 962 | ); |
| 963 | |
| 964 | if ( $queryCourse->have_posts() ) { |
| 965 | while ( $queryCourse->have_posts() ) { |
| 966 | $queryCourse->the_post(); |
| 967 | tutor_load_template( 'single.course.enrolled.lead-info' ); |
| 968 | } |
| 969 | wp_reset_postdata(); |
| 970 | } |
| 971 | |
| 972 | $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() ); |
| 973 | |
| 974 | if ( $echo ) { |
| 975 | echo tutor_kses_html( $output ); |
| 976 | } |
| 977 | |
| 978 | return $output; |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | if ( ! function_exists( 'tutor_lesson_lead_info' ) ) { |
| 983 | function tutor_lesson_lead_info( $lesson_id = 0, $echo = true ) { |
| 984 | if ( ! $lesson_id ) { |
| 985 | $lesson_id = get_the_ID(); |
| 986 | } |
| 987 | |
| 988 | ob_start(); |
| 989 | $course_id = tutor_utils()->get_course_id_by( 'lesson', $lesson_id ); |
| 990 | $course_post_type = tutor()->course_post_type; |
| 991 | $queryCourse = new WP_Query( |
| 992 | array( |
| 993 | 'p' => $course_id, |
| 994 | 'post_type' => $course_post_type, |
| 995 | ) |
| 996 | ); |
| 997 | |
| 998 | if ( $queryCourse->have_posts() ) { |
| 999 | while ( $queryCourse->have_posts() ) { |
| 1000 | $queryCourse->the_post(); |
| 1001 | tutor_load_template( 'single.course.enrolled.lead-info' ); |
| 1002 | } |
| 1003 | wp_reset_postdata(); |
| 1004 | } |
| 1005 | $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() ); |
| 1006 | |
| 1007 | if ( $echo ) { |
| 1008 | echo $output; |
| 1009 | } |
| 1010 | |
| 1011 | return $output; |
| 1012 | |
| 1013 | } |
| 1014 | } |
| 1015 | /** |
| 1016 | * @param bool $echo |
| 1017 | * |
| 1018 | * @return mixed |
| 1019 | * |
| 1020 | * Return enroll box in single course |
| 1021 | * |
| 1022 | * @since: v.1.0.0 |
| 1023 | */ |
| 1024 | |
| 1025 | if ( ! function_exists( 'tutor_course_enroll_box' ) ) { |
| 1026 | function tutor_course_enroll_box( $echo = true ) { |
| 1027 | $isLoggedIn = is_user_logged_in(); |
| 1028 | $enrolled = tutor_utils()->is_enrolled(); |
| 1029 | |
| 1030 | $is_administrator = current_user_can( 'administrator' ); |
| 1031 | $is_instructor = tutor_utils()->is_instructor_of_this_course(); |
| 1032 | $course_content_access = (bool) get_tutor_option( 'course_content_access_for_ia' ); |
| 1033 | ob_start(); |
| 1034 | |
| 1035 | if ( $enrolled ) { |
| 1036 | tutor_load_template( 'single.course.course-enrolled-box' ); |
| 1037 | $output = apply_filters( 'tutor_course/single/enrolled', ob_get_clean() ); |
| 1038 | } elseif ( $course_content_access && ( $is_administrator || $is_instructor ) ) { |
| 1039 | tutor_load_template( 'single.course.continue-lesson' ); |
| 1040 | $output = apply_filters( 'tutor_course/single/continue_lesson', ob_get_clean() ); |
| 1041 | } else { |
| 1042 | tutor_load_template( 'single.course.course-enroll-box' ); |
| 1043 | $output = apply_filters( 'tutor_course/single/enroll', ob_get_clean() ); |
| 1044 | } |
| 1045 | |
| 1046 | if ( $echo ) { |
| 1047 | echo $output; |
| 1048 | } |
| 1049 | |
| 1050 | return $output; |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * @param bool $echo |
| 1056 | * |
| 1057 | * @return string |
| 1058 | * |
| 1059 | * Get Only add to cart form |
| 1060 | */ |
| 1061 | |
| 1062 | function tutor_single_course_add_to_cart( $echo = true ) { |
| 1063 | ob_start(); |
| 1064 | |
| 1065 | $isLoggedIn = is_user_logged_in(); |
| 1066 | $output = ''; |
| 1067 | |
| 1068 | $template = tutor_utils()->is_course_fully_booked( null ) ? 'closed-enrollment' : 'add-to-cart'; |
| 1069 | |
| 1070 | tutor_load_template( 'single.course.' . $template ); |
| 1071 | $output .= apply_filters( 'tutor_course/single/' . $template, ob_get_clean() ); |
| 1072 | |
| 1073 | if ( ! $isLoggedIn ) { |
| 1074 | ob_start(); |
| 1075 | tutor_load_template( 'single.course.login' ); |
| 1076 | $login_form = apply_filters( 'tutor_course/global/login', ob_get_clean() ); |
| 1077 | |
| 1078 | $output .= '<div class="tutor-cart-box-login-form" style="display: none;"><span class="login-overlay-close"></span><div class="tutor-cart-box-login-form-inner"><button class="tutor-popup-form-close tutor-icon-line-cross"></button>' . $login_form . '</div></div>'; |
| 1079 | } |
| 1080 | |
| 1081 | if ( $echo ) { |
| 1082 | echo $output; |
| 1083 | } |
| 1084 | |
| 1085 | return $output; |
| 1086 | } |
| 1087 | |
| 1088 | if ( ! function_exists( 'tutor_course_enrolled_nav' ) ) { |
| 1089 | function tutor_course_enrolled_nav( $echo = true ) { |
| 1090 | $course_post_type = tutor()->course_post_type; |
| 1091 | $lesson_post_type = tutor()->lesson_post_type; |
| 1092 | |
| 1093 | ob_start(); |
| 1094 | global $post; |
| 1095 | |
| 1096 | if ( ! empty( $post->post_type ) && $post->post_type === $course_post_type ) { |
| 1097 | tutor_load_template( 'single.course.enrolled.nav' ); |
| 1098 | } elseif ( ! empty( $post->post_type ) && $post->post_type === $lesson_post_type ) { |
| 1099 | $lesson_id = get_the_ID(); |
| 1100 | $course_id = tutor_utils()->get_course_id_by( 'lesson', $lesson_id ); |
| 1101 | |
| 1102 | $course_post_type = tutor()->course_post_type; |
| 1103 | $queryCourse = new WP_Query( |
| 1104 | array( |
| 1105 | 'p' => $course_id, |
| 1106 | 'post_type' => $course_post_type, |
| 1107 | ) |
| 1108 | ); |
| 1109 | |
| 1110 | if ( $queryCourse->have_posts() ) { |
| 1111 | while ( $queryCourse->have_posts() ) { |
| 1112 | $queryCourse->the_post(); |
| 1113 | tutor_load_template( 'single.course.enrolled.nav' ); |
| 1114 | } |
| 1115 | wp_reset_postdata(); |
| 1116 | } |
| 1117 | } |
| 1118 | $output = apply_filters( 'tutor_course/single/enrolled/nav', ob_get_clean() ); |
| 1119 | |
| 1120 | if ( $echo ) { |
| 1121 | echo $output; |
| 1122 | } |
| 1123 | return $output; |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | if ( ! function_exists( 'tutor_course_video' ) ) { |
| 1128 | function tutor_course_video( $echo = true ) { |
| 1129 | ob_start(); |
| 1130 | tutor_load_template( 'single.video.video' ); |
| 1131 | $output = apply_filters( 'tutor_course/single/video', ob_get_clean() ); |
| 1132 | |
| 1133 | if ( $echo ) { |
| 1134 | echo $output; |
| 1135 | } |
| 1136 | return $output; |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | if ( ! function_exists( 'tutor_lesson_video' ) ) { |
| 1141 | function tutor_lesson_video( $echo = true ) { |
| 1142 | ob_start(); |
| 1143 | tutor_load_template( 'single.video.video' ); |
| 1144 | $output = apply_filters( 'tutor_lesson/single/video', ob_get_clean() ); |
| 1145 | |
| 1146 | if ( $echo ) { |
| 1147 | echo tutor_kses_html( $output ); |
| 1148 | } |
| 1149 | return $output; |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | /** |
| 1154 | * |
| 1155 | * Get all lessons attachments |
| 1156 | * |
| 1157 | * @param bool $echo |
| 1158 | * |
| 1159 | * @return mixed |
| 1160 | * |
| 1161 | * @since v.1.0.0 |
| 1162 | */ |
| 1163 | if ( ! function_exists( 'get_tutor_posts_attachments' ) ) { |
| 1164 | function get_tutor_posts_attachments( $echo = true ) { |
| 1165 | ob_start(); |
| 1166 | tutor_load_template( 'global.attachments' ); |
| 1167 | $output = apply_filters( 'tutor_lesson/single/attachments', ob_get_clean() ); |
| 1168 | |
| 1169 | if ( $echo ) { |
| 1170 | echo tutor_kses_html( $output ); |
| 1171 | } |
| 1172 | return $output; |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | /** |
| 1177 | * @param bool $echo |
| 1178 | * |
| 1179 | * @return mixed |
| 1180 | * |
| 1181 | * Get the lessons with topics |
| 1182 | * |
| 1183 | * @since v.1.0.0 |
| 1184 | */ |
| 1185 | if ( ! function_exists( 'tutor_lessons_sidebar' ) ) { |
| 1186 | function tutor_lessons_sidebar( $echo = true ) { |
| 1187 | ob_start(); |
| 1188 | tutor_load_template( 'single.lesson.lesson_sidebar' ); |
| 1189 | $output = apply_filters( 'tutor_lesson/single/lesson_sidebar', ob_get_clean() ); |
| 1190 | |
| 1191 | if ( $echo ) { |
| 1192 | echo tutor_kses_html( $output ); |
| 1193 | } |
| 1194 | |
| 1195 | return $output; |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | /** |
| 1200 | * @param bool $echo |
| 1201 | * |
| 1202 | * @return mixed |
| 1203 | * |
| 1204 | * Render Lesson Main Content |
| 1205 | * @since v.1.0.0 |
| 1206 | */ |
| 1207 | if ( ! function_exists( 'tutor_lesson_content' ) ) { |
| 1208 | function tutor_lesson_content( $echo = true ) { |
| 1209 | ob_start(); |
| 1210 | tutor_load_template( 'single.lesson.content' ); |
| 1211 | $output = apply_filters( 'tutor_lesson/single/content', ob_get_clean() ); |
| 1212 | |
| 1213 | if ( $echo ) { |
| 1214 | echo $output; |
| 1215 | } |
| 1216 | |
| 1217 | return $output; |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | if ( ! function_exists( 'tutor_lesson_mark_complete_html' ) ) { |
| 1222 | function tutor_lesson_mark_complete_html( $echo = true ) { |
| 1223 | ob_start(); |
| 1224 | tutor_load_template( 'single.lesson.complete_form' ); |
| 1225 | $output = apply_filters( 'tutor_lesson/single/complete_form', ob_get_clean() ); |
| 1226 | |
| 1227 | if ( $echo ) { |
| 1228 | echo tutor_kses_html( $output ); |
| 1229 | } |
| 1230 | |
| 1231 | return $output; |
| 1232 | } |
| 1233 | } |
| 1234 | |
| 1235 | if ( ! function_exists( 'tutor_course_mark_complete_html' ) ) { |
| 1236 | function tutor_course_mark_complete_html( $echo = true ) { |
| 1237 | ob_start(); |
| 1238 | tutor_load_template( 'single.course.complete_form' ); |
| 1239 | $output = apply_filters( 'tutor_course/single/complete_form', ob_get_clean() ); |
| 1240 | |
| 1241 | if ( $echo ) { |
| 1242 | echo tutor_kses_html( $output ); |
| 1243 | } |
| 1244 | |
| 1245 | return $output; |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | |
| 1250 | /** |
| 1251 | * @param bool $echo |
| 1252 | * |
| 1253 | * @return mixed |
| 1254 | * |
| 1255 | * @show progress bar about course complete |
| 1256 | * |
| 1257 | * @since v.1.0.0 |
| 1258 | */ |
| 1259 | |
| 1260 | if ( ! function_exists( 'tutor_course_completing_progress_bar' ) ) { |
| 1261 | function tutor_course_completing_progress_bar( $echo = true ) { |
| 1262 | ob_start(); |
| 1263 | tutor_load_template( 'single.course.enrolled.completing-progress' ); |
| 1264 | $output = apply_filters( 'tutor_course/single/completing-progress-bar', ob_get_clean() ); |
| 1265 | |
| 1266 | if ( $echo ) { |
| 1267 | echo tutor_kses_html( $output ); |
| 1268 | } |
| 1269 | |
| 1270 | return $output; |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | function tutor_course_question_and_answer( $echo = true ) { |
| 1275 | ob_start(); |
| 1276 | tutor_load_template( 'single.course.enrolled.question_and_answer' ); |
| 1277 | $output = apply_filters( 'tutor_course/single/question_and_answer', ob_get_clean() ); |
| 1278 | |
| 1279 | if ( $echo ) { |
| 1280 | echo $output; |
| 1281 | } |
| 1282 | |
| 1283 | return $output; |
| 1284 | } |
| 1285 | |
| 1286 | |
| 1287 | function tutor_course_announcements( $echo = true ) { |
| 1288 | ob_start(); |
| 1289 | tutor_load_template( 'single.course.enrolled.announcements' ); |
| 1290 | $output = apply_filters( 'tutor_course/single/announcements', ob_get_clean() ); |
| 1291 | |
| 1292 | if ( $echo ) { |
| 1293 | echo $output; |
| 1294 | } |
| 1295 | |
| 1296 | return $output; |
| 1297 | } |
| 1298 | |
| 1299 | function tutor_single_quiz_top( $echo = true ) { |
| 1300 | ob_start(); |
| 1301 | tutor_load_template( 'single.quiz.top' ); |
| 1302 | $output = apply_filters( 'tutor_single_quiz/top', ob_get_clean() ); |
| 1303 | |
| 1304 | if ( $echo ) { |
| 1305 | echo $output; |
| 1306 | } |
| 1307 | return $output; |
| 1308 | } |
| 1309 | |
| 1310 | function tutor_single_quiz_body( $echo = true ) { |
| 1311 | ob_start(); |
| 1312 | tutor_load_template( 'single.quiz.body' ); |
| 1313 | $output = apply_filters( 'tutor_single_quiz/body', ob_get_clean() ); |
| 1314 | |
| 1315 | if ( $echo ) { |
| 1316 | echo $output; |
| 1317 | } |
| 1318 | return $output; |
| 1319 | } |
| 1320 | |
| 1321 | /** |
| 1322 | * @param bool $echo |
| 1323 | * |
| 1324 | * @return mixed|void |
| 1325 | * |
| 1326 | * Get the quiz description |
| 1327 | */ |
| 1328 | function tutor_single_quiz_content( $echo = true ) { |
| 1329 | ob_start(); |
| 1330 | tutor_load_template( 'single.quiz.content' ); |
| 1331 | $output = apply_filters( 'tutor_single_quiz/content', ob_get_clean() ); |
| 1332 | |
| 1333 | if ( $echo ) { |
| 1334 | echo $output; |
| 1335 | } |
| 1336 | return $output; |
| 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | function tutor_single_quiz_no_course_belongs( $echo = true ) { |
| 1341 | ob_start(); |
| 1342 | tutor_load_template( 'single.quiz.no_course_belongs' ); |
| 1343 | $output = apply_filters( 'tutor_single_quiz/no_course_belongs', ob_get_clean() ); |
| 1344 | |
| 1345 | if ( $echo ) { |
| 1346 | echo $output; |
| 1347 | } |
| 1348 | return $output; |
| 1349 | } |
| 1350 | |
| 1351 | function single_quiz_contents( $echo = true ) { |
| 1352 | |
| 1353 | ob_start(); |
| 1354 | tutor_load_template( 'single.quiz.single_quiz_contents' ); |
| 1355 | $output = apply_filters( 'tutor_single_quiz/single_quiz_contents', ob_get_clean() ); |
| 1356 | |
| 1357 | if ( $echo ) { |
| 1358 | echo $output; |
| 1359 | } |
| 1360 | return $output; |
| 1361 | } |
| 1362 | |
| 1363 | function get_tutor_course_level( $course_id = 0 ) { |
| 1364 | if ( ! $course_id ) { |
| 1365 | $course_id = get_the_ID(); |
| 1366 | } |
| 1367 | if ( ! $course_id ) { |
| 1368 | return ''; |
| 1369 | } |
| 1370 | |
| 1371 | $course_level = get_post_meta( $course_id, '_tutor_course_level', true ); |
| 1372 | |
| 1373 | if ( $course_level ) { |
| 1374 | return tutor_utils()->course_levels( $course_level ); |
| 1375 | } |
| 1376 | return false; |
| 1377 | } |
| 1378 | |
| 1379 | if ( ! function_exists( 'get_tutor_course_duration_context' ) ) { |
| 1380 | function get_tutor_course_duration_context( $course_id = 0 ) { |
| 1381 | if ( ! $course_id ) { |
| 1382 | $course_id = get_the_ID(); |
| 1383 | } |
| 1384 | if ( ! $course_id ) { |
| 1385 | return ''; |
| 1386 | } |
| 1387 | $duration = get_post_meta( $course_id, '_course_duration', true ); |
| 1388 | $durationHours = tutor_utils()->avalue_dot( 'hours', $duration ); |
| 1389 | $durationMinutes = tutor_utils()->avalue_dot( 'minutes', $duration ); |
| 1390 | $durationSeconds = tutor_utils()->avalue_dot( 'seconds', $duration ); |
| 1391 | |
| 1392 | if ( $duration ) { |
| 1393 | $output = ''; |
| 1394 | if ( $durationHours > 0 ) { |
| 1395 | $output .= $durationHours . 'h '; |
| 1396 | } |
| 1397 | |
| 1398 | if ( $durationMinutes > 0 ) { |
| 1399 | $output .= $durationMinutes . 'm '; |
| 1400 | } |
| 1401 | |
| 1402 | if ( $durationSeconds > 0 ) { |
| 1403 | $output .= $durationSeconds . 's '; |
| 1404 | } |
| 1405 | |
| 1406 | return $output; |
| 1407 | } |
| 1408 | |
| 1409 | return false; |
| 1410 | } |
| 1411 | } |
| 1412 | if ( ! function_exists( 'get_tutor_course_categories' ) ) { |
| 1413 | function get_tutor_course_categories( $course_id = 0 ) { |
| 1414 | if ( ! $course_id ) { |
| 1415 | $course_id = get_the_ID(); |
| 1416 | } |
| 1417 | $terms = get_the_terms( $course_id, 'course-category' ); |
| 1418 | |
| 1419 | return $terms; |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | /** |
| 1424 | * @param int $course_id |
| 1425 | * |
| 1426 | * @return array|false|WP_Error |
| 1427 | * |
| 1428 | * Get course tags |
| 1429 | */ |
| 1430 | |
| 1431 | if ( ! function_exists( 'get_tutor_course_tags' ) ) { |
| 1432 | function get_tutor_course_tags( $course_id = 0 ) { |
| 1433 | if ( ! $course_id ) { |
| 1434 | $course_id = get_the_ID(); |
| 1435 | } |
| 1436 | $terms = get_the_terms( $course_id, 'course-tag' ); |
| 1437 | |
| 1438 | return $terms; |
| 1439 | } |
| 1440 | } |
| 1441 | |
| 1442 | /** |
| 1443 | * @param bool $echo |
| 1444 | * |
| 1445 | * @return mixed|void |
| 1446 | * |
| 1447 | * Template for course tags html |
| 1448 | */ |
| 1449 | |
| 1450 | if ( ! function_exists( 'tutor_course_tags_html' ) ) { |
| 1451 | function tutor_course_tags_html( $echo = true ) { |
| 1452 | ob_start(); |
| 1453 | tutor_load_template( 'single.course.tags' ); |
| 1454 | $output = apply_filters( 'tutor_course/single/tags_html', ob_get_clean() ); |
| 1455 | |
| 1456 | if ( $echo ) { |
| 1457 | echo tutor_kses_html( $output ); |
| 1458 | } |
| 1459 | |
| 1460 | return $output; |
| 1461 | } |
| 1462 | } |
| 1463 | |
| 1464 | /** |
| 1465 | * @param bool $echo |
| 1466 | * |
| 1467 | * @return mixed |
| 1468 | * |
| 1469 | * Get Q&A in lesson sidebar |
| 1470 | */ |
| 1471 | |
| 1472 | if ( ! function_exists( 'tutor_lesson_sidebar_question_and_answer' ) ) { |
| 1473 | function tutor_lesson_sidebar_question_and_answer( $echo = true ) { |
| 1474 | ob_start(); |
| 1475 | tutor_load_template( 'single.lesson.sidebar_question_and_answer' ); |
| 1476 | $output = apply_filters( 'tutor_lesson/single/sidebar_question_and_answer', ob_get_clean() ); |
| 1477 | |
| 1478 | if ( $echo ) { |
| 1479 | echo tutor_kses_html( $output ); |
| 1480 | } |
| 1481 | |
| 1482 | return $output; |
| 1483 | } |
| 1484 | } |
| 1485 | |
| 1486 | /** |
| 1487 | * @param bool $echo |
| 1488 | * |
| 1489 | * @return mixed|void |
| 1490 | * |
| 1491 | * Get Social Share button to share on social media |
| 1492 | */ |
| 1493 | |
| 1494 | if ( ! function_exists( 'tutor_social_share' ) ) { |
| 1495 | function tutor_social_share( $echo = true ) { |
| 1496 | |
| 1497 | $output = ''; |
| 1498 | $tutor_social_share_icons = tutor_utils()->tutor_social_share_icons(); |
| 1499 | |
| 1500 | if ( tutor_utils()->count( $tutor_social_share_icons ) ) { |
| 1501 | ob_start(); |
| 1502 | tutor_load_template( 'single.course.social_share', array( 'tutor_social_share_icons' => $tutor_social_share_icons ) ); |
| 1503 | $output = apply_filters( 'tutor_course/single/social_share', ob_get_clean() ); |
| 1504 | } |
| 1505 | |
| 1506 | if ( $echo && $output != '' ) { |
| 1507 | echo '<span>' . __( 'Share:', 'tutor' ) . '</span>'; |
| 1508 | echo tutor_kses_html( $output ); |
| 1509 | } |
| 1510 | |
| 1511 | return $output; |
| 1512 | } |
| 1513 | } |
| 1514 | |
| 1515 | /** |
| 1516 | * @param bool $echo |
| 1517 | * |
| 1518 | * @return mixed |
| 1519 | * |
| 1520 | * Get Assignment content |
| 1521 | * |
| 1522 | * @since v.1.3.3 |
| 1523 | */ |
| 1524 | |
| 1525 | if ( ! function_exists( 'tutor_assignment_content' ) ) { |
| 1526 | function tutor_assignment_content( $echo = true ) { |
| 1527 | ob_start(); |
| 1528 | tutor_load_template( 'single.assignment.content' ); |
| 1529 | $output = apply_filters( 'tutor_assignment/single/content', ob_get_clean() ); |
| 1530 | |
| 1531 | if ( $echo ) { |
| 1532 | echo tutor_kses_html( $output ); |
| 1533 | } |
| 1534 | |
| 1535 | return $output; |
| 1536 | } |
| 1537 | } |
| 1538 | |
| 1539 | /** |
| 1540 | * @param string $msg |
| 1541 | * @param string $title |
| 1542 | * @param string $type |
| 1543 | * |
| 1544 | * @return string |
| 1545 | * |
| 1546 | * @since v.1.4.0 |
| 1547 | */ |
| 1548 | |
| 1549 | if ( ! function_exists( 'get_tnotice' ) ) { |
| 1550 | function get_tnotice( $msg = '', $title = 'Success', $type = 'success' ) { |
| 1551 | |
| 1552 | $output = '<div class="tnotice tnotice--' . $type . '"> |
| 1553 | <div class="tnotice__icon">¡</div> |
| 1554 | <div class="tnotice__content">'; |
| 1555 | |
| 1556 | if ( $title ) { |
| 1557 | $output .= '<p class="tnotice__type">' . $title . '</p>'; |
| 1558 | } |
| 1559 | $output .= '<p class="tnotice__message">' . $msg . '</p> |
| 1560 | </div> |
| 1561 | </div>'; |
| 1562 | |
| 1563 | return $output; |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | /** |
| 1568 | * @param int $course_content_id |
| 1569 | * @param bool $echo |
| 1570 | * |
| 1571 | * @return mixed|void |
| 1572 | * |
| 1573 | * Next Previous Pagination |
| 1574 | * |
| 1575 | * @since v.1.4.7 |
| 1576 | */ |
| 1577 | |
| 1578 | function tutor_next_previous_pagination( $course_content_id = 0, $echo = true ) { |
| 1579 | $content_id = tutils()->get_post_id( $course_content_id ); |
| 1580 | $contents = tutils()->get_course_prev_next_contents_by_id( $content_id ); |
| 1581 | $previous_id = $contents->previous_id; |
| 1582 | $next_id = $contents->next_id; |
| 1583 | |
| 1584 | ob_start(); |
| 1585 | do_action( 'tutor_lesson_next_previous_pagination_before' ); |
| 1586 | tutor_load_template( 'single.next-previous-pagination', compact( 'previous_id', 'next_id' ) ); |
| 1587 | do_action( 'tutor_lesson_next_previous_pagination_after' ); |
| 1588 | $output = apply_filters( 'tutor/single/next_previous_pagination', ob_get_clean() ); |
| 1589 | |
| 1590 | if ( $echo ) { |
| 1591 | echo tutor_kses_html( $output ); |
| 1592 | } |
| 1593 | |
| 1594 | return $output; |
| 1595 | } |
| 1596 | |
| 1597 | /** |
| 1598 | * @param bool $echo |
| 1599 | * @return string |
| 1600 | * |
| 1601 | * Display login form in popup where necessary |
| 1602 | * |
| 1603 | * @since v.1.5.8 |
| 1604 | */ |
| 1605 | |
| 1606 | if ( ! function_exists( 'tutor_login_form_popup' ) ) { |
| 1607 | function tutor_login_form_popup( $echo = true ) { |
| 1608 | $output = ''; |
| 1609 | ob_start(); |
| 1610 | tutor_load_template( 'single.course.login' ); |
| 1611 | $login_form = apply_filters( 'tutor_course/global/login', ob_get_clean() ); |
| 1612 | $output .= '<div class="tutor-cart-box-login-form" style="display: none;"><span class="login-overlay-close"></span><div class="tutor-cart-box-login-form-inner"><button class="tutor-popup-form-close tutor-icon-line-cross"></button>' . $login_form . '</div></div>'; |
| 1613 | |
| 1614 | $output = apply_filters( 'tutor_login_form_popup_html', $output ); |
| 1615 | |
| 1616 | if ( $echo ) { |
| 1617 | echo tutor_kses_html( $output ); |
| 1618 | } |
| 1619 | return $output; |
| 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | /** |
| 1624 | * Load custom template from any given file |
| 1625 | * |
| 1626 | * Pass parameter as wish |
| 1627 | * |
| 1628 | * @since 1.9.8 |
| 1629 | */ |
| 1630 | if ( ! function_exists( 'tutor_load_template_from_custom_path' ) ) { |
| 1631 | function tutor_load_template_from_custom_path( $template = null, $data = array() ) { |
| 1632 | do_action( 'tutor_load_template_from_custom_path_before', $template, $data ); |
| 1633 | if ( file_exists( $template ) ) { |
| 1634 | include_once $template; |
| 1635 | } |
| 1636 | do_action( 'tutor_load_template_from_custom_path_after', $template, $data ); |
| 1637 | } |
| 1638 | } |
| 1639 |