Making WordPress.org


Ignore:
Timestamp:
05/09/2024 08:33:51 AM (2 years ago)
Author:
amieiro
Message:

Translate: Sync "Translation Events" from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/events-header.php

    r13541 r13683  
    33namespace Wporg\TranslationEvents;
    44
    5 use GP;
     5use WP_User;
    66use Wporg\TranslationEvents\Attendee\Attendee;
    77use Wporg\TranslationEvents\Event\Event;
    88
     9/** @var WP_User $user */
     10/** @var Attendee[] $hosts */
    911/** @var Attendee $attendee */
    10 /** @var Event  $event */
     12/** @var Event $event */
    1113/** @var string $event_page_title */
    12 /** @var bool   $is_editable_event */
    1314?>
    1415
     
    2223        <ul class="event-list-nav">
    2324                <?php if ( is_user_logged_in() ) : ?>
    24                         <li><a href="<?php echo esc_url( gp_url( '/events/my-events/' ) ); ?>">My Events</a></li>
    25                         <?php
    26                         /**
    27                          * Filter the ability to create, edit, or delete an event.
    28                          *
    29                          * @param bool $can_crud_event Whether the user can create, edit, or delete an event.
    30                          */
    31                         $can_crud_event = apply_filters( 'gp_translation_events_can_crud_event', GP::$permission->current_user_can( 'admin' ) );
    32                         if ( $can_crud_event ) :
    33                                 ?>
    34                                 <li><a class="button is-primary" href="<?php echo esc_url( gp_url( '/events/new/' ) ); ?>">Create Event</a></li>
     25                        <?php if ( current_user_can( 'manage_translation_events' ) ) : ?>
     26                                <li><a href="<?php echo esc_url( Urls::events_trashed() ); ?>">Deleted Events</a></li>
     27                        <?php endif; ?>
     28                        <li><a href="<?php echo esc_url( Urls::my_events() ); ?>">My Events</a></li>
     29                        <?php if ( current_user_can( 'create_translation_event' ) ) : ?>
     30                                <li><a class="button is-primary" href="<?php echo esc_url( Urls::event_create() ); ?>">Create Event</a></li>
    3531                        <?php endif; ?>
    3632                <?php endif; ?>
    3733        </ul>
    38         <?php if ( isset( $event ) && ! isset( $event_form_name ) ) : ?>
     34        <?php if ( isset( $event ) && ! isset( $event_form_name ) && ! isset( $hide_sub_head ) ) : ?>
    3935        <p class="event-sub-head">
    4036                        <span class="event-host">
    4137                                <?php
    42                                 if ( count( $hosts ) > 0 ) :
    43                                         if ( 1 === count( $hosts ) ) :
    44                                                 esc_html_e( 'Host:', 'gp-translation-events' );
     38                                if ( isset( $hosts ) ) :
     39                                        if ( count( $hosts ) > 0 ) :
     40                                                if ( 1 === count( $hosts ) ) :
     41                                                        esc_html_e( 'Host:', 'gp-translation-events' );
     42                                                else :
     43                                                        esc_html_e( 'Hosts:', 'gp-translation-events' );
     44                                                endif;
    4545                                        else :
    46                                                 esc_html_e( 'Hosts:', 'gp-translation-events' );
     46                                                esc_html_e( 'Created by:', 'gp-translation-events' );
     47                                                ?>
     48                                                &nbsp;<a href="<?php echo esc_attr( get_author_posts_url( $user->ID ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $user->ID ) ); ?></a>
     49                                                <?php
    4750                                        endif;
    48                                 else :
    49                                         esc_html_e( 'Created by:', 'gp-translation-events' );
    5051                                        ?>
    51                                         &nbsp;<a href="<?php echo esc_attr( get_author_posts_url( $user->ID ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $user->ID ) ); ?></a>
    52                                         <?php
    53                                 endif;
    54                                 ?>
    55                                 <?php foreach ( $hosts as $host ) : ?>
    56                                         &nbsp;<a href="<?php echo esc_attr( get_author_posts_url( $host->user_id() ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $host->user_id() ) ); ?></a>
    57                                         <?php if ( end( $hosts ) !== $host ) : ?>
    58                                                 ,
    59                                         <?php else : ?>
    60                                                 .
    61                                         <?php endif; ?>
    62                                 <?php endforeach; ?>
     52                                        <?php foreach ( $hosts as $host ) : ?>
     53                                                &nbsp;<a href="<?php echo esc_attr( get_author_posts_url( $host->user_id() ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $host->user_id() ) ); ?></a>
     54                                                <?php if ( end( $hosts ) !== $host ) : ?>
     55                                                        ,
     56                                                <?php else : ?>
     57                                                        .
     58                                                <?php endif; ?>
     59                                        <?php endforeach; ?>
     60                                <?php endif; ?>
    6361                        </span>
    64                         <?php $show_edit_button = ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'edit_post', $event->id() ) ) && $is_editable_event; ?>
    65                         <?php if ( $show_edit_button ) : ?>
    66                                 <a class="event-page-edit-link" href="<?php echo esc_url( gp_url( 'events/edit/' . $event->id() ) ); ?>"><span class="dashicons dashicons-edit"></span><?php esc_html_e( 'Edit event', 'gp-translation-events' ); ?></a>
     62                        <?php if ( current_user_can( 'edit_translation_event', $event->id() ) ) : ?>
     63                                <a class="event-page-edit-link" href="<?php echo esc_url( Urls::event_edit( $event->id() ) ); ?>"><span class="dashicons dashicons-edit"></span><?php esc_html_e( 'Edit event', 'gp-translation-events' ); ?></a>
     64                        <?php elseif ( current_user_can( 'edit_translation_event_attendees', $event->id() ) ) : ?>
     65                                <a class="event-page-attendees-link" href="<?php echo esc_url( Urls::event_attendees( $event->id() ) ); ?>"><?php esc_html_e( 'Manage attendees', 'gp-translation-events' ); ?></a>
    6766                        <?php endif ?>
    6867                </p>
Note: See TracChangeset for help on using the changeset viewer.