Exemple #1
0
 /**
  * Update the season of events to the season of the parent production.
  *
  * Triggered by the updated_post_meta action.
  *
  * Used when:
  * - a production is saved through the admin screen or
  * - an event is attached to a production.
  *
  * @since 0.7
  *
  */
 function updated_post_meta($meta_id, $object_id, $meta_key, $meta_value)
 {
     global $wp_theatre;
     // A production is saved through the admin screen.
     if ($meta_key == WPT_Season::post_type_name) {
         $post = get_post($object_id);
         if ($post->post_type == WPT_Production::post_type_name) {
             // avoid loops
             remove_action('updated_post_meta', array($this, 'updated_post_meta'), 20, 4);
             remove_action('added_post_meta', array($this, 'updated_post_meta'), 20, 4);
             $args = array('production' => $post->ID);
             $events = $wp_theatre->events->get($args);
             foreach ($events as $event) {
                 update_post_meta($event->ID, WPT_Season::post_type_name, $meta_value);
             }
             add_action('updated_post_meta', array($this, 'updated_post_meta'), 20, 4);
             add_action('added_post_meta', array($this, 'updated_post_meta'), 20, 4);
         }
     }
     // An event is attached to a production.
     if ($meta_key == WPT_Production::post_type_name) {
         $event = new WPT_Event($object_id);
         // avoid loops
         remove_action('updated_post_meta', array($this, 'updated_post_meta'), 20, 4);
         remove_action('added_post_meta', array($this, 'updated_post_meta'), 20, 4);
         // inherit season from production
         if ($season = $event->production()->season()) {
             update_post_meta($event->ID, WPT_Season::post_type_name, $season->ID);
         }
         // inherit categories from production
         $categories = wp_get_post_categories($meta_value);
         wp_set_post_categories($event->ID, $categories);
         add_action('updated_post_meta', array($this, 'updated_post_meta'), 20, 4);
         add_action('added_post_meta', array($this, 'updated_post_meta'), 20, 4);
     }
 }
Exemple #2
0
 /**
  * Redirects any visits to old style tickets page URLs to the new (0.12) pretty tickets page URLs.
  *
  * Old: http://example.com/tickets-page/?Event=123
  * New: http://example.com/tickets-page/my-event/123
  *
  * @since	0.12.3
  * @return	void
  */
 public function redirect_deprecated_tickets_page_url()
 {
     global $wp_theatre;
     $theatre_options = $wp_theatre->wpt_tickets_options;
     if (isset($theatre_options['iframepage']) && $theatre_options['iframepage'] == get_the_id() && isset($_GET[__('Event', 'wp_theatre')])) {
         // We are on the tickets page, using the old style URL, let's redirect
         $event = new WPT_Event($_GET[__('Event', 'wp_theatre')]);
         if (!empty($event)) {
             $tickets_url_iframe = $event->tickets_url_iframe();
             if (!empty($tickets_url_iframe)) {
                 // Redirect, Moved Permanently
                 wp_redirect($tickets_url_iframe, 301);
                 exit;
             }
         }
     }
 }
 /**
  * Gets the HTML for a single event in a listing.
  *
  * @since 	0.11
  * @access 	private
  * @param 	WPT_Event 	$event	The event.
  * @return 	string				The HTML.
  */
 private function get_listing_event_html($event)
 {
     $html = '';
     $args = array('html' => true);
     $html .= '<td>';
     $html .= $event->startdate_html();
     $html .= $event->starttime_html();
     $html .= '</td>';
     $html .= '<td>';
     $html .= $event->venue($args);
     $html .= $event->city($args);
     $html .= $event->remark($args);
     $html .= '</td>';
     $html .= '<td>';
     $html .= $event->tickets_html();
     $html .= '</td>';
     /**
      * Filter the HTML for a single event in a listing.
      *
      * @since 	0.11
      * @param 	string 		$html		The current HTML.
      * @param	WPT_Event	$event		The event.
      */
     return apply_filters('wpt/event_editor/listing/event/html', $html, $event);
 }
Exemple #4
0
 function wpt_event_ticket_button($atts, $content = null)
 {
     $atts = shortcode_atts(array('id' => false), $atts);
     extract($atts);
     if ($id) {
         $event = new WPT_Event($id);
         $args = array('html' => true);
         return $event->tickets($args);
     }
 }