/** * Use the production summary as the metadesc for a production. * Only if no metadesc is set using the WordPress SEO meta box. */ function wpseo_metadesc($metadesc) { if (!is_admin() && empty($metadesc)) { if (is_singular(WPT_Production::post_type_name)) { $production = new WPT_Production(); $metadesc = $production->summary(); } } return $metadesc; }
/** * Outputs the widget. * * @since 0.8.2 * @since 0.12.1 Added filters. * @since 0.12.1 Fixed PHP warnings. See #146. * * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. * @return void */ public function widget($args, $instance) { global $wp_theatre; $defaults = array('title' => '', 'template' => false, 'production' => false); $instance = wp_parse_args($instance, $defaults); $html = ''; if (is_numeric($instance['production'])) { $production = new WPT_Production($instance['production']); /** * Filter the widget title. * * @since 0.12.1 * @param string $title The widget title. * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ $title = apply_filters('wpt/production/widget/title', $instance['title'], $args, $instance); if (!empty($title)) { $html .= $args['before_title'] . $title . $args['after_title']; } /** * Filter the production template. * * @since 0.12.1 * @param string $template The production template. * @param array $args * @param array $instance */ $template = apply_filters('wpt/production/widget/template', $instance['template'], $args, $instance); $html_production = $production->html($template); /** * Filter the HTML of the production. * * @since 0.12.1 * @param string $html_production The HTML of the production. */ $html_production = apply_filters('wpt/production/widget/production/html', $html_production, $production); $html .= $html_production; $html = $args['before_widget'] . $html . $args['after_widget']; } /** * Filter the HTML of the widget. * * @since 0.12.1 * @param string $html The HTML of the widget. * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ $html = apply_filters('wpt/production/widget', $html, $args, $instance); echo $html; }
/** * Update the _wpt_order of a post (of any post_type). * * For productions the _wpt_order value is based on the event_date of the first upcoming event. * For events the _wpt_order value is based on the event_date. * The _wpt_order value is based on the post_date for all other post_types. * * @since 0.6.2 * @since 0.10.15 Always set _wpt_order in UTC. * Fixes #117. * */ function set_post_order($post) { global $wp_theatre; if (is_numeric($post)) { $post = get_post($post); } switch ($post->post_type) { case WPT_Production::post_type_name: $production = new WPT_Production($post->ID); $events = $production->upcoming(); if (!empty($events[0])) { $wpt_order = strtotime(get_post_meta($events[0]->ID, 'event_date', TRUE), current_time('timestamp')) - 3600 * get_option('gmt_offset'); break; } case WPT_Event::post_type_name: $wpt_order = strtotime(get_post_meta($post->ID, 'event_date', TRUE), current_time('timestamp')) - 3600 * get_option('gmt_offset'); break; default: $wpt_order = strtotime($post->post_date) + 3600 * get_option('gmt_offset'); } update_post_meta($post->ID, $this->meta_key, $wpt_order); }
function set_object_terms($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids) { if ('category' == $taxonomy && WPT_Production::post_type_name == get_post_type($object_id)) { $production = new WPT_Production($object_id); $events = $production->events(); $categories = wp_get_post_categories($object_id); foreach ($events as $event) { wp_set_post_categories($event->ID, $categories); } } }
public function widget($args, $instance) { global $wp_theatre; if (!empty($instance['production'])) { echo $args['before_widget']; if (!empty($instance['title'])) { $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $args['before_title'] . $title . $args['after_title']; } $filters = array('limit' => $instance['limit']); if (!empty($instance['template'])) { $filters['template'] = $instance['template']; } $production = new WPT_Production($instance['production']); $production_args = array(); if (!empty($instance['template'])) { $production_args['template'] = $instance['template']; } $html .= $production->html($production_args); echo $html; echo $args['after_widget']; } }
function manage_wp_theatre_prod_posts_custom_column($column_name, $post_id) { $production = new WPT_Production($post_id); switch ($column_name) { case 'thumbnail': echo $production->thumbnail_html(); break; case 'dates': echo $production->dates() . '<br />'; echo $production->cities(); break; } }