Пример #1
0
 /**
  * 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;
 }
Пример #2
0
</a>
	</div>
	<?php 
}
?>

	<div class="post-body">
		<?php 
the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>');
?>
		<div class="price">
			<?php 
if ('closed' != ib_edu_registration($course_id)) {
    echo ib_edu_format_price(ib_edu_get_course_price($course_id));
}
?>
		</div>
		<div class="post-excerpt"><?php 
the_excerpt();
?>
</div>
	</div>

	<footer class="post-meta">
		<?php 
echo educator_course_meta($course_id, array('num_lessons', 'difficulty'));
echo educator_share('menu');
?>
	</footer>
</article>
Пример #3
0
"><?php 
    the_post_thumbnail('ib-educator-main-column');
    ?>
</a>
	</div>
	<?php 
}
?>

	<div class="summary">
		<?php 
the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>');
?>
		<div class="price"><?php 
echo ib_edu_format_price(ib_edu_get_course_price($course_id));
?>
</div>
		<div class="post-excerpt">
			<?php 
the_excerpt();
?>
		</div>
	</div>

	<footer class="post-meta">
		<?php 
echo educator_course_meta();
echo educator_share('menu');
?>
	</footer>
</article>
Пример #4
0
function educator_single_course_meta()
{
    echo '<div class="post-meta course-meta">', educator_course_meta(get_the_ID(), array('num_lessons', 'categories')), '</div>';
}
Пример #5
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 '';
 }