Skip to content

Commit

Permalink
Update: coming soon display logic and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Anindra123 committed Feb 13, 2025
1 parent 46b7c66 commit 650d7d4
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 69 deletions.
21 changes: 11 additions & 10 deletions assets/scss/front/__archive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1473,21 +1473,22 @@ table.course-single-gradebooks a {
/**
* Coming soon block
*/
.tutor-coming-soon-btn{
.tutor-coming-soon-wrapper{
background-color: rgba(244, 249, 253, 1);
color: rgba(91, 97, 111, 1);
font-size: 13px;
line-height: 16px;
border-radius: 4px;
padding: 4px 25px 4px 20px;
font-weight: 500;
padding: 4px 25px 4px 21px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}

.tutor-add-to-cart-coming-soon-btn{
background-color: rgba(244, 249, 253, 1);
color: rgba(91, 97, 111, 1);
font-size: 13px;
line-height: 16px;
border-radius: 4px;
padding: 6px 8px 6px 8px;
max-width: 148px;

.tutor-coming-soon-wrapper.entry-box-wrapper {
padding: 7px 23px 7px 24px;

}
12 changes: 0 additions & 12 deletions assets/scss/front/_single_course.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,3 @@ table.course-single-gradebooks .datetime {
}
}


/**
* Coming soon block
*/
.tutor-coming-soon-btn{
background-color: rgba(244, 249, 253, 1);
color: rgba(91, 97, 111, 1);
font-size: 13px;
line-height: 16px;
border-radius: 4px;
padding: 4px 25px 4px 20px;
}
126 changes: 79 additions & 47 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,84 @@ public function __construct( $register_hooks = true ) {
add_filter( 'tutor_course_thumbnail_id', array( $this, 'set_coming_soon_thumbnail' ), 10, 2 );
add_filter( 'tutor_course_thumbnail_placeholder', array( $this, 'set_coming_soon_placeholder' ), 11, 2 );
add_action( 'pre_get_posts', array( $this, 'get_coming_soon_details' ) );
add_filter( 'tutor_add_to_cart_btn', array( $this, 'set_entry_box_coming_soon_button' ), 10, 2 );
add_filter( 'tutor_get_course_topics', array( $this, 'show_course_curriculum' ) );
add_filter( 'tutor_course_filter_args', array( $this, 'show_filtered_coming_soon_courses' ) );
add_action( 'tutor_course/single/entry/after', array( $this, 'set_entry_box_coming_soon_button' ), 10, 1 );
add_action( 'tutor_course_loop_footer_bottom', array( $this, 'show_course_coming_soon' ) );
add_filter( 'tutor_add_to_cart_btn', array( $this, 'remove_coming_soon_add_to_cart' ), 10, 2 );
add_filter( 'tutor_course_loop_add_to_cart_button', array( $this, 'remove_coming_soon_add_to_cart' ), 10, 2 );
}

/**
* Remove add to cart button when course coming soon.
*
* @since 3.3.0
*
* @param string $button the button content.
* @param int $course_id the course id.
*
* @return string
*/
public function remove_coming_soon_add_to_cart( $button, $course_id ) {
$course_coming_soon = (bool) get_post_meta( $course_id, '_tutor_course_enable_coming_soon', true );

if ( $course_coming_soon ) {
$button = '';
}

return $button;
}

/**
* Show coming soon on course list.
*
* @since 3.3.0
*
* @param int $course_id the course id.
*
* @return void
*/
public function show_course_coming_soon( $course_id ) {
$course = get_post( $course_id );
$course_coming_soon = (bool) get_post_meta( $course_id, '_tutor_course_enable_coming_soon', true );

if ( $course_coming_soon ) {
echo '<div class="tutor-coming-soon-wrapper">
<span class="tutor-icon-book-open-line tutor-color-black"></span>
<div class="tutor-fw-medium">
'
. __( 'Course available on ', 'tutor' ) .

Check failure on line 330 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'.
'<span class="tutor-utc-date-time tutor-color-success">' . esc_html( $course->post_date_gmt ) . '</span>' .
'
</div>
</div>';
}
}

/**
* Set coming soon for single course entry box.
*
* @since 3.3.0
*
* @param int $course_id the course id.
*
* @return void
*/
public function set_entry_box_coming_soon_button( $course_id ) {
$course = get_post( $course_id );
$course_coming_soon = (bool) get_post_meta( $course_id, '_tutor_course_enable_coming_soon', true );

if ( $course_coming_soon ) {
echo '<div class="tutor-coming-soon-wrapper entry-box-wrapper">
<span class="tutor-icon-book-open-line tutor-color-black"></span>
<div class="tutor-fw-medium">
'
. __( 'Course available on ', 'tutor' ) .

Check failure on line 356 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'.
'<span class="tutor-utc-date-time tutor-color-primary">' . esc_html( $course->post_date_gmt ) . '</span>' .
'
</div>
</div>';
}
}

/**
Expand Down Expand Up @@ -355,36 +430,6 @@ public function show_course_curriculum( $topics ) {
return $topics;
}

/**
* Restrict enrollment in course entry box for single course.
*
* @since 3.3.0
*
* @param string $button the enrollment button html.
* @param int $course_id the course id.
*
* @return string
*/
public function set_entry_box_coming_soon_button( $button, $course_id ) {
$course = get_post( $course_id );
$course_coming_soon = (bool) get_post_meta( $course_id, '_tutor_course_enable_coming_soon', true );
$available_date = tutor_get_formated_date( get_option( 'date_format' ), $course->post_date ) . ', ' . tutor_get_formated_date( get_option( 'time_format' ), $course->post_date );

if ( $course_coming_soon ) {
$button = '<div class="tutor-d-flex tutor-flex-row tutor-align-center tutor-justify-center tutor-coming-soon-btn tutor-gap-1">
<span class="tutor-icon-book-open-o tutor-fs-4 tutor-color-black"></span>
<div class="tutor-fw-medium">
'
. __( 'Course available on ', 'tutor' ) .
'<span class="tutor-utc-date-time tutor-color-primary">' . esc_html( $available_date ) . '</span>' .
'
</div>
</div>';
}

return $button;
}

/**
* Show coming soon course details for students.
*
Expand Down Expand Up @@ -1799,32 +1844,19 @@ public function tutor_update_course_content_order() {
* Restrict new student entry
*
* @since 1.0.0
* @param mixed $content content.
*
* @since 3.3.0
*
* @param mixed $content content.
* @param int $course_id the course id.
*
* @return mixed
*/
public function restrict_new_student_entry( $content, $course_id ) {

$course = get_post( $course_id );
$is_purchasable = tutor_utils()->is_course_purchasable( $course_id );
$course_coming_soon = (bool) get_post_meta( $course_id, '_tutor_course_enable_coming_soon', true );
$available_date = tutor_get_formated_date( get_option( 'date_format' ), $course->post_date ) . ', ' . tutor_get_formated_date( get_option( 'time_format' ), $course->post_date );
$btn_class = $is_purchasable ? 'tutor-add-to-cart-coming-soon-btn' : 'tutor-coming-soon-btn';
$icon_size = $is_purchasable ? 'tutor-fs-5' : 'tutor-fs-4';

if ( $course_coming_soon ) {
return '<div class="tutor-d-flex tutor-flex-row tutor-align-center tutor-justify-center ' . $btn_class . ' tutor-gap-1">
<span class="tutor-icon-book-open-o ' . $icon_size . ' tutor-color-black"></span>
<div class="tutor-fw-medium">
'
. __( 'Course available on ', 'tutor' ) .
'<span class="tutor-utc-date-time tutor-color-success">' . esc_html( $available_date ) . '</span>' .
'
</div>
</div>';
$content = '';
}

if ( ! tutor_utils()->is_course_fully_booked() ) {
Expand Down

0 comments on commit 650d7d4

Please sign in to comment.