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

Add edit link to event details page #367

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
}
$event_id = $attributes['id'];
$user_is_attending = $attributes['user_is_attending'];
$user_is_contributor = $attributes['user_is_contributor'];
$event = Translation_Events::get_event_repository()->get_event( $event_id );
if ( ! $event ) {
return '';
Expand All @@ -24,31 +23,20 @@
if ( is_user_logged_in() ) :
?>
<div class="event-details-join">
<?php if ( $event->end()->is_in_the_past() ) : ?>
<?php if ( $user_is_attending ) : ?>
<p class="has-charcoal-4-color has-text-color has-small-font-size" style="margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--20)"><?php esc_html_e( 'You attended this event.', 'wporg-translate-events-2024' ); ?></p>
<?php endif; ?>
<?php elseif ( $user_is_contributor ) : ?>
<?php // Contributors can't un-attend so don't show anything. ?>
<?php else : ?>
<form class="event-details-attend" method="post" action="<?php echo esc_url( Urls::event_toggle_attendee( $event->id() ) ); ?>">
<?php if ( ! $event->end()->is_in_the_past() ) : ?>
<form class="event-details-attend" method="post" action="<?php echo esc_url( Urls::event_toggle_attendee( $event->id() ) ); ?>">
<?php wp_nonce_field( '_attendee_nonce', '_attendee_nonce' ); ?>
<?php if ( $user_is_attending ) : ?>
<input type="submit" class="wp-block-button__link" value="<?php esc_attr_e( "You're attending", 'gp-translation-events' ); ?>" />
<?php else : ?>
<?php if ( ! $event->is_remote() ) : ?>
<input type="submit" class="wp-block-button__link" value="<?php esc_attr_e( 'Attend Event On-site', 'gp-translation-events' ); ?>"/>
<?php if ( ! $event->is_hybrid() ) : ?>
<p class="onsite-btn-note">
<?php echo wp_kses_post( __( '<strong>Note:</strong> This is an onsite-only event. Please only click attend if you are at the event. The host might otherwise remove you.', 'gp-translation-events' ) ); ?>
</p>
<?php endif; ?>
<?php endif; ?>
<?php if ( $event->is_remote() || $event->is_hybrid() ) : ?>
<input type="submit" name="attend_remotely" class="wp-block-button__link" value="<?php esc_attr_e( 'Attend Event Remotely', 'gp-translation-events' ); ?>"/>
<?php endif; ?>
<input type="submit" class="wp-block-button__link" value="<?php esc_attr_e( "You're attending", 'gp-translation-events' ); ?>" />
<?php else : ?>
<?php if ( ! $event->is_remote() ) : ?>
<input type="submit" class="wp-block-button__link" value="<?php esc_attr_e( 'Attend Event On-site', 'gp-translation-events' ); ?>"/>
<?php endif; ?>
<?php if ( $event->is_remote() || $event->is_hybrid() ) : ?>
<input type="submit" name="attend_remotely" class="wp-block-button__link" value="<?php esc_attr_e( 'Attend Event Remotely', 'gp-translation-events' ); ?>"/>
<?php endif; ?>
</form>
<?php endif; ?>
</form>
<?php endif; ?>
</div>
<?php else : ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

use Wporg\TranslationEvents\Attendee\Attendee;
use Wporg\TranslationEvents\Urls;

$event = $attributes['event'];
$user_is_attending = $attributes['user_is_attending'];
Expand All @@ -20,21 +20,59 @@
?>

/-->
<?php
if ( $event->is_past() ) :
?>
<!-- wp:wporg/notice {"type":"alert", "style":{"spacing":{"margin":{"top":"var:preset|spacing|20"}}}} -->
<div class="wp-block-wporg-notice is-alert-notice" style="margin-top:var(--wp--preset--spacing--20)">
<div class="wp-block-wporg-notice__icon"></div>
<div class="wp-block-wporg-notice__content">
<p>
<?php echo esc_html__( 'This event has ended.', 'wporg-translate-events-2024' ); ?>
</p>
</div>
</div>
<!-- /wp:wporg/notice -->

<?php if ( current_user_can( 'edit_translation_event', $event->id() ) ) : ?>
<a class="details-edit-event" href="<?php echo esc_url( Urls::event_edit( $event->id() ) ); ?>">
<span class="dashicons dashicons-edit"></span><?php echo esc_html__( 'Edit Event', 'wporg-translate-events-2024' ); ?>
</a>
<?php endif; ?>

<?php
if ( is_user_logged_in() ) :
if ( $event->is_past() ) :
?>
<!-- wp:wporg/notice {"type":"alert", "style":{"spacing":{"margin":{"top":"var:preset|spacing|20"}}}} -->
<div class="wp-block-wporg-notice is-alert-notice" style="margin-top:var(--wp--preset--spacing--20)">
<div class="wp-block-wporg-notice__icon"></div>
<div class="wp-block-wporg-notice__content">
<p>
<?php echo esc_html__( 'This event has ended.', 'wporg-translate-events-2024' ); ?>
</p>
</div>
</div>
<!-- /wp:wporg/notice -->
<?php
if ( $user_is_attending ) :
?>
<!-- wp:wporg/notice {"type":"info", "style":{"spacing":{"margin":{"top":"var:preset|spacing|20"}}}} -->
<div class="wp-block-wporg-notice is-info-notice" style="margin-top:var(--wp--preset--spacing--20)">
<div class="wp-block-wporg-notice__icon"></div>
<div class="wp-block-wporg-notice__content">
<p>
<?php esc_html_e( 'You attended this event.', 'wporg-translate-events-2024' ); ?>
</p>
</div>
</div>
<!-- /wp:wporg/notice -->
<?php endif; ?>
<?php else : ?>
<?php if ( ! $event->is_hybrid() && ! $event->is_remote() ) : ?>
<!-- wp:wporg/notice {"type":"tip","style":{"spacing":{"margin":{"top":"var:preset|spacing|20"}}}} -->
<div class="wp-block-wporg-notice is-tip-notice" style="margin-top:var(--wp--preset--spacing--20)">
<div class="wp-block-wporg-notice__icon"></div>
<div class="wp-block-wporg-notice__content">
<p>
<?php echo wp_kses_post( __( 'This is an onsite-only event. Please only click attend if you are at the event. The host might otherwise remove you.', 'wporg-translate-events-2024' ) ); ?>
</p>
</div>
</div>
<!-- /wp:wporg/notice -->
<?php endif; ?>
<?php
endif;
endif;
?>

<!-- wp:paragraph -->
<p>
<!-- wp:wporg-translate-events-2024/event-host-list <?php echo wp_json_encode( array( 'id' => $event->id() ) ); ?> /-->
Expand Down
15 changes: 14 additions & 1 deletion themes/wporg-translate-events-2024/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,20 @@ select.wp-block-form-input__input {
background-color: #46b450;
}

@media (min-width: 960px) {
.event-details-join {
display: inline-block;
}

a.details-edit-event span.dashicons-edit {
vertical-align: text-bottom;
}

a.details-edit-event {
float: right;
text-decoration: none;
}

@media (min-width: 960px) {

.wporg-marker-list__container .wporg-marker-list-item {
display: grid;
Expand Down
Loading