/**
  * Shortcode: educator_courses.
  *
  * @param array $atts
  * @param string $content
  * @return string
  */
 function educator_courses_shortcode($atts, $content = null)
 {
     $atts = shortcode_atts(array('show_price' => 1, 'ids' => '', 'number' => 15, 'categories' => null), $atts);
     $output = '<div class="courses-carousel owl-carousel">';
     $params = array('post_type' => 'ib_educator_course', 'orderby' => 'menu_order', 'posts_per_page' => intval($atts['number']));
     if ($atts['ids']) {
         $ids = explode(' ', $atts['ids']);
         $params['post__in'] = array();
         foreach ($ids as $id) {
             $params['post__in'][] = intval($id);
         }
         $params['posts_per_page'] = -1;
         $params['orderby'] = 'post__in';
     }
     if ($atts['categories']) {
         $categories = explode(' ', $atts['categories']);
         foreach ($categories as $key => $term_id) {
             $categories[$key] = intval($term_id);
         }
         $params['tax_query'] = array(array('taxonomy' => 'ib_educator_category', 'field' => 'term_id', 'terms' => $categories));
     }
     $query = new WP_Query($params);
     if ($query->have_posts()) {
         $course_id = 0;
         while ($query->have_posts()) {
             $query->the_post();
             $course_id = get_the_ID();
             $output .= '<article class="' . esc_attr(implode(' ', get_post_class('post-grid'))) . '">';
             if (has_post_thumbnail()) {
                 $output .= '<div class="post-thumb"><a href="' . esc_url(get_permalink()) . '">' . get_the_post_thumbnail($course_id, 'ib-educator-grid') . '</a></div>';
             }
             $output .= '<div class="post-body">';
             $output .= '<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '">' . the_title('', '', false) . '</a></h2>';
             if (1 == $atts['show_price'] && 'closed' != ib_edu_registration($course_id)) {
                 $output .= '<div class="price">' . ib_edu_format_course_price(ib_edu_get_course_price($course_id)) . '</div>';
             }
             ob_start();
             the_excerpt();
             $output .= '<div class="post-excerpt">' . ob_get_clean() . '</div>';
             $output .= '</div>';
             if (function_exists('educator_course_meta')) {
                 $output .= '<footer class="post-meta">' . educator_course_meta($course_id, array('num_lessons', 'difficulty')) . educator_share('menu') . '</footer>';
             }
             $output .= '</article>';
         }
         wp_reset_postdata();
     }
     $output .= '</div>';
     return $output;
 }
Exemple #2
0
/**
 * Get HTML for the course price widget.
 *
 * @param int $course_id
 * @param int $user_id
 * @param string $before
 * @param string $after
 * @return string
 */
function ib_edu_get_price_widget($course_id, $user_id, $before = '<div class="ib-edu-course-price">', $after = '</div>')
{
    // Registration allowed?
    if ('closed' == ib_edu_registration($course_id)) {
        return '';
    }
    // Check membership.
    $membership_access = IB_Educator_Memberships::get_instance()->membership_can_access($course_id, $user_id);
    /**
     * Filter the course price widget.
     *
     * @since 1.3.2
     *
     * @param bool $membership_access Whether the user's current membership allows him/her to take the course.
     */
    $output = apply_filters('ib_educator_course_price_widget', null, $membership_access, $course_id, $user_id);
    if (null !== $output) {
        return $output;
    }
    // Generate the widget.
    $output = $before;
    if ($membership_access) {
        $register_url = ib_edu_get_endpoint_url('edu-action', 'join', get_permalink($course_id));
        $output .= '<form action="' . esc_url($register_url) . '" method="post">';
        $output .= '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce('ib_educator_join') . '">';
        $output .= '<input type="submit" class="ib-edu-button" value="' . __('Join', 'ibeducator') . '">';
        $output .= '</form>';
    } else {
        $price = ib_edu_get_course_price($course_id);
        $price = 0 == $price ? __('Free', 'ibeducator') : ib_edu_format_course_price($price);
        $register_url = ib_edu_get_endpoint_url('edu-course', $course_id, get_permalink(ib_edu_page_id('payment')));
        $output .= '<span class="price">' . $price . '</span><a href="' . esc_url($register_url) . '" class="ib-edu-button">' . __('Register', 'ibeducator') . '</a>';
    }
    $output .= $after;
    return $output;
}
Exemple #3
0
 /**
  * Get related courses.
  *
  * @param int $post_id
  * @return string
  */
 function educator_related_courses($post_id)
 {
     $terms = get_the_terms($post_id, 'ib_educator_category');
     if (!$terms || is_wp_error($terms)) {
         return;
     }
     $args = array('post_type' => 'ib_educator_course', 'posts_per_page' => 3, 'post__not_in' => array($post_id));
     $terms_ids = array();
     foreach ($terms as $term) {
         $terms_ids[] = $term->term_id;
     }
     $args['tax_query'] = array(array('taxonomy' => 'ib_educator_category', 'terms' => $terms_ids));
     $query = new WP_Query($args);
     if ($query->have_posts()) {
         $output = '<section class="related-courses">';
         $output .= '<h1>' . __('Related Courses', 'ib-educator') . '</h1>';
         $api = IB_Educator::get_instance();
         $course_id = 0;
         while ($query->have_posts()) {
             $query->the_post();
             $course_id = get_the_ID();
             $output .= '<article class="' . esc_attr(implode(' ', get_post_class('clearfix'))) . '">';
             if (has_post_thumbnail()) {
                 $output .= '<div class="post-thumb"><a href="' . esc_url(get_permalink()) . '">' . get_the_post_thumbnail($course_id, 'thumbnail') . '</a></div>';
             }
             $output .= '<div class="post-summary">' . '<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '">' . the_title('', '', false) . '</a></h2>';
             ob_start();
             the_excerpt();
             $output .= '<div class="post-excerpt">' . ob_get_clean() . '</div>';
             $output .= '<div class="post-meta">';
             if ('closed' != ib_edu_registration($course_id)) {
                 $output .= '<span class="price">' . ib_edu_format_course_price(ib_edu_get_course_price($course_id)) . '</span>';
             }
             $output .= educator_course_meta($course_id, array('num_lessons', 'difficulty'));
             $output .= '</div>';
             $output .= '</div>';
             $output .= '</article>';
         }
         wp_reset_postdata();
         $output .= '</section>';
         return $output;
     }
     return '';
 }
?>
</h1>
						<?php 
do_action('ib_educator_after_course_title');
?>
						<div class="course-rating">
							<?php 
if (function_exists('the_ratings')) {
    the_ratings();
}
?>
						</div>
						<?php 
$output = '<ul class="list">';
$price = ib_edu_get_course_price($course_id);
$price = 0 == $price ? esc_html__('Free', 'training') : ib_edu_format_course_price($price);
$register_url = ib_edu_get_endpoint_url('edu-course', $course_id, get_permalink(ib_edu_page_id('payment')));
$output .= '<li class="price"><i class="uicon icon-price"></i><span class="lab">' . esc_html__('Price: ', 'training') . '</span> <span class="val">' . $price . '</span></li>';
if (isset($options['duration']) && $options['duration']) {
    $output .= '<li class="price"><i class="uicon icon-duration"></i><span class="lab">' . esc_html__('Duration: ', 'training') . '</span> <span class="val">' . $options['duration'] . '</span></li>';
}
if (isset($options['is_certificates'])) {
    $output .= '<li class="price hidden"><i class="uicon icon-certificates"></i><span class="lab">' . esc_html__('Certificates: ', 'training') . '</span> <span class="val">' . ($options['is_certificates'] ? esc_html__('Yes', 'training') : esc_html__('No', 'training')) . '</span></li>';
}
$output .= '<li class="lesson"><i class="uicon icon-students"></i><span class="lab">' . esc_html__('Students: ', 'training') . '</span> <span class="val">' . count($students) . '</span></li>';
$output .= '<li class="lesson"><i class="uicon icon-lesson"></i><span class="lab">' . esc_html__('Lesson: ', 'training') . '</span> <span class="val">' . $api->get_num_lessons(get_the_id()) . '</span></li>';
$output .= '</ul>';
echo trim($output);
?>

						<div class="action">