Beispiel #1
0
/**
 * Retrieve gig information in markup suitable for a RSS description.
 *
 * @since 1.0.0
 * @uses get_audiotheme_venue_vcard_rss()
 *
 * @param int|object $post Optional post ID or object. Default is global $post object.
 * @return string
 */
function get_audiotheme_gig_rss_description($post = null)
{
    $gig = get_audiotheme_gig($post);
    $output = '<strong>' . get_audiotheme_gig_time('l, F j, Y', ' @ g:i a') . '</strong>';
    $output .= empty($gig->venue) ? '' : get_audiotheme_venue_vcard($gig->venue->ID, array('container' => 'div'));
    $output .= empty($gig->post_excerpt) ? '' : wpautop($gig->post_excerpt);
    return $output;
}
Beispiel #2
0
<?php

/**
 * Gigs JSON feed template.
 *
 * @package AudioTheme_Framework
 * @subpackage Gigs
 */
@header('Content-Type: application/json; charset=' . get_option('blog_charset'));
foreach ($wp_query->posts as $post) {
    $post = get_audiotheme_gig($post);
    $event = new stdClass();
    $event->id = $post->ID;
    $event->title = $post->post_title;
    $event->description = $post->post_excerpt;
    $event->url = get_permalink($post->ID);
    $event->start->date = get_audiotheme_gig_time('Y-m-d');
    $event->start->time = get_post_meta($post->ID, '_audiotheme_gig_time', true);
    $event->start->datetime = get_audiotheme_gig_time('c', '', true);
    // @todo Attempt to add a property to display the date in UTC.
    if (!empty($post->venue)) {
        $event->venue->ID = $post->venue->ID;
        $event->venue->name = $post->venue->name;
        $event->venue->url = $post->venue->website;
        $event->venue->phone = $post->venue->phone;
        $event->venue->location->street = $post->venue->address;
        $event->venue->location->city = $post->venue->city;
        $event->venue->location->state = $post->venue->state;
        $event->venue->location->postalcode = $post->venue->postal_code;
        $event->venue->location->country = $post->venue->country;
        $event->venue->location->timezone = $post->venue->timezone_string;
 /**
  * Prepares the list of gigs for displaying.
  *
  * Modifies the query based on the current view and screen options and
  * begins setting up columns.
  *
  * @since 1.0.0
  */
 function prepare_items()
 {
     global $wp_query;
     $screen = get_current_screen();
     $per_page = get_user_option('toplevel_page_audiotheme_gigs_per_page');
     $per_page = empty($per_page) ? 20 : $per_page;
     // Set up column headers.
     $columns = $this->get_columns();
     $hidden = get_hidden_columns($screen->id);
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     // Compile the WP_Query args based on the current view and user options.
     $args = array('post_type' => 'audiotheme_gig', 'order' => isset($_REQUEST['order']) && 'asc' === strtolower($_REQUEST['order']) ? 'asc' : 'desc', 'post_status' => isset($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'publish,draft', 'posts_per_page' => $per_page);
     if (empty($_REQUEST['m']) && ('upcoming' === $this->current_view || 'past' === $this->current_view)) {
         $args['meta_query'][] = array('key' => '_audiotheme_gig_datetime', 'value' => isset($_REQUEST['gig_date']) ? urldecode($_REQUEST['gig_date']) : current_time('mysql'), 'compare' => isset($_REQUEST['compare']) ? urldecode($_REQUEST['compare']) : '>=', 'type' => 'DATETIME');
         // Sort upcoming in ascending order by default.
         $args['order'] = 'upcoming' === $this->current_view && !isset($_REQUEST['order']) ? 'asc' : $args['order'];
     } elseif (!empty($_REQUEST['m'])) {
         $m = absint(substr($_REQUEST['m'], 4));
         $y = absint(substr($_REQUEST['m'], 0, 4));
         $start = sprintf('%s-%s-01 00:00:00', $y, zeroise($m, 2));
         $end = sprintf('%s 23:59:59', date('Y-m-t', mktime(0, 0, 0, $m, 1, $y)));
         $args['meta_query'][] = array('key' => '_audiotheme_gig_datetime', 'value' => array($start, $end), 'compare' => 'BETWEEN', 'type' => 'DATETIME');
         $args['order'] = isset($_REQUEST['order']) ? $args['order'] : 'asc';
     }
     if (!empty($_REQUEST['venue'])) {
         $args['connected_type'] = 'audiotheme_venue_to_gig';
         $args['connected_items'] = absint($_REQUEST['venue']);
     }
     if (isset($_REQUEST['orderby'])) {
         switch ($_REQUEST['orderby']) {
             case 'title':
                 $args['orderby'] = 'title';
                 break;
             case 'venue':
                 // Handled after the query is run.
                 break;
             default:
                 $args['meta_key'] = '_audiotheme_' . $_REQUEST['orderby'];
                 $args['orderby'] = 'meta_value';
                 break;
         }
     } else {
         $args['meta_key'] = '_audiotheme_gig_datetime';
         $args['orderby'] = 'meta_value';
     }
     if (isset($_REQUEST['s'])) {
         $args['s'] = $_REQUEST['s'];
     }
     $args['paged'] = $this->get_pagenum();
     // Run the query and fetch the connected venues.
     $items = array();
     $wp_query = new WP_Query($args);
     p2p_type('audiotheme_venue_to_gig')->each_connected($wp_query);
     if (isset($wp_query->posts) && count($wp_query->posts)) {
         foreach ($wp_query->posts as $post) {
             $items[$post->ID] = get_audiotheme_gig($post->ID);
         }
         // Sort by venue.
         if (!empty($_GET['orderby']) && 'venue' === $_GET['orderby']) {
             $items = audiotheme_sort_objects($items, array('venue', 'name'), $args['order'], true, 'gig_datetime');
         }
     }
     $this->items = $items;
     $this->set_pagination_args(array('total_items' => $wp_query->found_posts, 'per_page' => $per_page, 'total_pages' => $wp_query->max_num_pages));
 }
Beispiel #4
0
/**
 * Setup and display the main gig fields for editing.
 *
 * @since 1.0.0
 */
function audiotheme_edit_gig_fields()
{
    global $post, $wpdb;
    $gig = get_audiotheme_gig($post->ID);
    $gig_date = '';
    $gig_time = '';
    $gig_venue = '';
    if ($gig->gig_datetime) {
        $timestamp = strtotime($gig->gig_datetime);
        // jQuery date format is kinda limited?
        $gig_date = date('Y/m/d', $timestamp);
        $t = date_parse($gig->gig_time);
        if (empty($t['errors'])) {
            $gig_time = date(audiotheme_compatible_time_format(), $timestamp);
        }
    }
    $gig_venue = isset($gig->venue->name) ? $gig->venue->name : '';
    $timezone_string = isset($gig->venue->timezone_string) ? $gig->venue->timezone_string : '';
    require AUDIOTHEME_DIR . 'modules/gigs/admin/views/edit-gig.php';
}
}
?>

<?php 
if ($loop->have_posts()) {
    ?>

	<?php 
    while ($loop->have_posts()) {
        $loop->the_post();
        ?>

		<dl class="vevent" itemscope itemtype="http://schema.org/MusicEvent">

			<?php 
        $gig = get_audiotheme_gig();
        echo get_audiotheme_gig_link($gig, array('before' => '<dt>', 'after' => '</dt>'));
        ?>

			<?php 
        if (audiotheme_gig_has_venue()) {
            ?>
				<dd class="location">
					<a href="<?php 
            the_permalink();
            ?>
"><span class="gig-title"><?php 
            echo get_audiotheme_gig_location();
            ?>
</span></a>
				</dd>
/**
 * Retrieve the static Google map URL for an address/venue.
 *
 * @since 1.6.0
 * @link https://developers.google.com/maps/documentation/staticmaps/?csw=1
 *
 * @param array $args Array of args.
 * @param int $venue_id Optional. Venue ID.
 * @return string
 */
function get_audiotheme_google_static_map_url($args = array(), $venue_id = 0)
{
    $args = wp_parse_args($args, array('address' => '', 'width' => 640, 'height' => 300));
    // Get the current post and determine if it's a gig with a venue.
    if (empty($args['address']) && ($gig = get_audiotheme_gig())) {
        if ('audiotheme_gig' === get_post_type($gig) && !empty($gig->venue->ID)) {
            $venue_id = $gig->venue->ID;
        }
    }
    // Retrieve the address for the venue.
    if ($venue_id) {
        $venue = get_audiotheme_venue($venue_id);
        $args['address'] = get_audiotheme_venue_address($venue->ID);
        $args['address'] = $args['address'] ? $venue->name . ', ' . $args['address'] : $venue->name;
    }
    $image_url = add_query_arg(array('center' => rawurlencode($args['address']), 'size' => $args['width'] . 'x' . $args['height'], 'scale' => 2, 'format' => 'jpg', 'sensor' => 'false', 'markers' => 'size:small|color:0xff0000|' . rawurlencode($args['address'])), '//maps.googleapis.com/maps/api/staticmap');
    $image_url = apply_filters('audiotheme_google_static_map_url', $image_url, $args, $venue_id);
    // @link https://developers.google.com/maps/documentation/staticmaps/?csw=1#StyledMaps
    $map_styles = apply_filters('audiotheme_google_static_map_styles', array());
    if (!empty($map_styles)) {
        foreach ($map_styles as $styles) {
            $image_url .= '&style=' . audiotheme_build_query($styles);
        }
    }
    return $image_url;
}
Beispiel #7
0
/**
 * Update a venue's cached gig count when gig is deleted.
 *
 * Determines if a venue's gig_count meta field needs to be updated
 * when a gig is deleted.
 *
 * @since 1.0.0
 *
 * @param int $post_id ID of the gig being deleted.
 */
function audiotheme_gig_before_delete($post_id)
{
    if ('audiotheme_gig' === get_post_type($post_id)) {
        $gig = get_audiotheme_gig($post_id);
        if (isset($gig->venue->ID)) {
            $count = get_audiotheme_venue_gig_count($gig->venue->ID);
            update_audiotheme_venue_gig_count($gig->venue->ID, --$count);
        }
    }
}