/**
  *    process_shortcode
  *
  *    [ESPRESSO_PROMOTIONS]
  *
  * @access 	public
  * @param 	array $attributes
  * @return 	string
  */
 public function process_shortcode($attributes = array())
 {
     /** @type EEM_Promotion $EEM_Promotion */
     $EEM_Promotion = EE_Registry::instance()->load_model('Promotion');
     EE_Registry::instance()->load_helper('Template');
     $active_promotions = $EEM_Promotion->get_all_active_codeless_promotions();
     $html = '<div id="ee-upcoming-promotions-dv">';
     foreach ($active_promotions as $promotion) {
         if ($promotion instanceof EE_Promotion) {
             $config = EED_Promotions::instance()->set_config();
             if (!empty($config->banner_template) && $config->banner_template == 'promo-banner-ribbon.template.php' && !empty($config->ribbon_banner_color)) {
                 $promo_bg_color = $config->ribbon_banner_color;
             } else {
                 $promo_bg_color = '';
             }
             $scope_objects = $promotion->get_objects_promo_applies_to();
             $html .= EEH_Template::locate_template(apply_filters('FHEE__EED_Promotions__process_shortcode__upcoming_promotions', EE_PROMOTIONS_PATH . 'templates' . DS . 'upcoming-promotions-grid.template.php'), array('PRO_ID' => $promotion->ID(), 'promo_bg_color' => apply_filters('FHEE__EED_Promotions__process_shortcode__promo_bg_color', $promo_bg_color), 'promo_header' => $promotion->name(), 'promo_desc' => $promotion->description() != '' ? $promotion->description() . '<br />' : '', 'promo_amount' => $promotion->pretty_amount(), 'promo_dates' => $promotion->promotion_date_range(), 'promo_scopes' => $promotion->get_promo_applies_to_link_array($scope_objects)));
         }
     }
     $html .= '</div>';
     return $html;
 }
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     // get the current post
     global $post;
     if (isset($post->post_content)) {
         // check the post content for the short code
         if (strpos($post->post_content, '[ESPRESSO_PROMOTIONS') === FALSE) {
             EED_Promotions::$shortcode_active = TRUE;
             // Before widget (defined by themes).
             echo $args['before_widget'];
             // Title of widget (before and after defined by themes).
             $title = apply_filters('widget_title', $instance['title']);
             if (!empty($title)) {
                 echo $args['before_title'] . $title . $args['after_title'];
             }
             // load scripts
             EED_Promotions::instance()->enqueue_scripts();
             // settings
             $attributes = array();
             echo EED_Promotions::instance()->display_promotions($attributes);
             // After widget (defined by themes).
             echo $args['after_widget'];
         }
     }
 }
 /**
  * _config
  *
  * @access protected
  * @return EE_Promotions_Config
  */
 protected function _config()
 {
     return EED_Promotions::instance()->set_config();
 }
 /**
  *    submit_promo_code
  *
  * @access 	public
  * @return 	void
  */
 public static function submit_promo_code()
 {
     EED_Promotions::instance()->set_config();
     EED_Promotions::instance()->_submit_promo_code();
 }