/** * 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']; } } }
/** * run - initial shortcode module setup called during "wp_loaded" hook * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed * * @access public * @param WP $WP * @return void */ public function run(WP $WP) { EED_Promotions::$shortcode_active = TRUE; EED_Promotions::enqueue_scripts(); }