echo ThemexCourse::$data['statistics']['user']['grade']; ?> %</span> <div class="clear"></div> </div> </div> </div> <div id="postimagediv" class="postbox"> <h3 class="normal"><?php _e('Options', 'academy'); ?> </h3> <div class="inside noborder"> <div class="misc-pub-section"> <form action="<?php echo themex_url(); ?> " method="GET" target="_blank"> <a class="button themex-refresh-button" href="#"><?php _e('Update', 'academy'); ?> </a> <a class="button themex-submit-button" href="#"><?php _e('Export', 'academy'); ?> </a> <input type="hidden" name="export" value="1" /> <input type="hidden" name="user" value="<?php echo ThemexCourse::$data['statistics']['user']['ID']; ?> " />
/** * Updates course * * @access public * @return void */ public static function updateCourse() { $data = $_POST; if (isset($_POST['data'])) { parse_str($_POST['data'], $data); $data['nonce'] = $_POST['nonce']; } if (isset($data['course_action'])) { $action = sanitize_key($data['course_action']); $redirect = false; if (isset($data['course_id'])) { self::refresh($data['course_id']); } if (is_user_logged_in()) { switch ($action) { case 'remove_user': self::removeUser($data['course_id'], get_current_user_id()); $redirect = true; break; case 'complete_course': self::completeCourse(); if (!get_query_var('quiz')) { $redirect = true; } break; case 'uncomplete_course': self::uncompleteCourse(); $redirect = true; break; case 'update_rating': self::updateRating($data['course_rating']); break; } } switch ($action) { case 'add_user': self::addUser($data['course_id'], get_current_user_id()); break; case 'subscribe_user': self::subscribeUser($data['plan_id'], get_current_user_id()); break; } if ($redirect) { wp_redirect(themex_url()); exit; } } }
<?php if (ThemexCourse::$data['status'] == 'premium' && ThemexCourse::$data['product'] != 0) { ?> <form action="<?php echo themex_url(); ?> " method="POST"> <?php } else { ?> <form action="<?php echo themex_url(true, ThemexCore::getURL('register')); ?> " method="POST"> <?php } ?> <?php if (!ThemexCourse::isSubscriber()) { ?> <a href="#" class="element-button medium submit-button left"><?php _e('Subscribe Now', 'academy'); ?> </a> <input type="hidden" name="course_action" value="subscribe_user" /> <input type="hidden" name="user_redirect" value="<?php echo intval(reset(ThemexCourse::$data['plans'])); ?> " /> <?php
/** * Updates user data * * @access public * @return void */ public static function updateUser() { $data = $_POST; if (isset($_POST['data'])) { parse_str($_POST['data'], $data); $data['nonce'] = $_POST['nonce']; } if (isset($data['user_action'])) { $action = sanitize_title($data['user_action']); $redirect = false; if (is_user_logged_in()) { $ID = get_current_user_id(); switch ($action) { case 'update_profile': self::updateProfile($ID, $data); break; case 'update_settings': self::updateSettings($ID, $data); break; case 'update_avatar': self::updateAvatar($ID, $_FILES['avatar']); break; } } else { switch ($action) { case 'register_user': self::registerUser($data); break; case 'login_user': self::loginUser($data); break; case 'reset_password': self::resetPassword($data); break; } } if ($redirect) { wp_redirect(themex_url()); exit; } } }
/** * Gets user links * * @access public * @param int $ID * @param array $data * @return array */ public static function getLinks($ID, $data = array()) { $links = array('profile' => array('name' => __('My Profile', 'makery'), 'url' => get_author_posts_url($ID), 'child' => array('address' => array('name' => __('Address', 'makery'), 'url' => ThemexCore::getURL('profile-address'), 'visible' => $data['woocommerce'] && $data['address']), 'links' => array('name' => __('Links', 'makery'), 'url' => ThemexCore::getURL('profile-links'), 'visible' => $data['links']))), 'orders' => array('name' => __('My Orders', 'makery'), 'url' => get_permalink(get_option('woocommerce_myaccount_page_id')), 'visible' => $data['woocommerce']), 'settings' => array('name' => __('My Settings', 'makery'), 'url' => ThemexCore::getURL('profile-settings')), 'referrals' => array('name' => __('My Referrals', 'makery'), 'url' => ThemexCore::getURL('profile-referrals'), 'visible' => $data['woocommerce'] && $data['referrals']), 'shop' => array('name' => __('My Shop', 'makery'), 'url' => ThemexCore::getURL('shop-settings'), 'visible' => $data['shops'], 'child' => array('products' => array('name' => __('Items', 'makery'), 'url' => ThemexCore::getURL('shop-products'), 'visible' => $data['shop'] && $data['woocommerce']), 'orders' => array('name' => __('Orders', 'makery'), 'url' => ThemexCore::getURL('shop-orders'), 'visible' => $data['shop'] && $data['woocommerce']), 'shipping' => array('name' => __('Shipping', 'makery'), 'url' => ThemexCore::getURL('shop-shipping'), 'visible' => $data['shop'] && $data['woocommerce'] && $data['shipping']))), 'earnings' => array('name' => __('My Earnings', 'makery'), 'url' => ThemexCore::getURL('profile-earnings'), 'visible' => ($data['shop'] && $data['shops'] || $data['referrals']) && $data['woocommerce'])); //custom links if (get_query_var('shop-product')) { $links['shop']['child']['products']['current'] = true; } if (get_query_var('shop-order')) { $links['shop']['child']['orders']['current'] = true; } //default links $current = themex_url(); foreach ($links as $link_key => &$link) { if (isset($link['visible']) && !$link['visible']) { unset($links[$link_key]); } else { $link['current'] = false; if (in_array($current, array($link['url'], $link['url'] . '/'))) { $link['current'] = true; } if (isset($link['child'])) { foreach ($link['child'] as $child_key => &$child) { if (isset($child['visible']) && !$child['visible']) { unset($link['child'][$child_key]); } else { if (!isset($child['current'])) { $child['current'] = false; if (in_array($current, array($child['url'], $child['url'] . '/'))) { $child['current'] = true; } } if ($child['current']) { $link['current'] = true; } } } } } } return $links; }
/** * Updates module data * * @access public * @return void */ public static function update() { $data = $_POST; if (isset($_POST['data'])) { parse_str($_POST['data'], $data); } //affiliate if (isset($_GET['ref'])) { self::setAffiliate($_GET['ref']); } //actions if (isset($data['woo_action'])) { $action = sanitize_title($data['woo_action']); $redirect = false; $ID = intval(themex_value('product_id', $data)); $order = intval(themex_value('order_id', $data)); $author = intval(get_post_field('post_author', $ID)); $user = get_current_user_id(); if ((empty($ID) || $user == $author) && !ThemexCore::checkOption('shop_multiple')) { switch ($action) { case 'update_product': self::updateProduct($ID, $data); break; case 'remove_product': self::removeProduct($ID); break; case 'add_image': self::addImage($ID, themex_array('product_image', $_FILES)); $redirect = true; break; case 'update_image': self::updateImage($ID, themex_array('product_image', $_FILES)); $redirect = true; break; case 'remove_image': self::removeImage($ID, themex_value('image_id', $data)); break; } } if (!empty($order)) { $author = intval(get_post_field('post_author', $order)); if ($user == $author) { switch ($action) { case 'complete_order': self::completeOrder($order, $data); break; } } } switch ($action) { case 'update_cart': self::updateCart($data); $redirect = true; break; } if ($redirect || empty(ThemexInterface::$messages)) { wp_redirect(themex_url()); exit; } } }
/** * Updates module data * * @access public * @return void */ public static function update() { $data = $_POST; if (isset($_POST['data'])) { parse_str($_POST['data'], $data); } if (isset($data['shop_action']) && is_user_logged_in()) { $action = sanitize_title($data['shop_action']); $redirect = false; $ID = intval(themex_value('shop_id', $data)); $author = intval(get_post_field('post_author', $ID)); $user = get_current_user_id(); if ((empty($ID) || $user == $author) && !ThemexCore::checkOption('shop_multiple')) { switch ($action) { case 'update_image': self::updateImage($ID, themex_array('shop_image', $_FILES)); $redirect = true; break; case 'update_profile': self::updateProfile($ID, $data); break; case 'update_shipping': self::updateShipping($ID, $data); break; case 'remove_shop': self::removeShop($ID); break; } } switch ($action) { case 'add_withdrawal': self::addWithdrawal($data); break; case 'remove_withdrawal': self::removeWithdrawal(themex_value('withdrawal_id', $data)); break; case 'submit_question': self::submitQuestion($data); break; case 'submit_report': self::submitReport($data); break; } if ($redirect || empty(ThemexInterface::$messages)) { wp_redirect(themex_url()); exit; } } }