public static function cp_mp_order_notification_body($content, $order)
 {
     if ('3.0' === self::get_base() && !is_object($order) && !empty($order)) {
         $order = new MP_Order($order);
     }
     if (cp_get_order_course_id($order->ID)) {
         $course_id = cp_get_order_course_id($order->ID);
         $course = new Course($course_id);
         $tags = array('CUSTOMER_NAME', 'BLOG_NAME', 'LOGIN_ADDRESS', 'WEBSITE_ADDRESS', 'COURSE_ADDRESS', 'COURSE_TITLE', 'ORDER_ID', 'ORDER_STATUS_URL');
         $course_title = '';
         $course_address = '';
         $order_name = '';
         $tracking_url = '';
         switch (self::get_base()) {
             case '3.0':
                 $cart = $order->get_cart();
                 $items = $cart->get_items();
                 $order_post = get_post($order->ID);
                 $course_title = '';
                 $course_address = '';
                 $order_name = $order->get_meta('mp_billing_info->first_name') . ' ' . $order->get_meta('mp_billing_info->last_name');
                 $counter = 0;
                 foreach ($items as $product_id => $qty) {
                     $counter += 1;
                     $course_id = (int) get_post_meta($product_id, 'course_id', true);
                     $course_title .= get_post_field('post_title', $course_id);
                     $course_address .= get_permalink($course_id);
                     if (count($items) > 0 && $counter !== count($items)) {
                         $course_title .= ', ';
                         $course_address .= ', ';
                     }
                 }
                 $tracking_url = apply_filters('wpml_marketpress_tracking_url', mp_orderstatus_link(false, true) . $order_post->post_title . '/');
                 break;
             case '2.0':
                 $order_name = $order->mp_shipping_info['name'];
                 $course_address = $course->get_permalink();
                 $course_title = $course->details->post_title;
                 $tracking_url = apply_filters('wpml_marketpress_tracking_url', mp_orderstatus_link(false, true) . $order->post_title . '/');
                 break;
         }
         $tags_replaces = array($order_name, get_bloginfo(), cp_student_login_address(), home_url(), $course_address, $course_title, $order->ID, $tracking_url);
         $message = coursepress_get_mp_order_content_email();
         $message = str_replace($tags, $tags_replaces, $message);
         add_filter('wp_mail_from', 'my_mail_from_function', 99);
         if (!function_exists('my_mail_from_function')) {
             function my_mail_from_function($email)
             {
                 return coursepress_get_mp_order_from_email();
             }
         }
         add_filter('wp_mail_from_name', 'my_mail_from_name_function', 99);
         if (!function_exists('my_mail_from_name_function')) {
             function my_mail_from_name_function($name)
             {
                 return coursepress_get_mp_order_from_name();
             }
         }
         return $message;
     } else {
         return $content;
     }
 }
Ejemplo n.º 2
0
 function header_actions()
 {
     //front
     global $post, $wp_query, $mp;
     wp_enqueue_style('font_awesome', $this->plugin_url . 'css/font-awesome.css');
     wp_enqueue_script('enrollment_process', $this->plugin_url . 'js/front-enrollment-process.js', array('jquery'), $this->version);
     wp_localize_script('enrollment_process', 'cp_vars', array('admin_ajax_url' => cp_admin_ajax_url(), 'message_all_fields_are_required' => __('All fields are required.', 'cp'), 'message_username_minimum_length' => __('Username must be at least 4 characters in length', 'cp'), 'message_username_exists' => __('Username already exists or invalid. Please choose another one.', 'cp'), 'message_email_exists' => __('E-mail already exists or invalid. Please choose another one.', 'cp'), 'message_emails_dont_match' => __("E-mails mismatch.", 'cp'), 'message_passwords_dont_match' => __("Passwords mismatch.", 'cp'), 'message_password_minimum_length' => sprintf(__('Password must be at least %d characters in length.', 'cp'), apply_filters('coursepress_min_password_length', 6)), 'minimum_password_lenght' => apply_filters('coursepress_min_password_length', 6), 'message_login_error' => __('Username and/or password is not valid.', 'cp'), 'message_passcode_invalid' => __('Passcode is not valid.', 'cp'), 'message_tos_invalid' => __('You must agree to the Terms of Service in order to signup.', 'cp'), 'debug' => 0));
     wp_enqueue_script('coursepress_front', $this->plugin_url . 'js/coursepress-front.js', array('jquery'), $this->version);
     wp_enqueue_script('coursepress_calendar', $this->plugin_url . 'js/coursepress-calendar.js', array('jquery'), $this->version);
     if ($post && !$this->is_preview($post->ID) && !isset($_GET['try'])) {
         wp_enqueue_script('coursepress_front_elements', $this->plugin_url . 'js/coursepress-front-elements.js', array('jquery'), $this->version);
     }
     $course_id = do_shortcode('[get_parent_course_id]');
     $units_archive_url = is_numeric($course_id) ? get_permalink($course_id) . trailingslashit($this->get_units_slug()) : '';
     wp_localize_script('coursepress_front', 'front_vars', array('withdraw_alert' => __('Please confirm that you want to withdraw from the course. If you withdraw, you will no longer be able to see your records for this course.', 'cp'), 'units_archive_url' => $units_archive_url));
     if (!is_admin()) {
         wp_enqueue_style('front_general', $this->plugin_url . 'css/front_general.css', array(), $this->version);
         wp_enqueue_style('front_enrollment_process', $this->plugin_url . 'css/front-enrollment-process.css', array(), $this->version);
     }
     wp_enqueue_script('coursepress-knob', $this->plugin_url . 'js/jquery.knob.js', array(), $this->version, true);
     if (isset($wp_query->query_vars['order_id']) || isset($_GET['order_id'])) {
         $order_id = isset($wp_query->query_vars['order_id']) ? $wp_query->query_vars['order_id'] : (isset($_GET['order_id']) ? $_GET['order_id'] : '');
         if (!empty($order_id) && isset($mp)) {
             $order = $mp->get_order($order_id);
             if (count($order) == 1) {
                 //CP supports only one item in the cart per order so there is no reason to do the check otherwise
                 if (cp_get_order_course_id($order_id)) {
                     wp_enqueue_style('front_mp_fix', $this->plugin_url . 'css/front_mp_fix.css', array(), $this->version);
                     add_filter('mp_order_status_section_title_shipping_info', array(&$this, 'return_empty'));
                 }
             }
         }
     }
     // Responsive Video
     //wp_enqueue_script( 'responsive-video', $this->plugin_url . 'js/responsive-video.js' );
 }