From 489181d3167d2fc1bd4cfc4799f65a43810beeef Mon Sep 17 00:00:00 2001 From: Mike Auteri Date: Thu, 28 Dec 2023 16:39:51 -0500 Subject: [PATCH 1/5] Updates to CLI scripts. --- includes/core/classes/class-autoloader.php | 3 +- includes/core/classes/class-cli.php | 97 +------------- includes/core/classes/class-setup.php | 5 +- .../core/classes/commands/class-cli-event.php | 123 ++++++++++++++++++ .../core/classes/commands/class-general.php | 0 5 files changed, 133 insertions(+), 95 deletions(-) create mode 100644 includes/core/classes/commands/class-cli-event.php create mode 100644 includes/core/classes/commands/class-general.php diff --git a/includes/core/classes/class-autoloader.php b/includes/core/classes/class-autoloader.php index 985374dbf..6937b92e4 100644 --- a/includes/core/classes/class-autoloader.php +++ b/includes/core/classes/class-autoloader.php @@ -46,8 +46,9 @@ static function( $class ): bool { array_unshift( $structure, 'includes' ); switch ( $class_type ) { - case 'traits': + case 'commands': case 'settings': + case 'traits': array_pop( $structure ); array_push( $structure, 'classes', $class_type ); break; diff --git a/includes/core/classes/class-cli.php b/includes/core/classes/class-cli.php index 4018459c1..6d8fdc9b7 100644 --- a/includes/core/classes/class-cli.php +++ b/includes/core/classes/class-cli.php @@ -11,6 +11,8 @@ namespace GatherPress\Core; +use GatherPress\Core\Traits\Singleton; +use GatherPress\Core\Commands\Cli_Event; use WP_CLI; /** @@ -21,98 +23,13 @@ * * @since 1.0.0 */ -class Cli extends WP_CLI { +class Cli { - /** - * Perform actions on an event. - * - * This method allows you to perform various actions related to events, such as adding responses. - * - * @since 1.0.0 - * - * @param array $args Positional arguments for the script. - * @param array $assoc_args Associative arguments for the script. - * @return void - */ - public function event( array $args = array(), array $assoc_args = array() ): void { - $event_id = (int) $args[0]; - $action = (string) $args[1]; + use Singleton; - if ( 'add-response' === $action ) { - $this->add_response( $event_id, $assoc_args ); + protected function __construct() { + if ( defined( 'WP_CLI' ) && WP_CLI ) { // @codeCoverageIgnore + WP_CLI::add_command( 'gatherpress event', Cli_Event::class ); // @codeCoverageIgnore } } - - /** - * Generate credits data for the credits page. - * - * This method generates credits data for displaying on the credits page. - * It retrieves user data from WordPress.org profiles based on the provided version. - * - * @since 1.0.0 - * - * @param array $args Positional arguments for the script. - * @param array $assoc_args Associative arguments for the script. - * @return void - */ - public function generate_credits( array $args = array(), array $assoc_args = array() ): void { - $credits = require_once GATHERPRESS_CORE_PATH . '/includes/data/credits/credits.php'; - $version = $assoc_args['version'] ?? GATHERPRESS_VERSION; - $latest = GATHERPRESS_CORE_PATH . '/includes/data/credits/latest.php'; - $data = array(); - - if ( empty( $credits[ $version ] ) ) { - WP_CLI::error( 'Version does not exist' ); - } - - unlink( $latest ); - $file = fopen( $latest, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen - - $data['version'] = $version; - - foreach ( $credits[ $version ] as $group => $users ) { - if ( 'contributors' === $group ) { - sort( $users ); - } - - $data[ $group ] = array(); - - foreach ( $users as $user ) { - $response = wp_remote_request( sprintf( 'https://profiles.wordpress.org/wp-json/wporg/v1/users/%s', $user ) ); - $user_data = json_decode( $response['body'], true ); - - // Remove unsecure data (eg http) and data we do not need. - unset( $user_data['description'], $user_data['url'], $user_data['meta'], $user_data['_links'] ); - - $data[ $group ][] = $user_data; - } - } - fwrite( $file, 'rsvp->save( $user_id, $status, $guests ); - - WP_CLI::success( $response ); - } - } diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 3e2912bb1..30831d220 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -13,7 +13,6 @@ use Exception; use GatherPress\Core\Traits\Singleton; -use WP_CLI; use WP_Post; /** @@ -55,14 +54,12 @@ protected function __construct() { protected function instantiate_classes(): void { Assets::get_instance(); Block::get_instance(); + Cli::get_instance(); Event_Query::get_instance(); Rest_Api::get_instance(); Settings::get_instance(); Venue::get_instance(); - if ( defined( 'WP_CLI' ) && WP_CLI ) { // @codeCoverageIgnore - WP_CLI::add_command( 'gatherpress', Cli::class ); // @codeCoverageIgnore - } } /** diff --git a/includes/core/classes/commands/class-cli-event.php b/includes/core/classes/commands/class-cli-event.php new file mode 100644 index 000000000..7c1b3959d --- /dev/null +++ b/includes/core/classes/commands/class-cli-event.php @@ -0,0 +1,123 @@ + $users ) { + if ( 'contributors' === $group ) { + sort( $users ); + } + + $data[ $group ] = array(); + + foreach ( $users as $user ) { + $response = wp_remote_request( sprintf( 'https://profiles.wordpress.org/wp-json/wporg/v1/users/%s', $user ) ); + $user_data = json_decode( $response['body'], true ); + + // Remove unsecure data (eg http) and data we do not need. + unset( $user_data['description'], $user_data['url'], $user_data['meta'], $user_data['_links'] ); + + $data[ $group ][] = $user_data; + } + } + fwrite( $file, '] + * : ID of an event. + * + * [--user_id=] + * : ID of a user. + * + * [--status=] + * : Attendance status. + * --- + * default: attending + * options: + * - attending + * - not_attending + * - waiting_list + * + * @since 1.0.0 + * + * @param array $args Positional arguments for the script. + * @param array $assoc_args Associative arguments for the script. + * @return void + */ + public function rsvp( array $args = array(), array $assoc_args = array() ): void { + $event_id = (int) $assoc_args['event_id']; + $user_id = (int) $assoc_args['user_id']; + $status = (string) $assoc_args['status'] ?? 'attending'; + $event = new Event( $event_id ); + + $response = $event->rsvp->save( $user_id, $status ); + + WP_CLI::success( + sprintf( + __( 'The RSVP status for Event ID "%1$d" has been successfully set to "%2$s" for User ID "%3$d".', 'gatherpress' ), + $event_id, + $response, + $user_id + ), + ); + } + +} diff --git a/includes/core/classes/commands/class-general.php b/includes/core/classes/commands/class-general.php new file mode 100644 index 000000000..e69de29bb From c8b5090ad9b7a2df8dfe8831f5a3eb899d28ab63 Mon Sep 17 00:00:00 2001 From: Mike Auteri Date: Fri, 29 Dec 2023 12:00:11 -0500 Subject: [PATCH 2/5] Updates to CLI commands. --- includes/core/classes/class-cli.php | 14 +++- .../core/classes/commands/class-cli-event.php | 50 ------------ .../core/classes/commands/class-general.php | 80 +++++++++++++++++++ 3 files changed, 92 insertions(+), 52 deletions(-) diff --git a/includes/core/classes/class-cli.php b/includes/core/classes/class-cli.php index 6d8fdc9b7..aa242fc31 100644 --- a/includes/core/classes/class-cli.php +++ b/includes/core/classes/class-cli.php @@ -1,8 +1,8 @@ $users ) { - if ( 'contributors' === $group ) { - sort( $users ); - } - - $data[ $group ] = array(); - - foreach ( $users as $user ) { - $response = wp_remote_request( sprintf( 'https://profiles.wordpress.org/wp-json/wporg/v1/users/%s', $user ) ); - $user_data = json_decode( $response['body'], true ); - - // Remove unsecure data (eg http) and data we do not need. - unset( $user_data['description'], $user_data['url'], $user_data['meta'], $user_data['_links'] ); - - $data[ $group ][] = $user_data; - } - } - fwrite( $file, '] + * : Plugin version to generate. + * + * @since 1.0.0 + * + * @param array $args Positional arguments for the script. + * @param array $assoc_args Associative arguments for the script. + * @return void + */ + public function generate_credits( array $args = array(), array $assoc_args = array() ): void { + $credits = require_once GATHERPRESS_CORE_PATH . '/includes/data/credits/credits.php'; + $version = $assoc_args['version'] ?? GATHERPRESS_VERSION; + $latest = GATHERPRESS_CORE_PATH . '/includes/data/credits/latest.php'; + $data = array(); + + if ( empty( $credits[ $version ] ) ) { + WP_CLI::error( 'Version does not exist' ); + } + + unlink( $latest ); + $file = fopen( $latest, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen + + $data['version'] = $version; + + foreach ( $credits[ $version ] as $group => $users ) { + if ( 'contributors' === $group ) { + sort( $users ); + } + + $data[ $group ] = array(); + + foreach ( $users as $user ) { + $response = wp_remote_request( sprintf( 'https://profiles.wordpress.org/wp-json/wporg/v1/users/%s', $user ) ); + $user_data = json_decode( $response['body'], true ); + + // Remove unsecure data (eg http) and data we do not need. + unset( $user_data['description'], $user_data['url'], $user_data['meta'], $user_data['_links'] ); + + $data[ $group ][] = $user_data; + } + } + + fwrite( $file, ' Date: Fri, 29 Dec 2023 15:39:34 -0500 Subject: [PATCH 3/5] Cleanup and refactoring. --- includes/core/classes/class-assets.php | 5 ++-- includes/core/classes/class-autoloader.php | 2 -- includes/core/classes/class-block.php | 5 ++-- includes/core/classes/class-cli.php | 7 +++-- includes/core/classes/class-event-query.php | 5 ++-- includes/core/classes/class-event.php | 2 -- includes/core/classes/class-rest-api.php | 5 ++-- includes/core/classes/class-rsvp.php | 2 -- includes/core/classes/class-settings.php | 5 ++-- includes/core/classes/class-setup.php | 5 ++-- includes/core/classes/class-utility.php | 2 -- includes/core/classes/class-venue.php | 5 ++-- .../core/classes/commands/class-cli-event.php | 28 +++++++++++-------- ...lass-general.php => class-cli-general.php} | 6 ++++ includes/core/classes/settings/class-base.php | 2 -- .../core/classes/settings/class-credits.php | 5 ++-- .../core/classes/settings/class-general.php | 5 ++-- .../classes/settings/class-leadership.php | 5 ++-- test/unit/php/class-test-gatherpress.php | 2 -- .../core/classes/class-test-assets.php | 1 - .../core/classes/class-test-block.php | 2 -- .../core/classes/class-test-event-query.php | 2 -- .../core/classes/class-test-event.php | 2 -- .../core/classes/class-test-rest-api.php | 2 -- .../includes/core/classes/class-test-rsvp.php | 2 -- .../core/classes/class-test-settings.php | 2 -- .../core/classes/class-test-setup.php | 2 -- .../core/classes/class-test-utility.php | 2 -- .../core/classes/class-test-venue.php | 2 -- .../core/classes/settings/class-test-base.php | 2 -- .../classes/settings/class-test-credits.php | 2 -- .../classes/settings/class-test-general.php | 2 -- .../settings/class-test-leadership.php | 2 -- 33 files changed, 57 insertions(+), 73 deletions(-) rename includes/core/classes/commands/{class-general.php => class-cli-general.php} (94%) diff --git a/includes/core/classes/class-assets.php b/includes/core/classes/class-assets.php index a42004c89..17be41b2f 100644 --- a/includes/core/classes/class-assets.php +++ b/includes/core/classes/class-assets.php @@ -21,7 +21,9 @@ * @since 1.0.0 */ class Assets { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -386,5 +388,4 @@ protected function get_asset_data( string $asset ): array { return $this->asset_data[ $asset ]; } - } diff --git a/includes/core/classes/class-autoloader.php b/includes/core/classes/class-autoloader.php index 6937b92e4..d47c270a9 100644 --- a/includes/core/classes/class-autoloader.php +++ b/includes/core/classes/class-autoloader.php @@ -20,7 +20,6 @@ * @since 1.0.0 */ class Autoloader { - /** * Register method for autoloader. * @@ -70,5 +69,4 @@ static function( $class ): bool { } ); } - } diff --git a/includes/core/classes/class-block.php b/includes/core/classes/class-block.php index c30f55215..778945156 100644 --- a/includes/core/classes/class-block.php +++ b/includes/core/classes/class-block.php @@ -20,7 +20,9 @@ * @since 1.0.0 */ class Block { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -63,5 +65,4 @@ public function register_blocks(): void { register_block_type( sprintf( '%1$s/build/blocks/%2$s', GATHERPRESS_CORE_PATH, $block ) ); } } - } diff --git a/includes/core/classes/class-cli.php b/includes/core/classes/class-cli.php index aa242fc31..8bc85acd8 100644 --- a/includes/core/classes/class-cli.php +++ b/includes/core/classes/class-cli.php @@ -11,9 +11,9 @@ namespace GatherPress\Core; -use GatherPress\Core\Traits\Singleton; use GatherPress\Core\Commands\Cli_Event; use GatherPress\Core\Commands\Cli_General; +use GatherPress\Core\Traits\Singleton; use WP_CLI; /** @@ -25,7 +25,9 @@ * @since 1.0.0 */ class Cli { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -41,5 +43,4 @@ protected function __construct() { WP_CLI::add_command( 'gatherpress event', Cli_Event::class ); // @codeCoverageIgnore } } - } diff --git a/includes/core/classes/class-event-query.php b/includes/core/classes/class-event-query.php index 07200fbe3..318266307 100644 --- a/includes/core/classes/class-event-query.php +++ b/includes/core/classes/class-event-query.php @@ -23,7 +23,9 @@ * @since 1.0.0 */ class Event_Query { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -340,5 +342,4 @@ public function adjust_event_sql( array $pieces, string $type = 'all', string $o return $pieces; } - } diff --git a/includes/core/classes/class-event.php b/includes/core/classes/class-event.php index cd5b98b0e..b5a626024 100644 --- a/includes/core/classes/class-event.php +++ b/includes/core/classes/class-event.php @@ -23,7 +23,6 @@ * @since 1.0.0 */ class Event { - /** * Cache key format for storing and retrieving event datetimes. * @@ -951,5 +950,4 @@ public function maybe_get_online_event_link(): string { return $event_link; } - } diff --git a/includes/core/classes/class-rest-api.php b/includes/core/classes/class-rest-api.php index c1ec0a9d1..2ed006b75 100644 --- a/includes/core/classes/class-rest-api.php +++ b/includes/core/classes/class-rest-api.php @@ -27,7 +27,9 @@ * @since 1.0.0 */ class Rest_Api { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -677,5 +679,4 @@ public function prepare_event_data( WP_REST_Response $response ): WP_REST_Respon return $response; } - } diff --git a/includes/core/classes/class-rsvp.php b/includes/core/classes/class-rsvp.php index 341d70649..2a5021d1f 100644 --- a/includes/core/classes/class-rsvp.php +++ b/includes/core/classes/class-rsvp.php @@ -22,7 +22,6 @@ * @since 1.0.0 */ class Rsvp { - /** * Table format for RSVPs. * @@ -413,5 +412,4 @@ function( $role ) { public function sort_by_timestamp( array $first, array $second ): bool { return ( strtotime( $first['timestamp'] ) < strtotime( $second['timestamp'] ) ); } - } diff --git a/includes/core/classes/class-settings.php b/includes/core/classes/class-settings.php index cee588a6b..6e650e195 100644 --- a/includes/core/classes/class-settings.php +++ b/includes/core/classes/class-settings.php @@ -25,7 +25,9 @@ * @since 1.0.0 */ class Settings { - + /** + * Enforces a single instance of this class. + */ use Singleton; const PARENT_SLUG = 'edit.php?post_type=gp_event'; @@ -639,5 +641,4 @@ public function datetime_preview( string $name, string $value ): void { ); } } - } diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 30831d220..ce6082cbc 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -23,7 +23,9 @@ * @since 1.0.0 */ class Setup { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -668,5 +670,4 @@ public function check_users_can_register() : void { ); } } - } diff --git a/includes/core/classes/class-utility.php b/includes/core/classes/class-utility.php index 8ca3e856b..055a44a11 100644 --- a/includes/core/classes/class-utility.php +++ b/includes/core/classes/class-utility.php @@ -20,7 +20,6 @@ * @since 1.0.0 */ class Utility { - /** * Renders a template file. * @@ -117,5 +116,4 @@ public static function timezone_choices(): array { return $timezones_clean; } - } diff --git a/includes/core/classes/class-venue.php b/includes/core/classes/class-venue.php index 64f6b9c3b..9261fb8c6 100644 --- a/includes/core/classes/class-venue.php +++ b/includes/core/classes/class-venue.php @@ -22,7 +22,9 @@ * @since 1.0.0 */ class Venue { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -392,5 +394,4 @@ public function get_venue_meta( int $post_id, string $post_type ): array { return $venue_meta; } - } diff --git a/includes/core/classes/commands/class-cli-event.php b/includes/core/classes/commands/class-cli-event.php index 489a2396b..fffc435c5 100644 --- a/includes/core/classes/commands/class-cli-event.php +++ b/includes/core/classes/commands/class-cli-event.php @@ -1,33 +1,33 @@ ] * : Plugin version to generate. * + * ## EXAMPLES + * + * # Generate credits. + * $ wp gatherpress generate_credits --version=1.0.0 + * Success: New latest.php file has been generated. + * * @since 1.0.0 * * @param array $args Positional arguments for the script. diff --git a/includes/core/classes/settings/class-base.php b/includes/core/classes/settings/class-base.php index f575f9b98..f25e947b8 100644 --- a/includes/core/classes/settings/class-base.php +++ b/includes/core/classes/settings/class-base.php @@ -20,7 +20,6 @@ * @since 1.0.0 */ class Base { - /** * The name of the settings page. * @@ -123,5 +122,4 @@ public function page(): array { 'sections' => $this->sections, ); } - } diff --git a/includes/core/classes/settings/class-credits.php b/includes/core/classes/settings/class-credits.php index 205eaa0d8..eaefc7317 100644 --- a/includes/core/classes/settings/class-credits.php +++ b/includes/core/classes/settings/class-credits.php @@ -22,7 +22,9 @@ * @since 1.0.0 */ class Credits extends Base { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -96,5 +98,4 @@ protected function credits_page(): void { true ); } - } diff --git a/includes/core/classes/settings/class-general.php b/includes/core/classes/settings/class-general.php index 213586708..e7eed5f72 100644 --- a/includes/core/classes/settings/class-general.php +++ b/includes/core/classes/settings/class-general.php @@ -24,7 +24,9 @@ * @since 1.0.0 */ class General extends Base { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -169,5 +171,4 @@ protected function get_section(): array { ), ); } - } diff --git a/includes/core/classes/settings/class-leadership.php b/includes/core/classes/settings/class-leadership.php index f568fa1de..1a45f04d8 100644 --- a/includes/core/classes/settings/class-leadership.php +++ b/includes/core/classes/settings/class-leadership.php @@ -23,7 +23,9 @@ * @since 1.0.0 */ class Leadership extends Base { - + /** + * Enforces a single instance of this class. + */ use Singleton; /** @@ -118,5 +120,4 @@ public function get_user_role( int $user_id ): string { return $default; } - } diff --git a/test/unit/php/class-test-gatherpress.php b/test/unit/php/class-test-gatherpress.php index 8af8d8d3a..8c47a8fdc 100644 --- a/test/unit/php/class-test-gatherpress.php +++ b/test/unit/php/class-test-gatherpress.php @@ -15,7 +15,6 @@ * Class Test_GatherPress. */ class Test_GatherPress extends Base { - /** * Check plugin version. * @@ -42,5 +41,4 @@ public function test_plugin_version(): void { 'Failed to assert version in gatherpress.php matches version in package.json.' ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-assets.php b/test/unit/php/includes/core/classes/class-test-assets.php index 218029760..d74cfd13b 100644 --- a/test/unit/php/includes/core/classes/class-test-assets.php +++ b/test/unit/php/includes/core/classes/class-test-assets.php @@ -20,7 +20,6 @@ * @coversDefaultClass \GatherPress\Core\Assets */ class Test_Assets extends Base { - /** * Coverage for setup_hooks. * diff --git a/test/unit/php/includes/core/classes/class-test-block.php b/test/unit/php/includes/core/classes/class-test-block.php index 6bc97db8a..aa31c0ed9 100644 --- a/test/unit/php/includes/core/classes/class-test-block.php +++ b/test/unit/php/includes/core/classes/class-test-block.php @@ -20,7 +20,6 @@ * @coversDefaultClass \GatherPress\Core\Block */ class Test_Block extends Base { - /** * Coverage for setup_hooks. * @@ -73,5 +72,4 @@ public function test_register_blocks(): void { $this->assertSame( $blocks, $expected ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-event-query.php b/test/unit/php/includes/core/classes/class-test-event-query.php index 1b2531475..2654c7216 100644 --- a/test/unit/php/includes/core/classes/class-test-event-query.php +++ b/test/unit/php/includes/core/classes/class-test-event-query.php @@ -20,7 +20,6 @@ * @coversDefaultClass \GatherPress\Core\Event_Query */ class Test_Event_Query extends Base { - /** * Coverage for setup_hooks method. * @@ -246,5 +245,4 @@ public function test_adjust_event_sql(): void { $this->assertStringContainsString( 'ASC', $retval['orderby'] ); $this->assertStringContainsString( "AND {$table}.datetime_end_gmt >=", $retval['where'] ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-event.php b/test/unit/php/includes/core/classes/class-test-event.php index 42b563d4f..6497d04c0 100644 --- a/test/unit/php/includes/core/classes/class-test-event.php +++ b/test/unit/php/includes/core/classes/class-test-event.php @@ -24,7 +24,6 @@ * @coversDefaultClass \GatherPress\Core\Event */ class Test_Event extends Base { - /** * Coverage for __construct method. * @@ -837,5 +836,4 @@ public function test_maybe_get_online_event_link(): void { 'Failed to assert empty string due to RSVP being set to null.' ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-rest-api.php b/test/unit/php/includes/core/classes/class-test-rest-api.php index e54223562..fb767c287 100644 --- a/test/unit/php/includes/core/classes/class-test-rest-api.php +++ b/test/unit/php/includes/core/classes/class-test-rest-api.php @@ -22,7 +22,6 @@ * @coversDefaultClass \GatherPress\Core\Rest_Api */ class Test_Rest_Api extends Base { - /** * Coverage for setup_hooks method. * @@ -674,5 +673,4 @@ public function test_update_rsvp(): void { 'Failed to assert that event ID matches.' ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-rsvp.php b/test/unit/php/includes/core/classes/class-test-rsvp.php index 818b3a419..9f30db5df 100644 --- a/test/unit/php/includes/core/classes/class-test-rsvp.php +++ b/test/unit/php/includes/core/classes/class-test-rsvp.php @@ -19,7 +19,6 @@ * @coversDefaultClass \GatherPress\Core\Rsvp */ class Test_Rsvp extends Base { - /** * Coverage for get method. * @@ -196,5 +195,4 @@ public function test_sort_by_timestamp(): void { 'Failed to assert correct sorting of timestamp.' ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-settings.php b/test/unit/php/includes/core/classes/class-test-settings.php index 7bc0a1e1e..b24a9a3ae 100644 --- a/test/unit/php/includes/core/classes/class-test-settings.php +++ b/test/unit/php/includes/core/classes/class-test-settings.php @@ -18,7 +18,6 @@ * @coversDefaultClass \GatherPress\Core\Settings */ class Test_Settings extends Base { - /** * Coverage for setup_hooks. * @@ -290,5 +289,4 @@ public function test_get_sub_pages(): void { 'Failed to assert that credits is last key.' ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-setup.php b/test/unit/php/includes/core/classes/class-test-setup.php index db947dc35..7c6704325 100644 --- a/test/unit/php/includes/core/classes/class-test-setup.php +++ b/test/unit/php/includes/core/classes/class-test-setup.php @@ -20,7 +20,6 @@ * @coversDefaultClass \GatherPress\Core\Setup */ class Test_Setup extends Base { - /** * Coverage for setup_hooks. * @@ -287,5 +286,4 @@ public function test_sortable_columns(): void { 'Failed to assert correct sortable columns.' ); } - } diff --git a/test/unit/php/includes/core/classes/class-test-utility.php b/test/unit/php/includes/core/classes/class-test-utility.php index a924a87a6..fc17229cc 100644 --- a/test/unit/php/includes/core/classes/class-test-utility.php +++ b/test/unit/php/includes/core/classes/class-test-utility.php @@ -20,7 +20,6 @@ * @coversDefaultClass \GatherPress\Core\Utility */ class Test_Utility extends Base { - /** * Coverage for render_template method. * @@ -107,5 +106,4 @@ public function test_timezone_choices(): void { $this->assertIsArray( $timezones[ $key ] ); } } - } diff --git a/test/unit/php/includes/core/classes/class-test-venue.php b/test/unit/php/includes/core/classes/class-test-venue.php index f48d47c10..0d5462e75 100644 --- a/test/unit/php/includes/core/classes/class-test-venue.php +++ b/test/unit/php/includes/core/classes/class-test-venue.php @@ -19,7 +19,6 @@ * @coversDefaultClass \GatherPress\Core\Venue */ class Test_Venue extends Base { - /** * Coverage for __construct and setup_hooks. * @@ -367,5 +366,4 @@ public function test_get_venue_meta(): void { 'Failed to assert venue title matches the venue meta title.' ); } - } diff --git a/test/unit/php/includes/core/classes/settings/class-test-base.php b/test/unit/php/includes/core/classes/settings/class-test-base.php index 930094a8e..48ae3ccca 100644 --- a/test/unit/php/includes/core/classes/settings/class-test-base.php +++ b/test/unit/php/includes/core/classes/settings/class-test-base.php @@ -18,7 +18,6 @@ * @coversDefaultClass \GatherPress\Core\Settings\Base */ class Test_Base extends Base_Unit_Test { - /** * Coverage for setup_up method. * @@ -75,5 +74,4 @@ public function test_get(): void { $this->assertNull( $instance->get( 'unit-test' ), 'Failed to assert property is null.' ); $this->assertSame( $slug, $instance->get( 'slug' ), 'Failed to assert property is unit-test.' ); } - } diff --git a/test/unit/php/includes/core/classes/settings/class-test-credits.php b/test/unit/php/includes/core/classes/settings/class-test-credits.php index ec7fa8a04..f832084a5 100644 --- a/test/unit/php/includes/core/classes/settings/class-test-credits.php +++ b/test/unit/php/includes/core/classes/settings/class-test-credits.php @@ -19,7 +19,6 @@ * @coversDefaultClass \GatherPress\Core\Settings\Credits */ class Test_Credits extends Base { - /** * Coverage for __construct method. * @@ -100,5 +99,4 @@ public function test_settings_section(): void { $this->assertNotEmpty( $response, 'Failed to assert markup was returned.' ); } - } diff --git a/test/unit/php/includes/core/classes/settings/class-test-general.php b/test/unit/php/includes/core/classes/settings/class-test-general.php index 68c8c6654..6f223fbda 100644 --- a/test/unit/php/includes/core/classes/settings/class-test-general.php +++ b/test/unit/php/includes/core/classes/settings/class-test-general.php @@ -18,7 +18,6 @@ * @coversDefaultClass \GatherPress\Core\Settings\General */ class Test_General extends Base { - /** * Coverage for __construct method. * @@ -67,5 +66,4 @@ public function test_get_section(): void { 'Failed to assert pages section is an array.' ); } - } diff --git a/test/unit/php/includes/core/classes/settings/class-test-leadership.php b/test/unit/php/includes/core/classes/settings/class-test-leadership.php index c9fcb30c8..05c5eb632 100644 --- a/test/unit/php/includes/core/classes/settings/class-test-leadership.php +++ b/test/unit/php/includes/core/classes/settings/class-test-leadership.php @@ -18,7 +18,6 @@ * @coversDefaultClass \GatherPress\Core\Settings\Leadership */ class Test_Leadership extends Base { - /** * Coverage for __construct method. * @@ -110,5 +109,4 @@ public function test_get_user_role(): void { delete_option( 'gp_leadership' ); } - } From 79087e2605a2d0d903c978517745dec292a04444 Mon Sep 17 00:00:00 2001 From: Mike Auteri Date: Fri, 29 Dec 2023 15:45:21 -0500 Subject: [PATCH 4/5] Fixed internationalization issue. --- includes/core/classes/class-event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/core/classes/class-event.php b/includes/core/classes/class-event.php index b5a626024..512eac3a1 100644 --- a/includes/core/classes/class-event.php +++ b/includes/core/classes/class-event.php @@ -250,7 +250,7 @@ public function get_display_datetime(): string { } if ( ! empty( $start ) && ! empty( $end ) ) { - return sprintf( '%s to %s', $start, $end ); + return sprintf( __( '%s to %s', 'gatherpress' ), $start, $end ); } return __( '—', 'gatherpress' ); From dee13061a19203e551b7b34aa8326246171bb923 Mon Sep 17 00:00:00 2001 From: Mike Auteri Date: Fri, 29 Dec 2023 15:51:50 -0500 Subject: [PATCH 5/5] PHPCS fixes. --- includes/core/classes/class-event.php | 3 ++- includes/core/classes/class-setup.php | 1 - includes/core/classes/commands/class-cli-event.php | 1 + includes/core/requirements-check.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/core/classes/class-event.php b/includes/core/classes/class-event.php index 512eac3a1..0234a872b 100644 --- a/includes/core/classes/class-event.php +++ b/includes/core/classes/class-event.php @@ -250,7 +250,8 @@ public function get_display_datetime(): string { } if ( ! empty( $start ) && ! empty( $end ) ) { - return sprintf( __( '%s to %s', 'gatherpress' ), $start, $end ); + /* translators: %1$s: start datetime, %2$s: end datetime. */ + return sprintf( __( '%1$s to %2$s', 'gatherpress' ), $start, $end ); } return __( '—', 'gatherpress' ); diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index ce6082cbc..f201c155a 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -61,7 +61,6 @@ protected function instantiate_classes(): void { Rest_Api::get_instance(); Settings::get_instance(); Venue::get_instance(); - } /** diff --git a/includes/core/classes/commands/class-cli-event.php b/includes/core/classes/commands/class-cli-event.php index fffc435c5..c744f9583 100644 --- a/includes/core/classes/commands/class-cli-event.php +++ b/includes/core/classes/commands/class-cli-event.php @@ -69,6 +69,7 @@ public function rsvp( array $args = array(), array $assoc_args = array() ): void WP_CLI::success( sprintf( + /* translators: %1$d: event ID, %2$s: attendance status, %3$d: user ID. */ __( 'The RSVP status for Event ID "%1$d" has been successfully set to "%2$s" for User ID "%3$d".', 'gatherpress' ), $event_id, $response, diff --git a/includes/core/requirements-check.php b/includes/core/requirements-check.php index 43f9f4bd0..95c659a5f 100644 --- a/includes/core/requirements-check.php +++ b/includes/core/requirements-check.php @@ -20,7 +20,7 @@ static function () {