Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks Added To Implement Enrollment Restriction Feature #1576

Open
wants to merge 3 commits into
base: 3.3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion templates/loop/add-to-cart-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
exit;
}

$course_id = get_the_ID();
$product_id = tutor_utils()->get_course_product_id();
$product = wc_get_product( $product_id );

Expand Down Expand Up @@ -82,6 +83,7 @@
),
$product,
$args
)
),
$course_id
);

2 changes: 1 addition & 1 deletion templates/loop/course-in-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

if ( $product ) {
$price_html = '<div class="tutor-d-flex tutor-align-center tutor-justify-between"><div class="list-item-price tutor-d-flex tutor-align-center"> <span class="price tutor-fs-6 tutor-fw-bold tutor-color-black">' . $product->get_price_html() . ' </span></div>';
$cart_html = '<div class="list-item-button"> ' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) . ' </div></div>';
$cart_html = '<div class="list-item-button"> ' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) . ' </div></div>';
}
}
echo wp_kses_post( $price_html );
Expand Down
6 changes: 3 additions & 3 deletions templates/loop/course-price-edd.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function( $defaults ) {

<?php
$course_id = get_the_ID();
$enroll_btn = '<div class="list-item-button">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block">' . __( 'Enroll Course', 'tutor' ) . '</a>' ) . '</div>';
$enroll_btn = '<div class="list-item-button">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block">' . __( 'Enroll Course', 'tutor' ) . '</a>', $course_id ) . '</div>';
$free_html = $enroll_btn;
if ( tutor_utils()->is_course_purchasable() ) {
$enroll_btn = tutor_course_loop_add_to_cart( false );
Expand Down Expand Up @@ -59,7 +59,7 @@ function( $defaults ) {
</div>
</div>
<div class="list-item-button tutor-mt-16 booking-available">
' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) . '
' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) . '
</div>';
// @codingStandardsIgnoreEnd
}
Expand Down Expand Up @@ -89,7 +89,7 @@ function( $defaults ) {
<div class="list-item-button">
<?php
// PHPCS - the variable $enroll_btn holds safe data.
echo apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --safe data
echo apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --safe data
?>
</div>
<?php
Expand Down
6 changes: 3 additions & 3 deletions templates/loop/course-price-tutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$required_loggedin_class = apply_filters( 'tutor_enroll_required_login_class', 'tutor-open-login-modal' );
}

$enroll_btn = '<div class="tutor-course-list-btn">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . $required_loggedin_class . '">' . __( 'Enroll Course', 'tutor' ) . '</a>' ) . '</div>';
$enroll_btn = '<div class="tutor-course-list-btn">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . $required_loggedin_class . '">' . __( 'Enroll Course', 'tutor' ) . '</a>', $course_id ) . '</div>';
$free_html = $enroll_btn;


Expand All @@ -43,7 +43,7 @@
</span>
</div>
<div class="list-item-button">
<?php echo wp_kses_post( apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) ); ?>
<?php echo wp_kses_post( apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) ); ?>
</div>
</div>
<?php
Expand All @@ -68,7 +68,7 @@
</div>
</div>
<div class="tutor-course-booking-availability tutor-mt-16">
<?php echo wp_kses_post( apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) ); ?>
<?php echo wp_kses_post( apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) ); ?>
</div>
<?php
} elseif ( $maximum_students > 0 && $maximum_students === $total_enrolled ) {
Expand Down
6 changes: 3 additions & 3 deletions templates/loop/course-price-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$required_loggedin_class = apply_filters( 'tutor_enroll_required_login_class', 'tutor-open-login-modal' );
}

$enroll_btn = '<div class="tutor-course-list-btn">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . $required_loggedin_class . '">' . __( 'Enroll Course', 'tutor' ) . '</a>' ) . '</div>';
$enroll_btn = '<div class="tutor-course-list-btn">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . $required_loggedin_class . '">' . __( 'Enroll Course', 'tutor' ) . '</a>', $course_id ) . '</div>';
$free_html = $enroll_btn;

// Show purchase button if purchaseable.
Expand Down Expand Up @@ -67,7 +67,7 @@
</div>
</div>
<div class="tutor-course-booking-availability tutor-mt-16"> ' .
apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) . '
apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) . '
</div>';
// @codingStandardsIgnoreEnd
}
Expand All @@ -81,7 +81,7 @@

if ( $product && 0 === $maximum_students ) {
$price_html = '<div class=" ' . $utility_classes . ' "><div class="list-item-price tutor-d-flex tutor-align-center"> <span class="price tutor-fs-6 tutor-fw-bold tutor-color-black">' . $wc_price_html . ' </span></div>';
$cart_html = '<div class="list-item-button"> ' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) . ' </div></div>';
$cart_html = '<div class="list-item-button"> ' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) . ' </div></div>';
echo $price_html; //phpcs:ignore --contain safe data
echo $cart_html; //phpcs:ignore
}
Expand Down
6 changes: 3 additions & 3 deletions templates/loop/course-price.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$attrs_string .= sprintf( '%s="%s" ', esc_attr( $key ), esc_attr( $value ) );
}

$enroll_btn = '<div class="tutor-course-list-btn">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . $button_class . ' " data-course-id="' . $course_id . '" ' . trim( $attrs_string ) . '>' . __( 'Enroll Course', 'tutor' ) . '</a>' ) . '</div>';
$enroll_btn = '<div class="tutor-course-list-btn">' . apply_filters( 'tutor_course_restrict_new_entry', '<a href="' . get_the_permalink() . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . $button_class . ' " data-course-id="' . $course_id . '" ' . trim( $attrs_string ) . '>' . __( 'Enroll Course', 'tutor' ) . '</a>', $course_id ) . '</div>';
$free_html = $enroll_btn;

if ( tutor_utils()->is_course_purchasable() ) {
Expand Down Expand Up @@ -68,7 +68,7 @@
</div>
<div class="tutor-course-booking-availability tutor-mt-16">
<button class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block">' .
apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) . '
apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) . '
</button>
</div>';
}
Expand All @@ -82,7 +82,7 @@

if ( $product && 0 == $maximum_students ) {
$price_html = '<div class="tutor-d-flex tutor-align-center tutor-justify-between"><div class="list-item-price tutor-d-flex tutor-align-center"> <span class="price tutor-fs-6 tutor-fw-bold tutor-color-black">' . $product->get_price_html() . ' </span></div>';
$cart_html = '<div class="list-item-button"> ' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn ) . ' </div></div>';
$cart_html = '<div class="list-item-button"> ' . apply_filters( 'tutor_course_restrict_new_entry', $enroll_btn, $course_id ) . ' </div></div>';
echo wp_kses_post( $price_html );
echo wp_kses_post( $cart_html );
}
Expand Down
4 changes: 3 additions & 1 deletion templates/loop/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @since 1.4.3
*/

$course_id = get_the_ID();

do_action( 'tutor_course/loop/before_content' );

do_action( 'tutor_course/loop/badge' );
Expand Down Expand Up @@ -52,7 +54,7 @@

do_action( 'tutor_course/loop/before_footer' );
do_action( 'tutor_course/loop/footer' );
do_action( 'tutor_course/loop/after_footer' );
do_action( 'tutor_course/loop/after_footer', $course_id );

do_action( 'tutor_course/loop/after_content' );

Expand Down
3 changes: 2 additions & 1 deletion templates/single/course/add-to-cart-edd.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* @since 1.4.3
*/

$course_id = get_the_ID();
$product_id = tutor_utils()->get_course_product_id();
$download = new EDD_Download( $product_id );

if ( $download->ID ) {
echo edd_get_purchase_link( array( 'download_id' => $download->ID ) ); //phpcs:ignore
echo apply_filters( 'tutor_add_to_cart_btn', edd_get_purchase_link( array( 'download_id' => $download->ID ) ), $course_id ); //phpcs:ignore
} else {
?>
<p class="tutor-alert-warning">
Expand Down
6 changes: 5 additions & 1 deletion templates/single/course/add-to-cart-tutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@
<a href="<?php echo esc_url( $cart_page_url ? $cart_page_url : '#' ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-mt-24 tutor-btn-lg tutor-btn-block <?php echo esc_attr( $cart_page_url ? '' : 'tutor-cart-page-not-configured' ); ?>">
<?php esc_html_e( 'View Cart', 'tutor' ); ?>
</a>
<?php } else { ?>
<?php
} else {
ob_start();
?>
<div class="tutor-mt-24">
<button type="button" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block <?php echo esc_attr( $required_loggedin_class ); ?>" data-course-id="<?php echo esc_attr( $course_id ); ?>" data-course-single>
<span class="tutor-icon-cart-line tutor-mr-8"></span>
<span><?php esc_html_e( 'Add to Cart', 'tutor' ); ?></span>
</button>
</div>
<?php
echo apply_filters( 'tutor_add_to_cart_btn', ob_get_clean(), $course_id ); //phpcs:ignore --already filtered
}
2 changes: 2 additions & 0 deletions templates/single/course/add-to-cart-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
</button>
</form>
<?php
ob_start();
echo apply_filters( 'tutor_add_to_cart_btn', ob_get_clean(), get_the_ID() ); //phpcs:ignore
}
} else {
?>
Expand Down
Loading