Skip to content

Commit

Permalink
wpml conflict,translation,add to cart , lesson edit issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahim-kardi committed Jun 6, 2023
1 parent eb9603f commit 8265149
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 230 deletions.
2 changes: 1 addition & 1 deletion classes/AssetsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static function set_default_template() {
$elementorData = file_get_contents( ETLMS_DIR_PATH . '/assets/layout/default.json' );
$elementorData = json_decode( $elementorData, true );
update_post_meta( $postID, '_elementor_controls_usage', $elementorData['controls'] );
update_post_meta( $postID, '_elementor_data', $elementorData['layout'] );
update_post_meta( $postID, '_elementor_data', json_encode( $elementorData['layout'] ) );
update_post_meta( $postID, $meta_key, 'yes' );
}
}
Expand Down
19 changes: 17 additions & 2 deletions classes/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace TutorLMS\Elementor;

use Elementor\Elements_Manager;
use TUTOR\User;

defined( 'ABSPATH' ) || die();

Expand All @@ -37,15 +38,29 @@ public function i18n() {
load_plugin_textdomain( 'tutor-lms-elementor-addons' );
}


public function init() {

$this->load_files();

// Plugin row meta
// Plugin row meta.
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
// Register custom category
// Register custom category.
add_action( 'elementor/elements/categories_registered', array( $this, 'add_category' ) );

add_filter(
'tutor_has_lesson_content',
function( $bool ) {
// Check if user is privileged.
$roles = array( User::ADMIN, User::INSTRUCTOR );
if ( ! User::has_any_role( $roles ) ) {
return $bool;
} else {
return true;
}
}
);

AddonsManager::init();
AssetsManager::init();
Template::instance();
Expand Down
22 changes: 12 additions & 10 deletions includes/addons/CourseCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function register_content_controls() {
),
),
'default' => 'row',
'prefix_class' => self::$prefix_class_layout . '%s',
'prefix_class' => self::$prefix_class_layout . '%s',
'toggle' => false,
'selectors' => array(
'{{WRAPPER}} .etlms-course-categories' => 'flex-direction: {{VALUE}};',
Expand Down Expand Up @@ -128,7 +128,7 @@ protected function register_content_controls() {
),
),
'selectors' => array(
'{{WRAPPER}} .etlms-course-categories' => 'gap: {{SIZE}}{{UNIT}};'
'{{WRAPPER}} .etlms-course-categories' => 'gap: {{SIZE}}{{UNIT}};',
),
)
);
Expand Down Expand Up @@ -258,23 +258,25 @@ protected function render() {
$course_categories = get_tutor_course_categories();
}

if ( is_array( $course_categories ) && count( $course_categories ) ) : $item = 1; ?>
if ( is_array( $course_categories ) && count( $course_categories ) ) :
$item = 1; ?>
<div class="etlms-course-categories tutor-meta">
<span class="tutor-meta-key"><?php esc_html_e('Categories', 'tutor'); ?></span>
<span class="tutor-meta-key"><?php esc_html_e( 'Categories', 'tutor-lms-elementor-addons' ); ?></span>
<span>
<?php
$category_links = array();
foreach ( $course_categories as $course_category ) :
$category_name = $course_category->name;
$category_link = get_term_link($course_category->term_id);
$category_links[] = wp_sprintf( '<a href="%1$s">%2$s</a>', esc_url( $category_link ), esc_html( $category_name ) );
foreach ( $course_categories as $course_category ) :
$category_name = $course_category->name;
$category_link = get_term_link( $course_category->term_id );
$category_links[] = wp_sprintf( '<a href="%1$s">%2$s</a>', esc_url( $category_link ), esc_html( $category_name ) );
endforeach;
echo implode(', ', $category_links);
echo implode( ', ', $category_links );
?>
</span>
</div>
<?php else : ?>
<?php if ( $this->is_elementor_editor() ) :
<?php
if ( $this->is_elementor_editor() ) :
esc_html_e( 'Please add category from Tutor course builder', 'tutor-lms-elementor-addons' );
endif;
endif;
Expand Down
14 changes: 7 additions & 7 deletions templates/course/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ function truncate( $text, $length = 100, $ending = '...', $exact = true, $consid
}
}

$excerpt = tutor_get_the_excerpt();
$is_enabled = get_tutor_option( 'enable_course_about' );
$string = $excerpt;
$limit = 100;
$has_show_more = false;
$excerpt = tutor_get_the_excerpt();
$is_enabled = get_tutor_option( 'enable_course_about' );
$string = $excerpt;
$limit = 100;
$has_show_more = false;

if ( strlen( $string ) > $limit ) {
$has_show_more = true;
Expand All @@ -111,7 +111,7 @@ function truncate( $text, $length = 100, $ending = '...', $exact = true, $consid

<?php if ( ! empty( $excerpt ) && $is_enabled ) : ?>
<div class='etlms-course-about tutor-mb-48'>
<div class='<?php echo $has_show_more ? "tutor-toggle-more-content tutor-toggle-more-collapsed" : "" ?>' <?php echo $has_show_more ? "data-tutor-toggle-more-content data-toggle-height='200' style='height: 200px;'" : "" ?>>
<div class='<?php echo $has_show_more ? 'tutor-toggle-more-content tutor-toggle-more-collapsed' : ''; ?>' <?php echo $has_show_more ? "data-tutor-toggle-more-content data-toggle-height='200' style='height: 200px;'" : ''; ?>>
<?php
if ( \Elementor\Plugin::instance()->editor->is_edit_mode() && empty( $excerpt ) ) {
echo '<span style="margin: 5px">' . esc_html__( 'Please add data from the course editor', 'tutor-lms-elementor-addons' ) . '</span>';
Expand All @@ -130,7 +130,7 @@ function truncate( $text, $length = 100, $ending = '...', $exact = true, $consid
<?php if ( $has_show_more ) : ?>
<a href="#" class="tutor-btn-show-more tutor-btn tutor-btn-ghost tutor-mt-32" data-tutor-toggle-more=".tutor-toggle-more-content">
<span class="tutor-toggle-btn-icon tutor-icon tutor-icon-plus tutor-mr-8" area-hidden="true"></span>
<span class="tutor-toggle-btn-text"><?php esc_html_e( 'Show More', 'tutor' ); ?></span>
<span class="tutor-toggle-btn-text"><?php esc_html_e( 'Show More', 'tutor-lms-elementor-addons' ); ?></span>
</a>
<?php endif; ?>
</div>
Expand Down
12 changes: 6 additions & 6 deletions templates/course/add-to-cart-edd.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/

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

if ($download->ID) {
if ( $download->ID ) {
echo edd_get_purchase_link( array( 'download_id' => $download->ID ) );
} else {
?>
<p class="tutor-alert-warning">
<?php _e('Please make sure that your EDD product exists and valid for this course', 'tutor'); ?>
</p>
<p class="tutor-alert-warning">
<?php _e( 'Please make sure that your EDD product exists and valid for this course', 'tutor-lms-elementor-addons' ); ?>
</p>
<?php
}
}
12 changes: 6 additions & 6 deletions templates/course/add-to-cart-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<?php
} else {
?>
<form action="<?php echo esc_url( apply_filters( 'tutor_course_add_to_cart_form_action', get_permalink( get_the_ID() ) ) ); ?>" method="post" enctype="multipart/form-data">
<button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block tutor-mt-24 tutor-add-to-cart-button">
<span class="btn-icon tutor-icon-cart-filled"></span>
<span><?php echo esc_html( $product->single_add_to_cart_text() ); ?></span>
</button>
</form>
<form action="<?php echo esc_url( apply_filters( 'tutor_course_add_to_cart_form_action', get_permalink( get_the_ID() ) ) ); ?>?add-to-cart=<?php echo esc_attr( $product->get_id() ); ?>" method="post" enctype="multipart/form-data">
<button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block tutor-mt-24 tutor-add-to-cart-button">
<span class="btn-icon tutor-icon-cart-filled"></span>
<span><?php echo esc_html( $product->single_add_to_cart_text() ); ?></span>
</button>
</form>
<?php
}
} else {
Expand Down
62 changes: 31 additions & 31 deletions templates/course/carousel/parts/info.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
<?php
global $post, $authordata;
$profile_url = tutor_utils()->profile_url( $authordata->ID, true );
$course_categories = get_tutor_course_categories();
$show_avatar = $settings['course_carousel_avatar_settings'];
$show_author = $settings['course_carousel_author_settings'];
$show_categories = $settings['course_carousel_category_settings'];
$profile_url = tutor_utils()->profile_url( $authordata->ID, true );
$course_categories = get_tutor_course_categories();
$show_avatar = $settings['course_carousel_avatar_settings'];
$show_author = $settings['course_carousel_author_settings'];
$show_categories = $settings['course_carousel_category_settings'];
?>

<?php if ( $show_avatar || $show_author || $show_categories ) : ?>
<div class="tutor-meta tutor-mt-auto">
<?php if ( $show_avatar ) : ?>
<div>
<a href="<?php echo $profile_url; ?>" class="tutor-d-flex">
<?php echo tutor_utils()->get_tutor_avatar( $post->post_author ); ?>
</a>
</div>
<?php endif; ?>
<?php if ( $show_avatar ) : ?>
<div>
<a href="<?php echo $profile_url; ?>" class="tutor-d-flex">
<?php echo tutor_utils()->get_tutor_avatar( $post->post_author ); ?>
</a>
</div>
<?php endif; ?>

<div>
<?php if ( $show_author ) : ?>
<span class="etlms-course-author-meta tutor-meta-key"><?php esc_html_e('By', 'tutor') ?></span>
<a class="etlms-course-author-meta tutor-meta-value" href="<?php echo $profile_url; ?>"><?php esc_html_e(get_the_author()); ?></a>
<?php endif; ?>
<div>
<?php if ( $show_author ) : ?>
<span class="etlms-course-author-meta tutor-meta-key"><?php esc_html_e( 'By', 'tutor-lms-elementor-addons' ); ?></span>
<a class="etlms-course-author-meta tutor-meta-value" href="<?php echo $profile_url; ?>"><?php esc_html_e( get_the_author() ); ?></a>
<?php endif; ?>

<?php if( $show_categories && ( !empty( $course_categories ) && is_array( $course_categories ) && count( $course_categories ) ) ) : ?>
<span class="etlms-course-category-meta tutor-meta-key"><?php esc_html_e('In', 'tutor'); ?></span>
<?php
$category_links = array();
foreach ( $course_categories as $course_category ) :
$category_name = $course_category->name;
$category_link = get_term_link($course_category->term_id);
$category_links[] = wp_sprintf( '<a class="etlms-course-category-meta tutor-meta-value" href="%1$s">%2$s</a>', esc_url( $category_link ), esc_html( $category_name ) );
endforeach;
echo implode(', ', $category_links);
?>
<?php endif; ?>
</div>
<?php if ( $show_categories && ( ! empty( $course_categories ) && is_array( $course_categories ) && count( $course_categories ) ) ) : ?>
<span class="etlms-course-category-meta tutor-meta-key"><?php esc_html_e( 'In', 'tutor-lms-elementor-addons' ); ?></span>
<?php
$category_links = array();
foreach ( $course_categories as $course_category ) :
$category_name = $course_category->name;
$category_link = get_term_link( $course_category->term_id );
$category_links[] = wp_sprintf( '<a class="etlms-course-category-meta tutor-meta-value" href="%1$s">%2$s</a>', esc_url( $category_link ), esc_html( $category_name ) );
endforeach;
echo implode( ', ', $category_links );
?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
75 changes: 37 additions & 38 deletions templates/course/curriculum.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

$topics = tutor_utils()->get_topics();
$title = $settings['course_curriculum_title'];
$title = $settings['course_curriculum_title'];
$course_id = get_the_ID();
$is_enrolled = tutor_utils()->is_enrolled( $course_id );
$index = 0;
Expand Down Expand Up @@ -34,9 +34,9 @@
$index++;
?>
<div class="tutor-accordion-item">
<h4 class="tutor-accordion-item-header<?php echo $index == 1 ? ' is-active': ''; ?>">
<h4 class="tutor-accordion-item-header<?php echo $index == 1 ? ' is-active' : ''; ?>">
<?php the_title(); ?>
<?php if ( ! empty( $topic_summery ) ): ?>
<?php if ( ! empty( $topic_summery ) ) : ?>
<div class="tooltip-wrap tooltip-icon">
<span class="tooltip-txt tooltip-right"><?php echo esc_attr( $topic_summery ); ?></span>
</div>
Expand All @@ -45,61 +45,61 @@

<?php $topic_contents = tutor_utils()->get_course_contents_by_topic( get_the_ID(), -1 ); ?>
<?php if ( $topic_contents->have_posts() ) : ?>
<div class="tutor-accordion-item-body" style="<?php echo $index != 1 ? 'display: none;': ''; ?>">
<div class="tutor-accordion-item-body" style="<?php echo $index != 1 ? 'display: none;' : ''; ?>">
<div class="tutor-accordion-item-body-content">
<ul class="tutor-course-content-list">
<?php while ( $topic_contents->have_posts() ) : ?>
<?php
$topic_contents->the_post();
global $post;

// Get Lesson video information if any
$video = tutor_utils()->get_video_info();
$play_time = $video ? $video->playtime : false;
$video = tutor_utils()->get_video_info();
$play_time = $video ? $video->playtime : false;
$is_preview = get_post_meta( $post->ID, '_is_preview', true );

// Determine topic content icon based on lesson, video, quiz etc.
$topic_content_icon = $play_time ? 'tutor-icon-brand-youtube-bold' : 'tutor-icon-document-text';
$post->post_type === 'tutor_quiz' ? $topic_content_icon = 'tutor-icon-circle-question-mark' : 0;
$post->post_type === 'tutor_assignments' ? $topic_content_icon = 'tutor-icon-document-text' : 0;
$post->post_type === 'tutor_zoom_meeting' ? $topic_content_icon = 'tutor-icon-brand-zoom' : 0;
$is_public_course = \TUTOR\Course_List::is_public( $course_id );
$is_locked = ! ( $is_enrolled || $is_preview || $is_public_course );
$topic_content_icon = $play_time ? 'tutor-icon-brand-youtube-bold' : 'tutor-icon-document-text';
$post->post_type === 'tutor_quiz' ? $topic_content_icon = 'tutor-icon-circle-question-mark' : 0;
$post->post_type === 'tutor_assignments' ? $topic_content_icon = 'tutor-icon-document-text' : 0;
$post->post_type === 'tutor_zoom_meeting' ? $topic_content_icon = 'tutor-icon-brand-zoom' : 0;

$is_public_course = \TUTOR\Course_List::is_public( $course_id );
$is_locked = ! ( $is_enrolled || $is_preview || $is_public_course );
?>
<li class="tutor-course-content-list-item">
<div class="tutor-d-flex tutor-align-center">
<span class="tutor-course-content-list-item-icon <?php echo $topic_content_icon; ?> tutor-mr-12"></span>
<h5 class="tutor-course-content-list-item-title">
<?php
$lesson_title = '';

// Add zoom meeting countdown info
$countdown = '';
if ( $post->post_type === 'tutor_zoom_meeting' ) {
$zoom_meeting = tutor_zoom_meeting_data( $post->ID );
$countdown = '<div class="tutor-zoom-lesson-countdown tutor-lesson-duration" data-timer="' . $zoom_meeting->countdown_date . '" data-timezone="' . $zoom_meeting->timezone . '"></div>';
}
if ( $post->post_type === 'tutor_zoom_meeting' ) {
$zoom_meeting = tutor_zoom_meeting_data( $post->ID );
$countdown = '<div class="tutor-zoom-lesson-countdown tutor-lesson-duration" data-timer="' . $zoom_meeting->countdown_date . '" data-timezone="' . $zoom_meeting->timezone . '"></div>';
}

// Show clickable content if enrolled
// Or if it is public and not paid, then show content forcefully
if ( $is_enrolled || ( get_post_meta( $course_id, '_tutor_is_public_course', true ) == 'yes' && ! tutor_utils()->is_course_purchasable( $course_id ) ) ) {
$lesson_title .= "<a href='" . get_the_permalink() . "'> " . get_the_title() . ' </a>';

if ( $countdown ) {
if ( $zoom_meeting->is_expired ) {
$lesson_title .= '<span class="tutor-zoom-label">' . __( 'Expired', 'tutor' ) . '</span>';
} elseif ( $zoom_meeting->is_started ) {
$lesson_title .= '<span class="tutor-zoom-label tutor-zoom-live-label">' . __( 'Live', 'tutor' ) . '</span>';
}
$lesson_title .= $countdown;
if ( $is_enrolled || ( get_post_meta( $course_id, '_tutor_is_public_course', true ) == 'yes' && ! tutor_utils()->is_course_purchasable( $course_id ) ) ) {
$lesson_title .= "<a href='" . get_the_permalink() . "'> " . get_the_title() . ' </a>';

if ( $countdown ) {
if ( $zoom_meeting->is_expired ) {
$lesson_title .= '<span class="tutor-zoom-label">' . __( 'Expired', 'tutor-lms-elementor-addons' ) . '</span>';
} elseif ( $zoom_meeting->is_started ) {
$lesson_title .= '<span class="tutor-zoom-label tutor-zoom-live-label">' . __( 'Live', 'tutor-lms-elementor-addons' ) . '</span>';
}

echo $lesson_title;
} else {
$lesson_title .= get_the_title();
echo apply_filters( 'tutor_course/contents/lesson/title', $lesson_title, get_the_ID() );
$lesson_title .= $countdown;
}

echo $lesson_title;
} else {
$lesson_title .= get_the_title();
echo apply_filters( 'tutor_course/contents/lesson/title', $lesson_title, get_the_ID() );
}
?>
</h5>
</div>
Expand All @@ -115,7 +115,7 @@
</ul>
</div>
</div>
<?php $topic_contents->reset_postdata(); ?>
<?php $topic_contents->reset_postdata(); ?>
<?php endif; ?>
</div>
<?php endwhile; ?>
Expand All @@ -126,4 +126,3 @@
</div>

<?php do_action( 'tutor_course/single/after/topics' ); ?>

Loading

0 comments on commit 8265149

Please sign in to comment.