diff --git a/ACTIONS_AND_FILTERS.md b/ACTIONS_AND_FILTERS.md index b518ebd..7919f60 100644 --- a/ACTIONS_AND_FILTERS.md +++ b/ACTIONS_AND_FILTERS.md @@ -14,8 +14,13 @@ ## JavaScript Actions -- `wpgraphqlide_destroyed` -- `wpgraphqlide_rendered` ([graphiql_rendered](https://www.wpgraphql.com/docs/customizing-wpgraphiql#graphiql_rendered)) +- `wpgraphql-ide.init` +- `wpgraphql-ide.rendered` ([graphiql_rendered](https://www.wpgraphql.com/docs/customizing-wpgraphiql#graphiql_rendered)) +- `wpgraphql-ide.destroyed` +- `wpgraphql-ide.afterRegisterToolbarButton` +- `wpgraphql-ide.registerToolbarButtonError` +- `wpgraphql-ide.afterRegisterActivityBarPanel` +- `wpgraphql-ide.registerActivityBarPanelError` ## JavaScript Filters diff --git a/package.json b/package.json index f38aacd..178ab95 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "wp-env": "wp-env" }, "devDependencies": { + "@changesets/cli": "^2.27.1", "@babel/preset-env": "^7.23.9", "@babel/preset-react": "^7.23.3", "@playwright/test": "^1.41.2", @@ -63,7 +64,6 @@ "sort-package-json": "^2.7.0" }, "dependencies": { - "@changesets/cli": "^2.27.1", "@graphiql/react": "^0.22.2", "@graphiql/toolkit": "^0.9.1", "@wordpress/components": "^27.0.0", diff --git a/readme.txt b/readme.txt index 83e41cf..f540fb8 100644 --- a/readme.txt +++ b/readme.txt @@ -18,6 +18,23 @@ GraphQL IDE for WPGraphQL == Frequently Asked Questions == += Where can I find the non-compressed JavaScript and CSS source code? = + +The non-compressed source code for the JavaScript and CSS files is available in the following directories: + +- **Scripts**: [src/ directory](https://github.com/wp-graphql/wpgraphql-ide/tree/main/src) +- **Styles**: [styles/ directory](https://github.com/wp-graphql/wpgraphql-ide/tree/main/styles) + +You can view or download the source code directly from the GitHub repository. + += What are some of the major dependencies used in the plugin? = + +The WPGraphQL IDE plugin includes several important dependencies. You can learn more about these libraries at the following links: + +- **GraphQL.js**: [https://github.com/graphql/graphql-js](https://github.com/graphql/graphql-js) +- **GraphiQL**: [https://github.com/graphql/graphiql](https://github.com/graphql/graphiql) +- **Vaul**: [https://github.com/emilkowalski/vaul](https://github.com/emilkowalski/vaul) + == Screenshots == == Changelog == diff --git a/src/access-functions.js b/src/access-functions.js index c2dda84..a0512ce 100644 --- a/src/access-functions.js +++ b/src/access-functions.js @@ -21,11 +21,11 @@ export function registerDocumentEditorToolbarButton( config, priority ); - hooks.doAction( 'afterRegisterToolbarButton', name, config, priority ); + hooks.doAction( 'wpgraphql-ide.afterRegisterToolbarButton', name, config, priority ); } catch ( error ) { console.error( `Failed to register button: ${ name }`, error ); hooks.doAction( - 'registerToolbarButtonError', + 'wpgraphql-ide.registerToolbarButtonError', name, config, priority, @@ -42,7 +42,7 @@ export function registerActivityBarPanel( name, config, priority = 10 ) { priority ); hooks.doAction( - 'afterRegisterActivityBarPanel', + 'wpgraphql-ide.afterRegisterActivityBarPanel', name, config, priority @@ -53,7 +53,7 @@ export function registerActivityBarPanel( name, config, priority = 10 ) { error ); hooks.doAction( - 'registerActivityBarPanelError', + 'wpgraphql-ide.registerActivityBarPanelError', name, config, priority, @@ -74,7 +74,7 @@ export function registerActivityBarPanel( name, config, priority = 10 ) { // priority // ); // hooks.doAction( -// 'afterRegisterActivityBarUtilityButton', +// 'wpgraphql-ide.afterRegisterActivityBarUtilityButton', // name, // config, // priority @@ -82,7 +82,7 @@ export function registerActivityBarPanel( name, config, priority = 10 ) { // } catch ( error ) { // console.error( `Failed to register button: ${ name }`, error ); // hooks.doAction( -// 'registerActivityBarUtilityButtonError', +// 'wpgraphql-ide.registerActivityBarUtilityButtonError', // name, // config, // priority, diff --git a/src/components/AppWrapper.jsx b/src/components/AppWrapper.jsx index 9d51660..89fdb40 100644 --- a/src/components/AppWrapper.jsx +++ b/src/components/AppWrapper.jsx @@ -88,22 +88,22 @@ export function AppWrapper() { /** * Perform actions on component mount. * - * Triggers a custom action 'wpgraphqlide_rendered' when the App component mounts, + * Triggers a custom action 'wpgraphql-ide.rendered' when the App component mounts, * allowing plugins or themes to hook into this event. The action passes * the current state of `drawerOpen` to any listeners, providing context * about the application's UI state. */ - doAction( 'wpgraphqlide_rendered' ); + doAction( 'wpgraphql-ide.rendered' ); /** * Cleanup action on component unmount. * - * Returns a cleanup function that triggers the 'wpgraphqlide_destroyed' action, + * Returns a cleanup function that triggers the 'wpgraphql-ide.destroyed' action, * signaling that the App component is about to unmount. This allows for * any necessary cleanup or teardown operations in response to the App * component's lifecycle. */ - return () => doAction( 'wpgraphqlide_destroyed' ); + return () => doAction( 'wpgraphql-ide.destroyed' ); }, [] ); return ; diff --git a/wpgraphql-ide.php b/wpgraphql-ide.php index 88f2b50..4791e35 100644 --- a/wpgraphql-ide.php +++ b/wpgraphql-ide.php @@ -253,7 +253,7 @@ function register_wpadminbar_menus(): void { $wp_admin_bar->add_node( [ 'id' => 'wpgraphql-ide', - 'title' => '
' . $app_context['drawerButtonLabel'] . '
', + 'title' => '
' . esc_html( $app_context['drawerButtonLabel'] ) . '
', 'href' => '#', ] ); @@ -262,8 +262,8 @@ function register_wpadminbar_menus(): void { $wp_admin_bar->add_node( [ 'id' => 'wpgraphql-ide', - 'title' => '' . $app_context['drawerButtonLabel'], - 'href' => admin_url( 'admin.php?page=graphql-ide' ), + 'title' => '' . esc_html( $app_context['drawerButtonLabel'] ), + 'href' => esc_url( admin_url( 'admin.php?page=graphql-ide' ) ), ] ); } @@ -290,8 +290,8 @@ function register_dedicated_ide_menu(): void { add_submenu_page( 'graphiql-ide', - __( 'GraphQL IDE', 'wpgraphql-ide' ), - __( 'GraphQL IDE', 'wpgraphql-ide' ), + esc_html__( 'GraphQL IDE', 'wpgraphql-ide' ), + esc_html__( 'GraphQL IDE', 'wpgraphql-ide' ), 'manage_graphql_ide', 'graphql-ide', __NAMESPACE__ . '\\render_dedicated_ide_page' @@ -534,8 +534,7 @@ function get_app_context(): array { * @param array $notices The array of notices to render. */ function graphql_admin_notices_render_notices( array $notices ): void { - echo ' - '; + + /** + * Register and enqueue the custom CSS is needed in order to properly add inline styles. + * This is needed because of the way graphql_admin_notices_render_notices is called, outside of the normal enqueue process. + */ + // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion + wp_register_style( 'wpgraphql-ide-admin-notices', false ); + wp_enqueue_style( 'wpgraphql-ide-admin-notices' ); + wp_add_inline_style( 'wpgraphql-ide-admin-notices', $custom_css ); } /** @@ -563,13 +570,20 @@ function graphql_admin_notices_render_notices( array $notices ): void { * @param int $count The count of notices. */ function graphql_admin_notices_render_notice( string $notice_slug, array $notice, bool $is_dismissable, int $count ): void { - echo ' - '; + + /** + * Register and enqueue the custom CSS is needed in order to properly add inline styles. + * This is needed because of the way graphql_admin_notices_render_notices is called, outside of the normal enqueue process. + */ + // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion + wp_register_style( 'wpgraphql-ide-admin-notice', false ); + wp_enqueue_style( 'wpgraphql-ide-admin-notice' ); + wp_add_inline_style( 'wpgraphql-ide-admin-notice', $custom_css ); } /** @@ -761,28 +775,28 @@ function rename_reorder_submenu_items(): void { * @return string The SVG logo markup. */ function graphql_logo_svg(): string { - return << - - - - - - - - - - - - - - - - - - - - - -XML; + $svg = ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + $svg .= ''; + + return $svg; }