Пример #1
0
 /**
  * Display course difficulty level.
  */
 function edr_show_course_difficulty()
 {
     $difficulty = ib_edu_get_difficulty(get_the_ID());
     if ($difficulty) {
         Edr_View::the_template('course/difficulty', array('difficulty' => $difficulty));
     }
 }
Пример #2
0
/**
 * Get the course meta.
 *
 * @param int $course_id
 * @param array $include
 * @return string
 */
function educator_course_meta($course_id = null, $include = null)
{
    if (!$course_id) {
        $course_id = get_the_ID();
    }
    if (!$include) {
        $include = array('lecturer', 'num_lessons', 'difficulty');
    }
    $include = apply_filters('edutheme_course_meta_include', $include);
    $meta = apply_filters('pre_educator_course_meta', '', $course_id, $include);
    if (!empty($meta)) {
        return $meta;
    }
    foreach ($include as $item) {
        switch ($item) {
            // Lecturer.
            case 'lecturer':
                $meta .= '<span class="author lecturer">' . sprintf(__('by %s', 'ib-educator'), get_the_author()) . '</span>';
                break;
                // Number of lessons.
            // Number of lessons.
            case 'num_lessons':
                $num_lessons = IB_Educator::get_instance()->get_num_lessons($course_id);
                if ($num_lessons) {
                    $meta .= '<span class="num-lessons">' . sprintf(_n('1 lesson', '%d lessons', $num_lessons, 'ib-educator'), $num_lessons) . '</span>';
                }
                break;
                // Difficulty.
            // Difficulty.
            case 'difficulty':
                $difficulty = ib_edu_get_difficulty($course_id);
                if ($difficulty) {
                    $meta .= '<span class="difficulty">' . esc_html($difficulty['label']) . '</span>';
                }
                break;
                // Categories.
            // Categories.
            case 'categories':
                $categories = get_the_term_list(get_the_ID(), 'ib_educator_category', '', __(', ', 'ib-educator'));
                if ($categories) {
                    echo '<span class="cat-links">' . $categories . '</span>';
                }
                break;
        }
    }
    return apply_filters('edutheme_course_meta', $meta);
}