Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missign files and Namespace for Tickets Editor views #921

Merged
merged 2 commits into from Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Tribe/Editor/Blocks/Attendees.php
Expand Up @@ -73,7 +73,7 @@ public function render( $attributes = array() ) {
// enqueue assets
tribe_asset_enqueue( 'tribe-tickets-gutenberg-block-attendees-style' );

return tribe( 'tickets.editor.template' )->template( array( 'blocks', $this->slug() ), $args, false );
return tribe( 'tickets.editor.template' )->template( array( 'editor', 'blocks', $this->slug() ), $args, false );
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Tribe/Editor/Blocks/Rsvp.php
Expand Up @@ -67,7 +67,7 @@ public function render( $attributes = array() ) {
tribe_asset_enqueue( 'tribe-tickets-gutenberg-rsvp' );
tribe_asset_enqueue( 'tribe-tickets-gutenberg-block-rsvp-style' );

return tribe( 'tickets.editor.template' )->template( array( 'blocks', $this->slug() ), $args, false );
return tribe( 'tickets.editor.template' )->template( array( 'editor', 'blocks', $this->slug() ), $args, false );
}

/*
Expand Down Expand Up @@ -176,7 +176,7 @@ public function rsvp_form() {
'going' => $going,
);

$html = tribe( 'tickets.editor.template' )->template( 'blocks/rsvp/form/form', $args, false );
$html = tribe( 'tickets.editor.template' )->template( 'editor/blocks/rsvp/form/form', $args, false );

$response['html'] = $html;

Expand Down Expand Up @@ -287,12 +287,12 @@ public function rsvp_process() {
$remaining = $ticket->remaining();

if ( ! $remaining ) {
$response['status_html'] = tribe( 'tickets.editor.template' )->template( 'blocks/rsvp/status', $args, false );
$response['status_html'] = tribe( 'tickets.editor.template' )->template( 'editor/blocks/rsvp/status', $args, false );
}

$response['remaining'] = $ticket->remaining();
$response['remaining_html'] = tribe( 'tickets.editor.template' )->template( 'blocks/rsvp/details/availability', $args, false );
$response['html'] = tribe( 'tickets.editor.template' )->template( 'blocks/rsvp/messages/success', $args, false );
$response['remaining_html'] = tribe( 'tickets.editor.template' )->template( 'editor/blocks/rsvp/details/availability', $args, false );
$response['html'] = tribe( 'tickets.editor.template' )->template( 'editor/blocks/rsvp/messages/success', $args, false );

wp_send_json_success( $response );

Expand Down
6 changes: 3 additions & 3 deletions src/Tribe/Editor/Blocks/Tickets.php
Expand Up @@ -84,7 +84,7 @@ public function render( $attributes = array() ) {
tribe_asset_enqueue( 'tribe-tickets-gutenberg-tickets' );
tribe_asset_enqueue( 'tribe-tickets-gutenberg-block-tickets-style' );

return tribe( 'tickets.editor.template' )->template( array( 'blocks', $this->slug() ), $args, false );
return tribe( 'tickets.editor.template' )->template( array( 'editor', 'blocks', $this->slug() ), $args, false );
}

/**
Expand Down Expand Up @@ -164,7 +164,7 @@ public function render_shortcode_attendees( $atts, $content = '' ) {
// Add the rendering attributes into global context
tribe( 'tickets.editor.template' )->add_template_globals( $args );

$content = tribe( 'tickets.editor.template' )->template( 'blocks/tickets/registration/content', $args, false );
$content = tribe( 'tickets.editor.template' )->template( 'editor/blocks/tickets/registration/content', $args, false );

return $content;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function ticket_availability( $tickets = array() ) {

// If there are no more available we will send the template part HTML to update the DOM
if ( 0 === $available ) {
$response['tickets'][ $ticket_id ]['unavailable_html'] = tribe( 'tickets.editor.template' )->template( 'blocks/tickets/quantity-unavailable', $ticket, false );
$response['tickets'][ $ticket_id ]['unavailable_html'] = tribe( 'tickets.editor.template' )->template( 'editor/blocks/tickets/quantity-unavailable', $ticket, false );
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/Tribe/Main.php
Expand Up @@ -91,6 +91,15 @@ public static function instance() {
return self::$instance;
}

/**
* Where in the themes we will look for templates
*
* @since TBD
*
* @var string
*/
public $template_namespace = 'tickets';

/**
* Class constructor
*/
Expand Down
27 changes: 27 additions & 0 deletions src/views/editor/blocks/attendees.php
@@ -0,0 +1,27 @@
<?php
/**
* This template renders the attendees
*
* @version TBD
*
*/
$title = $this->attr( 'title' );
$attendees = $this->get( 'attendees', array() );
$classes = array( 'tribe-block', 'tribe-block__attendees' );
?>
<div
id="tribe-block__attendees"
class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">

<?php $this->template( 'editor/blocks/attendees/title', array( 'title' => $title ) ); ?>

<?php $this->template( 'editor/blocks/attendees/description', array( 'attendees' => $attendees ) ); ?>

<?php foreach ( $attendees as $key => $attendee ) : ?>

<?php $this->template( 'editor/blocks/attendees/gravatar', array( 'attendee' => $attendee ) ); ?>

<?php endforeach; ?>

</div>

12 changes: 12 additions & 0 deletions src/views/editor/blocks/attendees/description.php
@@ -0,0 +1,12 @@
<?php
/**
* This template renders the attendees block description
*
* @version TBD
*
*/
$post_id = $this->get( 'post_id' );
$attendees_total = count( $attendees );
$message = _n( 'One person is attending %2$s', '%d people are attending %s', $attendees_total, 'events-gutenberg' );
?>
<p><?php echo esc_html( sprintf( $message, $attendees_total, get_the_title( $post_id ) ) ); ?></p>
8 changes: 8 additions & 0 deletions src/views/editor/blocks/attendees/gravatar.php
@@ -0,0 +1,8 @@
<?php
/**
* This template renders the attendee gravatar
*
* @version TBD
*
*/
echo get_avatar( $attendee['purchaser_email'], 60, '', $attendee['purchaser_name'] );
56 changes: 56 additions & 0 deletions src/views/editor/blocks/attendees/order-links.php
@@ -0,0 +1,56 @@
<?php
/**
* Link to Tickets
* Included on the Events Single Page after the meta
* the Message that Will link to the Tickets Page
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/tickets/orders-link.php
*
* @version 4.7.1
*/

if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}

$view = Tribe__Tickets__Tickets_View::instance();
$event_id = $this->get( 'post_id' );
$event = get_post( $event_id );
$post_type = get_post_type_object( $event->post_type );
$user_id = get_current_user_id();

$ticket_type = $this->get( 'type' );
$is_ticket = 'ticket' === $ticket_type;
$is_rsvp = 'RSVP' === $ticket_type;

$is_event_page = class_exists( 'Tribe__Events__Main' ) && Tribe__Events__Main::POSTTYPE === $event->post_type ? true : false;

$events_label_singular = $post_type->labels->singular_name;
$counters = array();
$rsvp_count = $view->count_rsvp_attendees( $event_id, $user_id );
$ticket_count = $view->count_ticket_attendees( $event_id, $user_id );

$has_rsvps = $is_rsvp && 0 !== $rsvp_count;
$has_tickets = $is_ticket && 0 !== $ticket_count;


$link = $view->get_tickets_page_url( $event_id, $is_event_page );
$message = sprintf( esc_html__( 'You have %s for this %s.', 'event-tickets' ), implode( __( ' and ', 'event-tickets' ), $counters ), $events_label_singular );

if ( ! $has_rsvps || ! $has_tickets ){
return false;
}

if ( $has_rsvps ) {
$counters[] = sprintf( _n( '%d %s', '%d %ss', $rsvp_count, 'event-tickets' ), $rsvp_count, $ticket_type );
}

if ( $has_tickets ) {
$counters[] = sprintf( _n( '%d %s', '%d %ss', $ticket_count, 'event-tickets' ), $ticket_count, $ticket_type );
}
?>

<div class="tribe-link-view-attendee">
<?php echo $message ?>
<a href="<?php echo esc_url( $link ) ?>"><?php echo sprintf( esc_html__( 'View your %s', 'event-tickets' ), $view->get_description_rsvp_ticket( $event_id, $user_id, true ) ) ?></a>
</div>
9 changes: 9 additions & 0 deletions src/views/editor/blocks/attendees/title.php
@@ -0,0 +1,9 @@
<?php
/**
* This template renders the attendees block title
*
* @version TBD
*
*/
?>
<h2 class="tribe-block__attendees__title"><?php echo esc_html( $title );?></h2>
32 changes: 32 additions & 0 deletions src/views/editor/blocks/rsvp.php
@@ -0,0 +1,32 @@
<?php
/**
* This template renders the RSVP ticket form
*
* @version 0.3.0-alpha
*
*/

$event_id = $this->get( 'post_id' );
$tickets = $this->get( 'tickets' );

?>

<?php $this->template( 'editor/blocks/attendees/order-links', array( 'type' => 'RSVP' ) ); ?>

<div class="tribe-block tribe-block__rsvp">

<?php foreach ( $tickets as $ticket ) : ?>

<div class="tribe-block__rsvp__ticket" data-rsvp-id="<?php echo absint( $ticket->ID ); ?>">

<?php $this->template( 'editor/blocks/rsvp/icon' ); ?>

<?php $this->template( 'editor/blocks/rsvp/content', array( 'ticket' => $ticket ) ); ?>

<?php $this->template( 'editor/blocks/rsvp/loader' ); ?>

</div>

<?php endforeach; ?>

</div>
18 changes: 18 additions & 0 deletions src/views/editor/blocks/rsvp/content.php
@@ -0,0 +1,18 @@
<?php
/**
* This template renders the RSVP ticket content
*
* @version 0.3.0-alpha
*
*/
?>
<div class="tribe-block__rsvp__content">

<div class="tribe-block__rsvp__details__status">
<?php $this->template( 'editor/blocks/rsvp/details', array( 'ticket' => $ticket ) ); ?>
<?php $this->template( 'editor/blocks/rsvp/status', array( 'ticket' => $ticket ) ); ?>
</div>

<?php $this->template( 'editor/blocks/rsvp/form', array( 'ticket' => $ticket ) ); ?>

</div>
17 changes: 17 additions & 0 deletions src/views/editor/blocks/rsvp/details.php
@@ -0,0 +1,17 @@
<?php
/**
* This template renders the RSVP ticket details
*
* @version 0.3.0-alpha
*
*/
?>
<div class="tribe-block__rsvp__details">

<?php $this->template( 'editor/blocks/rsvp/details/title', array( 'ticket' => $ticket ) ); ?>

<?php $this->template( 'editor/blocks/rsvp/details/description', array( 'ticket' => $ticket ) ); ?>

<?php $this->template( 'editor/blocks/rsvp/details/availability', array( 'ticket' => $ticket ) ); ?>

</div>
20 changes: 20 additions & 0 deletions src/views/editor/blocks/rsvp/details/availability.php
@@ -0,0 +1,20 @@
<?php
/**
* This template renders the RSVP ticket description
*
* @version 0.3.0-alpha
*
*/
$remaining_tickets = $ticket->remaining();
$is_unlimited = -1 === $remaining_tickets;
?>
<div class="tribe-block__rsvp__availability">
<?php if ( ! $ticket->is_in_stock() ) : ?>
<span class="tribe-block__rsvp__no-stock"><?php esc_html_e( 'Out of stock!', 'event-tickets' ); ?></span>
<?php elseif ( ! $is_unlimited ) : ?>
<span class="tribe-block__rsvp__quantity"><?php echo $ticket->remaining(); ?> </span>
<?php esc_html_e( 'remaining', 'events-gutenberg' ) ?>
<?php else : ?>
<span class="tribe-block__rsvp__unlimited"><?php esc_html_e( 'Unlimited', 'event-tickets' ); ?></span>
<?php endif; ?>
</div>
14 changes: 14 additions & 0 deletions src/views/editor/blocks/rsvp/details/description.php
@@ -0,0 +1,14 @@
<?php
/**
* This template renders the RSVP ticket description
*
* @version 0.3.0-alpha
*
*/
if ( ! $ticket->show_description() ) {
return;
}
?>
<div class="tribe-block__rsvp__description">
<?php echo wpautop( esc_html( $ticket->description ) ); ?>
</div>
11 changes: 11 additions & 0 deletions src/views/editor/blocks/rsvp/details/title.php
@@ -0,0 +1,11 @@
<?php
/**
* This template renders the RSVP ticket title
*
* @version 0.3.0-alpha
*
*/
?>
<header class="tribe-block__rsvp__title">
<?php echo esc_html( $ticket->name ); ?>
</header>
11 changes: 11 additions & 0 deletions src/views/editor/blocks/rsvp/form.php
@@ -0,0 +1,11 @@
<?php
/**
* This template renders the div that will receive the
* form from rsvp/form/form.php via AJAX
*
* @version 0.3.0-alpha
*
*/
?>
<!-- This div is where the AJAX returns the form -->
<div class="tribe-block__rsvp__form"></div>
26 changes: 26 additions & 0 deletions src/views/editor/blocks/rsvp/form/email.php
@@ -0,0 +1,26 @@
<?php
/**
* This template renders the RSVP ticket form email input
*
* @version 0.3.0-alpha
*
*/
/**
* Set the default value for the email on the RSVP form.
*
* @param string
* @param Tribe__Events_Gutenberg__Template $this
*
* @since 0.3.0-alpha
*
*/
$email = apply_filters( 'tribe_tickets_rsvp_form_email', '', $this );
?>
<input
type="email"
name="attendee[email]"
class="tribe-tickets-email"
placeholder="<?php esc_attr_e( 'Email', 'events-gutenberg' ); ?>"
value="<?php echo esc_attr( $email ); ?>"
required
/>
13 changes: 13 additions & 0 deletions src/views/editor/blocks/rsvp/form/error.php
@@ -0,0 +1,13 @@
<?php
/**
* This template renders the RSVP ticket error message on the form
*
* @version 0.3.0-alpha
*
*/
?>
<div class="tribe-block__rsvp__message__error">

<?php esc_html_e( 'Please fill in the RSVP confirmation name and email fields.', 'events-gutenberg' ); ?>

</div>