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