public static function begin_integration()
 {
     if (!self::is_active()) {
         return false;
     }
     if (false === self::$mp_base) {
         self::$mp_base = self::get_base();
     }
     // General hooks
     add_action('coursepress_course_created', array(__CLASS__, 'update_product_from_course'));
     add_action('coursepress_course_updated', array(__CLASS__, 'update_product_from_course'));
     add_action('coursepress_mp_update_product', array(__CLASS__, 'maybe_create_product'));
     add_action('post_updated', array(__CLASS__, 'update_course_from_product'), 10, 3);
     add_filter('coursepress_shortcode_course_cost', array(__CLASS__, 'shortcode_cost'), 10, 2);
     // Enable Payment Support
     add_filter('coursepress_offer_paid_courses', array(__CLASS__, 'enable_payment'));
     // Specific hooks
     switch (self::$mp_base) {
         case '3.0':
             /**
              * Enroll upon pay
              *
              * Reference to order ID, will need to get the actual product using the MarketPress Order class
              */
             add_action('mp_order_order_paid', array(__CLASS__, 'course_paid_3pt0'));
             /**
              * Override thumbnail placeholder with course list image.
              * Note: Typically course products won't have thumbnails, but if a product image is set, this filter
              * will not override the set product image.
              */
             add_filter('mp_product_image_show_placeholder', array(__CLASS__, 'placeholder_to_course_image'), 10, 2);
             /**
              * Return course list image as product image for: `mp_product_images` meta
              */
             add_filter('get_post_metadata', array(__CLASS__, 'course_product_images_meta'), 10, 4);
             add_filter('mp_order/notification_subject', array(__CLASS__, 'cp_mp_order_notification_subject', 10, 2));
             add_filter('mp_order/notification_body', array(__CLASS__, 'cp_mp_order_notification_body', 10, 2));
             add_filter('mp_meta/product', array(__CLASS__, 'verify_meta'), 10, 3);
             add_filter('mp_product/on_sale', array(__CLASS__, 'fix_mp3_on_sale'), 10, 2);
             // Fix missing MP3.0 meta fields
             add_filter('wpmudev_field/get_value/sku', array(__CLASS__, 'fix_mp3_sku'), 10, 4);
             add_filter('wpmudev_field/get_value/regular_price', array(__CLASS__, 'fix_mp3_regular_price'), 10, 4);
             add_filter('wpmudev_field/get_value/has_sale', array(__CLASS__, 'fix_mp3_has_sale'), 10, 4);
             add_filter('wpmudev_field/get_value/sale_price[amount]', array(__CLASS__, 'fix_mp3_sale_price_amount'), 10, 4);
             add_filter('wpmudev_field/get_value/file_url', array(__CLASS__, 'fix_mp3_file_url'), 10, 4);
             self::$product_ctp = MP_Product::get_post_type();
             break;
         case '2.0':
             add_action('mp_new_order', array(__CLASS__, 'listen_for_paid_status_for_courses_2pt0'));
             add_action('mp_order_paid', array(__CLASS__, 'listen_for_paid_status_changes_for_courses_2pt0'));
             add_filter('mp_order_notification_subject', array(__CLASS__, 'cp_mp_order_notification_subject', 10, 2));
             add_filter('mp_order_notification_body', array(__CLASS__, 'cp_mp_order_notification_body', 10, 2));
             break;
     }
 }
 private function _add_variation($app_id, $post_id, $service, $worker, $start, $end)
 {
     // Yeah, let's just go off with creating the variations
     $variation_id = wp_insert_post(array('post_parent' => $post_id, 'post_title' => get_the_title($post_id), 'post_status' => 'publish', 'post_type' => MP_Product::get_variations_post_type()), false);
     if (empty($variation_id)) {
         return false;
     }
     $price = false;
     $raw_price = apply_filters('app_mp_price', $this->_core->get_price(true), $service, $worker, $start, $end);
     // Filter added at V1.2.3.1
     if (function_exists('filter_var') && defined('FILTER_VALIDATE_FLOAT') && defined('FILTER_FLAG_ALLOW_THOUSAND')) {
         $price = filter_var($raw_price, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
         // Undo the problematic number formatting issue
     }
     if (false === $price) {
         $price = str_replace(',', '', $raw_price);
     }
     update_post_meta($variation_id, 'name', $app_id);
     update_post_meta($variation_id, 'sku', $this->_core->service);
     update_post_meta($variation_id, 'regular_price', $price);
     return $variation_id;
 }
 public function eab_mp_variation_check($content, $event_id)
 {
     $event = new Eab_EventModel(get_post($event_id));
     $product_id = get_post_meta($event_id, 'eab_product_id', true);
     if (isset($product_id) && (int) $product_id > 0) {
         $product = new MP_Product($product_id);
         if ($product->has_variations()) {
             $variations = $product->get_variations();
             $html = '<select name="action_variation" style="width: 100%; margin-bottom: 10px;">';
             foreach ($variations as $variation) {
                 $price = $variation->get_price();
                 $html .= '<option value="' . $variation->ID . '">' . $variation->get_meta('name') . ' - ' . mp_format_currency('', $price['regular']) . '</option>';
             }
             $html .= '</select><br>';
             $content = $html . $content;
         }
     }
     return $content;
 }