From a11a6ae8533d999845f1d74a4fa92c59d4122593 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Thu, 22 Oct 2026 19:40:21 -0400 Subject: [PATCH 1/2] refactor: rename headless-documents to hwp-documents and register it with release-please --- .changeset/headless-documents-initial.md | 5 -- .github/dependabot.yaml | 6 +- .release-please-manifest.json | 1 + docs/index.md | 2 +- llms.txt | 2 +- plugins/README.md | 2 +- .../headless-documents/headless-documents.php | 86 ------------------- .../phpcs/HeadlessStandard/ruleset.xml | 4 - .../.distignore | 0 .../.docker/.env.ci | 2 +- .../.docker/Dockerfile | 2 +- .../.docker/init-docker.sh | 0 .../.editorconfig | 0 .../.env.dist | 2 +- .../.gitignore | 0 .../.wp-env.json | 0 .../LICENSE | 0 .../README.md | 34 ++++---- .../activation.php | 8 +- .../bin/_lib.sh | 0 .../bin/build-docker.sh | 0 .../bin/install-plugins.sh | 2 +- .../bin/install-test-env.sh | 6 +- .../bin/local/run-qa.sh | 0 .../bin/local/run-unit-tests.sh | 4 +- .../bin/run-codeception.sh | 0 .../bin/sync-package-version.sh | 8 +- .../codeception.dist.yml | 6 +- .../composer.json | 12 +-- .../composer.lock | 2 +- .../deactivation.php | 6 +- .../docker-compose.yml | 0 plugins/hwp-documents/hwp-documents.php | 86 +++++++++++++++++++ .../package.json | 2 +- .../phpcs.xml | 18 ++-- .../ControlStructures/ElseKeywordSniff.php | 2 +- .../phpcs/HWPStandard/ruleset.xml | 4 + .../phpstan.neon.dist | 4 +- .../Rules/ClassConstantVarAnnotationRule.php | 2 +- .../psalm.xml | 4 +- .../readme.txt | 20 ++--- .../src/Admin/Documents_Page.php | 48 +++++------ .../src/Autoloader.php | 6 +- .../src/Capabilities.php | 4 +- .../src/Identifiers.php | 18 ++-- .../src/Plugin.php | 18 ++-- .../src/Rest/Documents_Controller.php | 8 +- .../src/Store/Document_Store.php | 26 +++--- .../src/Store/Document_Table.php | 6 +- .../tests/_data/.gitignore | 0 .../tests/_data/.gitkeep | 0 .../tests/_data/config.php | 0 .../tests/_output/.gitkeep | 0 .../tests/_support/.gitkeep | 0 .../tests/bootstrap.php | 8 +- .../tests/e2e/config/global-setup.js | 0 .../tests/e2e/playwright.config.js | 0 .../tests/e2e/specs/documents.spec.js | 10 +-- .../tests/wpunit.suite.dist.yml | 0 .../tests/wpunit/Admin/DocumentsPageTest.php | 12 +-- .../tests/wpunit/Core/AutoloaderTest.php | 12 +-- .../tests/wpunit/Core/PluginTest.php | 24 +++--- .../tests/wpunit/Core/UninstallTest.php | 22 ++--- .../tests/wpunit/Store/DocumentStoreTest.php | 32 +++---- .../tests/wpunit/bootstrap.php | 2 +- .../uninstall.php | 20 ++--- pnpm-lock.yaml | 2 +- release-please-config.json | 4 + 68 files changed, 313 insertions(+), 313 deletions(-) delete mode 100644 .changeset/headless-documents-initial.md delete mode 100644 plugins/headless-documents/headless-documents.php delete mode 100644 plugins/headless-documents/phpcs/HeadlessStandard/ruleset.xml rename plugins/{headless-documents => hwp-documents}/.distignore (100%) rename plugins/{headless-documents => hwp-documents}/.docker/.env.ci (98%) rename plugins/{headless-documents => hwp-documents}/.docker/Dockerfile (97%) rename plugins/{headless-documents => hwp-documents}/.docker/init-docker.sh (100%) rename plugins/{headless-documents => hwp-documents}/.editorconfig (100%) rename plugins/{headless-documents => hwp-documents}/.env.dist (98%) rename plugins/{headless-documents => hwp-documents}/.gitignore (100%) rename plugins/{headless-documents => hwp-documents}/.wp-env.json (100%) rename plugins/{headless-documents => hwp-documents}/LICENSE (100%) rename plugins/{headless-documents => hwp-documents}/README.md (86%) rename plugins/{headless-documents => hwp-documents}/activation.php (65%) rename plugins/{headless-documents => hwp-documents}/bin/_lib.sh (100%) rename plugins/{headless-documents => hwp-documents}/bin/build-docker.sh (100%) rename plugins/{headless-documents => hwp-documents}/bin/install-plugins.sh (60%) rename plugins/{headless-documents => hwp-documents}/bin/install-test-env.sh (97%) rename plugins/{headless-documents => hwp-documents}/bin/local/run-qa.sh (100%) rename plugins/{headless-documents => hwp-documents}/bin/local/run-unit-tests.sh (77%) rename plugins/{headless-documents => hwp-documents}/bin/run-codeception.sh (100%) rename plugins/{headless-documents => hwp-documents}/bin/sync-package-version.sh (83%) rename plugins/{headless-documents => hwp-documents}/codeception.dist.yml (93%) rename plugins/{headless-documents => hwp-documents}/composer.json (93%) rename plugins/{headless-documents => hwp-documents}/composer.lock (99%) rename plugins/{headless-documents => hwp-documents}/deactivation.php (67%) rename plugins/{headless-documents => hwp-documents}/docker-compose.yml (100%) create mode 100644 plugins/hwp-documents/hwp-documents.php rename plugins/{headless-documents => hwp-documents}/package.json (90%) rename plugins/{headless-documents => hwp-documents}/phpcs.xml (96%) rename plugins/{headless-documents/phpcs/HeadlessStandard => hwp-documents/phpcs/HWPStandard}/Sniffs/ControlStructures/ElseKeywordSniff.php (95%) create mode 100644 plugins/hwp-documents/phpcs/HWPStandard/ruleset.xml rename plugins/{headless-documents => hwp-documents}/phpstan.neon.dist (89%) rename plugins/{headless-documents => hwp-documents}/phpstan/Rules/ClassConstantVarAnnotationRule.php (95%) rename plugins/{headless-documents => hwp-documents}/psalm.xml (91%) rename plugins/{headless-documents => hwp-documents}/readme.txt (66%) rename plugins/{headless-documents => hwp-documents}/src/Admin/Documents_Page.php (77%) rename plugins/{headless-documents => hwp-documents}/src/Autoloader.php (90%) rename plugins/{headless-documents => hwp-documents}/src/Capabilities.php (92%) rename plugins/{headless-documents => hwp-documents}/src/Identifiers.php (69%) rename plugins/{headless-documents => hwp-documents}/src/Plugin.php (79%) rename plugins/{headless-documents => hwp-documents}/src/Rest/Documents_Controller.php (98%) rename plugins/{headless-documents => hwp-documents}/src/Store/Document_Store.php (96%) rename plugins/{headless-documents => hwp-documents}/src/Store/Document_Table.php (97%) rename plugins/{headless-documents => hwp-documents}/tests/_data/.gitignore (100%) rename plugins/{headless-documents => hwp-documents}/tests/_data/.gitkeep (100%) rename plugins/{headless-documents => hwp-documents}/tests/_data/config.php (100%) rename plugins/{headless-documents => hwp-documents}/tests/_output/.gitkeep (100%) rename plugins/{headless-documents => hwp-documents}/tests/_support/.gitkeep (100%) rename plugins/{headless-documents => hwp-documents}/tests/bootstrap.php (66%) rename plugins/{headless-documents => hwp-documents}/tests/e2e/config/global-setup.js (100%) rename plugins/{headless-documents => hwp-documents}/tests/e2e/playwright.config.js (100%) rename plugins/{headless-documents => hwp-documents}/tests/e2e/specs/documents.spec.js (90%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit.suite.dist.yml (100%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit/Admin/DocumentsPageTest.php (91%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit/Core/AutoloaderTest.php (91%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit/Core/PluginTest.php (72%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit/Core/UninstallTest.php (71%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit/Store/DocumentStoreTest.php (96%) rename plugins/{headless-documents => hwp-documents}/tests/wpunit/bootstrap.php (89%) rename plugins/{headless-documents => hwp-documents}/uninstall.php (50%) diff --git a/.changeset/headless-documents-initial.md b/.changeset/headless-documents-initial.md deleted file mode 100644 index e304a898..00000000 --- a/.changeset/headless-documents-initial.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@wpengine/headless-documents-wordpress-plugin": minor ---- - -feat: initial release of Headless Documents, a versioned JSON document store with REST routes that reject stale writes with a 409. diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index a63240a4..887324f5 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -11,7 +11,7 @@ updates: # composer (plugins) - package-ecosystem: "composer" - directory: "/plugins/headless-documents" + directory: "/plugins/hwp-documents" schedule: interval: "weekly" ignore: @@ -60,7 +60,7 @@ updates: # docker (Dockerfiles) - package-ecosystem: "docker" - directory: "/plugins/headless-documents/.docker" + directory: "/plugins/hwp-documents/.docker" schedule: interval: "weekly" ignore: @@ -85,7 +85,7 @@ updates: # docker (docker-compose) - package-ecosystem: "docker" - directory: "/plugins/headless-documents" + directory: "/plugins/hwp-documents" schedule: interval: "weekly" ignore: diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 9347d42c..5609a049 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,4 +1,5 @@ { + "plugins/hwp-documents": "0.0.0", "plugins/hwp-previews": "1.0.2", "plugins/wpgraphql-debug-extensions": "0.0.4", "plugins/wpgraphql-logging": "1.0.1", diff --git a/docs/index.md b/docs/index.md index 1dfedb6f..a7811349 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,7 +14,7 @@ The toolkit includes several WordPress plugins to enhance the headless experienc | Plugin | Description | |--------|-------------| | [wpgraphql-logging](../plugins/wpgraphql-logging/) | Logging for WPGraphQL requests with granular lifecycle events and Monolog integration. | -| [headless-documents](../plugins/headless-documents/) | Store your app's JSON documents in WordPress over REST, with versioned writes that reject stale updates. | +| [hwp-documents](../plugins/hwp-documents/) | Store your app's JSON documents in WordPress over REST, with versioned writes that reject stale updates. | | [hwp-previews](../plugins/hwp-previews/) | Headless Previews solution for WordPress: fully configurable preview URLs via the settings page which is framework agnostic. | ## Examples diff --git a/llms.txt b/llms.txt index fd265117..d2e6b01a 100644 --- a/llms.txt +++ b/llms.txt @@ -6,7 +6,7 @@ WordPress plugins for the Headless WordPress Toolkit. Each plugin is paired with an NPM package. -- [Headless Documents](https://github.com/wpengine/hwptoolkit/blob/main/plugins/headless-documents/README.md) +- [HWP Documents](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-documents/README.md) - [HWP CLI Plugin](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-cli/README.md) - [HWP Previews](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-previews/README.md) - [WPGraphQL Debug Extensions](https://github.com/wpengine/hwptoolkit/blob/main/plugins/wpgraphql-debug-extensions/README.md) diff --git a/plugins/README.md b/plugins/README.md index af6788c6..4de98260 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -6,7 +6,7 @@ WordPress plugins for the Headless WordPress Toolkit. Each plugin is paired with | Plugin | Description | |--------|-------------| -| [headless-documents](./headless-documents/README.md) | Store your app's JSON documents in WordPress over REST, with versioned writes that reject stale updates. | +| [hwp-documents](./hwp-documents/README.md) | Store your app's JSON documents in WordPress over REST, with versioned writes that reject stale updates. | | [hwp-previews](./hwp-previews/README.md) | Headless Previews solution for WordPress: fully configurable preview URLs via the settings page which is framework agnostic. | | [wpgraphql-webhooks](./wpgraphql-webhooks/README.md) | Extends WPGraphQL to support webhook subscriptions and dispatching for headless WordPress environments. | | [wpgraphql-logging](./wpgraphql-logging/README.md) | Logging for WPGraphQL requests with granular lifecycle events and Monolog integration. | diff --git a/plugins/headless-documents/headless-documents.php b/plugins/headless-documents/headless-documents.php deleted file mode 100644 index 996a2f71..00000000 --- a/plugins/headless-documents/headless-documents.php +++ /dev/null @@ -1,86 +0,0 @@ - - - Headless Documents custom coding standard. - diff --git a/plugins/headless-documents/.distignore b/plugins/hwp-documents/.distignore similarity index 100% rename from plugins/headless-documents/.distignore rename to plugins/hwp-documents/.distignore diff --git a/plugins/headless-documents/.docker/.env.ci b/plugins/hwp-documents/.docker/.env.ci similarity index 98% rename from plugins/headless-documents/.docker/.env.ci rename to plugins/hwp-documents/.docker/.env.ci index eef0bbd6..3dd4eb1b 100644 --- a/plugins/headless-documents/.docker/.env.ci +++ b/plugins/hwp-documents/.docker/.env.ci @@ -1,4 +1,4 @@ -PLUGIN_SLUG=headless-documents +PLUGIN_SLUG=hwp-documents # Configure these to match your existing testing environment or the one you want to create with Docker. ## Usually, these values should match the ones in the `wp-config.php` file. diff --git a/plugins/headless-documents/.docker/Dockerfile b/plugins/hwp-documents/.docker/Dockerfile similarity index 97% rename from plugins/headless-documents/.docker/Dockerfile rename to plugins/hwp-documents/.docker/Dockerfile index 85b4bc57..9e04f0bd 100644 --- a/plugins/headless-documents/.docker/Dockerfile +++ b/plugins/hwp-documents/.docker/Dockerfile @@ -1,5 +1,5 @@ ############################################################################### -# Pre-configured WordPress Installation w/ Headless Documents Plugin +# Pre-configured WordPress Installation w/ HWP Documents Plugin # For testing only, use in production not recommended. # ############################################################################### diff --git a/plugins/headless-documents/.docker/init-docker.sh b/plugins/hwp-documents/.docker/init-docker.sh similarity index 100% rename from plugins/headless-documents/.docker/init-docker.sh rename to plugins/hwp-documents/.docker/init-docker.sh diff --git a/plugins/headless-documents/.editorconfig b/plugins/hwp-documents/.editorconfig similarity index 100% rename from plugins/headless-documents/.editorconfig rename to plugins/hwp-documents/.editorconfig diff --git a/plugins/headless-documents/.env.dist b/plugins/hwp-documents/.env.dist similarity index 98% rename from plugins/headless-documents/.env.dist rename to plugins/hwp-documents/.env.dist index b9cb4cc5..45e62f27 100644 --- a/plugins/headless-documents/.env.dist +++ b/plugins/hwp-documents/.env.dist @@ -1,4 +1,4 @@ -PLUGIN_SLUG=headless-documents +PLUGIN_SLUG=hwp-documents # Configure these to match your existing testing environment or the one you want to create with Docker. ## Usually, these values should match the ones in the `wp-config.php` file. diff --git a/plugins/headless-documents/.gitignore b/plugins/hwp-documents/.gitignore similarity index 100% rename from plugins/headless-documents/.gitignore rename to plugins/hwp-documents/.gitignore diff --git a/plugins/headless-documents/.wp-env.json b/plugins/hwp-documents/.wp-env.json similarity index 100% rename from plugins/headless-documents/.wp-env.json rename to plugins/hwp-documents/.wp-env.json diff --git a/plugins/headless-documents/LICENSE b/plugins/hwp-documents/LICENSE similarity index 100% rename from plugins/headless-documents/LICENSE rename to plugins/hwp-documents/LICENSE diff --git a/plugins/headless-documents/README.md b/plugins/hwp-documents/README.md similarity index 86% rename from plugins/headless-documents/README.md rename to plugins/hwp-documents/README.md index 0d1ba409..af1485b0 100644 --- a/plugins/headless-documents/README.md +++ b/plugins/hwp-documents/README.md @@ -1,4 +1,4 @@ -# Headless Documents +# HWP Documents Store your app's JSON documents in WordPress over REST. Every write names the version it was based on, and WordPress rejects a write based on an old version with `409 Conflict` instead of silently overwriting the newer one. @@ -7,7 +7,7 @@ Store your app's JSON documents in WordPress over REST. Every write names the ve ----- -[![Version](https://img.shields.io/github/v/release/wpengine/hwptoolkit?include_prereleases&label=prerelease&filter=%40wpengine%2Fheadless-documents-wordpress-plugin-*)](https://github.com/wpengine/hwptoolkit/releases) +[![Version](https://img.shields.io/github/v/release/wpengine/hwptoolkit?include_prereleases&label=prerelease&filter=%40wpengine%2Fhwp-documents-wordpress-plugin-*)](https://github.com/wpengine/hwptoolkit/releases) [![License](https://img.shields.io/badge/license-GPLv2%2B-green)](https://www.gnu.org/licenses/gpl-2.0.html) [![Testing Integration](https://github.com/wpengine/hwptoolkit/actions/workflows/codeception.yml/badge.svg)](https://github.com/wpengine/hwptoolkit/actions/workflows/codeception.yml) [![Code Quality](https://github.com/wpengine/hwptoolkit/actions/workflows/code-quality.yml/badge.svg)](https://github.com/wpengine/hwptoolkit/actions/workflows/code-quality.yml) @@ -18,10 +18,10 @@ Store your app's JSON documents in WordPress over REST. Every write names the ve Documents are grouped into collections, such as `preferences` or `drafts`. Each document has an ID that's unique within its collection, a version number, and data that's a JSON object or array. Use it for app data such as settings, structured drafts or form submissions, without adding a second database. -- Documents live in their own table, `wp_headless_documents` (with your site's table prefix). +- Documents live in their own table, `wp_hwp_documents` (with your site's table prefix). - Writes and deletes use compare-and-swap on the version, so of two writers sending the same version, only one succeeds. - WordPress users and capabilities control access. -- **Tools → Headless Documents** lists what your app has stored. The screen is read-only. +- **Tools → HWP Documents** lists what your app has stored. The screen is read-only. Realtime updates, complex queries and high write volume are out of scope. @@ -34,7 +34,7 @@ Realtime updates, complex queries and high write volume are out of scope. Deactivating or deleting the plugin keeps your documents. To also drop the table, and every document in it, on every site when you delete the plugin, add this to `wp-config.php` first: ```php -define( 'HEADLESS_DOCUMENTS_UNINSTALL_PLUGIN', true ); +define( 'HWP_DOCUMENTS_UNINSTALL_PLUGIN', true ); ``` ### Permissions @@ -43,13 +43,13 @@ Users who can `manage_options` (administrators) can read and write documents. To | Capability | Allows | |---|---| -| `read_headless_documents` | Reading and listing documents | -| `read_headless_documents` and `edit_headless_documents` | Creating, updating and deleting documents | +| `read_hwp_documents` | Reading and listing documents | +| `read_hwp_documents` and `edit_hwp_documents` | Creating, updating and deleting documents | Writers need both, because a rejected write returns the current document. These capabilities don't grant access to anything else in WordPress. ```php -get_role( 'editor' )->add_cap( 'read_headless_documents' ); +get_role( 'editor' )->add_cap( 'read_hwp_documents' ); ``` ## REST API @@ -83,7 +83,7 @@ GET /wp-json/headless/v1/collections/preferences/documents/site-settings } ``` -`created` and `modified` are UTC timestamps. A document that doesn't exist returns `404` with the code `headless_document_not_found`. +`created` and `modified` are UTC timestamps. A document that doesn't exist returns `404` with the code `hwp_document_not_found`. ### Create or update a document @@ -102,7 +102,7 @@ If the document has changed since the version you sent, or a create finds that t ```json { - "code": "headless_document_conflict", + "code": "hwp_document_conflict", "message": "The document has changed since the version this write was based on.", "data": { "status": 409, @@ -162,23 +162,23 @@ DELETE /wp-json/headless/v1/collections/waitlist/documents/3f9c2a7e1b0d4c6a8e5f? |---|---|---| | `400` | `rest_invalid_json`, `rest_missing_callback_param`, `rest_invalid_param` | The body isn't valid JSON, or `version` or `data` is missing or invalid. `data` must be a JSON object or array. | | `401`, `403` | `rest_forbidden` | The request isn't authenticated, or the user lacks the capability. | -| `404` | `headless_document_not_found` | The document doesn't exist. | -| `409` | `headless_document_conflict` | The version is stale. | -| `413` | `headless_document_too_large` | The document is larger than the maximum size. | +| `404` | `hwp_document_not_found` | The document doesn't exist. | +| `409` | `hwp_document_conflict` | The version is stale. | +| `413` | `hwp_document_too_large` | The document is larger than the maximum size. | ## Actions and filters | Hook | Type | Arguments | |---|---|---| -| `headless_document_saved` | Action | `array $document`, `bool $created` | -| `headless_document_deleted` | Action | `array $previous` | -| `headless_document_max_bytes` | Filter | `int $max_bytes`, default 100 KB of encoded JSON | +| `hwp_document_saved` | Action | `array $document`, `bool $created` | +| `hwp_document_deleted` | Action | `array $previous` | +| `hwp_document_max_bytes` | Filter | `int $max_bytes`, default 100 KB of encoded JSON | For example, to send an email for each waitlist signup: ```php add_action( - 'headless_document_saved', + 'hwp_document_saved', function ( $document, $created ) { if ( $created && 'waitlist' === $document['collection'] ) { wp_mail( get_option( 'admin_email' ), 'New waitlist signup', $document['data']->email ); diff --git a/plugins/headless-documents/activation.php b/plugins/hwp-documents/activation.php similarity index 65% rename from plugins/headless-documents/activation.php rename to plugins/hwp-documents/activation.php index 48a21bb0..d9a6658c 100644 --- a/plugins/headless-documents/activation.php +++ b/plugins/hwp-documents/activation.php @@ -2,14 +2,14 @@ /** * Activation Hook * - * @package Headless\Documents + * @package HWP\Documents * * @since 0.1.0 */ declare(strict_types=1); -use Headless\Documents\Store\Document_Table; +use HWP\Documents\Store\Document_Table; if ( ! defined( 'ABSPATH' ) ) { exit; @@ -21,7 +21,7 @@ * Creates the documents table for the current site. On a network activation, * each other site creates its table on its first request. */ -function headless_documents_activation_callback(): void { +function hwp_documents_activation_callback(): void { Document_Table::maybe_install(); - do_action( 'headless_documents_activate' ); + do_action( 'hwp_documents_activate' ); } diff --git a/plugins/headless-documents/bin/_lib.sh b/plugins/hwp-documents/bin/_lib.sh similarity index 100% rename from plugins/headless-documents/bin/_lib.sh rename to plugins/hwp-documents/bin/_lib.sh diff --git a/plugins/headless-documents/bin/build-docker.sh b/plugins/hwp-documents/bin/build-docker.sh similarity index 100% rename from plugins/headless-documents/bin/build-docker.sh rename to plugins/hwp-documents/bin/build-docker.sh diff --git a/plugins/headless-documents/bin/install-plugins.sh b/plugins/hwp-documents/bin/install-plugins.sh similarity index 60% rename from plugins/headless-documents/bin/install-plugins.sh rename to plugins/hwp-documents/bin/install-plugins.sh index a6951f5d..efc414e6 100755 --- a/plugins/headless-documents/bin/install-plugins.sh +++ b/plugins/hwp-documents/bin/install-plugins.sh @@ -3,5 +3,5 @@ # Exit if any command fails. set -e -# Headless Documents doesn't depend on other plugins, so there's nothing to +# HWP Documents doesn't depend on other plugins, so there's nothing to # install. Add install functions here if the tests ever need one. diff --git a/plugins/headless-documents/bin/install-test-env.sh b/plugins/hwp-documents/bin/install-test-env.sh similarity index 97% rename from plugins/headless-documents/bin/install-test-env.sh rename to plugins/hwp-documents/bin/install-test-env.sh index f905a6f4..fd435841 100755 --- a/plugins/headless-documents/bin/install-test-env.sh +++ b/plugins/hwp-documents/bin/install-test-env.sh @@ -114,7 +114,7 @@ configure_wordpress() { # Install WordPress. echo -e "$(status_message "Installing WordPress...")" - SITE_TITLE=${WORDPRESS_SITE_TITLE:-"Headless Documents Tests"} + SITE_TITLE=${WORDPRESS_SITE_TITLE:-"HWP Documents Tests"} wp core install --title="$SITE_TITLE" --admin_user="$WORDPRESS_ADMIN_USER" --admin_password="$WORDPRESS_ADMIN_PASSWORD" --admin_email="$WORDPRESS_ADMIN_EMAIL" --skip-email --url="$WORDPRESS_URL" --allow-root @@ -144,12 +144,12 @@ setup_file_permissions() { setup_plugin() { if [ "${SKIP_WP_SETUP}" = "true" ]; then - echo -e "$(warning_message "Skipping headless-documents installation...")" + echo -e "$(warning_message "Skipping hwp-documents installation...")" return 0 fi # Add this repo as a plugin to the repo - if [ ! -d $WORDPRESS_ROOT_DIR/wp-content/plugins/headless-documents ]; then + if [ ! -d $WORDPRESS_ROOT_DIR/wp-content/plugins/hwp-documents ]; then echo -e "$(status_message "Symlinking the plugin to the WordPress plugins directory...")" cd "$ORIGINAL_PATH" diff --git a/plugins/headless-documents/bin/local/run-qa.sh b/plugins/hwp-documents/bin/local/run-qa.sh similarity index 100% rename from plugins/headless-documents/bin/local/run-qa.sh rename to plugins/hwp-documents/bin/local/run-qa.sh diff --git a/plugins/headless-documents/bin/local/run-unit-tests.sh b/plugins/hwp-documents/bin/local/run-unit-tests.sh similarity index 77% rename from plugins/headless-documents/bin/local/run-unit-tests.sh rename to plugins/hwp-documents/bin/local/run-unit-tests.sh index b206d7fb..e31ffa85 100755 --- a/plugins/headless-documents/bin/local/run-unit-tests.sh +++ b/plugins/hwp-documents/bin/local/run-unit-tests.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Running Unit Tests for the Headless Documents Plugin +# Running Unit Tests for the HWP Documents Plugin # Usage: ## - sh bin/local/run-unit-tests.sh @@ -24,4 +24,4 @@ if [[ "$1" == "coverage" ]]; then fi fi -docker exec $COVERAGE_ARG $COVERAGE_OUTPUT_ARG -e SUITES=wpunit -w /var/www/html/wp-content/plugins/headless-documents headless-documents-wordpress-1 bin/run-codeception.sh +docker exec $COVERAGE_ARG $COVERAGE_OUTPUT_ARG -e SUITES=wpunit -w /var/www/html/wp-content/plugins/hwp-documents hwp-documents-wordpress-1 bin/run-codeception.sh diff --git a/plugins/headless-documents/bin/run-codeception.sh b/plugins/hwp-documents/bin/run-codeception.sh similarity index 100% rename from plugins/headless-documents/bin/run-codeception.sh rename to plugins/hwp-documents/bin/run-codeception.sh diff --git a/plugins/headless-documents/bin/sync-package-version.sh b/plugins/hwp-documents/bin/sync-package-version.sh similarity index 83% rename from plugins/headless-documents/bin/sync-package-version.sh rename to plugins/hwp-documents/bin/sync-package-version.sh index 99797d1f..36b39f82 100755 --- a/plugins/headless-documents/bin/sync-package-version.sh +++ b/plugins/hwp-documents/bin/sync-package-version.sh @@ -38,8 +38,8 @@ else echo -e "${YELLOW}⚠ readme.txt not found${NC}" fi -# Update headless-documents.php -PLUGIN_FILE="headless-documents.php" +# Update hwp-documents.php +PLUGIN_FILE="hwp-documents.php" if [ -f "$PLUGIN_FILE" ]; then echo "Updating main plugin file: $PLUGIN_FILE..." @@ -47,8 +47,8 @@ if [ -f "$PLUGIN_FILE" ]; then # Update WordPress plugin header version (handles beta versions) sed -i.bak -E "s/(\* Version:[[:space:]]*)[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?/\1$VERSION/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak" - # Update HEADLESS_DOCUMENTS_VERSION define statement - sed -i.bak -E "s/(define\([[:space:]]*['\"]HEADLESS_DOCUMENTS_VERSION['\"][[:space:]]*,[[:space:]]*['\"])[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?(['\"][[:space:]]*\))/\1$VERSION\3/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak" + # Update HWP_DOCUMENTS_VERSION define statement + sed -i.bak -E "s/(define\([[:space:]]*['\"]HWP_DOCUMENTS_VERSION['\"][[:space:]]*,[[:space:]]*['\"])[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?(['\"][[:space:]]*\))/\1$VERSION\3/g" "$PLUGIN_FILE" && rm "${PLUGIN_FILE}.bak" echo -e "${GREEN}✓ Updated $PLUGIN_FILE${NC}" else diff --git a/plugins/headless-documents/codeception.dist.yml b/plugins/hwp-documents/codeception.dist.yml similarity index 93% rename from plugins/headless-documents/codeception.dist.yml rename to plugins/hwp-documents/codeception.dist.yml index e51280e5..e744f0e0 100644 --- a/plugins/headless-documents/codeception.dist.yml +++ b/plugins/hwp-documents/codeception.dist.yml @@ -35,7 +35,7 @@ extensions: coverage: enabled: true remote: false - c3_url: "%WORDPRESS_URL%/wp-content/plugins/headless-documents/headless-documents.php" + c3_url: "%WORDPRESS_URL%/wp-content/plugins/hwp-documents/hwp-documents.php" include: - src/* - /activation.php @@ -94,7 +94,7 @@ modules: adminEmail: "%WORDPRESS_ADMIN_EMAIL%" title: 'Test' plugins: - - headless-documents/headless-documents.php + - hwp-documents/hwp-documents.php activatePlugins: - - headless-documents/headless-documents.php + - hwp-documents/hwp-documents.php configFile: 'tests/_data/config.php' diff --git a/plugins/headless-documents/composer.json b/plugins/hwp-documents/composer.json similarity index 93% rename from plugins/headless-documents/composer.json rename to plugins/hwp-documents/composer.json index 3535280b..f672db7d 100644 --- a/plugins/headless-documents/composer.json +++ b/plugins/hwp-documents/composer.json @@ -1,5 +1,5 @@ { - "name": "wpengine/headless-documents", + "name": "wpengine/hwp-documents", "type": "wordpress-plugin", "description": "A WordPress plugin that stores versioned JSON documents for headless apps.", "license": "GPL-2.0", @@ -68,7 +68,7 @@ } }, "archive": { - "name": "headless-documents", + "name": "hwp-documents", "exclude": [ "/.*", "/build-sha.txt", @@ -98,7 +98,7 @@ }, "autoload": { "psr-4": { - "Headless\\Documents\\": "src/" + "HWP\\Documents\\": "src/" }, "exclude-from-classmap": [ "/vendor/wp-cli/" @@ -106,9 +106,9 @@ }, "autoload-dev": { "psr-4": { - "Headless\\Documents\\Tests\\": "tests/wpunit/", - "Headless\\Documents\\PHPStan\\": "phpstan/", - "HeadlessStandard\\": "phpcs/HeadlessStandard" + "HWP\\Documents\\Tests\\": "tests/wpunit/", + "HWP\\Documents\\PHPStan\\": "phpstan/", + "HWPStandard\\": "phpcs/HWPStandard" } }, "scripts": { diff --git a/plugins/headless-documents/composer.lock b/plugins/hwp-documents/composer.lock similarity index 99% rename from plugins/headless-documents/composer.lock rename to plugins/hwp-documents/composer.lock index aa39c941..4ae05f40 100644 --- a/plugins/headless-documents/composer.lock +++ b/plugins/hwp-documents/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "78c9bcf6726b7d490acdf5f235e3562b", + "content-hash": "825e937aa844aae85bd504dd954bf016", "packages": [], "packages-dev": [ { diff --git a/plugins/headless-documents/deactivation.php b/plugins/hwp-documents/deactivation.php similarity index 67% rename from plugins/headless-documents/deactivation.php rename to plugins/hwp-documents/deactivation.php index 28866ee0..56f1b227 100644 --- a/plugins/headless-documents/deactivation.php +++ b/plugins/hwp-documents/deactivation.php @@ -5,7 +5,7 @@ * Documents are kept when the plugin is deactivated. Deleting the plugin * drops them; see uninstall.php. * - * @package Headless\Documents + * @package HWP\Documents * * @since 0.1.0 */ @@ -19,6 +19,6 @@ /** * Runs when the plugin is deactivated. */ -function headless_documents_deactivation_callback(): void { - do_action( 'headless_documents_deactivate' ); +function hwp_documents_deactivation_callback(): void { + do_action( 'hwp_documents_deactivate' ); } diff --git a/plugins/headless-documents/docker-compose.yml b/plugins/hwp-documents/docker-compose.yml similarity index 100% rename from plugins/headless-documents/docker-compose.yml rename to plugins/hwp-documents/docker-compose.yml diff --git a/plugins/hwp-documents/hwp-documents.php b/plugins/hwp-documents/hwp-documents.php new file mode 100644 index 00000000..a32739ec --- /dev/null +++ b/plugins/hwp-documents/hwp-documents.php @@ -0,0 +1,86 @@ + - + - Coding standards for the Headless Documents plugin - ./headless-documents.php + Coding standards for the HWP Documents plugin + ./hwp-documents.php ./activation.php ./deactivation.php ./uninstall.php @@ -79,10 +79,10 @@ - - - - + + + + @@ -90,7 +90,7 @@ - + @@ -348,6 +348,6 @@ - + diff --git a/plugins/headless-documents/phpcs/HeadlessStandard/Sniffs/ControlStructures/ElseKeywordSniff.php b/plugins/hwp-documents/phpcs/HWPStandard/Sniffs/ControlStructures/ElseKeywordSniff.php similarity index 95% rename from plugins/headless-documents/phpcs/HeadlessStandard/Sniffs/ControlStructures/ElseKeywordSniff.php rename to plugins/hwp-documents/phpcs/HWPStandard/Sniffs/ControlStructures/ElseKeywordSniff.php index 1bfddbc3..98bd26de 100644 --- a/plugins/headless-documents/phpcs/HeadlessStandard/Sniffs/ControlStructures/ElseKeywordSniff.php +++ b/plugins/hwp-documents/phpcs/HWPStandard/Sniffs/ControlStructures/ElseKeywordSniff.php @@ -2,7 +2,7 @@ /** * Sniff to detect usage of else keywords in if statements */ -namespace HeadlessStandard\Sniffs\ControlStructures; +namespace HWPStandard\Sniffs\ControlStructures; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; diff --git a/plugins/hwp-documents/phpcs/HWPStandard/ruleset.xml b/plugins/hwp-documents/phpcs/HWPStandard/ruleset.xml new file mode 100644 index 00000000..fc9f79e9 --- /dev/null +++ b/plugins/hwp-documents/phpcs/HWPStandard/ruleset.xml @@ -0,0 +1,4 @@ + + + HWP Documents custom coding standard. + diff --git a/plugins/headless-documents/phpstan.neon.dist b/plugins/hwp-documents/phpstan.neon.dist similarity index 89% rename from plugins/headless-documents/phpstan.neon.dist rename to plugins/hwp-documents/phpstan.neon.dist index 82a66d16..f80a32de 100644 --- a/plugins/headless-documents/phpstan.neon.dist +++ b/plugins/hwp-documents/phpstan.neon.dist @@ -4,7 +4,7 @@ includes: services: - - class: Headless\Documents\PHPStan\Rules\ClassConstantVarAnnotationRule + class: HWP\Documents\PHPStan\Rules\ClassConstantVarAnnotationRule tags: [phpstan.rules.rule] parameters: @@ -28,7 +28,7 @@ parameters: min: 80200 max: 80400 paths: - - headless-documents.php + - hwp-documents.php - activation.php - deactivation.php - uninstall.php diff --git a/plugins/headless-documents/phpstan/Rules/ClassConstantVarAnnotationRule.php b/plugins/hwp-documents/phpstan/Rules/ClassConstantVarAnnotationRule.php similarity index 95% rename from plugins/headless-documents/phpstan/Rules/ClassConstantVarAnnotationRule.php rename to plugins/hwp-documents/phpstan/Rules/ClassConstantVarAnnotationRule.php index da16c9de..1515d560 100644 --- a/plugins/headless-documents/phpstan/Rules/ClassConstantVarAnnotationRule.php +++ b/plugins/hwp-documents/phpstan/Rules/ClassConstantVarAnnotationRule.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Headless\Documents\PHPStan\Rules; +namespace HWP\Documents\PHPStan\Rules; use PhpParser\Node; use PhpParser\Comment\Doc; diff --git a/plugins/headless-documents/psalm.xml b/plugins/hwp-documents/psalm.xml similarity index 91% rename from plugins/headless-documents/psalm.xml rename to plugins/hwp-documents/psalm.xml index 448d14b0..2bf388dc 100644 --- a/plugins/headless-documents/psalm.xml +++ b/plugins/hwp-documents/psalm.xml @@ -9,7 +9,7 @@ findUnusedCode="false" > - + @@ -27,7 +27,7 @@ - + diff --git a/plugins/headless-documents/readme.txt b/plugins/hwp-documents/readme.txt similarity index 66% rename from plugins/headless-documents/readme.txt rename to plugins/hwp-documents/readme.txt index be2d1a1c..c4577309 100644 --- a/plugins/headless-documents/readme.txt +++ b/plugins/hwp-documents/readme.txt @@ -1,4 +1,4 @@ -=== Headless Documents === +=== HWP Documents === Contributors: wpengine Tags: headless, rest api, json, documents, app data Requires at least: 6.0 @@ -12,7 +12,7 @@ Store your app's JSON documents in WordPress over REST, with versioned writes th == Description == -**Headless Documents** gives your headless app a place to store JSON documents, such as settings, structured drafts or form submissions, in the WordPress site you already have. +**HWP Documents** gives your headless app a place to store JSON documents, such as settings, structured drafts or form submissions, in the WordPress site you already have. Documents are grouped into collections. Each document has an ID that's unique within its collection, a version number, and data that's a JSON object or array. Every write names the version it was based on, and WordPress rejects a write based on an old version with `409 Conflict`, returning the current document so your app can merge or retry. @@ -21,17 +21,17 @@ Documents are grouped into collections. Each document has an ID that's unique wi * REST routes to read, create, update, delete, list and add documents under `headless/v1` * Compare-and-swap writes: of two writers sending the same version, only one succeeds * A dedicated database table, created on activation and kept when the plugin is deleted unless you opt in -* Access through WordPress users and the `read_headless_documents` and `edit_headless_documents` capabilities -* `headless_document_saved` and `headless_document_deleted` actions -* A read-only Tools → Headless Documents screen +* Access through WordPress users and the `read_hwp_documents` and `edit_hwp_documents` capabilities +* `hwp_document_saved` and `hwp_document_deleted` actions +* A read-only Tools → HWP Documents screen = Documentation = -For REST examples and setup, see the [README on GitHub](https://github.com/wpengine/hwptoolkit/tree/main/plugins/headless-documents). +For REST examples and setup, see the [README on GitHub](https://github.com/wpengine/hwptoolkit/tree/main/plugins/hwp-documents). == Installation == -1. Upload the plugin files to `/wp-content/plugins/headless-documents/`, or install the plugin through the WordPress plugins screen directly +1. Upload the plugin files to `/wp-content/plugins/hwp-documents/`, or install the plugin through the WordPress plugins screen directly 2. Activate the plugin through the 'Plugins' screen in WordPress 3. Authenticate your app's REST requests, for example with an Application Password for a user who can manage options @@ -39,11 +39,11 @@ For REST examples and setup, see the [README on GitHub](https://github.com/wpeng = Who can read and write documents? = -Administrators can. Give other users the `read_headless_documents` capability to read, and both `read_headless_documents` and `edit_headless_documents` to write. +Administrators can. Give other users the `read_hwp_documents` capability to read, and both `read_hwp_documents` and `edit_hwp_documents` to write. = What happens to my documents if I deactivate or delete the plugin? = -Deactivating or deleting the plugin keeps them. To drop the documents table and every document in it when you delete the plugin, define `HEADLESS_DOCUMENTS_UNINSTALL_PLUGIN` as `true` in `wp-config.php` first. +Deactivating or deleting the plugin keeps them. To drop the documents table and every document in it when you delete the plugin, define `HWP_DOCUMENTS_UNINSTALL_PLUGIN` as `true` in `wp-config.php` first. = Does it support WPGraphQL? = @@ -55,4 +55,4 @@ For support, feature requests, or bug reports, please visit our [GitHub issues p == Changelog == -For the changelog, see [CHANGELOG.md](https://github.com/wpengine/hwptoolkit/blob/main/plugins/headless-documents/CHANGELOG.md). +For the changelog, see [CHANGELOG.md](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-documents/CHANGELOG.md). diff --git a/plugins/headless-documents/src/Admin/Documents_Page.php b/plugins/hwp-documents/src/Admin/Documents_Page.php similarity index 77% rename from plugins/headless-documents/src/Admin/Documents_Page.php rename to plugins/hwp-documents/src/Admin/Documents_Page.php index 9c9a063e..141e16f1 100644 --- a/plugins/headless-documents/src/Admin/Documents_Page.php +++ b/plugins/hwp-documents/src/Admin/Documents_Page.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Headless\Documents\Admin; +namespace HWP\Documents\Admin; -use Headless\Documents\Identifiers; -use Headless\Documents\Store\Document_Store; +use HWP\Documents\Identifiers; +use HWP\Documents\Store\Document_Store; /** * Read-only Tools screen that lists documents and shows each document's data. * * Nothing here can change a document. * - * @package Headless\Documents\Admin + * @package HWP\Documents\Admin */ final class Documents_Page { /** @@ -27,8 +27,8 @@ final class Documents_Page { */ public static function register(): void { add_management_page( - __( 'Headless Documents', 'headless-documents' ), - __( 'Headless Documents', 'headless-documents' ), + __( 'HWP Documents', 'hwp-documents' ), + __( 'HWP Documents', 'hwp-documents' ), Identifiers::READ_CAPABILITY, // phpcs:ignore WordPress.WP.Capabilities.Undetermined -- Custom capability. Identifiers::ADMIN_PAGE_SLUG, [ self::class, 'render' ] @@ -40,7 +40,7 @@ public static function register(): void { */ public static function render(): void { if ( ! current_user_can( Identifiers::READ_CAPABILITY ) ) { // phpcs:ignore WordPress.WP.Capabilities.Undetermined -- Custom capability. - wp_die( esc_html__( 'Sorry, you are not allowed to view documents.', 'headless-documents' ), 403 ); + wp_die( esc_html__( 'Sorry, you are not allowed to view documents.', 'hwp-documents' ), 403 ); } $collection = self::query_arg( 'collection' ); @@ -113,20 +113,20 @@ private static function last_author( array $summary ): string { private static function render_list( int $paged ): void { $list = Document_Store::list_all( $paged, self::PER_PAGE ); - echo '

' . esc_html__( 'Headless Documents', 'headless-documents' ) . '

'; - echo '

' . esc_html__( 'Documents your app has saved through the document REST API. This screen is read-only.', 'headless-documents' ) . '

'; + echo '

' . esc_html__( 'HWP Documents', 'hwp-documents' ) . '

'; + echo '

' . esc_html__( 'Documents your app has saved through the document REST API. This screen is read-only.', 'hwp-documents' ) . '

'; if ( [] === $list['documents'] ) { - echo '

' . esc_html__( 'No documents yet. Your app creates a document the first time it saves one.', 'headless-documents' ) . '

'; + echo '

' . esc_html__( 'No documents yet. Your app creates a document the first time it saves one.', 'hwp-documents' ) . '

'; return; } echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; foreach ( $list['documents'] as $summary ) { @@ -182,29 +182,29 @@ private static function render_row( array $summary ): void { * @param string $id Document ID from the request. */ private static function render_detail( string $collection, string $id ): void { - echo '

' . esc_html__( 'Document', 'headless-documents' ) . '

'; - printf( '

%s

', esc_url( self::url() ), esc_html__( '← All documents', 'headless-documents' ) ); + echo '

' . esc_html__( 'Document', 'hwp-documents' ) . '

'; + printf( '

%s

', esc_url( self::url() ), esc_html__( '← All documents', 'hwp-documents' ) ); $valid = Document_Store::is_valid_key( $collection, $id ); $document = $valid ? Document_Store::get( $collection, $id ) : null; $summary = $valid ? Document_Store::get_summary( $collection, $id ) : null; if ( null === $document || null === $summary ) { - echo '

' . esc_html__( 'Document not found.', 'headless-documents' ) . '

'; + echo '

' . esc_html__( 'Document not found.', 'hwp-documents' ) . '

'; return; } $json = wp_json_encode( $document['data'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); echo '
' . esc_html__( 'Collection', 'headless-documents' ) . '' . esc_html__( 'ID', 'headless-documents' ) . '' . esc_html__( 'Version', 'headless-documents' ) . '' . esc_html__( 'Last saved', 'headless-documents' ) . '' . esc_html__( 'Saved by', 'headless-documents' ) . '' . esc_html__( 'Collection', 'hwp-documents' ) . '' . esc_html__( 'ID', 'hwp-documents' ) . '' . esc_html__( 'Version', 'hwp-documents' ) . '' . esc_html__( 'Last saved', 'hwp-documents' ) . '' . esc_html__( 'Saved by', 'hwp-documents' ) . '
'; - printf( '', esc_html__( 'Collection', 'headless-documents' ), esc_html( (string) $document['collection'] ) ); - printf( '', esc_html__( 'ID', 'headless-documents' ), esc_html( (string) $document['id'] ) ); - printf( '', esc_html__( 'Version', 'headless-documents' ), esc_html( (string) $document['version'] ) ); - printf( '', esc_html__( 'Last saved', 'headless-documents' ), esc_html( self::format_modified( $summary ) ) ); - printf( '', esc_html__( 'Saved by', 'headless-documents' ), esc_html( self::last_author( $summary ) ) ); + printf( '', esc_html__( 'Collection', 'hwp-documents' ), esc_html( (string) $document['collection'] ) ); + printf( '', esc_html__( 'ID', 'hwp-documents' ), esc_html( (string) $document['id'] ) ); + printf( '', esc_html__( 'Version', 'hwp-documents' ), esc_html( (string) $document['version'] ) ); + printf( '', esc_html__( 'Last saved', 'hwp-documents' ), esc_html( self::format_modified( $summary ) ) ); + printf( '', esc_html__( 'Saved by', 'hwp-documents' ), esc_html( self::last_author( $summary ) ) ); echo ''; - echo '

' . esc_html__( 'Data', 'headless-documents' ) . '

'; + echo '

' . esc_html__( 'Data', 'hwp-documents' ) . '

'; echo '
' . esc_html( (string) $json ) . '
'; } } diff --git a/plugins/headless-documents/src/Autoloader.php b/plugins/hwp-documents/src/Autoloader.php similarity index 90% rename from plugins/headless-documents/src/Autoloader.php rename to plugins/hwp-documents/src/Autoloader.php index 0c298380..2d62c843 100644 --- a/plugins/headless-documents/src/Autoloader.php +++ b/plugins/hwp-documents/src/Autoloader.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Headless\Documents; +namespace HWP\Documents; /** * Includes the composer Autoloader used for packages and classes in the src/ directory. * - * @package Headless\Documents + * @package HWP\Documents * * @since 0.0.1 */ @@ -65,7 +65,7 @@ protected static function require_autoloader( string $autoloader_file ): bool { * Displays a notice if the autoloader is missing. */ protected static function missing_autoloader_notice(): void { - $error_message = 'Headless Documents: The Composer autoloader was not found. If you installed the plugin from the GitHub source, make sure to run `composer install`.'; + $error_message = 'HWP Documents: The Composer autoloader was not found. If you installed the plugin from the GitHub source, make sure to run `composer install`.'; if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( esc_html( $error_message ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- This is a development notice. diff --git a/plugins/headless-documents/src/Capabilities.php b/plugins/hwp-documents/src/Capabilities.php similarity index 92% rename from plugins/headless-documents/src/Capabilities.php rename to plugins/hwp-documents/src/Capabilities.php index 49f91d28..282997a6 100644 --- a/plugins/headless-documents/src/Capabilities.php +++ b/plugins/hwp-documents/src/Capabilities.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Headless\Documents; +namespace HWP\Documents; /** * Grants the document capabilities. * - * @package Headless\Documents + * @package HWP\Documents */ final class Capabilities { /** diff --git a/plugins/headless-documents/src/Identifiers.php b/plugins/hwp-documents/src/Identifiers.php similarity index 69% rename from plugins/headless-documents/src/Identifiers.php rename to plugins/hwp-documents/src/Identifiers.php index b011de05..376562c4 100644 --- a/plugins/headless-documents/src/Identifiers.php +++ b/plugins/hwp-documents/src/Identifiers.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Headless\Documents; +namespace HWP\Documents; /** * Names the plugin registers with WordPress. @@ -10,7 +10,7 @@ * Hook names and the text domain are written out where they're used, because * WordPress tooling only finds literal strings. * - * @package Headless\Documents + * @package HWP\Documents */ final class Identifiers { /** @@ -25,47 +25,47 @@ final class Identifiers { * * @var string */ - public const TABLE = 'headless_documents'; + public const TABLE = 'hwp_documents'; /** * Option holding the installed documents table schema version. * * @var string */ - public const DB_VERSION_OPTION = 'headless_documents_db_version'; + public const DB_VERSION_OPTION = 'hwp_documents_db_version'; /** * Name of the lock held while the documents table is created or updated. * * @var string */ - public const INSTALL_LOCK = 'headless_documents_db'; + public const INSTALL_LOCK = 'hwp_documents_db'; /** * Capability needed to read documents. * * @var string */ - public const READ_CAPABILITY = 'read_headless_documents'; + public const READ_CAPABILITY = 'read_hwp_documents'; /** * Capability needed to create, update and delete documents. * * @var string */ - public const EDIT_CAPABILITY = 'edit_headless_documents'; + public const EDIT_CAPABILITY = 'edit_hwp_documents'; /** * Prefix of the error codes the document routes return. * * @var string */ - public const ERROR_PREFIX = 'headless_document_'; + public const ERROR_PREFIX = 'hwp_document_'; /** * Slug of the Tools screen that lists documents. * * @var string */ - public const ADMIN_PAGE_SLUG = 'headless-documents'; + public const ADMIN_PAGE_SLUG = 'hwp-documents'; } diff --git a/plugins/headless-documents/src/Plugin.php b/plugins/hwp-documents/src/Plugin.php similarity index 79% rename from plugins/headless-documents/src/Plugin.php rename to plugins/hwp-documents/src/Plugin.php index 8b826d92..be5f2c4d 100644 --- a/plugins/headless-documents/src/Plugin.php +++ b/plugins/hwp-documents/src/Plugin.php @@ -2,24 +2,24 @@ declare(strict_types=1); -namespace Headless\Documents; +namespace HWP\Documents; -use Headless\Documents\Admin\Documents_Page; -use Headless\Documents\Rest\Documents_Controller; -use Headless\Documents\Store\Document_Table; +use HWP\Documents\Admin\Documents_Page; +use HWP\Documents\Rest\Documents_Controller; +use HWP\Documents\Store\Document_Table; /** - * Plugin class for Headless Documents. + * Plugin class for HWP Documents. * * Registers the plugin's action and filter hooks. * - * @package Headless\Documents + * @package HWP\Documents */ final class Plugin { /** * The instance of the plugin. * - * @var \Headless\Documents\Plugin|null + * @var \HWP\Documents\Plugin|null */ protected static ?Plugin $instance = null; @@ -41,9 +41,9 @@ public static function init(): self { /** * Fires after the plugin is initialized. * - * @param \Headless\Documents\Plugin $instance The instance of the plugin class. + * @param \HWP\Documents\Plugin $instance The instance of the plugin class. */ - do_action( 'headless_documents_init', self::$instance ); + do_action( 'hwp_documents_init', self::$instance ); return self::$instance; } diff --git a/plugins/headless-documents/src/Rest/Documents_Controller.php b/plugins/hwp-documents/src/Rest/Documents_Controller.php similarity index 98% rename from plugins/headless-documents/src/Rest/Documents_Controller.php rename to plugins/hwp-documents/src/Rest/Documents_Controller.php index b3255e06..a12f599f 100644 --- a/plugins/headless-documents/src/Rest/Documents_Controller.php +++ b/plugins/hwp-documents/src/Rest/Documents_Controller.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Headless\Documents\Rest; +namespace HWP\Documents\Rest; -use Headless\Documents\Identifiers; -use Headless\Documents\Store\Document_Store; +use HWP\Documents\Identifiers; +use HWP\Documents\Store\Document_Store; use WP_REST_Request; use WP_REST_Response; @@ -20,7 +20,7 @@ * - PUT /collections/{collection}/documents/{id} Create (version 0) or update (current version) a document. * - DELETE /collections/{collection}/documents/{id} Delete the current version of a document. * - * @package Headless\Documents\Rest + * @package HWP\Documents\Rest */ final class Documents_Controller { /** diff --git a/plugins/headless-documents/src/Store/Document_Store.php b/plugins/hwp-documents/src/Store/Document_Store.php similarity index 96% rename from plugins/headless-documents/src/Store/Document_Store.php rename to plugins/hwp-documents/src/Store/Document_Store.php index 840a8d7d..416c79be 100644 --- a/plugins/headless-documents/src/Store/Document_Store.php +++ b/plugins/hwp-documents/src/Store/Document_Store.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Headless\Documents\Store; +namespace HWP\Documents\Store; -use Headless\Documents\Identifiers; +use HWP\Documents\Identifiers; use WP_Error; use stdClass; @@ -16,7 +16,7 @@ * and a write based on an old version is rejected instead of overwriting a * newer one. * - * @package Headless\Documents\Store + * @package HWP\Documents\Store */ final class Document_Store { /** @@ -66,7 +66,7 @@ public static function max_bytes(): int { * * @param int $max_bytes Maximum size in bytes. Default 100 KB. */ - return (int) apply_filters( 'headless_document_max_bytes', self::DEFAULT_MAX_BYTES ); + return (int) apply_filters( 'hwp_document_max_bytes', self::DEFAULT_MAX_BYTES ); } /** @@ -184,7 +184,7 @@ public static function list_all( int $page = 1, int $per_page = 20 ): array { * version is still the expected one, so if two writers send the same version * at once, only one of them succeeds. * - * Fires headless_document_saved after a successful write. + * Fires hwp_document_saved after a successful write. * * @param string $collection Collection name. * @param string $id Document ID. @@ -222,7 +222,7 @@ public static function save( string $collection, string $id, int $expected_versi * @param array $document The saved document. * @param bool $created True if the document was created. */ - do_action( 'headless_document_saved', $document, $result['is_new'] ); + do_action( 'hwp_document_saved', $document, $result['is_new'] ); return $document + [ 'is_new' => $result['is_new'] ]; } @@ -252,7 +252,7 @@ public static function add( string $collection, $data ) { /** * Delete a document if it's still at the expected version. * - * Fires headless_document_deleted after a successful delete. + * Fires hwp_document_deleted after a successful delete. * * @param string $collection Collection name. * @param string $id Document ID. @@ -296,7 +296,7 @@ public static function delete( string $collection, string $id, int $expected_ver * * @param array $previous The document as it was before it was deleted. */ - do_action( 'headless_document_deleted', $previous ); + do_action( 'hwp_document_deleted', $previous ); return $previous; } @@ -314,7 +314,7 @@ public static function error_code( string $kind ): string { * Build the error returned when a document doesn't exist. */ public static function not_found_error(): WP_Error { - return new WP_Error( self::error_code( 'not_found' ), __( 'Document not found.', 'headless-documents' ), [ 'status' => 404 ] ); + return new WP_Error( self::error_code( 'not_found' ), __( 'Document not found.', 'hwp-documents' ), [ 'status' => 404 ] ); } /** @@ -399,11 +399,11 @@ private static function format_summary( stdClass $row ): array { private static function encode( $data ) { $encoded = wp_json_encode( $data ); if ( false === $encoded ) { - return new WP_Error( self::error_code( 'invalid' ), __( 'The document data could not be encoded as JSON.', 'headless-documents' ), [ 'status' => 400 ] ); + return new WP_Error( self::error_code( 'invalid' ), __( 'The document data could not be encoded as JSON.', 'hwp-documents' ), [ 'status' => 400 ] ); } if ( strlen( $encoded ) > self::max_bytes() ) { - return new WP_Error( self::error_code( 'too_large' ), __( 'The document is larger than the maximum size.', 'headless-documents' ), [ 'status' => 413 ] ); + return new WP_Error( self::error_code( 'too_large' ), __( 'The document is larger than the maximum size.', 'hwp-documents' ), [ 'status' => 413 ] ); } return $encoded; @@ -609,7 +609,7 @@ private static function failed_write_error( $result, string $collection, string private static function conflict_error( string $collection, string $id, ?array $current ): WP_Error { return new WP_Error( self::error_code( 'conflict' ), - __( 'The document has changed since the version this write was based on.', 'headless-documents' ), + __( 'The document has changed since the version this write was based on.', 'hwp-documents' ), [ 'status' => 409, 'collection' => $collection, @@ -624,6 +624,6 @@ private static function conflict_error( string $collection, string $id, ?array $ * Build the error returned when the database rejects a query. */ private static function database_error(): WP_Error { - return new WP_Error( self::error_code( 'db_error' ), __( 'The document could not be saved.', 'headless-documents' ), [ 'status' => 500 ] ); + return new WP_Error( self::error_code( 'db_error' ), __( 'The document could not be saved.', 'hwp-documents' ), [ 'status' => 500 ] ); } } diff --git a/plugins/headless-documents/src/Store/Document_Table.php b/plugins/hwp-documents/src/Store/Document_Table.php similarity index 97% rename from plugins/headless-documents/src/Store/Document_Table.php rename to plugins/hwp-documents/src/Store/Document_Table.php index c47b5091..53ab9370 100644 --- a/plugins/headless-documents/src/Store/Document_Table.php +++ b/plugins/hwp-documents/src/Store/Document_Table.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Headless\Documents\Store; +namespace HWP\Documents\Store; -use Headless\Documents\Identifiers; +use HWP\Documents\Identifiers; use WP_Upgrader; /** * Creates, updates and drops the documents table. * - * @package Headless\Documents\Store + * @package HWP\Documents\Store */ final class Document_Table { /** diff --git a/plugins/headless-documents/tests/_data/.gitignore b/plugins/hwp-documents/tests/_data/.gitignore similarity index 100% rename from plugins/headless-documents/tests/_data/.gitignore rename to plugins/hwp-documents/tests/_data/.gitignore diff --git a/plugins/headless-documents/tests/_data/.gitkeep b/plugins/hwp-documents/tests/_data/.gitkeep similarity index 100% rename from plugins/headless-documents/tests/_data/.gitkeep rename to plugins/hwp-documents/tests/_data/.gitkeep diff --git a/plugins/headless-documents/tests/_data/config.php b/plugins/hwp-documents/tests/_data/config.php similarity index 100% rename from plugins/headless-documents/tests/_data/config.php rename to plugins/hwp-documents/tests/_data/config.php diff --git a/plugins/headless-documents/tests/_output/.gitkeep b/plugins/hwp-documents/tests/_output/.gitkeep similarity index 100% rename from plugins/headless-documents/tests/_output/.gitkeep rename to plugins/hwp-documents/tests/_output/.gitkeep diff --git a/plugins/headless-documents/tests/_support/.gitkeep b/plugins/hwp-documents/tests/_support/.gitkeep similarity index 100% rename from plugins/headless-documents/tests/_support/.gitkeep rename to plugins/hwp-documents/tests/_support/.gitkeep diff --git a/plugins/headless-documents/tests/bootstrap.php b/plugins/hwp-documents/tests/bootstrap.php similarity index 66% rename from plugins/headless-documents/tests/bootstrap.php rename to plugins/hwp-documents/tests/bootstrap.php index 5130528b..97a40df7 100644 --- a/plugins/headless-documents/tests/bootstrap.php +++ b/plugins/hwp-documents/tests/bootstrap.php @@ -2,17 +2,17 @@ /** * This is a global bootstrap file for autoloading. * - * @package Headless\Documents\Tests + * @package HWP\Documents\Tests * - * @link https://github.com/wpengine/hwptoolkit/blob/main/plugins/headless-documents/TESTING.md + * @link https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-documents/TESTING.md */ if (file_exists(__DIR__ . '/../../vendor/autoload.php')) { require_once __DIR__ . '/../../vendor/autoload.php'; } -if (file_exists(__DIR__ . '/../../headless-documents.php')) { - require_once __DIR__ . '/../../headless-documents.php'; +if (file_exists(__DIR__ . '/../../hwp-documents.php')) { + require_once __DIR__ . '/../../hwp-documents.php'; } if (file_exists(__DIR__ . '/../../access-functions.php')) { diff --git a/plugins/headless-documents/tests/e2e/config/global-setup.js b/plugins/hwp-documents/tests/e2e/config/global-setup.js similarity index 100% rename from plugins/headless-documents/tests/e2e/config/global-setup.js rename to plugins/hwp-documents/tests/e2e/config/global-setup.js diff --git a/plugins/headless-documents/tests/e2e/playwright.config.js b/plugins/hwp-documents/tests/e2e/playwright.config.js similarity index 100% rename from plugins/headless-documents/tests/e2e/playwright.config.js rename to plugins/hwp-documents/tests/e2e/playwright.config.js diff --git a/plugins/headless-documents/tests/e2e/specs/documents.spec.js b/plugins/hwp-documents/tests/e2e/specs/documents.spec.js similarity index 90% rename from plugins/headless-documents/tests/e2e/specs/documents.spec.js rename to plugins/hwp-documents/tests/e2e/specs/documents.spec.js index f6e393b6..4364d60c 100644 --- a/plugins/headless-documents/tests/e2e/specs/documents.spec.js +++ b/plugins/hwp-documents/tests/e2e/specs/documents.spec.js @@ -1,6 +1,6 @@ import { expect, test } from "@wordpress/e2e-test-utils-playwright"; -const PLUGIN_SLUG = "headless-documents"; +const PLUGIN_SLUG = "hwp-documents"; // A collection of its own per run, so reruns against the same site start empty. const COLLECTION = `e2e-${Date.now()}`; @@ -19,7 +19,7 @@ async function restError(promise) { throw new Error("Expected the request to fail."); } -test.describe("Headless Documents", () => { +test.describe("HWP Documents", () => { test.beforeAll(async ({ requestUtils }) => { await requestUtils.activatePlugin(PLUGIN_SLUG); }); @@ -48,7 +48,7 @@ test.describe("Headless Documents", () => { data: { version: 1, data: { text: "stale" } }, }), ); - expect(conflict.code).toBe("headless_document_conflict"); + expect(conflict.code).toBe("hwp_document_conflict"); expect(conflict.data.document.data).toEqual({ text: "second" }); const read = await requestUtils.rest({ path: documentPath("note") }); @@ -69,7 +69,7 @@ test.describe("Headless Documents", () => { params: { version: 5 }, }), ); - expect(conflict.code).toBe("headless_document_conflict"); + expect(conflict.code).toBe("hwp_document_conflict"); const deleted = await requestUtils.rest({ method: "DELETE", @@ -92,7 +92,7 @@ test.describe("Headless Documents", () => { await admin.visitAdminPage("tools.php", `page=${PLUGIN_SLUG}`); - await expect(page.locator("h1")).toHaveText("Headless Documents"); + await expect(page.locator("h1")).toHaveText("HWP Documents"); const row = page.locator("tr", { hasText: COLLECTION }).filter({ hasText: "listed", }); diff --git a/plugins/headless-documents/tests/wpunit.suite.dist.yml b/plugins/hwp-documents/tests/wpunit.suite.dist.yml similarity index 100% rename from plugins/headless-documents/tests/wpunit.suite.dist.yml rename to plugins/hwp-documents/tests/wpunit.suite.dist.yml diff --git a/plugins/headless-documents/tests/wpunit/Admin/DocumentsPageTest.php b/plugins/hwp-documents/tests/wpunit/Admin/DocumentsPageTest.php similarity index 91% rename from plugins/headless-documents/tests/wpunit/Admin/DocumentsPageTest.php rename to plugins/hwp-documents/tests/wpunit/Admin/DocumentsPageTest.php index 13dc54c2..ae2840f7 100644 --- a/plugins/headless-documents/tests/wpunit/Admin/DocumentsPageTest.php +++ b/plugins/hwp-documents/tests/wpunit/Admin/DocumentsPageTest.php @@ -2,16 +2,16 @@ declare( strict_types=1 ); -namespace Headless\Documents\Tests\Admin; +namespace HWP\Documents\Tests\Admin; -use Headless\Documents\Admin\Documents_Page; -use Headless\Documents\Identifiers; -use Headless\Documents\Store\Document_Store; -use Headless\Documents\Store\Document_Table; +use HWP\Documents\Admin\Documents_Page; +use HWP\Documents\Identifiers; +use HWP\Documents\Store\Document_Store; +use HWP\Documents\Store\Document_Table; use lucatume\WPBrowser\TestCase\WPTestCase; /** - * Tests for the read-only Tools → Headless Documents screen. + * Tests for the read-only Tools → HWP Documents screen. */ class DocumentsPageTest extends WPTestCase { diff --git a/plugins/headless-documents/tests/wpunit/Core/AutoloaderTest.php b/plugins/hwp-documents/tests/wpunit/Core/AutoloaderTest.php similarity index 91% rename from plugins/headless-documents/tests/wpunit/Core/AutoloaderTest.php rename to plugins/hwp-documents/tests/wpunit/Core/AutoloaderTest.php index 2216dbf3..1b94260d 100644 --- a/plugins/headless-documents/tests/wpunit/Core/AutoloaderTest.php +++ b/plugins/hwp-documents/tests/wpunit/Core/AutoloaderTest.php @@ -2,9 +2,9 @@ declare( strict_types=1 ); -namespace Headless\Documents\Tests\Core; +namespace HWP\Documents\Tests\Core; -use Headless\Documents\Autoloader; +use HWP\Documents\Autoloader; use lucatume\WPBrowser\TestCase\WPTestCase; use ReflectionClass; @@ -40,7 +40,7 @@ public function test_autoloader_autoload_instance() { public function test_autoload_sets_is_loaded_true_when_file_exists_and_returns_true(): void { // Create a temporary autoloader file that returns true - $temp_dir = sys_get_temp_dir() . '/headless-documents-test-' . uniqid(); + $temp_dir = sys_get_temp_dir() . '/hwp-documents-test-' . uniqid(); mkdir( $temp_dir . '/vendor', 0755, true ); $autoloader_path = $temp_dir . '/vendor/autoload.php'; file_put_contents( $autoloader_path, 'assertStringContainsString( 'Headless Documents: The Composer autoloader was not found', $output ); + $this->assertStringContainsString( 'HWP Documents: The Composer autoloader was not found', $output ); $this->assertStringContainsString( 'composer install', $output ); $this->assertStringContainsString( 'error notice', $output ); } public function test_get_composer_autoloader_path_returns_expected_path() { - headless_documents_constants(); - $expected = HEADLESS_DOCUMENTS_PLUGIN_DIR . 'vendor/autoload.php'; + hwp_documents_constants(); + $expected = HWP_DOCUMENTS_PLUGIN_DIR . 'vendor/autoload.php'; $this->assertEquals( $expected, Autoloader::get_composer_autoloader_path() diff --git a/plugins/headless-documents/tests/wpunit/Core/PluginTest.php b/plugins/hwp-documents/tests/wpunit/Core/PluginTest.php similarity index 72% rename from plugins/headless-documents/tests/wpunit/Core/PluginTest.php rename to plugins/hwp-documents/tests/wpunit/Core/PluginTest.php index ad87ddc5..8e8d9050 100644 --- a/plugins/headless-documents/tests/wpunit/Core/PluginTest.php +++ b/plugins/hwp-documents/tests/wpunit/Core/PluginTest.php @@ -2,13 +2,13 @@ declare( strict_types=1 ); -namespace Headless\Documents\Tests\Core; +namespace HWP\Documents\Tests\Core; -use Headless\Documents\Admin\Documents_Page; -use Headless\Documents\Capabilities; -use Headless\Documents\Plugin; -use Headless\Documents\Rest\Documents_Controller; -use Headless\Documents\Store\Document_Table; +use HWP\Documents\Admin\Documents_Page; +use HWP\Documents\Capabilities; +use HWP\Documents\Plugin; +use HWP\Documents\Rest\Documents_Controller; +use HWP\Documents\Store\Document_Table; use lucatume\WPBrowser\TestCase\WPTestCase; /** @@ -17,15 +17,15 @@ class PluginTest extends WPTestCase { public function test_constants_are_defined() { - $this->assertTrue( defined( 'HEADLESS_DOCUMENTS_VERSION' ) ); - $this->assertTrue( defined( 'HEADLESS_DOCUMENTS_PLUGIN_DIR' ) ); - $this->assertTrue( defined( 'HEADLESS_DOCUMENTS_PLUGIN_URL' ) ); + $this->assertTrue( defined( 'HWP_DOCUMENTS_VERSION' ) ); + $this->assertTrue( defined( 'HWP_DOCUMENTS_PLUGIN_DIR' ) ); + $this->assertTrue( defined( 'HWP_DOCUMENTS_PLUGIN_URL' ) ); } public function test_init_returns_the_same_instance_and_fires_an_action() { $fired = 0; add_action( - 'headless_documents_init', + 'hwp_documents_init', function () use ( &$fired ) { $fired++; } @@ -52,13 +52,13 @@ public function test_routes_are_registered_under_the_headless_namespace() { public function test_deactivation_fires_an_action() { $fired = false; add_action( - 'headless_documents_deactivate', + 'hwp_documents_deactivate', function () use ( &$fired ) { $fired = true; } ); - headless_documents_deactivation_callback(); + hwp_documents_deactivation_callback(); $this->assertTrue( $fired ); } diff --git a/plugins/headless-documents/tests/wpunit/Core/UninstallTest.php b/plugins/hwp-documents/tests/wpunit/Core/UninstallTest.php similarity index 71% rename from plugins/headless-documents/tests/wpunit/Core/UninstallTest.php rename to plugins/hwp-documents/tests/wpunit/Core/UninstallTest.php index 94ba2e89..92a0f4d1 100644 --- a/plugins/headless-documents/tests/wpunit/Core/UninstallTest.php +++ b/plugins/hwp-documents/tests/wpunit/Core/UninstallTest.php @@ -2,11 +2,11 @@ declare( strict_types=1 ); -namespace Headless\Documents\Tests\Core; +namespace HWP\Documents\Tests\Core; -use Headless\Documents\Identifiers; -use Headless\Documents\Store\Document_Store; -use Headless\Documents\Store\Document_Table; +use HWP\Documents\Identifiers; +use HWP\Documents\Store\Document_Store; +use HWP\Documents\Store\Document_Table; use lucatume\WPBrowser\TestCase\WPTestCase; /** @@ -18,8 +18,8 @@ class UninstallTest extends WPTestCase { * Runs before the test below defines the constant, which can't be undone. */ public function test_uninstall_keeps_documents_without_the_constant() { - if ( defined( 'HEADLESS_DOCUMENTS_UNINSTALL_PLUGIN' ) ) { - $this->markTestSkipped( 'HEADLESS_DOCUMENTS_UNINSTALL_PLUGIN is already defined.' ); + if ( defined( 'HWP_DOCUMENTS_UNINSTALL_PLUGIN' ) ) { + $this->markTestSkipped( 'HWP_DOCUMENTS_UNINSTALL_PLUGIN is already defined.' ); } delete_option( Identifiers::DB_VERSION_OPTION ); @@ -27,7 +27,7 @@ public function test_uninstall_keeps_documents_without_the_constant() { Document_Store::save( 'prefs', 'kept', 0, [ 'theme' => 'dark' ] ); if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { - define( 'WP_UNINSTALL_PLUGIN', 'headless-documents/headless-documents.php' ); + define( 'WP_UNINSTALL_PLUGIN', 'hwp-documents/hwp-documents.php' ); } include dirname( __DIR__, 3 ) . '/uninstall.php'; @@ -38,8 +38,8 @@ public function test_uninstall_keeps_documents_without_the_constant() { public function test_uninstall_drops_the_table_and_its_version() { global $wpdb; - if ( ! defined( 'HEADLESS_DOCUMENTS_UNINSTALL_PLUGIN' ) ) { - define( 'HEADLESS_DOCUMENTS_UNINSTALL_PLUGIN', true ); + if ( ! defined( 'HWP_DOCUMENTS_UNINSTALL_PLUGIN' ) ) { + define( 'HWP_DOCUMENTS_UNINSTALL_PLUGIN', true ); } delete_option( Identifiers::DB_VERSION_OPTION ); @@ -47,14 +47,14 @@ public function test_uninstall_drops_the_table_and_its_version() { Document_Store::save( 'prefs', 'settings', 0, [ 'theme' => 'dark' ] ); $fired = false; add_action( - 'headless_documents_after_uninstall', + 'hwp_documents_after_uninstall', function () use ( &$fired ) { $fired = true; } ); if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { - define( 'WP_UNINSTALL_PLUGIN', 'headless-documents/headless-documents.php' ); + define( 'WP_UNINSTALL_PLUGIN', 'hwp-documents/hwp-documents.php' ); } include dirname( __DIR__, 3 ) . '/uninstall.php'; diff --git a/plugins/headless-documents/tests/wpunit/Store/DocumentStoreTest.php b/plugins/hwp-documents/tests/wpunit/Store/DocumentStoreTest.php similarity index 96% rename from plugins/headless-documents/tests/wpunit/Store/DocumentStoreTest.php rename to plugins/hwp-documents/tests/wpunit/Store/DocumentStoreTest.php index 3d86f5a9..3c445290 100644 --- a/plugins/headless-documents/tests/wpunit/Store/DocumentStoreTest.php +++ b/plugins/hwp-documents/tests/wpunit/Store/DocumentStoreTest.php @@ -2,11 +2,11 @@ declare( strict_types=1 ); -namespace Headless\Documents\Tests\Store; +namespace HWP\Documents\Tests\Store; -use Headless\Documents\Identifiers; -use Headless\Documents\Store\Document_Store; -use Headless\Documents\Store\Document_Table; +use HWP\Documents\Identifiers; +use HWP\Documents\Store\Document_Store; +use HWP\Documents\Store\Document_Table; use lucatume\WPBrowser\TestCase\WPTestCase; /** @@ -39,7 +39,7 @@ public function tearDown(): void { global $wp_rest_server; $wp_rest_server = null; - remove_all_filters( 'headless_document_max_bytes' ); + remove_all_filters( 'hwp_document_max_bytes' ); Document_Table::uninstall(); parent::tearDown(); @@ -113,7 +113,7 @@ private function normalize( $value ) { public function test_activation_creates_the_table() { Document_Table::uninstall(); - headless_documents_activation_callback(); + hwp_documents_activation_callback(); $this->assertTrue( $this->table_exists() ); $this->assertSame( Document_Table::DB_VERSION, (int) get_option( Identifiers::DB_VERSION_OPTION ) ); @@ -210,7 +210,7 @@ public function test_get_missing_document_returns_404() { $response = $this->get( 'missing' ); $this->assertSame( 404, $response->get_status() ); - $this->assertSame( 'headless_document_not_found', $response->get_data()['code'] ); + $this->assertSame( 'hwp_document_not_found', $response->get_data()['code'] ); } public function test_put_with_matching_version_updates_and_bumps_version() { @@ -231,7 +231,7 @@ public function test_put_with_stale_version_returns_409_and_keeps_document() { $error = $response->get_data(); $this->assertSame( 409, $response->get_status() ); - $this->assertSame( 'headless_document_conflict', $error['code'] ); + $this->assertSame( 'hwp_document_conflict', $error['code'] ); $this->assertSame( 2, $error['data']['version'] ); $this->assertSame( [ 'theme' => 'light' ], $this->normalize( $error['data']['document']['data'] ) ); $this->assertSame( [ 'theme' => 'light' ], $this->normalize( Document_Store::get( 'prefs', 'settings' )['data'] ) ); @@ -277,7 +277,7 @@ function ( $query ) use ( &$raced ) { $this->assertTrue( $raced ); $this->assertWPError( $result ); - $this->assertSame( 'headless_document_conflict', $result->get_error_code() ); + $this->assertSame( 'hwp_document_conflict', $result->get_error_code() ); $this->assertSame( [ 'theme' => 'light' ], $this->normalize( Document_Store::get( 'prefs', 'settings' )['data'] ) ); $this->assertSame( 2, Document_Store::get( 'prefs', 'settings' )['version'] ); } @@ -304,7 +304,7 @@ function ( $query ) use ( &$raced ) { global $wpdb; $this->assertTrue( $raced ); $this->assertWPError( $result ); - $this->assertSame( 'headless_document_conflict', $result->get_error_code() ); + $this->assertSame( 'hwp_document_conflict', $result->get_error_code() ); $this->assertSame( [ 'theme' => 'dark' ], $this->normalize( Document_Store::get( 'prefs', 'settings' )['data'] ) ); $this->assertSame( '1', $wpdb->get_var( 'SELECT COUNT(*) FROM ' . Document_Table::name() ) ); } @@ -332,7 +332,7 @@ function ( $query ) use ( &$raced ) { $this->assertTrue( $raced ); $this->assertWPError( $result ); - $this->assertSame( 'headless_document_not_found', $result->get_error_code() ); + $this->assertSame( 'hwp_document_not_found', $result->get_error_code() ); } /** @@ -357,7 +357,7 @@ function ( $query ) use ( &$raced ) { $result = Document_Store::delete( 'prefs', 'settings', 1 ); $this->assertTrue( $raced ); - $this->assertSame( 'headless_document_conflict', $result->get_error_code() ); + $this->assertSame( 'hwp_document_conflict', $result->get_error_code() ); $this->assertSame( 2, $result->get_error_data()['version'] ); $this->assertSame( [ 'theme' => 'light' ], $this->normalize( Document_Store::get( 'prefs', 'settings' )['data'] ) ); } @@ -379,7 +379,7 @@ function ( $query ) { $wpdb->suppress_errors( $suppress ); $this->assertSame( 500, $response->get_status() ); - $this->assertSame( 'headless_document_db_error', $response->get_data()['code'] ); + $this->assertSame( 'hwp_document_db_error', $response->get_data()['code'] ); $this->assertSame( [ 'status' => 500 ], $response->get_data()['data'] ); $this->assertSame( 500, $deleted->get_status() ); } @@ -488,7 +488,7 @@ public function test_a_non_json_body_cannot_replace_the_validated_data() { public function test_document_larger_than_max_size_returns_413() { add_filter( - 'headless_document_max_bytes', + 'hwp_document_max_bytes', function () { return 10; } @@ -656,7 +656,7 @@ public function test_saving_and_deleting_fire_actions() { $saved = []; $deleted = []; add_action( - 'headless_document_saved', + 'hwp_document_saved', function ( $document, $created ) use ( &$saved ) { $saved[] = [ $document['version'], $created ]; }, @@ -664,7 +664,7 @@ function ( $document, $created ) use ( &$saved ) { 2 ); add_action( - 'headless_document_deleted', + 'hwp_document_deleted', function ( $previous ) use ( &$deleted ) { $deleted[] = $previous['version']; } diff --git a/plugins/headless-documents/tests/wpunit/bootstrap.php b/plugins/hwp-documents/tests/wpunit/bootstrap.php similarity index 89% rename from plugins/headless-documents/tests/wpunit/bootstrap.php rename to plugins/hwp-documents/tests/wpunit/bootstrap.php index 5f09593b..e774f14c 100644 --- a/plugins/headless-documents/tests/wpunit/bootstrap.php +++ b/plugins/hwp-documents/tests/wpunit/bootstrap.php @@ -8,4 +8,4 @@ // Activating the plugin created a real documents table. Drop it, so each test // creates its own temporary table and table checks see only that one. -Headless\Documents\Store\Document_Table::uninstall(); +HWP\Documents\Store\Document_Table::uninstall(); diff --git a/plugins/headless-documents/uninstall.php b/plugins/hwp-documents/uninstall.php similarity index 50% rename from plugins/headless-documents/uninstall.php rename to plugins/hwp-documents/uninstall.php index d559365b..7c1706cd 100644 --- a/plugins/headless-documents/uninstall.php +++ b/plugins/hwp-documents/uninstall.php @@ -1,18 +1,18 @@ 'ids', 'number' => 0, ] ); - foreach ( $headless_documents_site_ids as $headless_documents_site_id ) { - switch_to_blog( (int) $headless_documents_site_id ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.switch_to_blog_switch_to_blog -- Only the database context is needed. + foreach ( $hwp_documents_site_ids as $hwp_documents_site_id ) { + switch_to_blog( (int) $hwp_documents_site_id ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.switch_to_blog_switch_to_blog -- Only the database context is needed. Document_Table::uninstall(); restore_current_blog(); } } // Fire action for extensibility. -do_action( 'headless_documents_after_uninstall' ); +do_action( 'hwp_documents_after_uninstall' ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c39344a3..a51dd107 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,7 +106,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 - plugins/headless-documents: {} + plugins/hwp-documents: {} plugins/hwp-previews: {} diff --git a/release-please-config.json b/release-please-config.json index 144423f6..f1e27501 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -21,6 +21,10 @@ { "type": "style", "section": "Styles", "hidden": true } ], "packages": { + "plugins/hwp-documents": { + "component": "@wpengine/hwp-documents-wordpress-plugin", + "exclude-paths": ["plugins/hwp-documents/examples"] + }, "plugins/hwp-previews": { "component": "@wpengine/hwp-previews-wordpress-plugin", "exclude-paths": ["plugins/hwp-previews/examples"] From a158557857f83416beddb6d2e569f29cfbd19085 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 22 Oct 2026 23:41:12 +0000 Subject: [PATCH 2/2] chore: regenerate llms.txt [skip ci] --- llms.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llms.txt b/llms.txt index d2e6b01a..d28d23a2 100644 --- a/llms.txt +++ b/llms.txt @@ -6,8 +6,8 @@ WordPress plugins for the Headless WordPress Toolkit. Each plugin is paired with an NPM package. -- [HWP Documents](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-documents/README.md) - [HWP CLI Plugin](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-cli/README.md) +- [HWP Documents](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-documents/README.md) - [HWP Previews](https://github.com/wpengine/hwptoolkit/blob/main/plugins/hwp-previews/README.md) - [WPGraphQL Debug Extensions](https://github.com/wpengine/hwptoolkit/blob/main/plugins/wpgraphql-debug-extensions/README.md) - [WPGraphQL Logging](https://github.com/wpengine/hwptoolkit/blob/main/plugins/wpgraphql-logging/README.md)