From e2dff564a6324e9eb17262577e9b04a369950081 Mon Sep 17 00:00:00 2001 From: Christoph Khouri Date: Fri, 17 Jan 2025 13:39:58 -0500 Subject: [PATCH 01/10] Defines the examples as plugins --- example/rest-api/art-institute/README.md | 4 +++- example/rest-api/art-institute/register.php | 10 ++++++++++ example/rest-api/zip-code/README.md | 4 +++- example/rest-api/zip-code/register.php | 18 +++++++++++++++--- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/example/rest-api/art-institute/README.md b/example/rest-api/art-institute/README.md index f916dac9..7a7bab20 100644 --- a/example/rest-api/art-institute/README.md +++ b/example/rest-api/art-institute/README.md @@ -1,3 +1,5 @@ # Example: "Art Institute of Chicago" block -This example registers a remote data block representing an artwork from the [Art Institute of Chicago's public API](http://api.artic.edu/docs/). +This example plugin registers a remote data block representing an artwork from the [Art Institute of Chicago's public API](http://api.artic.edu/docs/). The source is defined in the plugin code directly, as opposed to the in settings screen like the Zip Code example. + +To enable it, simply copy the art-institute.php file to your plugins folder and activate it. This will expose a new custom block called `Art Institute of Chicago` \ No newline at end of file diff --git a/example/rest-api/art-institute/register.php b/example/rest-api/art-institute/register.php index 8be11d9a..46e5d904 100644 --- a/example/rest-api/art-institute/register.php +++ b/example/rest-api/art-institute/register.php @@ -1,5 +1,15 @@ [ 'query' => $zipcode_query, ], + 'icon' => 'smiley', ] ); } -add_action( 'init', __NAMESPACE__ . '\\register_zipcode_block' ); +add_action( 'init', __NAMESPACE__ . '\\register_zipcode_block' ); \ No newline at end of file From cd6d50db52db175f8fe7c7cc0ec6cb354d01cdfe Mon Sep 17 00:00:00 2001 From: Christoph Khouri Date: Fri, 17 Jan 2025 13:57:03 -0500 Subject: [PATCH 02/10] Renaming main plugin files --- .../rest-api/art-institute/{register.php => art-institute.php} | 0 example/rest-api/zip-code/{register.php => zip-code.php} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename example/rest-api/art-institute/{register.php => art-institute.php} (100%) rename example/rest-api/zip-code/{register.php => zip-code.php} (100%) diff --git a/example/rest-api/art-institute/register.php b/example/rest-api/art-institute/art-institute.php similarity index 100% rename from example/rest-api/art-institute/register.php rename to example/rest-api/art-institute/art-institute.php diff --git a/example/rest-api/zip-code/register.php b/example/rest-api/zip-code/zip-code.php similarity index 100% rename from example/rest-api/zip-code/register.php rename to example/rest-api/zip-code/zip-code.php From 38a003ced2a96e64c23968c77aa9bf5a28865f94 Mon Sep 17 00:00:00 2001 From: Max Schmeling Date: Fri, 17 Jan 2025 14:44:54 -0600 Subject: [PATCH 03/10] Fix formatting --- .../rest-api/art-institute/art-institute.php | 22 +++++++++---------- example/rest-api/zip-code/zip-code.php | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/example/rest-api/art-institute/art-institute.php b/example/rest-api/art-institute/art-institute.php index 46e5d904..28cc0af2 100644 --- a/example/rest-api/art-institute/art-institute.php +++ b/example/rest-api/art-institute/art-institute.php @@ -1,14 +1,14 @@ [ '__version' => 1, 'display_name' => 'Art Institute of Chicago', @@ -26,9 +26,9 @@ function register_aic_block(): void { 'Content-Type' => 'application/json', ], ], - ] ); + ]); - $get_art_query = HttpQuery::from_array( [ + $get_art_query = HttpQuery::from_array([ 'data_source' => $aic_data_source, 'endpoint' => function ( array $input_variables ) use ( $aic_data_source ): string { return sprintf( '%s/%s', $aic_data_source->get_endpoint(), $input_variables['id'] ?? '' ); @@ -64,9 +64,9 @@ function register_aic_block(): void { ], ], ], - ] ); + ]); - $search_art_query = HttpQuery::from_array( [ + $search_art_query = HttpQuery::from_array([ 'data_source' => $aic_data_source, 'endpoint' => function ( array $input_variables ) use ( $aic_data_source ): string { $query = $input_variables['search_terms']; @@ -94,9 +94,9 @@ function register_aic_block(): void { ], ], ], - ] ); + ]); - register_remote_data_block( [ + register_remote_data_block([ 'title' => 'Art Institute of Chicago', 'render_query' => [ 'query' => $get_art_query, @@ -107,6 +107,6 @@ function register_aic_block(): void { 'type' => 'search', ], ], - ] ); + ]); } add_action( 'init', __NAMESPACE__ . '\\register_aic_block' ); diff --git a/example/rest-api/zip-code/zip-code.php b/example/rest-api/zip-code/zip-code.php index 3b65c37e..84629693 100644 --- a/example/rest-api/zip-code/zip-code.php +++ b/example/rest-api/zip-code/zip-code.php @@ -1,14 +1,14 @@ $zipcode_data_source, 'endpoint' => function ( array $input_variables ) use ( $zipcode_data_source ): string { return $zipcode_data_source->get_endpoint() . $input_variables['zip_code']; @@ -59,14 +59,14 @@ function register_zipcode_block(): void { ], ], ], - ] ); + ]); - register_remote_data_block( [ + register_remote_data_block([ 'title' => 'Zip Code', 'render_query' => [ 'query' => $zipcode_query, ], - 'icon' => 'smiley', - ] ); + 'icon' => 'smiley', + ]); } -add_action( 'init', __NAMESPACE__ . '\\register_zipcode_block' ); \ No newline at end of file +add_action( 'init', __NAMESPACE__ . '\\register_zipcode_block' ); From 75f0204194596967b70c51f6a6b831888fe0e344 Mon Sep 17 00:00:00 2001 From: Max Schmeling Date: Fri, 17 Jan 2025 14:52:46 -0600 Subject: [PATCH 04/10] Fix README formatting --- example/rest-api/art-institute/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/rest-api/art-institute/README.md b/example/rest-api/art-institute/README.md index 7a7bab20..661376a4 100644 --- a/example/rest-api/art-institute/README.md +++ b/example/rest-api/art-institute/README.md @@ -2,4 +2,4 @@ This example plugin registers a remote data block representing an artwork from the [Art Institute of Chicago's public API](http://api.artic.edu/docs/). The source is defined in the plugin code directly, as opposed to the in settings screen like the Zip Code example. -To enable it, simply copy the art-institute.php file to your plugins folder and activate it. This will expose a new custom block called `Art Institute of Chicago` \ No newline at end of file +To enable it, simply copy the art-institute.php file to your plugins folder and activate it. This will expose a new custom block called `Art Institute of Chicago` From 7c8271a42b2533b3a499027839cf8a1e831df633 Mon Sep 17 00:00:00 2001 From: Max Schmeling Date: Fri, 17 Jan 2025 15:41:15 -0600 Subject: [PATCH 05/10] Fix two phpcs issues --- example/rest-api/art-institute/art-institute.php | 1 - example/rest-api/zip-code/zip-code.php | 1 - 2 files changed, 2 deletions(-) diff --git a/example/rest-api/art-institute/art-institute.php b/example/rest-api/art-institute/art-institute.php index 28cc0af2..90d8161c 100644 --- a/example/rest-api/art-institute/art-institute.php +++ b/example/rest-api/art-institute/art-institute.php @@ -1,5 +1,4 @@ Date: Fri, 17 Jan 2025 15:46:52 -0600 Subject: [PATCH 06/10] Run lint:phpcs:fix --- example/rest-api/art-institute/art-institute.php | 1 + example/rest-api/zip-code/zip-code.php | 1 + 2 files changed, 2 insertions(+) diff --git a/example/rest-api/art-institute/art-institute.php b/example/rest-api/art-institute/art-institute.php index 90d8161c..28cc0af2 100644 --- a/example/rest-api/art-institute/art-institute.php +++ b/example/rest-api/art-institute/art-institute.php @@ -1,4 +1,5 @@ Date: Fri, 17 Jan 2025 15:57:01 -0600 Subject: [PATCH 07/10] Exclude phpcs rule --- phpcs.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpcs.xml b/phpcs.xml index ac2201dc..ce1ba226 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -78,6 +78,11 @@ + + + + + From a3b461710819d243acba6817cc9845a461bfddad Mon Sep 17 00:00:00 2001 From: Max Schmeling Date: Fri, 17 Jan 2025 15:58:16 -0600 Subject: [PATCH 08/10] Revert "Exclude phpcs rule" This reverts commit de0ddd0cdf8ce626a0c46f8d76f1f72bce4f8b18. --- phpcs.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index ce1ba226..ac2201dc 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -78,11 +78,6 @@ - - - - - From 801cad52eb3cd6d4846c0b05f4666366b78a1531 Mon Sep 17 00:00:00 2001 From: Max Schmeling Date: Sat, 18 Jan 2025 22:41:27 -0600 Subject: [PATCH 09/10] Add sample plugins to PSR12.Files.FileHeader.IncorrectOrder ignore --- phpcs.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpcs.xml b/phpcs.xml index ac2201dc..3a8de2fc 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -102,6 +102,8 @@ remote-data-blocks.php + zip-code.php + art-institute.php functions.php From 964b5d572e86f352a7c0f63d90cf5cc5653609f6 Mon Sep 17 00:00:00 2001 From: Max Schmeling Date: Sat, 18 Jan 2025 22:53:51 -0600 Subject: [PATCH 10/10] Remove icon config option --- example/rest-api/zip-code/zip-code.php | 1 - 1 file changed, 1 deletion(-) diff --git a/example/rest-api/zip-code/zip-code.php b/example/rest-api/zip-code/zip-code.php index 84629693..57183a5e 100644 --- a/example/rest-api/zip-code/zip-code.php +++ b/example/rest-api/zip-code/zip-code.php @@ -66,7 +66,6 @@ function register_zipcode_block(): void { 'render_query' => [ 'query' => $zipcode_query, ], - 'icon' => 'smiley', ]); } add_action( 'init', __NAMESPACE__ . '\\register_zipcode_block' );