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