Skip to content

Commit

Permalink
Fixed linting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauteri committed Jan 26, 2024
1 parent 0663474 commit 0b7a40e
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build/blocks/events-list/events-list.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '5aeb2dc869f0cb9e38a1');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '5a0952f104a4df5253e4');
2 changes: 1 addition & 1 deletion build/blocks/events-list/events-list.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/events-list/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '6cf2e1c97c8609ffc48b');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '2475de36efc4fadbd98a');
2 changes: 1 addition & 1 deletion build/blocks/events-list/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'f6a9504f57ebd1308ea6');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '0ad9486882f6472eb7e4');
2 changes: 1 addition & 1 deletion build/blocks/rsvp/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/rsvp.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '51c799342898259a8366');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'f162146932e80722650a');
2 changes: 1 addition & 1 deletion build/blocks/rsvp/rsvp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/panels.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-date', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '591755b330a494b563fd');
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-date', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => 'cae20aed2e506b7187c5');
2 changes: 1 addition & 1 deletion build/panels.js

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions includes/core/classes/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,30 +271,30 @@ protected function localize( int $post_id ): array {
$settings = Settings::get_instance();

return array(
'responses' => ( $event->rsvp ) ? $event->rsvp->responses() : array(),
'current_user' => ( $event->rsvp && $event->rsvp->get( get_current_user_id() ) )
'responses' => ( $event->rsvp ) ? $event->rsvp->responses() : array(),
'current_user' => ( $event->rsvp && $event->rsvp->get( get_current_user_id() ) )
? $event->rsvp->get( get_current_user_id() )
: '', // Cleanup needed.
'is_user_logged_in' => is_user_logged_in(),
'default_timezone' => sanitize_text_field( wp_timezone_string() ),
'event_announced' => ( get_post_meta( $post_id, 'gp-event-announce', true ) ) ? 1 : 0,
'event_datetime' => $event->get_datetime(),
'event_rest_api' => home_url( 'wp-json/gatherpress/v1/event' ),
'event_allow_anonymous_rsvp' => ( get_post_meta( $post_id, 'allow_anonymous_rsvp', true ) ) ? 1 : 0,
'has_event_past' => $event->has_event_past(),
'is_admin' => is_admin(),
'nonce' => wp_create_nonce( 'wp_rest' ),
'post_id' => $post_id,
'settings' => array(
'date_format' => $settings->get_value( 'general', 'formatting', 'date_format' ),
'time_format' => $settings->get_value( 'general', 'formatting', 'time_format' ),
'show_timezone' => ( 1 === (int) $settings->get_value( 'general', 'formatting', 'show_timezone' ) ),
'allow_anonymous_rsvp' => ( 1 === (int) $settings->get_value( 'general', 'general', 'allow_anonymous_rsvp' ) ),
'is_user_logged_in' => is_user_logged_in(),
'default_timezone' => sanitize_text_field( wp_timezone_string() ),
'event_announced' => ( get_post_meta( $post_id, 'gp-event-announce', true ) ) ? 1 : 0,
'event_datetime' => $event->get_datetime(),
'event_rest_api' => home_url( 'wp-json/gatherpress/v1/event' ),
'enable_anonymous_rsvp' => (bool) get_post_meta( $post_id, 'enable_anonymous_rsvp', true ),
'has_event_past' => $event->has_event_past(),
'is_admin' => is_admin(),
'nonce' => wp_create_nonce( 'wp_rest' ),
'post_id' => $post_id,
'settings' => array(
'date_format' => $settings->get_value( 'general', 'formatting', 'date_format' ),
'time_format' => $settings->get_value( 'general', 'formatting', 'time_format' ),
'show_timezone' => ( 1 === (int) $settings->get_value( 'general', 'formatting', 'show_timezone' ) ),
'enable_anonymous_rsvp' => ( 1 === (int) $settings->get_value( 'general', 'general', 'enable_anonymous_rsvp' ) ),
),
'login_url' => $this->get_login_url( $post_id ),
'registration_url' => $this->get_registration_url( $post_id ),
'timezone_choices' => Utility::timezone_choices(),
'unregister_blocks' => $this->unregister_blocks(),
'login_url' => $this->get_login_url( $post_id ),
'registration_url' => $this->get_registration_url( $post_id ),
'timezone_choices' => Utility::timezone_choices(),
'unregister_blocks' => $this->unregister_blocks(),
);
}

Expand Down
4 changes: 2 additions & 2 deletions includes/core/classes/class-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static function get_post_type_registration_args(): array {
*/
public static function get_post_meta_registration_args(): array {
return array(
'_online_event_link' => array(
'_online_event_link' => array(
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
Expand All @@ -184,7 +184,7 @@ public static function get_post_meta_registration_args(): array {
'single' => true,
'type' => 'string',
),
'allow_anonymous_rsvp' => array(
'enable_anonymous_rsvp' => array(
'auth_callback' => function() {
return current_user_can( 'edit_posts' );
},
Expand Down
22 changes: 12 additions & 10 deletions includes/core/classes/class-rsvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,17 @@ public function get( int $user_id ): array {
* Save a user's RSVP status for the event.
*
* This method allows assigning a user's RSVP status for the event. The user can be assigned
* one of the following RSVP statuses: 'attending', 'not_attending', or 'waiting_list', and
* optionally specify the number of guests accompanying them. The method handles the storage
* of this information in the database and updates the RSVP status accordingly.
* one of the following RSVP statuses: 'attending', 'not_attending', or 'waiting_list'. The user
* can optionally specify the number of guests accompanying them and whether their RSVP is anonymous.
* The method handles the storage of this information in the database and updates the RSVP status accordingly.
*
* @since 1.0.0
*
* @param int $user_id A user ID.
* @param string $status RSVP status ('attending', 'not_attending', 'waiting_list').
* @param int $guests Number of guests accompanying the user.
* @return string The updated RSVP status ('attending', 'not_attending', 'waiting_list').
* @param int $user_id A user ID.
* @param string $status RSVP status ('attending', 'not_attending', 'waiting_list').
* @param int $anonymous Indicates if the RSVP is anonymous (1 for anonymous, 0 for not anonymous).
* @param int $guests Number of guests accompanying the user.
* @return string The updated RSVP status ('attend', 'attending', 'not_attending', 'waiting_list').
*/
public function save( int $user_id, string $status, int $anonymous = 0, int $guests = 0 ): string {
global $wpdb;
Expand Down Expand Up @@ -176,8 +177,8 @@ public function save( int $user_id, string $status, int $anonymous = 0, int $gue

// If not attending and anonymous, just remove record.
if ( 'not_attending' === $status && $anonymous ) {
$save = $wpdb->delete( $table, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$status = 'attend';
$save = $wpdb->delete( $table, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$status = 'attend'; // Set default status for UI.
} else {
$save = $wpdb->update( $table, $data, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
Expand Down Expand Up @@ -339,8 +340,9 @@ public function responses(): array {

if ( ! current_user_can( 'edit_posts' ) && ! empty( $anonymous ) ) {
$user_id = 0;
$user_info->display_name = __( 'Anonymous', 'gatherpress' );
$profile = '';

$user_info->display_name = __( 'Anonymous', 'gatherpress' );
}

$responses[] = array(
Expand Down
13 changes: 7 additions & 6 deletions includes/core/classes/settings/class-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function get_sections(): array {
'gatherpress'
),
'options' => array(
'post_or_event_date' => array(
'post_or_event_date' => array(
'labels' => array(
'name' => __( 'Publish Date', 'gatherpress' ),
),
Expand All @@ -100,7 +100,7 @@ protected function get_sections(): array {
),
),
),
'max_attending_limit' => array(
'max_attending_limit' => array(
'labels' => array(
'name' => __( 'Maximum Attending Limit', 'gatherpress' ),
),
Expand All @@ -113,12 +113,13 @@ protected function get_sections(): array {
),
),
),
'allow_anonymous_rsvp' => array(
'labels' => array(
'enable_anonymous_rsvp' => array(
'labels' => array(
'name' => __( 'Anonymous RSVPs', 'gatherpress' ),
),
'field' => array(
'label' => __( 'Allow events to permit anonymous RSVPs.', 'gatherpress' ),
'description' => __( 'Set this as your default, but you can still override it for each event as you like.', 'gatherpress' ),
'field' => array(
'label' => __( 'Enable Anonymous RSVPs Across All Events.', 'gatherpress' ),
'type' => 'checkbox',
'options' => array(
'default' => 1,
Expand Down
20 changes: 12 additions & 8 deletions src/components/AnonymousRsvp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ import { useDispatch, useSelect } from '@wordpress/data';
import { getFromGlobal } from '../helpers/globals';

const AnonymousRsvp = () => {
if (!getFromGlobal('settings.allow_anonymous_rsvp')) {
return <></>;
}

const { editPost, unlockPostSaving } = useDispatch('core/editor');
const defaultAnonymousRsvp = useSelect((select) => {
const isNewEvent = useSelect((select) => {
return select('core/editor').isCleanNewPost();
}, []);

let defaultAnonymousRsvp = useSelect((select) => {
return select('core/editor').getEditedPostAttribute('meta')
.allow_anonymous_rsvp;
.enable_anonymous_rsvp;
}, []);

if (isNewEvent) {
defaultAnonymousRsvp = getFromGlobal('settings.enable_anonymous_rsvp');
}

const [anonymousRsvp, setAnonymousRsvp] = useState(defaultAnonymousRsvp);

const updateAnonymousRsvp = (value) => {
const meta = { allow_anonymous_rsvp: Number(value) };
const meta = { enable_anonymous_rsvp: Number(value) };

setAnonymousRsvp(value);
editPost({ meta });
Expand All @@ -34,7 +38,7 @@ const AnonymousRsvp = () => {

return (
<CheckboxControl
label={__('Allow anonymous RSVPs', 'gatherpress')}
label={__('Enable anonymous RSVPs', 'gatherpress')}
checked={anonymousRsvp}
onChange={(value) => {
updateAnonymousRsvp(value);
Expand Down
11 changes: 6 additions & 5 deletions src/components/Rsvp.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import apiFetch from '@wordpress/api-fetch';
import { Broadcaster } from '../helpers/broadcasting';
import RsvpStatusResponse from './RsvpStatusResponse';
import { getFromGlobal } from '../helpers/globals';
import { useSelect } from '@wordpress/data';

/**
* Rsvp component for GatherPress.
Expand All @@ -39,7 +38,9 @@ import { useSelect } from '@wordpress/data';
*/
const Rsvp = ({ eventId, currentUser = '', type }) => {
const [rsvpStatus, setRsvpStatus] = useState(currentUser.status);
const [rsvpAnonymous, setRsvpAnonymous] = useState(Number(currentUser.anonymous));
const [rsvpAnonymous, setRsvpAnonymous] = useState(
Number(currentUser.anonymous)
);
const [rsvpGuests, setRsvpGuests] = useState(currentUser.guests);
const [selectorHidden, setSelectorHidden] = useState('hidden');
const [selectorExpanded, setSelectorExpanded] = useState('false');
Expand Down Expand Up @@ -245,7 +246,7 @@ const Rsvp = ({ eventId, currentUser = '', type }) => {
)
)}
</div>
{1 === getFromGlobal('event_allow_anonymous_rsvp') ?
{getFromGlobal('enable_anonymous_rsvp') ? (
<div className="gp-modal__anonymous">
<input
id="gp-anonymous"
Expand All @@ -267,9 +268,9 @@ const Rsvp = ({ eventId, currentUser = '', type }) => {
{__('List me as anonymous.', 'gatherpress')}
</label>
</div>
:
) : (
<></>
}
)}
{/*@todo Guests feature coming in later version of GatherPress*/}
{/* <label htmlFor="gp-guests">*/}
{/* {__('Number of guests?', 'gatherpress')}*/}
Expand Down
1 change: 0 additions & 1 deletion src/panels/event-settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import DateTimeRangePanel from './datetime-range';
import NotifyMembersPanel from './notify-members';
import OnlineEventLinkPanel from './online-link';
import VenueSelectorPanel from './venue-selector';
import { getFromGlobal } from '../../helpers/globals';

/**
* A settings panel for event-specific settings in the block editor.
Expand Down

0 comments on commit 0b7a40e

Please sign in to comment.