'widget_register_ticket', 'description' => __( 'Display a Register/Ticket button for your Featured Eventbrite Event', 'eventbrite-parent' ) ); parent::__construct( 'register-ticket', __( 'Eventbrite: Register/Ticket Button', 'eventbrite-parent' ), $widget_ops ); $this->alt_option_name = 'widget_register_ticket'; add_action( 'save_post', array($this, 'flush_widget_cache') ); add_action( 'deleted_post', array($this, 'flush_widget_cache') ); add_action( 'switch_theme', array($this, 'flush_widget_cache') ); } /** * Display function for widget * @param type $args * @param type $instance * @return type */ function widget($args, $instance) { if ( !Voce_Eventbrite_API::get_auth_service() ) return; $cache = wp_cache_get('widget_register_ticket', 'widget'); if ( !is_array($cache) ) $cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; if ( isset( $cache[ $args['widget_id'] ] ) ) { echo wp_kses( $cache[ $args['widget_id'] ], wp_kses_allowed_html( 'post' ) ); return; } if ( ! $featured_events_setting = Voce_Settings_API::GetInstance()->get_setting( 'featured-event-ids', Eventbrite_Settings::eventbrite_group_key() , array() ) ) { return; } ob_start(); $featured_event_id = array_shift( maybe_unserialize( $featured_events_setting ) ); ?>