/** * 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) { // this will trigger the EED_New_Addon module's run() method during the pre_get_posts hook point, // this allows us to initialize things, enqueue assets, etc, // as well, this saves an instantiation of the module in an array, using 'new_addon' as the key, so that we can retrieve it EE_Registry::instance()->REQ->set('ee', 'new_addon'); EED_New_Addon::$shortcode_active = TRUE; }
/** * 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_NEW_ADDON') === FALSE) { EED_New_Addon::$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 EE_New_Addon::instance()->enqueue_scripts(); // settings $attributes = array(); echo EE_New_Addon::instance()->display_new_addon($attributes); // After widget (defined by themes). echo $args['after_widget']; } } }