-
+
@@ -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 '| ' . esc_html__( 'Collection', 'headless-documents' ) . ' | ';
- echo '' . esc_html__( 'ID', 'headless-documents' ) . ' | ';
- echo '' . esc_html__( 'Version', 'headless-documents' ) . ' | ';
- echo '' . esc_html__( 'Last saved', 'headless-documents' ) . ' | ';
- echo '' . esc_html__( 'Saved by', 'headless-documents' ) . ' | ';
+ echo '' . esc_html__( 'Collection', 'hwp-documents' ) . ' | ';
+ echo '' . esc_html__( 'ID', 'hwp-documents' ) . ' | ';
+ echo '' . esc_html__( 'Version', 'hwp-documents' ) . ' | ';
+ echo '' . esc_html__( 'Last saved', 'hwp-documents' ) . ' | ';
+ echo '' . esc_html__( 'Saved by', 'hwp-documents' ) . ' | ';
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 '';
- 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"]