function the_quiz_button($button, $quiz_id) { global $post; $quiz_id = get_the_ID(); $user_id = get_current_user_id(); $flag = 1; if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { $pid = get_post_meta($quiz_id, 'vibe_quiz_product', true); if (isset($pid) && is_numeric($pid) && get_post_type($pid) == 'product') { $product_taken = wc_customer_bought_product('', $user_id, $pid); if (!$product_taken) { $pid = get_permalink($pid); $check = vibe_get_option('direct_checkout'); $check = intval($check); if (isset($check) && $check) { $pid .= '?redirect'; } $flag = 0; $html = '<a href="' . $pid . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>'; } else { $flag = 1; } } } if (in_array('paid-memberships-pro/paid-memberships-pro.php', apply_filters('active_plugins', get_option('active_plugins'))) && is_user_logged_in()) { $membership_ids = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_membership', false)); if (!pmpro_hasMembershipLevel($membership_ids, $user_id) && isset($membership_ids) && count($membership_ids) >= 1) { $membership_taken = get_user_meta($user_id, $quiz_id, true); if (!$membership_taken) { $pmpro_levels_page_id = get_option('pmpro_levels_page_id'); $link = get_permalink($pmpro_levels_page_id); $html = '<a href="' . $link . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>'; $flag = 0; } else { $flag = 1; } } } if (in_array('wplms-mycred-addon/wplms-mycred-addon.php', apply_filters('active_plugins', get_option('active_plugins')))) { $points = get_post_meta($quiz_id, 'vibe_quiz_mycred_points', true); $mycred = mycred(); $balance = $mycred->get_users_cred($user_id); if ($balance < $points) { $flag = 0; $html = '<a href="#"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '<span>' . __('<br/>Not enough points.', 'vibe') . '</span></a>'; } if (!$mycred->has_entry('purchase_quiz', $quiz_id, $user_id)) { $flag = 1; $deduct = -1 * $points; $mycred->update_users_balance($user_id, $deduct); $mycred->add_to_log('purchase_quiz', $user_id, $deduct, __('Student subscibed to quiz', 'wplms-mycred'), $quiz_id); } else { $flag = 1; } } if (!$flag) { return $html; } return $button; }
function get_order_report_data($start_date, $end_date) { global $wpdb; $order_item_meta_table = $wpdb->prefix . 'woocommerce_order_itemmeta'; $order_items_table = $wpdb->prefix . 'woocommerce_order_items'; $inst_commissions = $wpdb->get_results("SELECT order_items.order_id,order_meta.meta_key as instructor,order_meta.meta_value as commission\n\t\t\tFROM {$wpdb->posts} as posts\n\t\t\tLEFT JOIN {$order_items_table} as order_items ON posts.ID = order_items.order_id\n\t\t\tLEFT JOIN {$order_item_meta_table} as order_meta ON order_items.order_item_id = order_meta.order_item_id\n\t\t\tWHERE posts.post_type='shop_order'\n\t\t\tAND posts.post_status='wc-completed'\n\t\t\tAND posts.post_date BETWEEN '{$start_date}' AND '{$end_date}'\n\t\t\tAND order_meta.meta_key LIKE 'commission%'"); if (is_array($inst_commissions)) { foreach ($inst_commissions as $inst_commission) { $order_ids[] = $inst_commission->order_id; $inst = explode('commission', $inst_commission->instructor); if (is_numeric($inst[1])) { $instructor_commissions[$inst[1]] += $inst_commission->commission; } } if (is_array($order_ids)) { $order_id_string = implode(',', $order_ids); } } $query = "SELECT order_items.order_item_id,order_meta.meta_value as total_sales\n\t\t\tFROM {$wpdb->posts} as posts\n\t\t\tLEFT JOIN {$order_items_table} as order_items ON posts.ID = order_items.order_id\n\t\t\tLEFT JOIN {$order_item_meta_table} as order_meta ON order_items.order_item_id = order_meta.order_item_id\n\t\t\tWHERE posts.post_type='shop_order'\n\t\t\tAND posts.post_status='wc-completed'\n\t\t\tAND posts.post_date BETWEEN '{$start_date}' AND '{$end_date}'\n\t\t\tAND order_meta.meta_key = '_line_total'"; if (isset($order_id_string)) { $query .= "AND posts.ID NOT IN ({$order_id_string})"; } $inst_commissions = $wpdb->get_results($query); $commissions = get_option('instructor_commissions'); foreach ($inst_commissions as $inst_commission) { $oid = $inst_commission->order_item_id; $pid = woocommerce_get_order_item_meta($oid, '_product_id', true); $courses = vibe_sanitize(get_post_meta($pid, 'vibe_courses', false)); if (isset($courses) && is_array($courses) && count($courses)) { $n = count($courses); foreach ($courses as $course) { $instructors = apply_filters('wplms_course_instructors', get_post_field('post_author', $course), $course); if (is_numeric($instructors)) { if (!isset($commission[$course][$instructors])) { $commission[$course][$instructors] = 70; } echo $commission[$course][$instructors] * $inst_commission->total_sales; $instructor_commissions[$instructors] += $commission[$course][$instructors] * $inst_commission->total_sales; } else { if (is_Array($instructors)) { $k = count($instructors); foreach ($instructors as $instructor) { if (!isset($commission[$course][$instructor])) { $commission[$course][$instructor] = floor(70 / $k); } $instructor_commissions[$instructor] += $commission[$course][$instructor] * $inst_commission->total_sales; } } } } } } return $instructor_commissions; }
function wplms_edd_completed_purchase($payment_id, $new_status, $old_status) { if ($old_status == 'publish' || $old_status == 'complete') { return; } // Make sure that payments are only completed once // Make sure the payment completion is only processed when new status is complete if ($new_status != 'publish' && $new_status != 'complete') { return; } $user_id = get_current_user_id(); $cart_items = edd_get_payment_meta_cart_details($payment_id); foreach ($cart_items as $key => $cart_item) { $item_id = isset($cart_item['id']) ? $cart_item['id'] : $cart_item; if (is_numeric($item_id) && get_post_type($item_id) == 'download') { $courses = vibe_sanitize(get_post_meta($item_id, 'vibe_courses', false)); $subscribed = get_post_meta($product_id, 'vibe_subscription', true); if (vibe_validate($subscribed)) { $duration = get_post_meta($product_id, 'vibe_duration', true); $product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400); // Product duration for subscription based $t = time() + $duration * $product_duration_parameter; foreach ($courses as $course) { update_post_meta($course, $user_id, 0); update_user_meta($user_id, $course, $t); $group_id = get_post_meta($course, 'vibe_group', true); if (isset($group_id) && $group_id != '') { groups_join_group($group_id, $user_id); } bp_course_record_activity(array('action' => __('Student subscribed for course ', 'vibe') . get_the_title($course), 'content' => __('Student ', 'vibe') . bp_core_get_userlink($user_id) . __(' subscribed for course ', 'vibe') . get_the_title($course) . __(' for ', 'vibe') . $duration . __(' days', 'vibe'), 'type' => 'subscribe_course', 'item_id' => $course, 'primary_link' => get_permalink($course), 'secondary_item_id' => $user_id)); } } else { if (isset($courses) && is_array($courses)) { foreach ($courses as $course) { $duration = get_post_meta($course, 'vibe_duration', true); $course_duration_parameter = apply_filters('vibe_course_duration_parameter', 86400); // Course duration for subscription based $t = time() + $duration * $course_duration_parameter; update_post_meta($course, $user_id, 0); update_user_meta($user_id, $course, $t); $group_id = get_post_meta($course, 'vibe_group', true); if (isset($group_id) && $group_id != '') { groups_join_group($group_id, $user_id); } bp_course_record_activity(array('action' => __('Student subscribed for course ', 'vibe') . get_the_title($course), 'content' => __('Student ', 'vibe') . bp_core_get_userlink($user_id) . __(' subscribed for course ', 'vibe') . get_the_title($course) . __(' for ', 'vibe') . $duration . __(' days', 'vibe'), 'type' => 'subscribe_course', 'item_id' => $course, 'primary_link' => get_permalink($course), 'secondary_item_id' => $user_id)); } } } } } }
function wplms_unit_assignments($unit_id) { $assignment_ids = get_post_meta($unit_id, 'vibe_assignment', false); if (is_Array($assignment_ids) && is_array($assignment_ids[0])) { $assignment_ids = vibe_sanitize($assignment_ids); } $assignment_duration_parameter = apply_filters('vibe_assignment_duration_parameter', 86400); if (isset($assignment_ids) && is_array($assignment_ids)) { foreach ($assignment_ids as $assignment_id) { if (is_numeric($assignment_id)) { $marks = get_post_meta($assignment_id, 'vibe_assignment_marks', true); $duration = get_post_meta($assignment_id, 'vibe_assignment_duration', true); echo '<h3 class="assignment_heading heading">' . __('ASSIGNMENT : ', 'wplms-assignments') . ' <strong><a href="' . get_permalink($assignment_id) . '" target="_blank">' . get_the_title($assignment_id) . '<i class="icon-in-alt"></i></a></strong> <span>' . __('MARKS : ', 'wplms-assignments') . $marks . '</span> <span>' . __('DURATION : ', 'wplms-assignments') . (function_exists('tofriendlytime') ? tofriendlytime($duration * $assignment_duration_parameter) : $duration . __(' days', 'wplms-assignments')) . '</span> </h3>'; } } } }
<?php /** * Single product short description * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ global $post; $vcourses = array(); $vcourses = apply_filters('wplms_product_course_order_filter', vibe_sanitize(get_post_meta($post->ID, 'vibe_courses', false))); if (count($vcourses)) { echo '<div class="connected_courses"><h6>'; _e('Courses Included', 'wplms_modern'); echo '</h6><ul>'; foreach ($vcourses as $course) { echo '<li><a href="' . get_permalink($course) . '"><i class="icon-book-open"></i> ' . get_the_title($course) . '</a></li>'; } echo '</ul></div>'; } if (!$post->post_excerpt) { return; } ?> <div itemprop="description"> <?php echo apply_filters('woocommerce_short_description', $post->post_excerpt); ?> </div>
<?php get_header(); if (have_posts()) { while (have_posts()) { the_post(); $print = get_post_meta($post->ID, 'vibe_print', true); $course = get_post_meta($post->ID, 'vibe_event_course', true); $private_event = get_post_meta($post->ID, 'vibe_private_event', true); $icon_class = get_post_meta($post->ID, 'vibe_icon', true); $color = get_post_meta($post->ID, 'vibe_color', true); $start_date = get_post_meta($post->ID, 'vibe_start_date', true); $end_date = get_post_meta($post->ID, 'vibe_end_date', true); $show_location = get_post_meta($post->ID, 'vibe_show_location', true); $location = vibe_sanitize(get_post_meta($post->ID, 'vibe_location', false)); $additional_info = vibe_sanitize(get_post_meta($post->ID, 'vibe_additional_info', false)); $more_info = get_post_meta($post->ID, 'vibe_more_info', true); $send_invitation = get_post_meta($post->ID, 'vibe_send_invitation', true); $access_flag = 1; if (vibe_validate($private_event)) { $access_flag = 0; } do_action('wplms_before_single_event'); ?> <section id="title"> <div class="container"> <div class="row"> <div class="col-md-9 col-sm-8"> <div class="pagetitle"> <span><?php echo '<a href="' . get_permalink($course) . '">' . get_the_title($course) . '</a>';
function bp_course_disable_access($order_id) { $order = new WC_Order($order_id); $items = $order->get_items(); $user_id = $order->user_id; foreach ($items as $item) { $product_id = $item['product_id']; $subscribed = get_post_meta($product_id, 'vibe_subscription', true); $courses = vibe_sanitize(get_post_meta($product_id, 'vibe_courses', false)); if (isset($courses) && is_array($courses)) { foreach ($courses as $course) { delete_post_meta($course, $user_id); delete_user_meta($user_id, $course); $group_id = get_post_meta($course, 'vibe_group', true); if (isset($group_id) && function_exists('groups_remove_member')) { groups_remove_member($user_id, $group_id); } else { $group_id = ''; } $instructors = apply_filters('wplms_course_instructors', get_post_field('post_author', $course, 'raw'), $course); if (is_array($instructors)) { foreach ($instructors as $instructor) { woocommerce_update_order_item_meta($item_id, 'commission' . $instructor, 0); //Nulls the commission } } do_action('wplms_course_unsubscribe', $course_id, $user_id, $group_id); } } } }
echo '</li>'; } } echo '</ul>'; } wp_nonce_field('vibe_assignment', 'asecurity'); echo '</div>'; } /*========================================================================*/ /* 02. QUIZ SUBMISSIONS /*========================================================================*/ echo '<div class="submissions"><h4 class="minmax">'; _e('QUIZ SUBMISSIONS', 'vibe'); echo '<i class="icon-plus-1"></i></h4>'; $student_field = vibe_get_option('student_field'); $curriculum = vibe_sanitize(get_post_meta(get_the_ID(), 'vibe_course_curriculum', false)); echo '<ul class="quiz_students">'; if (isset($curriculum) && is_array($curriculum)) { foreach ($curriculum as $c) { if (is_numeric($c)) { if (get_post_type($c) == 'quiz') { // RUN META QUERY : GET ALL POST META WITH VALUE 0 FOR UNCHECKED QUIZ, THE KEY IS THE USERID $members_unchecked_quiz = $wpdb->get_results("select meta_key from {$wpdb->postmeta} where meta_value = '0' && post_id = {$c}", ARRAY_A); // Internal Query if (count($members_unchecked_quiz)) { foreach ($members_unchecked_quiz as $unchecked_quiz) { if (is_numeric($unchecked_quiz['meta_key'])) { $member_id = $unchecked_quiz['meta_key']; $bp_name = bp_core_get_userlink($member_id); if (isset($student_field)) { $profile_data = 'field=' . $student_field . '&user_id=' . $member_id;
function generate_fields($field, $id = null) { if (!empty($id)) { $this->course_id = $id; } $user_id = get_current_user_id(); if (!empty($this->course_id)) { switch ($field['from']) { case 'post': $field['value'] = get_post_field($field['id'], $this->course_id); break; case 'taxonomy': $terms = wp_get_post_terms($this->course_id, $field['taxonomy']); if (!empty($terms)) { $field['value'] = $terms[0]->term_id; } break; default: if ($field['value_type'] == 'array') { $single = false; } else { $single = true; } $field['value'] = get_post_meta($this->course_id, $field['id'], $single); break; } } else { $field['value'] = $field['default']; } switch ($field['type']) { case 'heading': echo '<strong>' . $field['label'] . '</strong>'; break; case 'number': echo '<div class="field_wrapper ' . $field['style'] . '"> <label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>' . (!empty($field['text']) ? '<strong>' . $field['text'] . '</strong>' : ''); echo (!empty($field['text']) ? '<div class="right">' : '') . '<input type="number" id="" class="small_box post_field ' . (empty($field['text']) ? 'form_field' : '') . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" placeholder="' . $field['default'] . '" value="' . $field['value'] . '"/>' . (isset($field['extra']) ? $field['extra'] : '') . '</div>'; echo !empty($field['text']) ? '</div>' : ''; break; case 'text': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; echo !empty($field['text']) ? '<strong>' . $field['text'] . '</strong>' : ''; echo '<input type="text" placeholder="' . $field['default'] . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" class="mid_box post_field ' . (empty($field['text']) ? 'form_field' : '') . '" value="' . $field['value'] . '"/>' . (isset($field['extra']) ? $field['extra'] : ''); echo '</div>'; break; case 'title': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; echo '<input type="text" class="megatext post_field" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" placeholder="' . $field['default'] . '" value="' . ($field['default'] != $field['value'] ? $field['value'] : '') . '" />'; echo '</div>'; break; case 'taxonomy': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; ?> <ul id="<?php echo $field['id']; ?> " class="wplms-taxonomy"> <li> <select id="<?php echo $field['id']; ?> -select" class="chosen post_field" <?php echo 'data-id="' . $field['id'] . '" data-taxonomy="' . $field['taxonomy'] . '" data-type="' . $field['type'] . '"'; ?> > <option><?php echo $field['default']; ?> </option> <?php $new_tax = apply_filters('wplms_front_end_new_tax_cap', true, $field); if ($new_tax) { ?> <option value="new"><?php _e('Add new', 'wplms-front-end'); ?> </option> <?php } $terms = get_terms($field['taxonomy'], apply_filters('wplms_front_end_field_taxonomy_args', array('hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC'), $field)); if (isset($terms) && is_array($terms)) { foreach ($terms as $term) { $parenttermname = ''; if ($term->parent) { $parentterm = get_term_by('id', $term->parent, $field['taxonomy'], 'ARRAY_A'); $parenttermname = $parentterm['name'] . ' › '; } echo '<option value="' . $term->term_id . '" ' . (isset($_GET['action']) ? selected($field['value'], $term->term_id) : '') . '>' . $parenttermname . $term->name . '</option>'; } } ?> </select> </li> <li><input type="text" id="new_<?php echo str_replace('-', '_', $field['id']); ?> " class="ccf_text post_field wplms-new-taxonomy" <?php echo 'data-id="' . $field['taxonomy'] . '" data-type="' . $field['type'] . '_new"'; ?> placeholder="<?php _e('Enter a new', 'wplms-front-end'); ?> " /></li> </ul><br /> <?php echo '</div>'; echo '<hr />'; break; case 'featured_image': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; ?> <div id="<?php echo $field['id']; ?> " class="upload_image_button" data-input-name="<?php echo $field['id']; ?> " data-uploader-title="<?php echo $field['upload_title']; ?> " data-uploader-button-text="<?php echo $field['upload_button']; ?> " data-uploader-allow-multiple="false"> <?php if (isset($this->course_id) && has_post_thumbnail($this->course_id)) { if ($field['level'] == 'thumbnail') { echo get_the_post_thumbnail($this->course_id, 'thumbnail'); echo '<input type="hidden" value="' . get_post_thumbnail_id($this->course_id) . '" class="post_field" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" />'; } } else { ?> <img src="<?php echo $field['default']; ?> " alt="course image" class="default" /> <?php } ?> </div> <?php echo '</div>'; break; case 'media': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; echo (empty($field['text']) ? '' : '<strong>' . $field['text'] . '</strong>') . ' <div class="upload_button">'; if (is_numeric($field['value'])) { $attachment = wp_get_attachment_image_src($field['value']); if (empty($attachment)) { echo '<a id="' . $field['id'] . '" data-input-name="' . $field['id'] . '" data-uploader-title="' . $field['title'] . '" data-uploader-button-text="' . $field['button'] . '"><i class="icon-image-photo-file-1"></i></a>'; } else { $url = $attachment[0]; echo '<a id="' . $field['id'] . '" data-input-name="' . $field['id'] . '" data-uploader-title="' . $field['title'] . '" data-uploader-button-text="' . $field['button'] . '"><img src="' . $url . '" class="submission_thumb thumbnail" /><input type="hidden" value="' . $field['value'] . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" /></a>'; } } else { echo '<a id="' . $field['id'] . '" data-input-name="' . $field['id'] . '" data-uploader-title="' . $field['title'] . '" data-uploader-button-text="' . $field['button'] . '"><i class="icon-image-photo-file-1"></i></a>'; } echo '<script> var media_uploader' . $field['id'] . '; jQuery("#' . $field['id'] . '").on("click", function( event ){ var button = jQuery( this ); if ( media_uploader' . $field['id'] . ' ) { media_uploader' . $field['id'] . '.open(); return; } // Create the media uploader. media_uploader' . $field['id'] . ' = wp.media.frames.media_uploader' . $field['id'] . ' = wp.media({ title: button.attr( "data-uploader-title"), library: { type: "image", query: false }, button: { text: button.attr("data-uploader-button-text"), }, }); // Create a callback when the uploader is called media_uploader' . $field['id'] . '.on( "select", function() { var selection = media_uploader' . $field['id'] . '.state().get("selection"), input_name = button.data( "input-name"); selection.map( function( attachment ) { attachment = attachment.toJSON(); console.log(attachment); button.html("<img src=\'"+attachment.url+"\' class=\'submission_thumb thumbnail\' /><input id=\'"+input_name +"\' class=\'form-control post_field\' name=\'"+input_name+"\' data-id=\'' . $field['id'] . '\' data-type=\'' . $field['type'] . '\' type=\'hidden\' value=\'"+attachment.id+"\' />"); }); }); // Open the uploader media_uploader' . $field['id'] . '.open(); }); </script> </div>'; break; case 'textarea': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; echo '<textarea id="' . $field['id'] . '" class="post_field" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '">' . $field['value'] . '</textarea>' . (empty($field['extras']) ? '' : $field['extras']); echo '</div>'; break; case 'editor': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . '</label>'; wp_editor($field['value'], $field['id'], array('editor_class' => 'post_field')); echo '</div>'; if (!isset($field['noscript'])) { echo '<script>jQuery(document).ready(function($){ tinyMCE.execCommand("mceRemoveEditor", true, "' . $field['id'] . '"); tinyMCE.execCommand("mceAddEditor", false, "' . $field['id'] . '"); quicktags({id : "element_content"}); tinyMCE.triggerSave();}); </script>'; } break; case 'date': case 'calendar': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; echo !empty($field['text']) ? '<strong>' . $field['text'] . '</strong><div class="right">' : ''; echo '<input type="text" placeholder="' . $field['default'] . '" value="' . $field['value'] . '" data-id="' . $field['id'] . '" class="mid_box date_box post_field ' . (empty($field['text']) ? 'form_field' : '') . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '"/>'; echo !empty($field['text']) ? '</div>' : ''; echo '<script>jQuery(document).ready(function(){ jQuery( ".date_box" ).datepicker({ dateFormat: "yy-mm-dd", numberOfMonths: 1, showButtonPanel: true, });});</script><style>.ui-datepicker{z-index:99 !important;}</style></div>'; break; case 'time': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; echo !empty($field['text']) ? '<strong>' . $field['text'] . '</strong><div class="right">' : ''; echo '<input type="text" placeholder="' . $field['default'] . '" value="' . $field['value'] . '" data-id="' . $field['id'] . '" class="mid_box time_box post_field ' . (empty($field['text']) ? 'form_field' : '') . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '"/>'; echo !empty($field['text']) ? '</div>' : ''; echo '<script> jQuery(document).ready(function(){ jQuery( ".time_box" ).each(function(){ jQuery(this).timePicker({ show24Hours: false, separator:":", step: 15 }); });});</script></div>'; break; case 'group': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; ?> <input type="hidden" id="vibe_group" class="post_field" value="<?php echo $field['value']; ?> " <?php echo 'data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" '; ?> /> <?php echo '<span class="dashicons dashicons-dismiss clear_input" data-id="vibe_group"><div class="hide"><span>' . $field['text'] . '</span></div></span>'; echo '<h3>'; if (empty($field['value']) || $field['value'] == $field['default']) { echo '<span>' . $field['text'] . '</span>'; $flag = 0; } else { echo self::get_group_name($field['value']); echo '<span><a id="edit_group" href="' . self::get_group_permalink($field['value']) . '" target="_blank"><i>' . __('edit', 'wplms-front-end') . '</i></a> <i>' . __('change', 'wplms-front-end') . '</i></span>'; $flag = 1; } echo '</h3>'; ?> <div id="change_group" <?php echo $flag ? 'style="display:none;"' : ''; ?> > <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select Existing Group', 'wplms-front-end'); ?> </a> <div class="select_group_form"> <select class="selectgroup" data-placeholder="<?php _e('Select a Group', 'wplms-front-end'); ?> "> </select> <a class="use_selected button"><?php _e('Set', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create New Group', 'wplms-front-end'); ?> </a> <div class="new_group_form"> <input type="text" class="form_field" id="vibe_group_name" name="name" placeholder="<?php _e('Group Name', 'wplms-front-end'); ?> "> <select id="vibe_group_privacy" class="chosen form_field"> <option value="public"><?php _e('Public', 'wplms-front-end'); ?> </option> <option value="private"><?php _e('Private', 'wplms-front-end'); ?> </option> <option value="hidden"><?php _e('Hidden', 'wplms-front-end'); ?> </option> </select> <textarea class="description" id="vibe_group_description" placeholder="<?php _e('Group Description', 'wplms-front-end'); ?> "></textarea> <a class="button small" id="create_new_group"><?php _e('Create New Group', 'wplms-front-end'); ?> </a> </div> </div> </div> <?php echo '</div>'; break; case 'forum': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; ?> <input type="hidden" id="vibe_forum" class="post_field" value="<?php echo $field['value']; ?> " <?php echo 'data-id="' . $field['id'] . '" data-type="' . $field['type'] . '"'; ?> /> <?php echo '<span class="dashicons dashicons-dismiss clear_input" data-id="vibe_forum"><div class="hide"><span>' . $field['text'] . '</span></div></span>'; echo '<h3>'; if (empty($field['value']) || $field['value'] == $field['default']) { echo '<span>' . $field['text'] . '</span>'; $flag = 0; } else { echo get_the_title($field['value']); echo '<span><a href="' . get_permalink($field['value']) . '" target="_blank"><i>' . __('edit', 'wplms-front-end') . '</i></a> <i>' . __('change', 'wplms-front-end') . '</i></span>'; $flag = 1; } echo '</h3>'; ?> <div id="change_forum" <?php echo $flag ? 'style="display:none;"' : ''; ?> > <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select Existing Forum', 'wplms-front-end'); ?> </a> <div class="select_forum_form"> <select class="selectforum" data-placeholder="<?php _e('Select a Forum', 'wplms-front-end'); ?> "> </select> <a class="use_selected button"><?php _e('Set', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create New Forum', 'wplms-front-end'); ?> </a> <div class="new_forum_form"> <input type="text" class="form_field" id="vibe_forum_name" name="name" placeholder="<?php _e('Forum Name', 'wplms-front-end'); ?> "> <select id="vibe_forum_privacy" class="chosen form_field"> <option value="publish"><?php _e('Public', 'wplms-front-end'); ?> </option> <option value="private"><?php _e('Private', 'wplms-front-end'); ?> </option> <option value="hidden"><?php _e('Hidden', 'wplms-front-end'); ?> </option> </select> <textarea class="description" id="vibe_forum_description" placeholder="<?php _e('Forum Description', 'wplms-front-end'); ?> "></textarea> <a class="button small" id="create_new_forum"><?php _e('Create New Forum', 'wplms-front-end'); ?> </a> </div> </div> </div> <?php break; case 'yesno': case 'showhide': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label><strong>' . $field['text'] . '</strong><div class="switch">'; $i = 0; foreach ($field['options'] as $option) { echo '<input type="radio" class="switch-input post_field ' . $field['id'] . '" name="' . $field['id'] . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" value="' . $option['value'] . '" id="' . $field['id'] . $option['value'] . '" '; checked($field['value'], $option['value']); echo '>'; echo '<label for="' . $field['id'] . $option['value'] . '" class="switch-label switch-label-' . (!($i % 2) ? 'off' : 'on') . '">' . $option['label'] . '</label>'; $i++; } echo '<span class="switch-selection"></span></div></div>'; break; case 'switch': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label><strong>' . $field['text'] . '</strong><div class="switch">'; $i = 0; if (empty($field['value'])) { if (empty($field['default'])) { if (!empty($field['std'])) { $field['value'] = $field['std']; } } else { $field['value'] = $field['default']; } } foreach ($field['options'] as $key => $value) { echo '<input type="radio" class="switch-input post_field ' . $field['id'] . '" name="' . $field['id'] . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" value="' . $key . '" id="' . $field['id'] . $key . '" '; checked($field['value'], $key); echo '>'; echo '<label for="' . $field['id'] . $key . '" class="switch-label switch-label-' . (!($i % 2) ? 'off' : 'on') . '">' . $value . '</label>'; $i++; } echo '<span class="switch-selection"></span></div></div>'; break; case 'conditionalswitch': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label><strong>' . $field['text'] . '</strong> <div class="switch conditional">'; $i = 0; if (empty($field['value'])) { if (empty($field['default'])) { if (!empty($field['std'])) { $field['value'] = $field['std']; } } else { $field['value'] = $field['default']; } } foreach ($field['options'] as $key => $value) { echo '<input type="radio" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" class="switch-input post_field conditional-switch ' . $field['id'] . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" name="' . $field['id'] . '" value="' . $key . '" id="' . $field['id'] . $key . '" '; checked($field['value'], $key); echo '>'; echo '<label for="' . $field['id'] . $key . '" class="switch-label switch-label-' . (!($i % 2) ? 'off' : 'on') . '">' . $value . '</label>'; $i++; } echo '<span class="switch-selection"></span></div></div>'; if (!empty($field['hide_nodes'])) { echo '<script> jQuery(document).ready(function($){ $(".conditional-switch.' . $field['id'] . '").each(function(){ $(this).on("click",function(){ var val = $(this).parent().find(".conditional-switch.' . $field['id'] . ':checked").val(); if(val == "S" || val === "S" || val == "on" || val === "on" || val == "yes" || val === "yes"){'; foreach ($field['hide_nodes'] as $node) { echo '$(".vibe_' . $node . '").show(200).addClass("conditional_display");'; } echo '}else{'; foreach ($field['hide_nodes'] as $node) { echo '$(".vibe_' . $node . '").hide(200).removeClass("conditional_display");'; } echo ' } }); }); }); </script><style>'; if (empty($field['value']) || $field['value'] != "S" || $field['value'] != "on" || $field['value'] != "yes") { foreach ($field['hide_nodes'] as $key => $node) { if (!empty($key)) { echo ','; } echo '.vibe_' . $node . ''; } echo '{display:none !important;}'; } echo '</style>'; } break; case 'reverseconditionalswitch': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label><strong>' . $field['text'] . '</strong> <div class="switch conditional">'; $i = 0; if (empty($field['value'])) { if (empty($field['default'])) { if (!empty($field['std'])) { $field['value'] = $field['std']; } } else { $field['value'] = $field['default']; } } foreach ($field['options'] as $key => $value) { echo '<input type="radio" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" class="switch-input post_field conditional-switch ' . $field['id'] . '" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" name="' . $field['id'] . '" value="' . $key . '" id="' . $field['id'] . $key . '" '; checked($field['value'], $key); echo '>'; echo '<label for="' . $field['id'] . $key . '" class="switch-label switch-label-' . (!($i % 2) ? 'off' : 'on') . '">' . $value . '</label>'; $i++; } echo '<span class="switch-selection"></span></div></div>'; if (!empty($field['hide_nodes'])) { echo '<script> jQuery(document).ready(function($){ $(".conditional-switch.' . $field['id'] . '").each(function(){ $(this).on("click",function(){ var val = $(this).parent().find(".conditional-switch.' . $field['id'] . ':checked").val(); if(val == "H" || val === "H" || val == "off" || val === "off" || val == "no" || val === "no"){'; foreach ($field['hide_nodes'] as $node) { echo '$(".vibe_' . $node . '").show(200).addClass("conditional_display");'; } echo '}else{'; foreach ($field['hide_nodes'] as $node) { echo '$(".vibe_' . $node . '").hide(200).removeClass("conditional_display");'; } echo ' } }); }); }); </script>'; } break; case 'select': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>' . (!empty($field['text']) ? '<strong>' . $field['text'] . '</strong>' : ''); echo '<select class="post_field" style="width: 100%;" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" >'; if (!empty($field['options'])) { foreach ($field['options'] as $option) { echo '<option value="' . $option['value'] . '" ' . ($field['value'] == $option['value'] ? 'selected="selected"' : '') . '>' . $option['label'] . '</option>'; } } echo '</select></div>'; break; case 'duration': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>' . (!empty($field['text']) ? '<strong>' . $field['text'] . '</strong>' : ''); echo '<select data-id="' . $field['id'] . '" class="post_field" data-type="' . $field['type'] . '" >'; $field['options'] = array(array('value' => 1, 'label' => __('Seconds', 'wplms-front-end')), array('value' => 60, 'label' => __('Minutes', 'wplms-front-end')), array('value' => 3600, 'label' => __('Hours', 'wplms-front-end')), array('value' => 86400, 'label' => __('Days', 'wplms-front-end')), array('value' => 604800, 'label' => __('Weeks', 'wplms-front-end')), array('value' => 2592000, 'label' => __('Months', 'wplms-front-end')), array('value' => 31536000, 'label' => __('Years', 'wplms-front-end'))); if (!empty($field['options'])) { foreach ($field['options'] as $option) { echo '<option value="' . $option['value'] . '" ' . ($field['value'] == $option['value'] ? 'selected="selected"' : '') . '>' . $option['label'] . '</option>'; } } echo '</select></div>'; break; case 'selectcpt': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>' . (!empty($field['text']) ? '<strong>' . $field['text'] . '</strong>' : ''); if (empty($field['post_status'])) { $field['post_status'] = 'publish'; } else { $field['post_status'] = implode(',', $field['post_status']); } echo (!empty($field['text']) ? '<div class="right">' : '') . '<select class="select2 selectcpt post_field" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" data-status="' . $field['post_status'] . '" style="width: 100%;" data-placeholder="' . $field['placeholder'] . '" data-cpt="' . ($field['cpt'] ? $field['cpt'] : ($field['post_type'] ? $field['post_type'] : '')) . '">'; if (!empty($field['value']) && $field['value'] != $field['default']) { echo '<option value="' . $field['value'] . '">' . get_the_title($field['value']) . '</option>'; } echo '</select></div>'; break; case 'selectproduct': $product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400); $product_fields = apply_filters('wplms_front_end_new_product', array(array('label' => __('Title', 'wplms-front-end'), 'placeholder' => __('Product Title', 'wplms-front-end'), 'type' => 'text', 'style' => '', 'from' => 'post', 'id' => 'post_title', 'desc' => __('Product title is useful to identify courses connected to this product.', 'wplms-front-end')), array('label' => __('Price', 'wplms-front-end'), 'text' => __('Price', 'wplms-front-end'), 'type' => 'text', 'style' => 'col-md-6', 'id' => '_regular_price', 'extra' => get_woocommerce_currency(), 'desc' => __('Set price of the course', 'wplms-front-end')), array('label' => __('Sale', 'wplms-front-end'), 'text' => __('Sale Price', 'wplms-front-end'), 'type' => 'text', 'style' => 'col-md-6', 'id' => '_sale_price', 'extra' => get_woocommerce_currency(), 'desc' => __('Blank if product not in sale', 'wplms-front-end')), array('label' => __('Subscription', 'wplms-front-end'), 'type' => 'conditionalswitch', 'text' => __('Subscription Type', 'wplms-front-end'), 'hide_nodes' => array('vibe_product_duration', 'vibe_product_duration_parameter'), 'options' => array('H' => __('FULL DURATION', 'wplms-front-end'), 'S' => __('LIMITED', 'wplms-front-end')), 'style' => '', 'default' => 'H', 'id' => 'vibe_subscription', 'desc' => __('Set subscription type of product.', 'wplms-front-end')), array('label' => __('Subscription Duration', 'wplms-front-end'), 'type' => 'text', 'text' => __('Set subscription duration', 'wplms-front-end'), 'style' => '', 'id' => 'vibe_product_duration', 'from' => 'meta', 'default' => __('Must not be 0', 'wplms-front-end')), array('label' => __('Subscription Duration Parameter', 'wplms-front-end'), 'text' => __('Set subscription duration parameter', 'wplms-front-end'), 'type' => 'duration', 'style' => '', 'id' => 'vibe_product_duration_parameter', 'default' => $product_duration_parameter, 'from' => 'meta'))); echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>'; if (!empty($field['value']) && $field['value'] != $field['default']) { $product = wc_get_product($field['value']); echo '<span class="dashicons dashicons-dismiss clear_input" data-id="product_id"><div class="hide">' . $field['text'] . '<span class="change_product">' . __('Set Product', 'wplms-front-end') . '</span><input type="hidden" id="product_id" class="post_field" data-id="vibe_product" /></div></span>'; echo '<h3>' . get_the_title($field['value']) . '<span class="change_product">' . __('Change', 'wplms-front-end') . '</span><span class="edit_product">' . __('Edit', 'wplms-front-end') . '</span><strong class="price">' . (is_object($product) ? $product->get_price_html() : '') . '</strong> <input type="hidden" id="product_id" class="post_field" data-id="vibe_product" value="' . $field['value'] . '" /></h3>'; } else { echo '<h3>' . $field['text'] . '<span class="change_product">' . __('Set Product', 'wplms-front-end') . '</span></h3>'; } ?> <div id="change_product" class="field_wrapper" <?php if (empty($field['value'])) { echo 'style="display:block;"'; } else { echo 'style="display:none;"'; } ?> > <a class="hide_parent"><i class="icon-x"></i></a> <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select existing product', 'wplms-front-end'); ?> </a> <div class="select_product_form"> <select class="selectcpt select2" data-cpt="product" data-placeholder="<?php _e('Search a product', 'wplms-front-end'); ?> "> </select> <a class="use_selected_product button"><?php _e('Set Product', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create new product', 'wplms-front-end'); ?> </a> <div class="new_product_form"> <?php foreach ($product_fields as $product_field) { echo '<div class="vibe_' . $product_field['id'] . ' ' . (empty($product_field['style']) ? '' : $product_field['style']) . '">'; unset($product_field['style']); self::generate_fields($product_field); echo '</div>'; } ?> <a class="button small" id="create_new_product"><?php _e('Create Product', 'wplms-front-end'); ?> </a> </div> </div> </div> <?php if (!empty($field['value'])) { ?> <div id="edit_product" class="field_wrapper"> <a class="hide_parent"><i class="icon-x"></i></a> <?php foreach ($product_fields as $product_field) { echo '<div class="vibe_' . $product_field['id'] . ' ' . (empty($product_field['style']) ? '' : $product_field['style']) . '">'; unset($product_field['style']); if ($product_field['id'] == 'vibe_subscription') { $product_field['id'] = 'vibe_subscription1'; } self::generate_fields($product_field, $field['value']); echo '</div>'; } ?> <input type="hidden" class="post_field" data-id="ID" value="<?php echo $field['value']; ?> " /> <a class="button small" id="edit_course_product"><?php _e('Edit Product', 'wplms-front-end'); ?> </a> </div> <?php } break; case 'multiselect': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label><strong>' . $field['text'] . '</strong>'; echo '<select class="select2 post_field" data-id="' . $field['id'] . '" style="width: 100%;" multiple>'; if (!empty($field['options'])) { foreach ($field['options'] as $key => $option) { if (!empty($option)) { if (empty($field['value'])) { $field['value'] = array(); } echo '<option value="' . $option['value'] . '" ' . (in_array($option['value'], $field['value']) ? 'selected="selected"' : '') . '>' . $option['label'] . '</option>'; } } } echo '</select></div>'; break; case 'selectmulticpt': echo '<div class="field_wrapper ' . $field['style'] . '">'; echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>' . (!empty($field['text']) ? '<strong>' . $field['text'] . '</strong>' : ''); if (empty($field['post_status'])) { $field['post_status'] = 'publish'; } else { $field['post_status'] = implode(',', $field['post_status']); } echo (!empty($field['text']) ? '<div class="right" style="width:240px">' : '') . '<select class="select2 selectcpt post_field" data-id="' . $field['id'] . '" data-type="' . $field['type'] . '" data-status="' . $field['post_status'] . '" style="width: 100%;" data-placeholder="' . $field['placeholder'] . '" data-cpt="' . ($field['cpt'] ? $field['cpt'] : ($field['post_type'] ? $field['post_type'] : '')) . '" multiple>'; if (!empty($field['value']) && $field['value'] != $field['default']) { if (is_array($field['value'])) { foreach ($field['value'] as $value) { echo '<option value="' . $value . '" selected="selected">' . get_the_title($value) . '</option>'; } } } echo '</select></div>'; break; case 'course_live': ?> <?php if (!empty($_GET['action'])) { ?> <strong class="heading"><?php _e('Modify Course', 'wplms-front-end'); ?> <span><a href="<?php echo get_permalink($_GET['action']); ?> "><?php _e('Back to course', 'wplms-front-end'); ?> </a></span></strong> <?php if (get_post_type($_GET['action']) == 'course') { $post_status = get_post_status($_GET['action']); if ($post_status == 'publish') { $new_course_status = vibe_get_option('new_course_status'); if (isset($new_course_status) && $new_course_status == 'publish') { echo '<a id="offline_course" class="button big hero">' . __('TAKE OFFLINE', 'wplms-front-end') . '</a>'; } else { echo '<a id="publish_course" class="button big hero">' . __('SEND FOR APPROVAL', 'wplms-front-end') . '</a>'; } } else { $new_course_status = vibe_get_option('new_course_status'); if (isset($new_course_status) && $new_course_status == 'publish') { echo '<a id="publish_course" class="button big hero">' . __('GO LIVE', 'wplms-front-end') . '</a>'; } else { echo '<a id="publish_course" class="button big hero">' . __('SEND FOR APPROVAL', 'wplms-front-end') . '</a>'; } } $delete_enable = apply_filters('wplms_front_end_course_delete', 0); if ($delete_enable) { echo '<hr /><a id="delete_course" class="button big full primary">' . __('DELETE COURSE', 'wplms-front-end') . '</a>'; echo '<a class="link right showhide_indetails">' . __('SHOW OPTIONS', 'wplms-front-end') . '</a>'; $delete_options = apply_filters('wplms_course_delete_options', array('unit' => array('label' => __('Delete Units', 'wplms-front-end'), 'post_type' => 'unit', 'post_meta' => 'vibe_course_curriculum'), 'quiz' => array('label' => __('Delete Quizzes', 'wplms-front-end'), 'post_type' => 'quiz', 'post_meta' => 'vibe_course_curriculum'), 'assignment' => array('label' => __('Delete Assignments', 'wplms-front-end'), 'post_type' => 'wplms-assignment', 'post_meta' => 'vibe_assignment_course'))); echo '<div class="in_details"><ul class="clear">'; foreach ($delete_options as $option) { echo '<li><label>' . $option['label'] . '</label><input class="delete_field right" type="checkbox" value="1" data-posttype="' . $option['post_type'] . '" data-meta="' . $option['post_meta'] . '" /></li>'; } echo '</ul></div>'; } } else { ?> <?php echo '<p class="message">' . __('Course not set', 'wplms-front-end') . '</p>'; } ?> <?php } else { ?> <strong class="heading"><?php _e('Go Live', 'wplms-front-end'); ?> </strong> <?php $new_course_status = vibe_get_option('new_course_status'); if (isset($new_course_status) && $new_course_status == 'publish') { echo '<a id="publish_course" class="button big hero">' . __('GO LIVE', 'wplms-front-end') . '</a>'; } else { echo '<a id="publish_course" class="button big hero">' . __('SEND FOR APPROVAL', 'wplms-front-end') . '</a>'; } ?> <?php } ?> <?php break; case 'button': echo '<br class="clear" /><hr />'; echo '<a id="' . $field['id'] . '" class="button hero">' . $field['label'] . '</a>'; break; case 'small_button': echo '<a id="' . $field['id'] . '" ' . (empty($field['href']) ? '' : 'href="' . $field['href'] . '"') . ' ' . (empty($field['data-id']) ? '' : 'data-id="' . $field['data-id'] . '"') . ' target="_blank" class="button">' . $field['label'] . '</a>'; break; case 'dynamic_taxonomy': echo '<label>' . $field['label'] . (empty($field['desc']) ? '' : '<a class="tip" title="' . $field['desc'] . '"><i class="icon-question"></i></a>') . '</label>' . (empty($field['text']) ? '' : '<strong>' . $field['text'] . '</strong>'); echo '<select class="select2 post_field" data-id="' . $field['id'] . '" data-type="array" style="width: 100%;" multiple>'; $terms = get_terms($field['taxonomy'], array('hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'id=>name')); if (empty($field['value'])) { $field['value'] = array(); } if (!empty($terms) && is_array($terms)) { foreach ($terms as $key => $term) { echo '<option value="' . $key . '" ' . (in_array($key, $field['value']) ? 'SELECTED' : '') . '>' . $term . '</option>'; } } echo '</select>'; break; case 'repeatable_count': ?> <a class="button small primary add_repeatable_count_option"><?php _e('ADD OPTION', 'wplms-front-end'); ?> </a> <ul id="<?php echo $field['id']; ?> " data-id="<?php echo $field['id']; ?> " class="repeatable post_field"> <?php if (isset($field['value']) && is_array($field['value'])) { foreach ($field['value'] as $key => $option) { echo '<li><span>' . ($key + 1) . '</span> <input type="text" class="option very_large_box" value="' . $option . '" /> <a class="rem"><i class="icon-x"></i></a> </li>'; } } ?> </ul> <ul class="hidden"> <li><span></span><input type="text" class="option very_large_box" /><a class="rem"><i class="icon-x"></i></a></li> </ul> <?php break; case 'assignment': ?> <?php if (!empty($field['value'])) { foreach ($field['value'] as $k => $assignment_id) { ?> <div class="list-group-item assignment_block"> <span class="dashicons dashicons-sort"></span> <strong class="title" data-id="<?php echo $assignment_id; ?> "><?php echo get_the_title($assignment_id); ?> </strong> <input type="hidden" class="assignment_id" value="<?php echo $assignment_id; ?> " /> <?php echo '<ul class="data_links"> <li><a class="edit_sub" title="' . __('Edit', 'wplms-front-end') . '"><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview_sub" title="' . __('Preview', 'wplms-front-end') . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove_sub" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete_sub" title="' . __('Delete', 'wplms-front-end') . '"><span class="dashicons dashicons-trash"></span></a></li> </ul>'; ?> </div> <?php } } ?> <div class="list-group-item hidden_block hide"> <span class="dashicons dashicons-sort"></span> <strong class="title" data-id=""></strong> <input type="hidden" class="assignment_id" value="" /> <?php echo '<ul class="data_links"> <li><a class="edit_sub" title="' . __('Edit', 'wplms-front-end') . '"><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview_sub" title="' . __('Preview', 'wplms-front-end') . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove_sub" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete_sub" title="' . __('Delete', 'wplms-front-end') . '"><span class="dashicons dashicons-trash"></span></a></li> </ul>'; ?> </div> <div class="list-group-item"> <div class="add_cpt"> <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select existing assignment', 'wplms-front-end'); ?> </a> <div class="select_existing_cpt"> <select class="selectcpt select2" data-cpt="wplms-assignment" data-placeholder="<?php _e('Search an assignment', 'wplms-front-end'); ?> "> </select> <a class="use_selected_assignment button"><?php _e('Set Assignment', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create new Assignment', 'wplms-front-end'); ?> </a> <div class="new_cpt"> <input type="text" class="form_field" id="vibe_assignment_title" name="name" placeholder="<?php _e('Reference title', 'wplms-front-end'); ?> "> <a class="button small" id="create_new_assignment"><?php _e('Create Assignment', 'wplms-front-end'); ?> </a> </div> </div> </div> </div> <?php ?> <?php break; case 'quiz_questions': ?> <?php if (!empty($field['value']) && !empty($field['value']['ques'])) { foreach ($field['value']['ques'] as $k => $question_id) { ?> <div class="list-group-item question_block"> <span class="dashicons dashicons-sort"></span> <strong class="title" data-id="<?php echo $question_id; ?> "><?php echo get_the_title($question_id); ?> </strong> <input type="hidden" class="question_id" value="<?php echo $question_id; ?> " /> <?php echo '<ul class="data_links"> <li><a class="edit_sub" title="' . __('Edit', 'wplms-front-end') . '"><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview_sub" title="' . __('Preview', 'wplms-front-end') . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove_sub" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete_sub" title="' . __('Delete', 'wplms-front-end') . '"><span class="dashicons dashicons-trash"></span></a></li> </ul>'; ?> <div class="right"> <input type="number" class="small_box question_marks" value="<?php echo $field['value']['marks'][$k]; ?> " /> <span><?php _e('Marks', 'wplms-front-end'); ?> </span> </div> </div> <?php } } ?> <div class="list-group-item hidden_block hide"> <span class="dashicons dashicons-sort"></span> <strong class="title" data-id=""></strong> <input type="hidden" class="question_id" value="" /> <?php echo '<ul class="data_links"> <li><a class="edit_sub" title="' . __('Edit', 'wplms-front-end') . '"><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview_sub" title="' . __('Preview', 'wplms-front-end') . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove_sub" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete_sub" title="' . __('Delete', 'wplms-front-end') . '"><span class="dashicons dashicons-trash"></span></a></li> </ul>'; ?> <div class="right"> <input type="number" class="small_box question_marks" value="<?php echo $field['value']['marks'][$k]; ?> " /> <span><?php _e('Marks', 'wplms-front-end'); ?> </span> </div> </div> <div class="list-group-item"> <div class="add_cpt"> <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select existing question', 'wplms-front-end'); ?> </a> <div class="select_existing_cpt"> <select class="selectcpt select2" data-cpt="question" data-placeholder="<?php _e('Search a question', 'wplms-front-end'); ?> "> </select> <a class="use_selected_question button"><?php _e('Set Question', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create new Question', 'wplms-front-end'); ?> </a> <div class="new_cpt"> <input type="text" class="form_field" id="vibe_question_title" name="name" placeholder="<?php _e('Reference title', 'wplms-front-end'); ?> "> <?php $field = array('label' => __('Question Tags', 'wplms-front-end'), 'type' => 'taxonomy', 'taxonomy' => 'question-tag', 'from' => 'taxonomy', 'value_type' => 'single', 'style' => '', 'id' => 'question-tag', 'default' => __('Select a Tag', 'wplms-front-end')); self::generate_fields($field); ?> <?php $question_types = apply_filters('wplms_question_types', array(array('label' => __('True or False', 'vibe-customtypes'), 'value' => 'truefalse'), array('label' => __('Multiple Choice', 'vibe-customtypes'), 'value' => 'single'), array('label' => __('Multiple Correct', 'vibe-customtypes'), 'value' => 'multiple'), array('label' => __('Sort Answers', 'vibe-customtypes'), 'value' => 'sort'), array('label' => __('Match Answers', 'vibe-customtypes'), 'value' => 'match'), array('label' => __('Fill in the Blank', 'vibe-customtypes'), 'value' => 'fillblank'), array('label' => __('Dropdown Select', 'vibe-customtypes'), 'value' => 'select'), array('label' => __('Small Text', 'vibe-customtypes'), 'value' => 'smalltext'), array('label' => __('Large Text', 'vibe-customtypes'), 'value' => 'largetext'))); ?> <select class="chosen" id="vibe_question_template"> <?php foreach ($question_types as $type) { echo '<option value="' . $type['value'] . '">' . $type['label'] . '</option>'; } ?> </select> <a class="button small" id="create_new_question"><?php _e('Create question', 'wplms-front-end'); ?> </a> </div> </div> </div> </div> <?php ?> <?php break; case 'curriculum': ?> <ul class="curriculum post_field"> <?php if (isset($_GET['action'])) { $curriculum = vibe_sanitize(get_post_meta($_GET['action'], 'vibe_course_curriculum', false)); if (isset($curriculum) && is_array($curriculum)) { foreach ($curriculum as $kid) { if (is_numeric($kid)) { if (get_post_type($kid) == 'unit') { echo '<li><strong class="title" data-id="' . $kid . '"><i class="icon-file"></i> ' . get_the_title($kid) . '</strong> <ul class="data_links"> <li><a class="edit" title="' . __('Edit Unit', 'wplms-front-end') . '"><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview" title="' . __('Preview', 'wplms-front-end') . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete" title="' . __('Delete', 'wplms-front-end') . '"><span class="dashicons dashicons-trash"></span></a></li> </ul> </li>'; } else { echo '<li><strong class="title" data-id="' . $kid . '"><i class="icon-task"></i> ' . get_the_title($kid) . '</strong> <ul class="data_links"> <li><a class="edit" title="' . __('Edit Quiz', 'wplms-front-end') . '"><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview" title="' . __('Preview', 'wplms-front-end') . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete" title="' . __('Delete', 'wplms-front-end') . '"><span class="dashicons dashicons-trash"></span></a></li> </ul> </li>'; } } else { echo '<li class="new_section"><strong>' . $kid . '</strong> <ul class="data_links"> <li> <a class="remove" title="' . __('Remove', 'wplms-front-end') . '"><span class="dashicons dashicons-no-alt"></span></a> </li> </ul> </li>'; } } } } ?> </ul> <ul class="hide"> <li><strong class="title" data-id=""><i class="icon-task"></i> <span></span></strong> <ul class="data_links"> <li><a class="edit" title="<?php _e('Edit Quiz', 'wplms-front-end'); ?> "><span class="dashicons dashicons-edit"></span></a></li> <li><a class="preview" title="<?php _e('Preview', 'wplms-front-end'); ?> " target="_blank"><span class="dashicons dashicons-visibility"></span></a></li> <li><a class="remove" title="<?php _e('Remove', 'wplms-front-end'); ?> "><span class="dashicons dashicons-no-alt"></span></a></li> <li><a class="delete" title="<?php _e('Delete', 'wplms-front-end'); ?> "><span class="dashicons dashicons-trash"></span></a></li> </ul> </li> </ul> <ul id="hidden_base"> <li class="new_section"> <input type="text" class="section " placeholder="<?php _e('Enter Section Title', 'wplms-front-end'); ?> " /> <a class="rem"><i class="icon-x"></i></a> </li> <li class="new_unit"> <div class="add_cpt"> <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select existing unit', 'wplms-front-end'); ?> </a> <div class="select_existing_cpt"> <select data-cpt="unit" data-placeholder="<?php _e('Search a unit', 'wplms-front-end'); ?> "> </select> <a class="use_selected_curriculum button"><?php _e('Set Unit', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create new unit', 'wplms-front-end'); ?> </a> <div class="new_cpt"> <input type="text" class="form_field vibe_curriculum_title" name="name" placeholder="<?php _e('Unit title', 'wplms-front-end'); ?> "> <input type="hidden" class="vibe_cpt" value="unit" /> <a class="button small create_new_curriculum"><?php _e('Create Unit', 'wplms-front-end'); ?> </a> </div> </div> </div> <a class="rem"><i class="icon-x"></i></a> </li> <li class="new_quiz"> <div class="add_cpt"> <div class="col-md-6"> <a class="more"><i class="icon-users"></i> <?php _e('Select existing quiz', 'wplms-front-end'); ?> </a> <div class="select_existing_cpt"> <select data-cpt="quiz" data-placeholder="<?php _e('Search a quiz', 'wplms-front-end'); ?> "> </select> <a class="use_selected_curriculum button"><?php _e('Set Quiz', 'wplms-front-end'); ?> </a> </div> </div> <div class="col-md-6"> <a class="more"><i class="icon-user"></i> <?php _e('Create new quiz', 'wplms-front-end'); ?> </a> <div class="new_cpt"> <input type="text" class="form_field vibe_curriculum_title" name="name" placeholder="<?php _e('Quiz title', 'wplms-front-end'); ?> "> <input type="hidden" class="vibe_cpt" value="quiz" /> <a class="button small create_new_curriculum"><?php _e('Create Quiz', 'wplms-front-end'); ?> </a> </div> </div> </div> <a class="rem"><i class="icon-x"></i></a> </li> </ul> <div class="add_element"> <?php if (!empty($field['buttons'])) { foreach ($field['buttons'] as $key => $label) { echo '<a id="' . $key . '" class="button primary">' . $label . '</a>'; } } ?> </div> <a id="save_course_curriculum_button" class="button hero"><?php _e('SAVE CURRICULUM', 'wplms-front-end'); ?> </a> <?php break; default: do_action('wplms_front_end_generate_fields_default', $field, $_GET['action']); break; } }
$the_quiz = new WP_QUERY(array('post_type' => 'quiz', 'paged' => $paged, 'meta_query' => array(array('key' => $user_id, 'compare' => 'EXISTS')))); if ($the_quiz->have_posts()) { ?> <h3 class="heading"><?php _e('Quiz Results', 'vibe'); ?> </h3> <ul class="quiz_results"> <?php while ($the_quiz->have_posts()) { $the_quiz->the_post(); $value = get_post_meta(get_the_ID(), $user_id, true); $questions = vibe_sanitize(get_post_meta(get_the_ID(), 'quiz_questions' . $user_id, false)); if (!isset($questions) || !is_array($questions)) { // Fallback for Older versions $questions = vibe_sanitize(get_post_meta(get_the_ID(), 'vibe_quiz_questions', false)); } if (is_Array($questions['marks']) && isset($questions['marks'])) { $max = array_sum($questions['marks']); } else { $max = 0; } ?> <li><i class="icon-task"></i> <a href="?action=<?php echo get_the_ID(); ?> "><?php the_title(); ?> </a>
$myavg = get_post_meta($course->ID, $user_id, true); if (!isset($myavg) || $myavg == '') { $myavg = __('TAKING', 'vibe'); } echo '<strong>' . __('MY SCORE : ', 'vibe') . '<span>' . apply_filters('wplms_course_marks', $myavg . '/100', $course->ID) . '</span></strong>'; echo '<ul class="in_details">'; if (isset($curriculum) && is_array($curriculum)) { foreach ($curriculum as $c) { if (is_numeric($c)) { if (get_post_type($c) == 'quiz') { $myavg = get_post_meta($c, $user_id, true); $avg = get_post_meta($c, 'average', true); $questions = vibe_sanitize(get_post_meta($c, 'quiz_questions' . $user_id, false)); if (!isset($questions) || !is_array($questions)) { // Fallback for Older versions $questions = vibe_sanitize(get_post_meta($c, 'vibe_quiz_questions', false)); } if (isset($questions['marks']) && is_array($questions['marks'])) { $marks = $questions['marks']; $max = array_sum($marks); } if (isset($myavg) && $myavg != '') { echo '<li>' . __('Average Marks in', 'vibe') . ' ' . get_the_title($c) . ' : ' . $avg . ''; echo '<strong>' . __('My Marks', 'vibe') . ' : ' . $myavg . ' / ' . $max . '</strong></li>'; } } else { $check = get_user_meta($user_id, $c, true); echo '<li>' . get_the_title($c) . '<strong>' . ($check ? '<i class="icon-check"></i>' : '<i class="icon-alarm-clock"></i>') . '</strong></li>'; } } }
function incourse_start_quiz() { $quiz_id = $_POST['quiz_id']; if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security') || !is_numeric($quiz_id)) { _e('Security check Failed. Contact Administrator.', 'vibe'); die; } $user_id = get_current_user_id(); do_action('wplms_before_quiz_begining', $quiz_id); $get_questions = vibe_sanitize(get_post_meta($quiz_id, 'quiz_questions' . $user_id, false)); if (!isset($get_questions) || !is_array($get_questions)) { $get_questions = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_questions', false)); update_post_meta($quiz_id, 'quiz_questions' . $user_id, $get_questions); } // Fallback for Older versions if (!is_array($get_questions) || !is_array($get_questions['ques']) || !is_array($get_questions['marks'])) { _e('Questions not set.', 'vibe'); die; } $questions = $get_questions['ques']; $marks = $get_questions['marks']; $posts_per_page = apply_filters('wplms_incourse_quiz_per_page', 10); $page = $_POST['page']; if (!isset($page) || !is_numeric($page) || !$page) { $page = 1; // Add user to quiz : Quiz attempted by user update_post_meta($quiz_id, $user_id, 0); $quiz_duration_parameter = apply_filters('vibe_quiz_duration_parameter', 60); $quiz_duration = get_post_meta($quiz_id, 'vibe_duration', true) * $quiz_duration_parameter; // Quiz duration in seconds $expire = time() + $quiz_duration; update_user_meta($user_id, $quiz_id, $expire); do_action('wplms_start_quiz', $quiz_id, $user_id); // Start Quiz Notifications } $args = apply_filters('wplms_in_course_quiz_args', array('post__in' => $questions, 'post_type' => 'question', 'posts_per_page' => $posts_per_page, 'paged' => $page, 'orderby' => 'post__in')); $the_query = new WP_Query($args); $quiz_questions = array(); if ($the_query->have_posts()) { echo '<script>var all_questions_json = ' . json_encode($questions) . '</script>'; while ($the_query->have_posts()) { $the_query->the_post(); global $post; $loaded_questions[] = get_the_ID(); $key = array_search(get_the_ID(), $questions); $hint = get_post_meta(get_the_ID(), 'vibe_question_hint', true); $type = get_post_meta(get_the_ID(), 'vibe_question_type', true); echo '<div class="in_question " data-ques="' . $post->ID . '">'; echo '<i class="marks">' . (isset($marks[$key]) ? '<i class="icon-check-5"></i>' . $marks[$key] : '') . '</i>'; echo '<div class="question ' . $type . '">'; the_content(); if (isset($hint) && strlen($hint) > 5) { echo '<a class="show_hint tip" tip="' . __('SHOW HINT', 'vibe') . '"><span></span></a>'; echo '<div class="hint"><i>' . __('HINT', 'vibe') . ' : ' . apply_filters('the_content', $hint) . '</i></div>'; } echo '</div>'; switch ($type) { case 'truefalse': case 'single': case 'multiple': case 'sort': case 'match': $options = vibe_sanitize(get_post_meta(get_the_ID(), 'vibe_question_options', false)); if ($type == 'truefalse') { $options = array(0 => __('FALSE', 'vibe'), 1 => __('TRUE', 'vibe')); } if (isset($options) || $options) { $answers = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'user_id' => $user_id)); if (isset($answers) && is_array($answers) && count($answers)) { $answer = reset($answers); $content = explode(',', $answer->comment_content); } else { $content = array(); } echo '<ul class="question_options ' . $type . '">'; if ($type == 'single') { foreach ($options as $key => $value) { echo '<li> <div class="radio"> <input type="radio" id="' . $post->post_name . $key . '" class="ques' . $post->ID . '" name="' . $post->ID . '" value="' . ($key + 1) . '" ' . (in_array($key + 1, $content) ? 'checked' : '') . '/> <label for="' . $post->post_name . $key . '">' . do_shortcode($value) . '</label> </div> </li>'; } } else { if ($type == 'sort') { foreach ($options as $key => $value) { echo '<li id="' . ($key + 1) . '" class="ques' . $post->ID . ' sort_option"> <label for="' . $post->post_name . $key . '"><span></span> ' . do_shortcode($value) . '</label> </li>'; } } else { if ($type == 'match') { foreach ($options as $key => $value) { echo '<li id="' . ($key + 1) . '" class="ques' . $post->ID . ' match_option"> <label for="' . $post->post_name . $key . '"><span></span> ' . do_shortcode($value) . '</label> </li>'; } } else { if ($type == 'truefalse') { foreach ($options as $key => $value) { echo '<li> <div class="radio"> <input type="radio" id="' . $post->post_name . $key . '" class="ques' . $post->ID . '" name="' . $post->ID . '" value="' . $key . '" ' . (in_array($key, $content) ? 'checked' : '') . '/> <label for="' . $post->post_name . $key . '">' . $value . '</label> </div> </li>'; } } else { foreach ($options as $key => $value) { echo '<li> <div class="checkbox"> <input type="checkbox" class="ques' . $post->ID . '" id="' . $post->post_name . $key . '" name="' . $post->ID . $key . '" value="' . ($key + 1) . '" ' . (in_array($key + 1, $content) ? 'checked' : '') . '/> <label for="' . $post->post_name . $key . '">' . do_shortcode($value) . '</label> </div> </li>'; } } } } } echo '</ul>'; } break; // End Options // End Options case 'fillblank': break; case 'select': break; case 'smalltext': echo '<input type="text" name="' . $k . '" class="ques' . $k . ' form_field" value="' . ($content ? $content : '') . '" placeholder="' . __('Type Answer', 'vibe') . '" />'; break; case 'largetext': echo '<textarea name="' . $k . '" class="ques' . $k . ' form_field" placeholder="' . __('Type Answer', 'vibe') . '">' . ($content ? $content : '') . '</textarea>'; break; } echo '</div>'; } $count = count($questions); if ($posts_per_page < $count) { echo '<div class="pagination"><label>' . __('PAGES', 'vibe') . '</label> <ul>'; $max = $count / $posts_per_page; if ($count % $posts_per_page) { $max++; } for ($i = 1; $i <= $max; $i++) { if ($page == $i) { echo '<li><span>' . $i . '</span></li>'; } else { echo '<li><a class="quiz_page">' . $i . '</a><li>'; } } echo '</ul> </div>'; } echo '<script>var questions_json = ' . json_encode($loaded_questions) . '</script>'; } wp_reset_postdata(); die; }
function thumbnail_generator($custom_post, $featured_style, $cols = 'medium', $n = 100, $link = 0, $zoom = 0) { $return = $read_more = $class = ''; global $post; $more = __('Read more', 'vibe-customtypes'); if (strlen($custom_post->post_content) > $n) { $read_more = '<a href="' . get_permalink($custom_post->ID) . '" class="link">' . $more . '</a>'; } $cache_duration = vibe_get_option('cache_duration'); if (!isset($cache_duration)) { $cache_duration = 0; } if ($cache_duration) { $key = $featured_style . '_' . $custom_post->post_type . '_' . $custom_post->ID; if (is_user_logged_in()) { $user_id = get_current_user_id(); $user_meta = get_user_meta($user_id, $custom_post->ID, true); if (isset($user_meta)) { $key .= '_' . $user_id; } } $result = wp_cache_get($key, 'featured_block'); } else { $result = false; } if (false === $result) { switch ($featured_style) { case 'course': $return .= '<div class="block courseitem">'; $return .= '<div class="block_media">'; $return .= apply_filters('vibe_thumb_featured_image', '<a href="' . get_permalink($custom_post->ID) . '">' . featured_component($custom_post->ID, $cols) . '</a>', $featured_style); $return .= '</div>'; $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $category = ''; if (get_post_type($custom_post->ID) == 'course') { $rating = get_post_meta($custom_post->ID, 'average_rating', true); $rating_count = get_post_meta($custom_post->ID, 'rating_count', true); $meta = '<div class="star-rating">'; for ($i = 1; $i <= 5; $i++) { if (isset($rating)) { if ($rating >= 1) { $meta .= '<span class="fill"></span>'; } elseif ($rating < 1 && $rating > 0.4) { $meta .= '<span class="half"></span>'; } else { $meta .= '<span></span>'; } $rating--; } else { $meta .= '<span></span>'; } } $meta = apply_filters('vibe_thumb_rating', $meta, $featured_style, $rating); $meta .= apply_filters('vibe_thumb_reviews', '( ' . (isset($rating_count) ? $rating_count : '0') . ' ' . __('REVIEWS', 'vibe-customtypes') . ' )', $featured_style) . '</div>'; $free_course = get_post_meta($custom_post->ID, 'vibe_course_free', true); $meta .= bp_course_get_course_credits(array('id' => $custom_post->ID)); $meta .= '<span class="clear"></span>'; $instructor_meta = ''; if (function_exists('bp_course_get_instructor')) { $instructor_meta .= bp_course_get_instructor(); } $meta .= apply_filters('vibe_thumb_instructor_meta', $instructor_meta, $featured_style); $st = get_post_meta($custom_post->ID, 'vibe_students', true); if (isset($st) && $st != '') { $meta .= apply_filters('vibe_thumb_student_count', '<strong>' . $st . ' ' . __('Students', 'vibe-customtypes') . '</strong>'); } $return .= $meta; } $return .= apply_filters('wplms_course_thumb_extras', ''); // Use this filter to add Extra HTML to the course featured block $return .= '</div>'; $return .= '</div>'; break; case 'course2': $return .= '<div class="block courseitem course2">'; $return .= '<div class="block_media">'; $return .= apply_filters('vibe_thumb_featured_image', '<a href="' . get_permalink($custom_post->ID) . '">' . featured_component($custom_post->ID, $cols) . '</a>', $featured_style); $return .= '</div>'; $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $category = ''; if (get_post_type($custom_post->ID) == 'course') { $rating = get_post_meta($custom_post->ID, 'average_rating', true); $rating_count = get_post_meta($custom_post->ID, 'rating_count', true); $meta = '<div class="star-rating">'; for ($i = 1; $i <= 5; $i++) { if (isset($rating)) { if ($rating >= 1) { $meta .= '<span class="fill"></span>'; } elseif ($rating < 1 && $rating > 0.4) { $meta .= '<span class="half"></span>'; } else { $meta .= '<span></span>'; } $rating--; } else { $meta .= '<span></span>'; } } $meta = apply_filters('vibe_thumb_rating', $meta, $featured_style, $rating); $meta .= apply_filters('vibe_thumb_reviews', '( ' . (isset($rating_count) ? $rating_count : '0') . ' ' . __('REVIEWS', 'vibe-customtypes') . ' )', $featured_style) . '</div>'; $free_course = get_post_meta($custom_post->ID, 'vibe_course_free', true); $st = get_post_meta($custom_post->ID, 'vibe_students', true); if (isset($st) && $st != '') { $meta .= apply_filters('vibe_thumb_student_count', '<strong><i class="icon-users"></i> ' . $st . '</strong>'); } $meta .= '<span class="clear"></span>'; $instructor_meta = ''; if (function_exists('bp_course_get_instructor')) { $instructor_meta .= bp_course_get_instructor(); } $meta .= apply_filters('vibe_thumb_instructor_meta', $instructor_meta, $featured_style); $meta .= bp_course_get_course_credits(array('id' => $custom_post->ID)); $return .= $meta; } $return .= apply_filters('wplms_course_thumb_extras', ''); // Use this filter to add Extra HTML to the course featured block $return .= '</div>'; $return .= '</div>'; break; case 'side': $return .= '<div class="block side">'; $return .= '<div class="block_media">'; if (isset($link) && $link) { $return .= '<span class="overlay"></span>'; } if (isset($link) && $link) { $return .= '<a href="' . get_permalink($custom_post->ID) . '" class="hover-link hyperlink"><i class="icon-hyperlink"></i></a>'; } $featured = getPostMeta($custom_post->ID, 'vibe_select_featured'); if (isset($zoom) && $zoom && has_post_thumbnail($custom_post->ID)) { $return .= '<a href="' . wp_get_attachment_url(get_post_thumbnail_id($custom_post->ID), $cols) . '" class="hover-link pop"><i class="icon-arrows-out"></i></a>'; } $return .= apply_filters('vibe_thumb_featured_image', featured_component($custom_post->ID, $cols), $featured_style); $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } $return .= '</div>'; $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $return .= apply_filters('vibe_thumb_date', '<div class="date"><small>' . get_the_time('F d,Y') . '' . (strlen($category) > 2 ? ' / ' . $category : '') . ' / ' . get_comments_number('0', '1', '%') . ' ' . __(' Comments', 'vibe-customtypes') . '</small></div>', $featured_style); $return .= apply_filters('vibe_thumb_desc', '<p class="block_desc">' . custom_excerpt($n, $custom_post->ID) . '</p>', $featured_style); $return .= '</div>'; $return .= '</div>'; break; case 'images_only': $return .= '<div class="block">'; $return .= '<div class="block_media images_only">'; if (isset($link) && $link) { $return .= '<span class="overlay"></span>'; } if (isset($link) && $link) { $return .= '<a href="' . get_permalink($custom_post->ID) . '" class="hover-link hyperlink"><i class="icon-hyperlink"></i></a>'; } if (isset($zoom) && has_post_thumbnail($custom_post->ID) && $zoom) { $return .= '<a href="' . wp_get_attachment_url(get_post_thumbnail_id($custom_post->ID), $cols) . '" class="hover-link pop"><i class="icon-arrows-out"></i></a>'; } $return .= apply_filters('vibe_thumb_featured_image', featured_component($custom_post->ID, $cols), $featured_style); $return .= '</div>'; $return .= '</div>'; break; case 'testimonial': $return .= '<div class="block testimonials">'; $author = getPostMeta($custom_post->ID, 'vibe_testimonial_author_name'); $designation = getPostMeta($custom_post->ID, 'vibe_testimonial_author_designation'); if (has_post_thumbnail($custom_post->ID)) { $image = get_the_post_thumbnail($custom_post->ID, 'full'); } else { $image = get_avatar('*****@*****.**', 96); } $return .= '<div class="testimonial_item style2 clearfix"> <div class="testimonial-content"> <p>' . custom_excerpt($n, $custom_post->ID) . ($n < strlen($custom_post->post_content) ? $read_more : '') . '</p> <div class="author"> ' . $image . ' <h4>' . html_entity_decode($author) . '</h4> <small>' . html_entity_decode($designation) . '</small> </div> </div> </div>'; $return .= '</div>'; break; case 'blogpost': $return .= '<div class="block blogpost">'; $return .= '<div class="blog-item"> ' . apply_filters('vibe_thumb_date', '<div class="blog-item-date"> <span class="day">' . get_the_time('d') . '</span> <p class="month">' . get_the_time('M') . '\'' . get_the_time('y') . '</p> </div>', $featured_style) . ' ' . apply_filters('vibe_thumb_heading', '<h4><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style) . ' <p>' . apply_filters('vibe_thumb_desc', custom_excerpt($n, $custom_post->ID), $featured_style) . '</p> </div>'; $return .= '</div>'; break; case 'event_card': $return .= '<div class="event_card">'; $icon_class = get_post_meta($custom_post->ID, 'vibe_icon', true); $color = get_post_meta($custom_post->ID, 'vibe_color', true); $start_date = get_post_meta($custom_post->ID, 'vibe_start_date', true); $end_date = get_post_meta($custom_post->ID, 'vibe_end_date', true); $start_time = get_post_meta($custom_post->ID, 'vibe_start_time', true); $end_time = get_post_meta($custom_post->ID, 'vibe_end_time', true); $show_location = get_post_meta($custom_post->ID, 'vibe_show_location', true); $all_day = get_post_meta($custom_post->ID, 'vibe_all_day', true); $location = vibe_sanitize(get_post_meta($custom_post->ID, 'vibe_location', false)); $repeatable = get_post_meta($custom_post->ID, 'vibe_repeatable', true); $repeat_value = get_post_meta($custom_post->ID, 'vibe_repeat_value', true); $repeat_unit = get_post_meta($custom_post->ID, 'vibe_repeat_unit', true); $repeat_count = get_post_meta($custom_post->ID, 'vibe_repeat_count', true); $return .= ' <span class="event_icon" style="color:' . $color . '"><i class="' . $icon_class . '"></i></span> <h4 style="background:' . $color . '"><i class="' . $icon_class . '"></i> ' . __('Event ', 'vibe-customtypes') . '</label><span><a href="' . get_permalink($custom_post->ID) . '">' . get_the_title($custom_post->ID) . '</a></span></h4> <ul> '; if (isset($start_date) && $start_date != '') { $return .= '<li><label><i class="icon-calendar"></i> ' . __('Start Date ', 'vibe-customtypes') . '</label><span>' . date('F j Y', strtotime($start_date)) . '</span></li>'; } if (isset($end_date) && $end_date != '') { $return .= '<li><label><i class="icon-calendar"></i> ' . __('End Date ', 'vibe-customtypes') . '</label><span>' . date('F j Y', strtotime($end_date)) . '</span>'; } if (isset($start_time) && $start_time != '') { $return .= '<li><label><i class="icon-clock"></i> ' . __('Start Time ', 'vibe-customtypes') . '</label><span>' . $start_time . '</span>'; } if (isset($end_time) && $end_time != '') { $return .= '<li><label><i class="icon-clock"></i> ' . __('End Time ', 'vibe-customtypes') . '</label><span>' . $end_time . '</span>'; } if (vibe_validate($all_day)) { $return .= '<li><label><i class="icon-circle-full"></i> ' . __('All Day ', 'vibe-customtypes') . '</label><span>' . __('Yes', 'vibe-customtypes') . '</span>'; } if (vibe_validate($repeatable)) { $return .= '<li><label><i class="icon-flash"></i> ' . __('Frequency ', 'vibe-customtypes') . '</label><span>' . __('Every ', 'vibe-customtypes') . (isset($repeat_value) && $repeat_value > 1 ? $repeat_value : '') . ' ' . $repeat_unit . ' ' . __('for ', 'vibe-customtypes') . $repeat_count . ' ' . $repeat_unit . '</span>'; } if (vibe_validate($show_location)) { $return .= '<li><label><i class="icon-pin-alt"></i> ' . __('Venue ', 'vibe-customtypes') . '</label><span>' . (isset($location['staddress']) ? $location['staddress'] : '') . (isset($location['city']) ? ', ' . $location['city'] : '') . (isset($location['state']) ? ', ' . $location['state'] : '') . (isset($location['country']) ? ', ' . $location['country'] : '') . (isset($location['pincode']) ? ' - ' . $location['pincode'] : '') . '</span>'; } $return .= '</ul> <a href="' . get_permalink($custom_post->ID) . '" class="event_full_details tip" title="' . __('View full details', 'vibe-customtypes') . '" style="background:' . $color . '"><i class="icon-plus-1"></i></a> </div>'; break; default: $return .= '<div class="block">'; $return .= '<div class="block_media">'; if (isset($link) && $link) { $return .= '<a href="' . get_permalink($custom_post->ID) . '" class="hover-link hyperlink"><i class="icon-hyperlink"></i></a>'; } $featured = getPostMeta($custom_post->ID, 'vibe_select_featured'); if (isset($zoom) && $zoom && has_post_thumbnail($custom_post->ID)) { $return .= '<a href="' . wp_get_attachment_url(get_post_thumbnail_id($custom_post->ID), $cols) . '" class="hover-link pop"><i class="icon-arrows-out"></i></a>'; } $return .= featured_component($custom_post->ID, $cols); $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } $return .= '</div>'; $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } if (get_post_type($custom_post->ID) == 'portfolio') { $cats = get_the_category(); if (is_array($cats)) { $category .= '<div class="categories">'; if (!is_wp_error(get_the_term_list($custom_post->ID, 'portfolio-type', ' ', ' ', ''))) { $category .= get_the_term_list($custom_post->ID, 'portfolio-type', ' ', ' ', ''); } $category .= '</div>'; } } $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $return .= apply_filters('vibe_thumb_date', '<div class="date"><small>' . get_the_time('F d,Y') . '' . (strlen($category) > 2 ? ' / ' . $category : '') . ' / ' . get_comments_number('0', '1', '%') . ' ' . __('Comments', 'vibe-customtypes') . '</small></div>', $featured_style); $return .= apply_filters('vibe_thumb_desc', '<p class="block_desc">' . custom_excerpt($n, $custom_post->ID) . '</p>', $featured_style); $return .= '</div>'; $return .= '</div>'; break; } if ($cache_duration) { wp_cache_set($course_key, $result, 'featured_block', $cache_duration); } } //end If return apply_filters('vibe_featured_thumbnail_style', $return, $custom_post, $featured_style); }
<a id="add_course_section" data-help-tag="14" class="button primary small"><?php _e('ADD SECTION', 'vibe'); ?> </a> <a id="add_course_unit" data-help-tag="15" class="button primary small"><?php _e('ADD UNIT', 'vibe'); ?> </a> <a id="add_course_quiz" data-help-tag="15" class="button primary small"><?php _e('ADD QUIZ', 'vibe'); ?> </a> <ul class="curriculum"> <?php if (isset($_GET['action'])) { $curriculum = vibe_sanitize(get_post_meta($_GET['action'], 'vibe_course_curriculum', false)); if (isset($curriculum) && is_array($curriculum)) { foreach ($curriculum as $kid) { if (is_numeric($kid)) { if (get_post_type($kid) == 'unit') { echo '<li><h3 class="title" data-id="' . $kid . '"><i class="icon-file"></i> ' . get_the_title($kid) . '</h3> <div class="btn-group"> <button type="button" class="btn btn-course dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button> <ul class="dropdown-menu" role="menu"> <li><a href="' . get_permalink($kid) . 'edit/?id=' . $_GET['action'] . '" target="_blank" class="edit_unit">' . __('Edit Unit', 'vibe') . '</a></li> <li><a href="' . get_permalink($kid) . '?id=' . $_GET['action'] . '" target="_blank">' . __('Preview', 'vibe') . '</a></li> <li><a class="remove">' . __('Remove', 'vibe') . '</a></li> <li><a class="delete">' . __('Delete', 'vibe') . '</a></li> </ul> </div> </li>';
/** * Gets allowed file types extensions * * @return array */ public function getAllowedFileExtensions() { $return = array(); $pluginFileTypes = $this->getMimeTypes(); if (!function_exists('vibe_sanitize')) { return; } global $post; if (isset($_POST['comment_post_ID'])) { $assignment_id = $_POST['comment_post_ID']; } if (empty($assignment_id)) { $assignment_id = $post->ID; } $attachment_type = vibe_sanitize(get_post_meta($assignment_id, 'vibe_attachment_type', false)); if (is_array($attachment_type) && in_array('JPG', $attachment_type)) { $attachment_type[] = 'JPEG'; } return $attachment_type; }
function show_assignments_in_units($html, $mins, $unit_id) { $assignments = vibe_sanitize(get_post_meta($unit_id, 'vibe_assignment', false)); if (isset($assignments) && is_array($assignments) && count($assignments)) { foreach ($assignments as $assignment) { $html .= '<small><strong>' . __('Assignment :', 'vibe-customtypes') . '</strong>' . get_the_title($assignment) . '</small>'; } } return $html; }
function bp_get_course_check_course_complete($args = NULL) { // AUTO EVALUATION FOR COURSE global $post; $defaults = array('id' => $post->ID, 'user_id' => get_current_user_id()); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); $return = '<div class="course_finish">'; $course_curriculum = bp_course_get_curriculum_units($id); //vibe_sanitize(get_post_meta($id,'vibe_course_curriculum',false)); if (isset($course_curriculum) && count($course_curriculum)) { $flag = 0; foreach ($course_curriculum as $unit_id) { //if(is_numeric($unit_id)){ $unittaken = get_user_meta($user_id, $unit_id, true); if (!isset($unittaken) || !$unittaken) { $flag = $unit_id; break; } //} } $flag = apply_filters('wplms_finish_course_check', $flag, $course_curriculum); if (!$flag) { $course_id = $id; $auto_eval = get_post_meta($id, 'vibe_course_auto_eval', true); if (vibe_validate($auto_eval)) { // AUTO EVALUATION $curriculum = bp_course_get_curriculum_units($id); //vibe_sanitize(get_post_meta($id,'vibe_course_curriculum',false)); $total_marks = $student_marks = 0; foreach ($curriculum as $c) { if (is_numeric($c)) { if (get_post_type($c) == 'quiz') { $k = get_post_meta($c, $user_id, true); $student_marks += $k; //Current user is the Student here $questions = vibe_sanitize(get_post_meta($c, 'quiz_questions' . $user_id, false)); if (!isset($questions) || !is_array($questions)) { $questions = vibe_sanitize(get_post_meta($c, 'vibe_quiz_questions', false)); } $total_marks += array_sum($questions['marks']); } } } do_action('wplms_submit_course', $post->ID, $user_id); // Apply Filters on Auto Evaluation $student_marks = apply_filters('wplms_course_student_marks', $student_marks, $id, $user_id); $total_marks = apply_filters('wplms_course_maximum_marks', $total_marks, $id, $user_id); if (!$total_marks) { $total_marks = $student_marks = 1; } // Avoid the Division by Zero Error $marks = round($student_marks * 100 / $total_marks); $return .= '<div class="message" class="updated"><p>' . __('COURSE EVALUATED ', 'vibe') . '</p></div>'; $badge_per = get_post_meta($id, 'vibe_course_badge_percentage', true); $passing_cert = get_post_meta($id, 'vibe_course_certificate', true); // Certificate Enable $passing_per = get_post_meta($id, 'vibe_course_passing_percentage', true); // Certificate Passing Percentage //finish bit for student 1.8.4 update_user_meta($user_id, 'course_status' . $id, 3); //end finish bit do_action('wplms_evaluate_course', $id, $marks, $user_id, 1); $badge_filter = 0; if (isset($badge_per) && $badge_per && $marks >= $badge_per) { $badge_filter = 1; } $badge_filter = apply_filters('wplms_course_student_badge_check', $badge_filter, $course_id, $user_id, $marks, $badge_per); if ($badge_filter) { $badges = array(); $badges = vibe_sanitize(get_user_meta($user_id, 'badges', false)); if (isset($badges) && is_array($badges)) { $badges[] = $id; } else { $badges = array($id); } update_user_meta($user_id, 'badges', $badges); $b = bp_get_course_badge($id); $badge = wp_get_attachment_info($b); $badge_url = wp_get_attachment_image_src($b); if (isset($badge) && is_numeric($b)) { $return .= '<div class="congrats_badge">' . __('Congratulations ! You\'ve earned the ', 'vibe') . ' <strong>' . get_post_meta($id, 'vibe_course_badge_title', true) . '</strong> ' . __('Badge', 'vibe') . '<a class="tip ajax-badge" data-course="' . get_the_title($id) . '" title="' . get_post_meta($id, 'vibe_course_badge_title', true) . '"><img src="' . $badge_url[0] . '" title="' . $badge['title'] . '"/></a></div>'; } do_action('wplms_badge_earned', $id, $badges, $user_id, $badge_filter); } $passing_filter = 0; if (vibe_validate($passing_cert) && isset($passing_per) && $passing_per && $marks >= $passing_per) { $passing_filter = 1; } $passing_filter = apply_filters('wplms_course_student_certificate_check', $passing_filter, $course_id, $user_id, $marks, $passing_per); if ($passing_filter) { $pass = array(); $pass = vibe_sanitize(get_user_meta($user_id, 'certificates', false)); if (isset($pass) && is_array($pass)) { $pass[] = $id; } else { $pass = array($id); } update_user_meta($user_id, 'certificates', $pass); $return .= '<div class="congrats_certificate">' . __('Congratulations ! You\'ve successfully passed the course and earned the Course Completion Certificate !', 'vibe') . '<a href="' . bp_get_course_certificate('user_id=' . $user_id . '&course_id=' . $id) . '" class="ajax-certificate right"><span>' . __('View Certificate', 'vibe') . '</span></a></div>'; do_action('wplms_certificate_earned', $id, $pass, $user_id, $passing_filter); } update_post_meta($id, $user_id, $marks); $course_end_status = apply_filters('wplms_course_status', 4); update_user_meta($user_id, 'course_status' . $id, $course_end_status); //EXCEPTION $message = sprintf(__('You\'ve obtained %s in course %s ', 'vibe'), apply_filters('wplms_course_marks', $marks . '/100'), ' <a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a>'); $return .= '<div class="congrats_message">' . $message . '</div>'; } else { $return .= '<div class="message" class="updated"><p>' . __('COURSE SUBMITTED FOR EVALUATION', 'vibe') . '</p></div>'; bp_course_update_user_course_status($user_id, $id, 2); // 2 determines Course is Complete do_action('wplms_submit_course', $post->ID, $user_id); } // Show the Generic Course Submission $content = get_post_meta($id, 'vibe_course_message', true); $return .= apply_filters('the_content', $content); $return = apply_filters('wplms_course_finished', $return); } else { $type = get_post_type($flag); switch ($type) { case 'unit': $type = __('UNIT', 'vibe'); break; case 'assignment': $type = __('ASSIGNMENT', 'vibe'); break; case 'quiz': $type = __('QUIZ', 'vibe'); break; } //Default for other customized options $message = __('PLEASE COMPLETE THE ', 'vibe') . $type . ' : ' . get_the_title($flag); $return .= '<div class="message"><p>' . apply_filters('wplms_unfinished_unit_quiz_message', $message, $flag) . '</p></div>'; } } else { $retun .= __('COURSE CURRICULUM NOT SET', 'vibe'); } $return .= '</div>'; return $return; }
function wplms_get_course_unfinished_unit_sau($course_id) { $user_id = get_current_user_id(); if (isset($_COOKIE['course'])) { $coursetaken = 1; } else { $coursetaken = get_user_meta($user_id, $course_id, true); } $course_curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false)); $key = 0; $uid = ''; if (isset($coursetaken) && $coursetaken) { if (isset($course_curriculum) && is_array($course_curriculum) && count($course_curriculum)) { foreach ($course_curriculum as $uid) { if (is_numeric($uid)) { $units[$key] = $uid; $unittaken = get_user_meta($user_id, $uid, true); if (!isset($unittaken) || !$unittaken) { break; } $key++; } } } else { echo '<div class="error"><p>' . __('Course Curriculum Not Set', 'vibe') . '</p></div>'; return; } } $flag = apply_filters('wplms_next_unit_access', true, $units[$key - 1]); $drip_enable = get_post_meta($course_id, 'vibe_course_drip', true); $drip_duration_parameter = apply_filters('vibe_drip_duration_parameter', 86400); if (vibe_validate($drip_enable)) { $drip_duration = get_post_meta($course_id, 'vibe_course_drip_duration', true); if ($key > 0) { $pre_unit_time = get_post_meta($units[$key - 1], $user_id, true); if (isset($pre_unit_time) && $pre_unit_time) { $value = $pre_unit_time + $key * $drip_duration * $drip_duration_parameter; $value = apply_filters('wplms_drip_value', $value, $units[$key - 1], $course_id, $units[$unitkey]); if ($value > time()) { $flag = 0; } } else { $flag = 0; } } } if (isset($uid) && $flag && $key) { // Should Always be set $unit_id = $uid; // Last un finished unit } else { if (isset($key) && $key > 0) { $unit_id = $units[$key - 1]; } else { $unit_id = $units[0]; } } return $unit_id; }
<?php $items = $order->get_items(); foreach ($items as $item) { $product_name = $item['name']; $product_id = $item['product_id']; $subs = ''; $subscribed = get_post_meta($product_id, 'vibe_subscription', true); if (vibe_validate($subscribed)) { $duration = get_post_meta($product_id, 'vibe_duration', true); $product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400); $date = tofriendlytime($duration * $product_duration_parameter); $subs = '<strong>' . __('COURSE SUBSCRIBED FOR ', 'vibe') . ' : <span>' . $date . '</span></strong>'; } else { $subs = '<strong>' . __('SUSBSCRIBED FOR FULL COURSE', 'vibe') . '</strong>'; } $vcourses = vibe_sanitize(get_post_meta($product_id, 'vibe_courses', false)); if (count($vcourses)) { echo '<h3 class="heading">' . __('Courses Subscribed', 'vibe') . '</h3> <ul class="order_details"> <li><a>' . __('COURSE', 'vibe') . '</a> <strong>' . __('SUBSCRIPTION', 'vibe') . '</strong></li>'; if ($order->status == 'completed' || $order->status == 'complete') { $ostatus = __('START COURSE', 'vibe'); } else { if ($order->status == 'pending') { do_action('wplms_force_woocommerce_order_complete', $order); $ostatus = __('WAITING FOR ORDER CONFIRMATION TO START COURSE', 'vibe'); } else { $ostatus = __('WAITING FOR ADMIN APPROVAL', 'vibe'); } }
function widget($args, $instance) { extract($args); global $wpdb; $user_id = get_current_user_id(); //Our variables from the widget settings. $title = apply_filters('widget_title', $instance['title']); $width = $instance['width']; $user_id = get_current_user_id(); echo '<div class="' . $width . '"> <div class="dash-widget">' . $before_widget; if ($title) { echo $before_title . $title . $after_title; } $commision_array = vibe_sanitize(get_user_meta($user_id, 'commission_data', false)); $commission_recieved = vibe_sanitize(get_user_meta($user_id, 'commission_recieved', false)); $sales_pie = vibe_sanitize(get_user_meta($user_id, 'sales_pie', false)); $total_commission = get_user_meta($user_id, 'total_commission', true); $symbol = get_woocommerce_currency_symbol(); if (!isset($symbol)) { $symbol = '$'; } $value = $symbol . $total_commission; echo '<a class="commission_reload"><i class="icon-reload"></i></a>'; echo '<div id="instructor_commissions" class="morris"></div>'; echo '<div class="row"> <div class="col-md-6"> <label class="sales_labels">' . __('Course', 'wplms-dashboard') . '<strong>' . __('Earnings', 'wplms-dashboard') . ' (' . $symbol . ')</strong></label> <div class="course_list">'; $sales_pie_array = array(); if (isset($sales_pie) && is_array($sales_pie) && count($sales_pie)) { echo '<ul class="course_sales_list">'; foreach ($sales_pie as $cid => $sales) { if ($cid == 'commission') { echo '<li>' . __('Commissions Paid', 'wplms-dashboard') . '<strong>' . $sales . '</strong></li>'; } $ctitle = get_the_title($cid); echo '<li>' . $ctitle . '<strong>' . $sales . '</strong></li>'; $sales_pie_array[] = array('label' => $ctitle, 'value' => $sales); } echo '</ul>'; } else { echo '<div class="message"><p>' . __('No data found', 'wplms-dashboard') . '</p></div>'; } echo '</div></div><div class="col-md-6"> <div id="commission_breakup" class="morris"></div> </div></div>'; echo '</div>'; echo $after_widget . ' </div>'; if (isset($commision_array) && is_array($commision_array)) { foreach ($commision_array as $key => $commission) { if (isset($commission_recieved[$key])) { $commision_array[$key]['commission'] = $commission_recieved[$key]['commission']; } else { $commision_array[$key]['commission'] = 0; } } } echo '<script> var instructor_commission_data=['; $first = 0; if (isset($commision_array) && is_array($commision_array)) { foreach ($commision_array as $data) { if ($first) { echo ','; } $first = 1; echo str_replace('"', '\'', json_encode($data, JSON_NUMERIC_CHECK)); } } echo ']; var commission_breakup =['; $first = 0; if (isset($sales_pie_array) && is_Array($sales_pie_array)) { foreach ($sales_pie_array as $data) { if ($first) { echo ','; } $first = 1; echo str_replace('"', '\'', json_encode($data, JSON_NUMERIC_CHECK)); } } echo ']; </script>'; }
function wplms_front_end_assignment_settings($assignment_settings) { $id = get_the_ID(); if (is_array($assignment_settings)) { foreach ($assignment_settings as $key => $settings) { if ($key == 'vibe_attachment_type') { $val = get_post_meta($id, $key, false); if (isset($val) && is_array($val)) { $assignment_settings[$key] = vibe_sanitize($val); } } else { $val = get_post_meta($id, $key, true); if (isset($val) && $val) { $assignment_settings[$key] = $val; } } } } return $assignment_settings; }
<?php global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $pmpro_currency_symbol; if (is_user_logged_in()) { $course_id = url_to_postid($_SERVER['HTTP_REFERER']); if (is_numeric($course_id) && $course_id) { $membership_levels = vibe_sanitize(get_post_meta($course_id, 'vibe_pmpro_membership', false)); if (isset($current_user->membership_level->ID) && is_array($membership_levels)) { if (in_array($current_user->membership_level->ID, $membership_levels)) { $course_duration = get_post_meta($course_id, 'vibe_duration', true); $course_duration_parameter = apply_filters('vibe_course_duration_parameter', 86400); $course_duration = time() + $course_duration * $course_duration_parameter; $user_id = get_current_user_id(); update_user_meta($user_id, $course_id, $course_duration); echo '<p class="message success">' . __('Course Renewed', 'vibe') . ' <a href="' . get_permalink($course_id) . '" class="link right">' . __('Back to course', 'vibe') . '</a></p>'; } } } } ?> <div class="pmpro_content"> <?php if ($pmpro_msg) { ?> <div class="pmpro_message <?php echo $pmpro_msgt; ?> "><?php echo $pmpro_msg; ?> </div>
get_header('buddypress'); do_action('wplms_start_course'); $user_id = get_current_user_id(); if (isset($_POST['course_id'])) { $course_id = $_POST['course_id']; $coursetaken = get_user_meta($user_id, $course_id, true); } else { if (isset($_COOKIE['course'])) { $course_id = $_COOKIE['course']; $coursetaken = 1; } } if (!isset($course_id) || !is_numeric($course_id)) { wp_die(__('INCORRECT COURSE VALUE. CONTACT ADMIN', 'vibe')); } $course_curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false)); $unit_id = wplms_get_course_unfinished_unit_sau($course_id); $unit_comments = vibe_get_option('unit_comments'); if (have_posts()) { while (have_posts()) { the_post(); ?> <section id="content"> <!--Khải edit--> <div class="menu-unit"> <div class="row"> <div class="col-md-6 name-course"> <?php echo get_the_title($course_id); ?>
public function get_modules($id, $post_type, $module, $data, $reviews, $user_data) { $prefix = 'vibe_'; switch ($post_type) { case 'course': $curriculum = vibe_sanitize(get_post_meta($id, $prefix . 'course_curriculum', false)); foreach ($curriculum as $unit) { if (is_numeric($unit)) { $this->get_module_data($unit, 'unit'); $this->get_connected_data($unit, 'unit'); } } if ($reviews) { foreach ($curriculum as $unit) { if (is_numeric($unit)) { $this->get_comments($unit); } } } if ($user_data) { foreach ($curriculum as $unit) { if (is_numeric($unit)) { $this->get_user_data($unit); } } } if ($module) { foreach ($curriculum as $unit) { if (is_numeric($unit)) { $post_type = get_post_type($unit); $this->get_modules($unit, $post_type, $module, $data, $reviews, $user_data); } } } break; case 'quiz': $quiz_questions = vibe_sanitize(get_post_meta($id, $prefix . 'quiz_questions', false)); if (is_array($quiz_questions['ques'])) { foreach ($quiz_questions['ques'] as $ques) { if (is_numeric($ques)) { $this->get_module_data($ques); $this->get_connected_data($ques, 'question'); } } if ($reviews) { foreach ($quiz_questions['ques'] as $ques) { if (is_numeric($ques)) { $this->get_comments($ques); } } } if ($user_data) { foreach ($quiz_questions['ques'] as $ques) { if (is_numeric($ques)) { $this->get_user_data($ques); } } } } break; case 'unit': $assignments = vibe_sanitize(get_post_meta($id, $prefix . 'assignment', false)); if (is_array($assignments)) { foreach ($assignments as $assignment) { if (is_numeric($assignment)) { $this->get_module_data($assignment); $this->get_connected_data($assignment, 'wplms-assignment'); } } if ($reviews) { foreach ($assignments as $assignment) { if (is_numeric($assignment)) { $this->get_comments($assignment); } } } if ($user_data) { foreach ($assignments as $assignment) { if (is_numeric($assignment)) { $this->get_user_data($assignment); } } } } break; } }
/** * Gets allowed file types extensions * * @return array */ public function getAllowedFileExtensions() { $return = array(); $pluginFileTypes = $this->getMimeTypes(); global $post; if (!function_exists('vibe_sanitize')) { return; } $attachment_type = vibe_sanitize(get_post_meta($post->ID, 'vibe_attachment_type', false)); if (in_array('JPG', $attachment_type)) { $attachment_type[] = 'JPEG'; } return $attachment_type; }
function show_profile_snapshot() { global $bp; $user_id = bp_displayed_user_id(); $bids = vibe_sanitize(get_user_meta($user_id, 'badges', false)); if (isset($bids) && is_Array($bids) && count($bids)) { echo '<div class="badges"><h6>' . __('Badges', 'vibe') . '</h6>'; echo '<ul>'; foreach ($bids as $bid) { $b = bp_get_course_badge($bid); $badge = wp_get_attachment_info($b); $badge_url = wp_get_attachment_image_src($b); if (isset($badge) && is_numeric($b)) { echo '<li><a class="tip ajax-badge" data-course="' . get_the_title($bid) . '" title="' . get_post_meta($bid, 'vibe_course_badge_title', true) . '"> <img src="' . $badge_url[0] . '" title="' . $badge['title'] . '"/></a> </li>'; } } echo '</ul>'; echo '</div>'; } $certis = vibe_sanitize(get_user_meta($user_id, 'certificates', false)); if (isset($certis) && is_Array($certis) && count($certis)) { echo '<div class="certifications"><h6>' . __('Certifications', 'vibe') . '</h6><ul class="slides">'; if (isset($certis) && is_Array($certis)) { foreach ($certis as $certi) { echo '<li><a href="' . bp_get_course_certificate('user_id=' . $user_id . '&course_id=' . $certi) . '" class="ajax-certificate"><i class="icon-certificate-file"></i><span>' . get_the_title($certi) . '</span></a></li>'; } } echo '</ul></div>'; } if (user_can($user_id, 'edit_posts')) { $instructing_courses = apply_filters('wplms_instructing_courses_endpoint', 'instructing-courses'); echo '<div class="instructor_line"> <h3><a href="' . get_author_posts_url($user_id) . $instructing_courses . '/">' . __('Check all Courses created by ', 'vibe') . bp_core_get_user_displayname($user_id) . ' <i class="icon-plus-1"></i></a></h3> </div>'; } }
function vibe_question($atts, $content = null) { extract(shortcode_atts(array('id' => ''), $atts)); if (!is_numeric($id) || get_post_type($id) != 'question') { return ''; } $question = get_post($id); $hint = get_post_meta($id, 'vibe_question_hint', true); $type = get_post_meta($id, 'vibe_question_type', true); $return = '<div class="question ' . $type . '">'; $return .= '<div class="question_content">' . apply_filters('the_content', $question->post_content); if (isset($hint) && strlen($hint) > 5) { $return .= '<a class="show_hint tip" tip="' . __('SHOW HINT', 'vibe-shortcodes') . '"><span></span></a>'; $return .= '<div class="hint"><i>' . __('HINT', 'vibe-shortcodes') . ' : ' . apply_filters('the_content', $hint) . '</i></div>'; } $return .= '</div>'; switch ($type) { case 'truefalse': case 'single': case 'multiple': case 'sort': case 'match': $options = vibe_sanitize(get_post_meta($id, 'vibe_question_options', false)); if ($type == 'truefalse') { $options = array(0 => __('FALSE', 'vibe-shortcodes'), 1 => __('TRUE', 'vibe-shortcodes')); } if (isset($options) || $options) { $return .= '<ul class="question_options ' . $type . '">'; if ($type == 'single') { foreach ($options as $key => $value) { $return .= '<li> <input type="radio" id="' . $question->post_name . $key . '" class="ques' . $id . '" name="' . $id . '" value="' . ($key + 1) . '" /> <label for="' . $question->post_name . $key . '"><span></span> ' . do_shortcode($value) . '</label> </li>'; } } else { if ($type == 'sort') { foreach ($options as $key => $value) { $return .= '<li id="' . ($key + 1) . '" class="ques' . $question->ID . ' sort_option"> <label for="' . $question->post_name . $key . '"><span></span> ' . do_shortcode($value) . '</label> </li>'; } } else { if ($type == 'match') { foreach ($options as $key => $value) { $return .= '<li id="' . ($key + 1) . '" class="ques' . $question->ID . ' match_option"> <label for="' . $question->post_name . $key . '"><span></span> ' . do_shortcode($value) . '</label> </li>'; } } else { if ($type == 'truefalse') { foreach ($options as $key => $value) { $return .= '<li> <input type="radio" id="' . $question->post_name . $key . '" class="ques' . $question->ID . '" name="' . $question->ID . '" value="' . $key . '" /> <label for="' . $question->post_name . $key . '"><span></span> ' . $value . '</label> </li>'; } } else { foreach ($options as $key => $value) { $return .= '<li> <input type="checkbox" class="ques' . $question->ID . '" id="' . $question->post_name . $key . '" name="' . $question->ID . $key . '" value="' . ($key + 1) . '" /> <label for="' . $question->post_name . $key . '"><span></span> ' . do_shortcode($value) . '</label> </li>'; } } } } } $return .= '</ul>'; } break; // End Options // End Options case 'fillblank': break; case 'select': break; case 'smalltext': $return .= '<input type="text" name="' . $k . '" class="ques' . $k . ' form_field" value="" placeholder="' . __('Type Answer', 'vibe-shortcodes') . '" />'; break; case 'largetext': $return .= '<textarea name="' . $k . '" class="ques' . $k . ' form_field" placeholder="' . __('Type Answer', 'vibe-shortcodes') . '"></textarea>'; break; } $return .= '<ul class="check_options">'; $answer = get_post_meta($id, 'vibe_question_answer', true); if (isset($answer) && strlen($answer) && in_array($type, array('single', 'multiple', 'truefalse', 'sort', 'match'))) { $return .= '<li><a class="check_answer" data-id="' . $id . '">' . __('Check Answer', 'vibe-shortcodes') . '</a></li>'; $ans_json = array('type' => $type); if (in_array($type, array('multiple'))) { $ans_array = explode(',', $answer); $ans_json['answer'] = $ans_array; } else { $ans_json['answer'] = $answer; } echo '<script> var ans_json' . $id . '= ' . json_encode($ans_json) . '; </script>'; } $explaination = get_post_meta($id, 'vibe_question_explaination', true); if (isset($explaination) && strlen($explaination) > 2) { $return .= '<li><a href="#question_explaination' . $id . '" class="open_popup_link">' . __('Explanation', 'vibe-shortcodes') . '</a></li>'; echo '<div id="question_explaination' . $id . '" class="white-popup mfp-hide"> ' . do_shortcode($explaination) . ' </div>'; } $return .= '</ul></div>'; return $return; }
function wplms_dynamic_quiz_select_questions($quiz_id = NULL) { $user_id = get_current_user_id(); if (!is_numeric($user_id)) { return; } if (!isset($quiz_id)) { global $post; $quiz_id = $post->ID; } $quiz_created = get_post_meta($quiz_id, 'quiz_questions' . $user_id, false); if (isset($quiz_created) && $quiz_created && is_array($quiz_created)) { return; } $quiz_dynamic = get_post_meta($quiz_id, 'vibe_quiz_dynamic', true); $quiz_questions = array('ques' => array(), 'marks' => array()); if (vibe_validate($quiz_dynamic)) { $tags = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_tags', false)); $number = get_post_meta($quiz_id, 'vibe_quiz_number_questions', true); if (!isset($number) || !is_numeric($number)) { $number = 0; } $marks = get_post_meta($quiz_id, 'vibe_quiz_marks_per_question', true); $args = array('post_type' => 'question', 'orderby' => 'rand', 'posts_per_page' => $number, 'tax_query' => array(array('taxonomy' => 'question-tag', 'field' => 'id', 'terms' => $tags))); $the_query = new WP_Query($args); while ($the_query->have_posts()) { $the_query->the_post(); $quiz_questions['ques'][] = get_the_ID(); $quiz_questions['marks'][] = $marks; } wp_reset_postdata(); } else { $quiz_questions = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_questions', false)); $randomize = get_post_meta($quiz_id, 'vibe_quiz_random', true); if (isset($randomize) && $randomize != 'H') { if (isset($quiz_questions['ques']) && is_array($quiz_questions['ques']) && count($quiz_questions['ques']) > 1) { $randomized_keys = array_rand($quiz_questions['ques'], count($quiz_questions['ques'])); shuffle($randomized_keys); foreach ($randomized_keys as $current_key) { $rand_quiz_questions['ques'][] = $quiz_questions['ques'][$current_key]; $rand_quiz_questions['marks'][] = $quiz_questions['marks'][$current_key]; } } $quiz_questions = $rand_quiz_questions; } } add_post_meta($quiz_id, 'quiz_questions' . $user_id, $quiz_questions); }
function bp_course_instructor_controls() { global $bp, $wpdb; $user_id = $bp->loggedin_user->id; $course_id = get_the_ID(); $curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false)); $course_quizes = array(); if (isset($curriculum)) { foreach ($curriculum as $c) { if (is_numeric($c)) { if (get_post_type($c) == 'quiz') { $course_quizes[] = $c; } } } } echo '<ul class="instructor_action_buttons">'; $course_query = $wpdb->get_results($wpdb->prepare("SELECT COUNT(meta_key) as num FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_value = %d", $course_id, 2)); $num = 0; if (isset($course_query) && $course_query != '') { $num = $course_query[0]->num; } else { $num = 0; } echo '<li><a href="' . get_permalink($course_id) . '/?action=admin&submissions" class="action_icon tip" title="' . __('Evaluate course submissions', 'vibe') . '"><i class="icon-task"></i><span>' . $num . '</span></a></li>'; if (isset($course_quizes) && count($course_quizes)) { if (count($course_quizes) > 1) { $quiz_ids = join(',', $course_quizes); $query = $wpdb->get_results($wpdb->prepare("SELECT COUNT(meta_key) as num FROM {$wpdb->postmeta} WHERE post_id IN {$quiz_ids} AND meta_value = %d", 0)); } else { $query = $wpdb->get_results($wpdb->prepare("SELECT COUNT(meta_key) as num FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_value = %d", $course_quizes, 0)); } if (isset($query) && $query != '') { $num = intval($query[0]->num); } else { $num = 0; } echo '<li><a href="' . get_permalink($course_id) . '/?action=admin&submissions" class="action_icon tip" title="' . __('Evaluate Quiz submissions', 'vibe') . '"><i class="icon-check-clipboard-1"></i><span>' . $num . '</span></a></li>'; } $n = get_post_meta($course_id, 'vibe_students', true); if (isset($n) && $n != '') { $num = $n; } else { $num = 0; } echo '<li><a href="' . get_permalink($course_id) . '/?action=admin&members" class="action_icon tip" title="' . __('Manage Students', 'vibe') . '"><i class="icon-users"></i><span>' . $num . '</span></a></li>'; echo '<li><a href="' . get_permalink($course_id) . '/?action=admin&stats" class="action_icon tip" title="' . __('See Stats', 'vibe') . '"><i class="icon-analytics-chart-graph"></i></a></li>'; echo '<li><a href="' . get_permalink($course_id) . '/?action=admin&activity" class="action_icon tip" title="' . __('See all Activity', 'vibe') . '"><i class="icon-atom"></i></a></li>'; echo '</ul>'; }
function section_wise_drip($value, $pre_unit_id, $course_id, $unit_id) { $curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false)); $user_id = get_current_user_id(); $drip_duration = get_post_meta($course_id, 'vibe_course_drip_duration', true); if (is_array($curriculum)) { $key = array_search($unit_id, $curriculum); if (!isset($key) || !$key) { return $value; } //GET Previous Two Sections $i = $key; while ($i >= 0) { if (!is_numeric($curriculum[$i])) { if (!isset($k2)) { $k2 = $i; } else { if (!isset($k1)) { $k1 = $i; } } } $i--; } //First section incomplete if (!isset($k2) || !isset($k1) || !$k2 || $k1 == $k2 || $k2 < $k1) { return 0; } //Get first unit in previous section for ($i = $k1; $i <= $k2; $i++) { if (is_numeric($curriculum[$i]) && get_post_type($curriculum[$i]) == 'unit') { break; } } if ($i == $k2) { return 0; // section drip feed disabled if a section has all quizzes } $start_section_timestamp = get_post_meta($curriculum[$i], $user_id, true); $drip_duration_parameter = apply_filters('vibe_drip_duration_parameter', 86400); $value = $start_section_timestamp + $drip_duration * $drip_duration_parameter; } return $value; }