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