Making WordPress.org

Changeset 13906


Ignore:
Timestamp:
07/17/2024 11:19:52 AM (22 months ago)
Author:
psrpinto
Message:

Translate: Sync "Translation Events" from GitHub

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events
Files:
24 added
4 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/assets/css/translation-events.css

    r13800 r13906  
    8989    margin-right: 1em;
    9090    margin-bottom: .5em;
    91     width: 15em;
     91    width: 20em;
    9292}
    9393
     
    472472    border-color: var(----gp-color-btn-danger-hover-border);
    473473}
     474form.add-remove-user-as-host .button {
     475    margin-bottom: 4px;
     476}
     477
     478p.onsite-btn-note {
     479    font-size: .8em;
     480}
     481
     482label.event-radio-label {
     483    width: auto;
     484}
    474485
    475486/* show the event-details-right below instead of on the right on mobile */
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/autoload.php

    r13800 r13906  
    33require_once __DIR__ . '/includes/upgrade.php';
    44require_once __DIR__ . '/includes/urls.php';
     5require_once __DIR__ . '/includes/theme-loader.php';
    56require_once __DIR__ . '/includes/templates.php';
    67require_once __DIR__ . '/includes/routes/route.php';
     
    3637require_once __DIR__ . '/includes/routes/attendee/list.php';
    3738require_once __DIR__ . '/includes/routes/attendee/remove.php';
     39require_once __DIR__ . '/includes/routes/user/attendance-mode.php';
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/attendee/attendee-repository.php

    r13753 r13906  
    1616        $wpdb->query(
    1717            $wpdb->prepare(
    18                 "insert ignore into {$gp_table_prefix}event_attendees (event_id, user_id, is_host, is_new_contributor) values (%d, %d, %d, %d)",
     18                "insert ignore into {$gp_table_prefix}event_attendees (event_id, user_id, is_host, is_new_contributor, is_remote) values (%d, %d, %d, %d, %d)",
    1919                array(
    2020                    'event_id'           => $attendee->event_id(),
     
    2222                    'is_host'            => $attendee->is_host() ? 1 : 0,
    2323                    'is_new_contributor' => $attendee->is_new_contributor() ? 1 : 0,
     24                    'is_remote'          => $attendee->is_remote() ? 1 : 0,
    2425                ),
    2526            ),
     
    4344        $wpdb->update(
    4445            "{$gp_table_prefix}event_attendees",
    45             array( 'is_host' => $attendee->is_host() ? 1 : 0 ),
     46            array(
     47                'is_host'   => $attendee->is_host() ? 1 : 0,
     48                'is_remote' => $attendee->is_remote() ? 1 : 0,
     49            ),
    4650            array(
    4751                'event_id' => $attendee->event_id(),
     
    132136                        is_host,
    133137                        is_new_contributor,
     138                        is_remote,
    134139                        (
    135140                            select group_concat( distinct locale )
     
    159164                    '1' === $row->is_new_contributor,
    160165                    null === $row->locales ? array() : explode( ',', $row->locales ),
     166                    '1' === $row->is_remote,
    161167                );
    162168            },
     
    184190                    is_host,
    185191                    is_new_contributor,
     192                    is_remote,
    186193                    (
    187194                        select group_concat( distinct locale )
     
    209216                    '1' === $row->is_new_contributor,
    210217                    null === $row->locales ? array() : explode( ',', $row->locales ),
     218                    '1' === $row->is_remote,
    211219                );
    212220            },
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/attendee/attendee.php

    r13739 r13906  
    1010    private bool $is_host;
    1111    private bool $is_new_contributor;
     12    private bool $is_remote;
    1213
    1314    /**
     
    1920     * @throws Exception
    2021     */
    21     public function __construct( int $event_id, int $user_id, bool $is_host = false, $is_new_contributor = false, array $contributed_locales = array() ) {
     22    public function __construct( int $event_id, int $user_id, bool $is_host = false, $is_new_contributor = false, array $contributed_locales = array(), $is_remote = false ) {
    2223        if ( $event_id < 1 ) {
    2324            throw new Exception( 'invalid event id' );
     
    3132        $this->is_host             = $is_host;
    3233        $this->is_new_contributor  = $is_new_contributor;
     34        $this->is_remote           = $is_remote;
    3335        $this->contributed_locales = $contributed_locales;
    3436    }
     
    5456    }
    5557
     58    public function is_remote(): bool {
     59        return $this->is_remote;
     60    }
     61
    5662    public function mark_as_host(): void {
    5763        $this->is_host = true;
     
    6672    }
    6773
     74    public function mark_as_remote_attendee(): void {
     75        $this->is_remote = true;
     76    }
     77
     78    public function mark_as_in_person_attendee(): void {
     79        $this->is_remote = false;
     80    }
     81
    6882    /**
    6983     * @return string[]
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-capabilities.php

    r13800 r13906  
    1313
    1414class Event_Capabilities {
    15     private const MANAGE           = 'manage_translation_events';
    16     private const CREATE           = 'create_translation_event';
    17     private const VIEW             = 'view_translation_event';
    18     private const EDIT             = 'edit_translation_event';
    19     private const TRASH            = 'trash_translation_event';
    20     private const DELETE           = 'delete_translation_event';
    21     private const EDIT_ATTENDEES   = 'edit_translation_event_attendees';
    22     private const EDIT_TITLE       = 'edit_translation_event_title';
    23     private const EDIT_DESCRIPTION = 'edit_translation_event_description';
    24     private const EDIT_START       = 'edit_translation_event_start';
    25     private const EDIT_END         = 'edit_translation_event_end';
    26     private const EDIT_TIMEZONE    = 'edit_translation_event_timezone';
     15    private const MANAGE               = 'manage_translation_events';
     16    private const CREATE               = 'create_translation_event';
     17    private const VIEW                 = 'view_translation_event';
     18    private const EDIT                 = 'edit_translation_event';
     19    private const TRASH                = 'trash_translation_event';
     20    private const DELETE               = 'delete_translation_event';
     21    private const EDIT_ATTENDEES       = 'edit_translation_event_attendees';
     22    private const EDIT_TITLE           = 'edit_translation_event_title';
     23    private const EDIT_DESCRIPTION     = 'edit_translation_event_description';
     24    private const EDIT_START           = 'edit_translation_event_start';
     25    private const EDIT_END             = 'edit_translation_event_end';
     26    private const EDIT_TIMEZONE        = 'edit_translation_event_timezone';
     27    private const EDIT_ATTENDANCE_MODE = 'edit_translation_event_attendance_mode';
    2728
    2829    /**
     
    4243        self::EDIT_END,
    4344        self::EDIT_TIMEZONE,
     45        self::EDIT_ATTENDANCE_MODE,
    4446    );
    4547
     
    8587            case self::EDIT_END:
    8688            case self::EDIT_TIMEZONE:
     89            case self::EDIT_ATTENDANCE_MODE:
    8790                if ( ! isset( $args[2] ) || ! is_numeric( $args[2] ) ) {
    8891                    return false;
     
    108111                    return $this->has_edit_attendees( $user, $event );
    109112                }
    110                 if ( self::EDIT_TITLE === $cap || self::EDIT_DESCRIPTION === $cap || self::EDIT_START === $cap || self::EDIT_END === $cap || self::EDIT_TIMEZONE === $cap ) {
     113                if ( self::EDIT_TITLE === $cap || self::EDIT_DESCRIPTION === $cap || self::EDIT_START === $cap || self::EDIT_END === $cap || self::EDIT_TIMEZONE === $cap || self::EDIT_ATTENDANCE_MODE === $cap ) {
    111114                    return $this->has_edit_field( $user, $event, $cap );
    112115                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-form-handler.php

    r13857 r13906  
    152152                    if ( current_user_can( 'edit_translation_event_end', $event->id() ) ) {
    153153                        $event->set_end( $new_event->end() );
     154                    }
     155                    if ( current_user_can( 'edit_translation_event_attendance_mode', $event->id() ) ) {
     156                        $event->set_attendance_mode( $new_event->attendance_mode() );
    154157                    }
    155158                } catch ( Exception $e ) {
     
    198201        // This will be sanitized by sanitize_post which is called in wp_insert_post.
    199202        // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
    200         $description    = isset( $data['event_description'] ) ? force_balance_tags( wp_unslash( $data['event_description'] ) ) : '';
    201         $event_start    = isset( $data['event_start'] ) ? sanitize_text_field( wp_unslash( $data['event_start'] ) ) : '';
    202         $event_end      = isset( $data['event_end'] ) ? sanitize_text_field( wp_unslash( $data['event_end'] ) ) : '';
    203         $event_timezone = isset( $data['event_timezone'] ) ? sanitize_text_field( wp_unslash( $data['event_timezone'] ) ) : '';
     203        $description     = isset( $data['event_description'] ) ? force_balance_tags( wp_unslash( $data['event_description'] ) ) : '';
     204        $event_start     = isset( $data['event_start'] ) ? sanitize_text_field( wp_unslash( $data['event_start'] ) ) : '';
     205        $event_end       = isset( $data['event_end'] ) ? sanitize_text_field( wp_unslash( $data['event_end'] ) ) : '';
     206        $event_timezone  = isset( $data['event_timezone'] ) ? sanitize_text_field( wp_unslash( $data['event_timezone'] ) ) : '';
     207        $attendance_mode = isset( $data['event_attendance_mode'] ) ? sanitize_text_field( wp_unslash( $data['event_attendance_mode'] ) ) : 'onsite';
    204208
    205209        $event_status = '';
     
    234238            $title,
    235239            $description,
     240            $attendance_mode,
    236241        );
    237242        $event->set_id( intval( $event_id ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-repository.php

    r13800 r13906  
    145145                $post->post_title,
    146146                $post->post_content,
     147                $meta['attendance_mode'],
    147148            );
    148149            $event->set_id( $post->ID );
     
    532533                $title = ' ';
    533534            }
     535            if ( empty( $meta['attendance_mode'] ) ) {
     536                $meta['attendance_mode'] = 'onsite';
     537            }
    534538
    535539            $event = new Event(
     
    541545                $title,
    542546                $post->post_content,
     547                $meta['attendance_mode'],
    543548            );
    544549            $event->set_id( $post->ID );
     
    577582
    578583        return array(
    579             'start'    => new Event_Start_Date( $meta['_event_start'][0], $utc ),
    580             'end'      => new Event_End_Date( $meta['_event_end'][0], $utc ),
    581             'timezone' => new DateTimeZone( $meta['_event_timezone'][0] ),
     584            'start'           => new Event_Start_Date( $meta['_event_start'][0], $utc ),
     585            'end'             => new Event_End_Date( $meta['_event_end'][0], $utc ),
     586            'timezone'        => new DateTimeZone( $meta['_event_timezone'][0] ),
     587            'attendance_mode' => ! isset( $meta['_event_attendance_mode'][0] ) ? 'onsite' : $meta['_event_attendance_mode'][0],
    582588        );
    583589    }
     
    596602        update_post_meta( $event->id(), '_event_timezone', $event->timezone()->getName() );
    597603        update_post_meta( $event->id(), '_hosts', $hosts_ids );
     604        update_post_meta( $event->id(), '_event_attendance_mode', $event->attendance_mode() );
    598605    }
    599606}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event.php

    r13800 r13906  
    4343    private string $title;
    4444    private string $description;
     45    private string $attendance_mode;
    4546
    4647    /**
     
    5657        string $status,
    5758        string $title,
    58         string $description
     59        string $description,
     60        string $attendance_mode = 'onsite'
    5961    ) {
    6062        $this->author_id = $author_id;
     
    6668        $this->set_title( $title );
    6769        $this->set_description( $description );
     70        $this->set_attendance_mode( $attendance_mode );
    6871    }
    6972
     
    103106    public function is_past(): bool {
    104107        return $this->end->is_in_the_past();
     108    }
     109
     110    public function is_remote(): bool {
     111        return 'remote' === $this->attendance_mode;
     112    }
     113
     114    public function is_hybrid(): bool {
     115        return 'hybrid' === $this->attendance_mode;
    105116    }
    106117
     
    145156    }
    146157
     158    public function attendance_mode(): string {
     159        return $this->attendance_mode;
     160    }
     161
    147162    /**
    148163     * @throws InvalidStatus
     
    163178    }
    164179
     180    public function set_attendance_mode( string $attendance_mode ): void {
     181        $this->attendance_mode = $attendance_mode;
     182    }
     183
    165184    /**
    166185     * @throws InvalidStart
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/routes/route.php

    r13739 r13906  
    55use GP_Route;
    66use Wporg\TranslationEvents\Templates;
     7use Wporg\TranslationEvents\Theme_Loader;
    78
    89abstract class Route extends GP_Route {
     10    private Theme_Loader $theme_loader;
     11    private bool $use_theme = false;
     12
     13    public function __construct() {
     14        parent::__construct();
     15        $this->theme_loader = new Theme_Loader( 'wporg-translate-events-2024' );
     16    }
     17
    918    public function tmpl( $template, $args = array(), $honor_api = true ) {
    1019        $this->set_notices_and_errors();
    1120        $this->header( 'Content-Type: text/html; charset=utf-8' );
    1221
    13         Templates::render( $template, $args );
     22        if ( ! $this->use_theme ) {
     23            $this->enqueue_legacy_styles();
     24            Templates::render( $template, $args );
     25            return;
     26        }
     27
     28        $json = wp_json_encode( $args );
     29        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     30        echo do_blocks( "<!-- wp:wporg-translate-events-2024/page-events-$template $json /-->" );
     31    }
     32
     33    protected function use_theme( bool $also_in_production = false ): void {
     34        if ( $also_in_production ) {
     35            $this->use_theme = true;
     36        } else {
     37            // Only enable if new design has been explicitly enabled.
     38            $this->use_theme = defined( 'TRANSLATION_EVENTS_NEW_DESIGN' ) && TRANSLATION_EVENTS_NEW_DESIGN;
     39        }
     40
     41        if ( ! $this->use_theme ) {
     42            return;
     43        }
     44
     45        $this->theme_loader->load();
     46    }
     47
     48    private function enqueue_legacy_styles(): void {
     49        wp_register_style(
     50            'translation-events-css',
     51            plugins_url( '/assets/css/translation-events.css', realpath( __DIR__ . '/../' ) ),
     52            array( 'dashicons' ),
     53            filemtime( __DIR__ . '/../../assets/css/translation-events.css' )
     54        );
     55        wp_enqueue_style( 'translation-events-css' );
    1456    }
    1557}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/routes/user/attend-event.php

    r13753 r13906  
    3232
    3333    public function handle( int $event_id ): void {
     34        $nonce_name = '_attendee_nonce';
     35        if ( isset( $_POST['_attendee_nonce'] ) ) {
     36            $nonce_value = sanitize_text_field( wp_unslash( $_POST['_attendee_nonce'] ) );
     37            if ( ! wp_verify_nonce( $nonce_value, $nonce_name ) ) {
     38                $this->die_with_error( esc_html__( 'You are not authorized to change the attendance mode of this attendee', 'gp-translation-events' ), 403 );
     39            }
     40        }
    3441        $user = wp_get_current_user();
    3542        if ( ! $user ) {
     
    4754        }
    4855
    49         $attendee = $this->attendee_repository->get_attendee_for_event_for_user( $event->id(), $user_id );
     56        $attendee           = $this->attendee_repository->get_attendee_for_event_for_user( $event->id(), $user_id );
     57        $is_remote_attendee = isset( $_POST['attend_remotely'] );
     58
    5059        if ( $attendee instanceof Attendee ) {
    5160            if ( $attendee->is_contributor() ) {
     
    5463            $this->attendee_repository->remove_attendee( $event->id(), $user_id );
    5564        } else {
    56             $attendee = new Attendee( $event->id(), $user_id );
     65            $attendee = new Attendee( $event->id(), $user_id, false, false, array(), $is_remote_attendee );
    5766            $this->attendee_adder->add_to_event( $event, $attendee );
    5867        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/routes/user/my-events.php

    r13800 r13906  
    5252        $current_user_attendee_per_event = $this->attendee_repository->get_attendees_for_events_for_user( $event_ids, $user_id );
    5353
    54         Templates::use_new_design();
     54        $this->use_theme();
    5555        $this->tmpl(
    5656            'my-events',
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/templates.php

    r13800 r13906  
    33namespace Wporg\TranslationEvents;
    44
     5/**
     6 * Legacy (non-theme) templates.
     7 */
    58class Templates {
    6     private static bool $use_new_design = false;
    7 
    8     public static function use_new_design( bool $also_in_production = false ): void {
    9         if ( $also_in_production ) {
    10             // If it's enabled for production, it's also enabled for development, so it's always enabled.
    11             self::$use_new_design = true;
    12         } else {
    13             // Only enable if new design has been explicitly enabled.
    14             self::$use_new_design = defined( 'TRANSLATION_EVENTS_NEW_DESIGN' ) && TRANSLATION_EVENTS_NEW_DESIGN;
    15         }
    16 
    17         if ( self::$use_new_design ) {
    18             wp_register_style(
    19                 'translation-events-new-design-css',
    20                 plugins_url( 'assets/css/new-design.css', __DIR__ ),
    21                 array( 'dashicons' ),
    22                 filemtime( __DIR__ . '/../assets/css/new-design.css' )
    23             );
    24             gp_enqueue_styles( 'translation-events-new-design-css' );
    25         }
    26     }
    27 
    28     public static function render( string $template, array $data = array() ) {
    29         $template_path = __DIR__ . '/../templates/';
    30         if ( self::$use_new_design ) {
    31             $template_path = $template_path . 'new-design/';
    32         }
    33 
    34         gp_tmpl_load( $template, $data, $template_path );
    35     }
     9    private const LEGACY_TEMPLATE_DIRECTORY = __DIR__ . '/../templates/';
    3610
    3711    public static function header( array $data = array() ) {
     
    4317    }
    4418
    45     public static function part( string $template, array $data ) {
     19    public static function part( string $template, array $data = array() ) {
    4620        self::render( "parts/$template", $data );
    4721    }
     22
     23    public static function render( string $template, array $data = array() ) {
     24        gp_tmpl_load( $template, $data, self::LEGACY_TEMPLATE_DIRECTORY );
     25    }
    4826}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/upgrade.php

    r13739 r13906  
    77
    88class Upgrade {
    9     private const VERSION        = 3;
     9    private const VERSION        = 4;
    1010    private const VERSION_OPTION = 'wporg_gp_translations_events_version';
    1111
     
    6363                `is_host` tinyint(1) default 0 not null comment 'Whether the user is a host of the event',
    6464                `is_new_contributor` tinyint(1) default 0 not null comment 'Whether the user is a new translation contributor',
     65                `is_remote` tinyint(1) default 0 not null comment 'Whether the user attends the event remotely',
    6566            PRIMARY KEY (`translate_event_attendees_id`),
    6667            UNIQUE KEY `event_per_user` (`event_id`,`user_id`),
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/urls.php

    r13753 r13906  
    8989        return gp_url( "/events/$event_id/attendees/remove/$user_id" );
    9090    }
     91
     92    public static function event_toggle_attendance_mode( int $event_id, int $user_id ): string {
     93        return gp_url( "/events/attendance-mode/$event_id/$user_id" );
     94    }
    9195}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-attendees.php

    r13801 r13906  
    3232            <tr>
    3333                <th scope="col"><?php esc_html_e( 'Name', 'gp-translation-events' ); ?></th>
     34                <th><?php esc_html_e( 'Remote', 'gp-translation-events' ); ?></th>
    3435                <th><?php esc_html_e( 'Host', 'gp-translation-events' ); ?></th>
    3536                <th><?php esc_html_e( 'Action', 'gp-translation-events' ); ?></th>
     
    4243                        <a class="attendee-avatar" href="<?php echo esc_url( get_author_posts_url( $attendee->user_id() ) ); ?>" class="avatar"><?php echo get_avatar( $attendee->user_id(), 48 ); ?></a>
    4344                        <a href="<?php echo esc_url( get_author_posts_url( $attendee->user_id() ) ); ?>" class="name"><?php echo esc_html( get_the_author_meta( 'display_name', $attendee->user_id() ) ); ?></a>
     45                        <?php if ( $attendee->is_new_contributor() ) : ?>
     46                            <span class="first-time-contributor-tada" title="<?php esc_attr_e( 'New Translation Contributor', 'gp-translation-events' ); ?>"></span>
     47                        <?php endif; ?>
     48                    </td>
     49                    <td>
     50                        <?php if ( $attendee->is_remote() ) : ?>
     51                            <span><?php esc_html_e( 'Yes', 'gp-translation-events' ); ?></span>
     52                            <?php endif; ?>
    4453                    </td>
    4554                    <td>
     
    5463                            <?php else : ?>
    5564                                    <input type="submit" class="button is-secondary convert-to-host" value="<?php echo esc_attr__( 'Make co-host', 'gp-translation-events' ); ?>"/>
     65                            <?php endif; ?>
     66                            <?php if ( $event->is_hybrid() ) : ?>
     67                                <a href="<?php echo esc_url( Urls::event_toggle_attendance_mode( $event->id(), $attendee->user_id() ) ); ?>" class="button set-attendance-mode"><?php $attendee->is_remote() ? esc_html_e( 'Set as on-site', 'gp-translation-events' ) : esc_html_e( 'Set as remote', 'gp-translation-events' ); ?></a>
    5668                            <?php endif; ?>
    5769                            <?php if ( ! $attendee->is_host() ) : ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-details.php

    r13801 r13906  
    102102                            <a href="<?php echo esc_url( get_author_posts_url( $contributor->user_id() ) ); ?>" class="name"><?php echo esc_html( get_the_author_meta( 'display_name', $contributor->user_id() ) ); ?></a>
    103103                            <?php if ( $contributor->is_new_contributor() ) : ?>
    104                                 <span class="first-time-contributor-tada" title="<?php esc_html_e( 'New Translation Contributor', 'gp-translation-events' ); ?>"></span>
     104                                <span class="first-time-contributor-tada" title="<?php esc_attr_e( 'New Translation Contributor', 'gp-translation-events' ); ?>"></span>
    105105                            <?php endif; ?>
    106106                        </li>
     
    285285            <?php else : ?>
    286286                <form class="event-details-attend" method="post" action="<?php echo esc_url( Urls::event_toggle_attendee( $event->id() ) ); ?>">
     287                    <?php wp_nonce_field( '_attendee_nonce', '_attendee_nonce' ); ?>
    287288                    <?php if ( $user_is_attending ) : ?>
    288289                        <input type="submit" class="button is-secondary attending-btn" value="<?php esc_attr_e( "You're attending", 'gp-translation-events' ); ?>" />
    289290                    <?php else : ?>
    290                         <input type="submit" class="button is-primary attend-btn" value="<?php esc_attr_e( 'Attend Event', 'gp-translation-events' ); ?>"/>
     291                        <?php if ( ! $event->is_remote() ) : ?>
     292                            <input type="submit" class="button is-primary attend-btn" value="<?php esc_attr_e( 'Attend Event On-site', 'gp-translation-events' ); ?>"/>
     293                            <?php if ( ! $event->is_hybrid() ) : ?>
     294                                <p class="onsite-btn-note">
     295                                    <?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' ) ); ?>
     296                                </p>   
     297                            <?php endif; ?>
     298                        <?php endif; ?>
     299                        <?php if ( $event->is_remote() || $event->is_hybrid() ) : ?>
     300                            <input type="submit" name="attend_remotely" class="button is-primary attend-btn" value="<?php esc_attr_e( 'Attend Event Remotely', 'gp-translation-events' ); ?>"/>
     301                        <?php endif; ?>
    291302                    <?php endif; ?>
    292303                </form>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/home.php

    r13857 r13906  
    2020);
    2121?>
    22 
    2322<div class="event-page-wrapper">
     23    <div class="notice" style="padding: .5rem">
     24        <?php
     25        echo wp_kses(
     26            sprintf(
     27            // translators: %s is a link to a page about hosting events.
     28                __( 'Do you want to host your own event? <a href="%s">Find more information here</a>.', 'gp-translation-events' ),
     29                'https://make.wordpress.org/polyglots/2024/05/29/translation-events-inviting-gtes-to-create-and-manage-events/'
     30            ),
     31            array( 'a' => array( 'href' => array() ) )
     32        );
     33        ?>
     34    </div>
    2435<div class="event-left-col">
    2536<?php
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/parts/event-form.php

    r13801 r13906  
    7272            </select>
    7373        </div>
     74        <div>
     75            <label for="event-attendance-mode"><?php esc_html_e( 'Attendance Mode', 'gp-translation-events' ); ?></label>
     76            <label class="event-radio-label" title="Attendees can attend remotely and on-site">
     77                <input type="radio" id="event-attendance-mode-hybrid" name="event_attendance_mode" <?php echo $event->is_hybrid() ? esc_attr( 'checked' ) : ''; ?> value="hybrid" required>
     78                <?php esc_html_e( 'Hybrid (Remote and On-site)', 'gp-translation-events' ); ?>
     79            </label>
     80            <label class="event-radio-label" title="Attendees can only attend remotely">
     81                <input type="radio" id="event-attendance-mode-remote" name="event_attendance_mode" <?php echo $event->is_remote() ? esc_attr( 'checked' ) : ''; ?> value="remote" required>
     82                <?php esc_html_e( 'Remote', 'gp-translation-events' ); ?>
     83            </label>
     84            <label class="event-radio-label" title="Attendees can only attend on-site">
     85                <input type="radio" id="event-attendance-mode-onsite" name="event_attendance_mode" <?php echo ! $event->is_hybrid() && ! $event->is_remote() ? esc_attr( 'checked' ) : ''; ?> value="onsite" required>
     86                <?php esc_html_e( 'On-site', 'gp-translation-events' ); ?>
     87            </label>
     88        </div>
    7489        <div class="submit-btn-group">
    7590            <label for="event-status"></label>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/wporg-gp-translation-events.php

    r13857 r13906  
    8383
    8484    public function __construct() {
     85        register_theme_directory( __DIR__ . '/themes' );
     86
    8587        add_action( 'wp_ajax_submit_event_ajax', array( $this, 'submit_event_ajax' ) );
    8688        add_action( 'wp_ajax_nopriv_submit_event_ajax', array( $this, 'submit_event_ajax' ) );
     
    132134        GP::$router->add( "/events/$slug/attendees", array( 'Wporg\TranslationEvents\Routes\Attendee\List_Route', 'handle' ) );
    133135        GP::$router->add( "/events/$id/attendees/remove/$id", array( 'Wporg\TranslationEvents\Routes\Attendee\Remove_Attendee_Route', 'handle' ) );
     136        GP::$router->add( "/events/attendance-mode/$id/$id", array( 'Wporg\TranslationEvents\Routes\User\Attendance_Mode_Route', 'handle' ), 'get' );
    134137
    135138        $stats_listener = new Stats_Listener( self::get_event_repository() );
    136139        $stats_listener->start();
     140    }
     141
     142    public function register_translation_event_js() {
     143        wp_register_script(
     144            'translation-events-js',
     145            plugins_url( 'assets/js/translation-events.js', __FILE__ ),
     146            array( 'jquery', 'gp-common' ),
     147            filemtime( __DIR__ . '/assets/js/translation-events.js' ),
     148            false
     149        );
     150        gp_enqueue_script( 'translation-events-js' );
     151        wp_localize_script(
     152            'translation-events-js',
     153            '$translation_event',
     154            array(
     155                'url'          => admin_url( 'admin-ajax.php' ),
     156                '_event_nonce' => wp_create_nonce( self::CPT ),
     157            )
     158        );
    137159    }
    138160
     
    266288    }
    267289
    268     public function register_translation_event_js() {
    269         wp_register_style( 'translation-events-css', plugins_url( 'assets/css/translation-events.css', __FILE__ ), array( 'dashicons' ), filemtime( __DIR__ . '/assets/css/translation-events.css' ) );
    270         gp_enqueue_styles( 'translation-events-css' );
    271         wp_register_script( 'translation-events-js', plugins_url( 'assets/js/translation-events.js', __FILE__ ), array( 'jquery', 'gp-common' ), filemtime( __DIR__ . '/assets/js/translation-events.js' ), false );
    272         gp_enqueue_script( 'translation-events-js' );
    273         wp_localize_script(
    274             'translation-events-js',
    275             '$translation_event',
    276             array(
    277                 'url'          => admin_url( 'admin-ajax.php' ),
    278                 '_event_nonce' => wp_create_nonce( self::CPT ),
    279             )
    280         );
    281     }
    282 
    283290    /**
    284291     * Handle the event status transition.
     
    431438     */
    432439    public function wp_post_revision_meta_keys( array $keys ): array {
    433         $meta_keys_to_keep = array( '_event_start', '_event_end', '_event_timezone', '_hosts' );
     440        $meta_keys_to_keep = array( '_event_start', '_event_end', '_event_timezone', '_hosts', '_event_attendance_mode' );
    434441        return array_merge( $keys, $meta_keys_to_keep );
    435442    }
Note: See TracChangeset for help on using the changeset viewer.