public function get_return_url($order = null)
 {
     if ($order) {
         $return_url = $order->get_checkout_order_received_url();
     } else {
         $return_url = learn_press_get_endpoint_url('lp-order-received', '', learn_press_get_page_link('checkout'));
     }
     return apply_filters('learn_press_get_return_url', $return_url, $order);
 }
 static function auto_shortcode($template)
 {
     if (is_page()) {
         global $post, $wp_query, $wp;
         $page_id = $wp_query->queried_object_id;
         if ($page_id == learn_press_get_page_id('checkout')) {
             if (!preg_match('/\\[learn_press_checkout\\s?(.*)\\]/', $post->post_content)) {
                 $post->post_content .= '[learn_press_checkout]';
             }
         } elseif ($page_id == learn_press_get_page_id('profile')) {
             if (empty($wp->query_vars['user'])) {
                 $current_user = wp_get_current_user();
                 if (!empty($current_user->user_login)) {
                     wp_redirect(learn_press_get_endpoint_url('', $current_user->user_login, learn_press_get_page_link('profile')));
                     die;
                 } else {
                     learn_press_404_page();
                 }
             } else {
                 $query = array();
                 parse_str($wp->matched_query, $query);
                 if ($query) {
                     $profile_endpoints = (array) LP()->settings->get('profile_endpoints');
                     $endpoints = array_keys($profile_endpoints);
                     foreach ($query as $k => $v) {
                         if ($k == 'view') {
                             if (!$v) {
                                 $v = reset($profile_endpoints);
                             }
                             if (!in_array($v, apply_filters('learn_press_profile_tab_endpoints', $profile_endpoints))) {
                                 learn_press_404_page();
                             }
                         }
                         if (!empty($v)) {
                             $wp->query_vars[$k] = $v;
                         }
                     }
                 }
             }
             if (!preg_match('/\\[learn_press_profile\\s?(.*)\\]/', $post->post_content)) {
                 $post->post_content .= '[learn_press_profile]';
             }
         } elseif ($page_id == learn_press_get_page_id('cart')) {
             if (!preg_match('/\\[learn_press_cart\\s?(.*)\\]/', $post->post_content)) {
                 $post->post_content .= '[learn_press_cart]';
             }
         }
     }
     return $template;
 }
Esempio n. 3
0
 /**
  * Get checkout order success url
  *
  * @return mixed
  */
 public function get_checkout_order_received_url()
 {
     $received_url = learn_press_get_endpoint_url('order-received', $this->id, learn_press_get_page_link('checkout'));
     $received_url = add_query_arg('key', $this->order_key, $received_url);
     return apply_filters('learn_press_get_checkout_order_received_url', $received_url, $this);
 }
 function get_view_order_url()
 {
     global $wp_query;
     $view_order_url = learn_press_get_endpoint_url('view-order', $this->id, learn_press_get_page_link('profile'));
     //
     $user = learn_press_get_current_user();
     $view_order_endpoint = LP()->settings->get('profile_endpoints.profile-order-details');
     if (!$view_order_endpoint) {
         $view_order_endpoint = 'order-details';
     }
     if (get_option('permalink_structure')) {
         $view_order_url = learn_press_get_page_link('profile') . $user->user_login . '/' . $view_order_endpoint . '/' . $this->id;
     } else {
         $args = array('user' => $user->user_login);
         $args['view'] = $view_order_endpoint;
         if ($view_order_endpoint) {
             $args['id'] = $this->id;
         }
         $view_order_url = add_query_arg($args, learn_press_get_page_link('profile'));
     }
     return apply_filters('learn_press_view_order_url', $view_order_url, $this);
 }