?> </a> <?php } ?> </header> <?php if (!ThemexCore::checkOption('course_popularity') || !ThemexCore::checkOption('course_rating')) { ?> <footer class="course-footer clearfix"> <?php if (!ThemexCore::checkOption('course_popularity')) { ?> <div class="course-users left"> <?php echo ThemexCore::getPostMeta($post->ID, 'course_popularity', '0'); ?> </div> <?php } ?> <?php if (!ThemexCore::checkOption('course_rating')) { ?> <?php get_template_part('module', 'rating'); ?> <?php } ?> </footer>
/** * Renders metabox * * @access public * @return void */ public static function renderMetabox($post, $args) { //create nonce $out = '<input type="hidden" name="themex_nonce" value="' . wp_create_nonce($post->ID) . '" />'; $out .= '<table class="themex-metabox">'; //render metabox foreach (ThemexCore::$components['meta_boxes'] as $meta_box) { if ($meta_box['id'] == $args['args']['ID']) { foreach ($meta_box['options'] as $option) { //get option value $option['value'] = ThemexCore::getPostMeta($post->ID, $post->post_type . '_' . $option['id']); //render option if ($option['type'] == 'module') { $option['wrap'] = false; $out .= self::renderOption($option); } else { $option['id'] = '_' . $post->post_type . '_' . $option['id']; $out .= '<tr><th><h4 class="themex-meta-title">' . $option['name'] . '</h4></th><td>' . self::renderOption($option) . '</td></tr>'; } } } } $out .= '</table>'; echo $out; }
/** * Gets course certificate * * @access public * @param int $ID * @param int $user * @return array */ public static function getCertificate($ID, $user) { $certificate['content'] = ThemexCore::getPostMeta($ID, 'course_certificate_content'); $certificate['progress'] = self::getProgress($ID, $user); if (!empty($certificate['content']) && $certificate['progress'] == 100) { $username = trim(get_user_meta($user, 'first_name', true) . ' ' . get_user_meta($user, 'last_name', true)); $title = get_the_title($ID); $grade = self::getGrade($ID, $user) . '%'; $number = themex_encode($ID, $user); $time = ThemexCore::getUserRelations($user, $ID, 'certificate', true); $date = date_i18n(get_option('date_format'), $time); if ($time == 0) { $date = date_i18n(get_option('date_format')); } $keywords = array('username' => $username, 'title' => $title, 'grade' => $grade, 'number' => $number, 'date' => $date); $certificate['user'] = $user; $certificate['background'] = ThemexCore::getPostMeta($ID, 'course_certificate_background'); $certificate['content'] = wpautop(themex_keywords($certificate['content'], $keywords)); } return $certificate; }
$pause = ThemexCore::getOption('slider_pause', '0'); $speed = ThemexCore::getOption('slider_speed', '1000'); $query = new WP_Query(array('post_type' => 'slide', 'showposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); if ($query->have_posts()) { if ($type == 'boxed') { ?> <div class="row"> <div class="boxed-slider themex-slider"> <ul> <?php while ($query->have_posts()) { ?> <?php $query->the_post(); $video = ThemexCore::getPostMeta($post->ID, 'slide_video'); $link = ThemexCore::getPostMeta($post->ID, 'slide_link'); ?> <li> <?php if (!empty($video)) { ?> <div class="embedded-video"> <?php echo themex_html($video); ?> </div> <?php } else { ?> <?php if (!empty($link)) {
/** * Gets lesson attachments * * @access public * @param int $ID * @return array */ public static function getAttachments($ID) { $attachments = array_values(themex_filter(ThemexCore::getPostMeta($ID, 'lesson_attachments'))); foreach ($attachments as $index => &$attachment) { $attachment['redirect'] = ThemexCore::getURL('file', themex_encode($index, $ID)); } return $attachments; }
/** * Updates order * * @access public * @param int $ID * @return void */ public static function updateOrder($ID) { $order = get_post($ID); ThemexShop::updateBalance($order->post_author, array('order' => $ID)); $affiliate = intval(ThemexCore::getPostMeta($ID, 'affiliate')); if (!empty($affiliate) && $order->post_author != $affiliate) { ThemexShop::updateBalance($affiliate); } }
/** * Updates shop balance * * @access public * @param int $user * @param array $data * @return void */ public static function updateBalance($user, $data = array()) { $shop = ThemexUser::getShop($user); //values $revenue = 0; $profit = 0; $balance = 0; $sales = 0; //rates $rate_min = absint(ThemexCore::getOption('shop_rate_min', 50)); $rate_max = absint(ThemexCore::getOption('shop_rate_max', 70)); $rate_amount = absint(ThemexCore::getOption('shop_rate_amount', 1000)); if (isset($data['order'])) { $rate = $rate_min; if ($rate_max > $rate_min) { $rate = absint(ThemexCore::getUserMeta($user, 'rate', $rate_min)); } $rate = self::filterRate($shop, $rate); ThemexCore::updatePostMeta($data['order'], 'rate', $rate); } //orders $orders = ThemexWoo::getOrders($user, array('post_status' => 'wc-completed')); foreach ($orders as $order) { $object = wc_get_order($order); $rate = absint(ThemexCore::getPostMeta($order, 'rate', $rate_min)); $total = $object->get_total() - $object->get_total_refunded(); $amount = $total * $rate / 100; $revenue = $revenue + $total; $profit = $profit + $amount; if ($object->payment_method != 'paypal-adaptive-payments') { $balance = $balance + $amount; } $sales = $sales + $object->get_item_count(); } //referrals $rate = absint(ThemexCore::getOption('shop_rate_referral', '30')); $referrals = ThemexWoo::getReferrals($user, array('post_status' => 'wc-completed')); foreach ($referrals as $referral) { $object = wc_get_order($referral); $total = $object->get_total() - $object->get_total_refunded(); $amount = $total * $rate / 100; $profit = $profit + $amount; $balance = $balance + $amount; } //withdrawals $withdrawals = self::getWithdrawals($user, array('post_status' => array('pending', 'publish'))); foreach ($withdrawals as $withdrawal) { $amount = abs(floatval(ThemexCore::getPostMeta($withdrawal, 'amount'))); $balance = $balance - $amount; } //rate if ($rate_max > $rate_min) { $rate = absint($rate_min + $revenue / ($rate_amount / ($rate_max - $rate_min))); ThemexCore::updateUserMeta($user, 'rate', $rate); } ThemexCore::updateUserMeta($user, 'revenue', $revenue); ThemexCore::updateUserMeta($user, 'profit', $profit); ThemexCore::updateUserMeta($user, 'balance', $balance); ThemexCore::updatePostMeta($shop, 'sales', $sales); }
/** * Gets membership period * * @access public * @param int $membership * @return string */ public static function getPeriod($membership) { $price = ''; $product = intval(ThemexCore::getPostMeta($membership, 'product')); if (!empty($product)) { $period = intval(ThemexCore::getPostMeta($membership, 'period')); $price = ThemexWoo::getPeriod($product, $period); } return $price; }
/** * Renders background * * @access public * @return void */ public static function renderBackground() { global $post; $out = ''; if (ThemexCore::getOption('background_type', 'fullwidth') != 'tiled') { $background = ThemexCore::getOption('background_image', THEME_URI . 'images/bgs/site_bg.jpg'); if (is_page()) { $background = ThemexCore::getPostMeta($post->ID, 'page_background', $background); } else { if (is_singular('course')) { $background = ThemexCore::getPostMeta($post->ID, 'course_background', $background); } else { if (is_singular('lesson')) { $course = ThemexCore::getPostRelations($post->ID, 0, 'lesson_course', true); if ($course != 0) { $background = ThemexCore::getPostMeta($course, 'course_background', $background); } } } } $out = '<img src="' . $background . '" class="fullwidth" alt="" />'; } echo $out; }
/** * Updates order * * @access public * @param int $ID * @return void */ public static function updateOrder($ID) { $post = self::getPost($ID, 'membership'); if (!empty($post)) { $order = wc_get_order($ID); $status = $order->get_status(); if ($status == 'completed') { ThemexUser::addMembership($post->post_author, $post->ID, false); } else { ThemexUser::removeMembership($post->post_author); } } else { $order = get_post($ID); ThemexShop::updateBalance($order->post_author, array('order' => $ID)); $affiliate = intval(ThemexCore::getPostMeta($ID, 'affiliate')); if (!empty($affiliate) && $order->post_author != $affiliate) { ThemexShop::updateBalance($affiliate); } } }