Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2acd608
Get asset compiling setup with proper webpack config
dkotter Nov 6, 2025
cbd8a46
Add a class that can be used to load assets
dkotter Nov 6, 2025
c37a85b
Add the structure needed in the src directory
dkotter Nov 6, 2025
443b29d
Load the assets in our feature
dkotter Nov 6, 2025
b7c395b
Rename file
dkotter Nov 6, 2025
ef41f62
Rename everywhere
dkotter Nov 6, 2025
958409d
Add base structure to modify the post title block and add in a custom…
dkotter Nov 6, 2025
25e7597
Add the same toolbar when not in template mode (when the title isn't …
dkotter Nov 7, 2025
273c189
Update comment
dkotter Nov 7, 2025
57000ef
Merge branch 'feature/title-generation-execute' into feature/title-ge…
dkotter Nov 7, 2025
de5fadf
Add a new wrapper around our toolbar and the title input. Add proper …
dkotter Nov 7, 2025
b2973b1
Keep toolbar open if sub-menu is open
dkotter Nov 7, 2025
74d9adb
Remove react-dom. Ensure strings are translated
dkotter Nov 7, 2025
078bf4b
Wire up the title generation API request
dkotter Nov 7, 2025
394e447
Add a method to build the REST API path
dkotter Nov 7, 2025
9c574d9
Add better loading state. Fix lint errors
dkotter Nov 7, 2025
8ca9217
Merge branch 'feature/title-generation-execute' into feature/title-ge…
dkotter Nov 13, 2025
8549253
Update doc
dkotter Nov 13, 2025
a6c84cb
Merge branch 'trunk' into feature/title-generation-ui
dkotter Nov 14, 2025
d07365f
Fix lint issues
dkotter Nov 14, 2025
1d98d49
Switch from making direct API requests to the Ability endpoint to usi…
dkotter Nov 14, 2025
f0aba6f
Merge branch 'trunk' into feature/title-generation-ui
dkotter Nov 14, 2025
4781318
Ensure the build directory ends up in our final release
dkotter Nov 14, 2025
12c1f12
Merge branch 'trunk' into feature/title-generation-ui
dkotter Nov 18, 2025
040c68f
Merge branch 'trunk' into feature/title-generation-ui
dkotter Nov 19, 2025
b770588
Remove casing options for now
dkotter Nov 19, 2025
c39bd1c
Allow multiple titles to be generated and show those in a modal. Allo…
dkotter Nov 19, 2025
1f11540
Fix all JS lint issues. Turn our JS linting workflow on
dkotter Nov 19, 2025
5703748
Merge branch 'trunk' into feature/title-generation-ui
dkotter Nov 20, 2025
0390cd4
Remove autosave of title after selection
dkotter Nov 24, 2025
dea4acb
Rename variables to be more specific
dkotter Nov 24, 2025
63c9934
Create a new component for a single title option
dkotter Nov 24, 2025
88c8fa2
Add proper type
dkotter Nov 24, 2025
cf8cdd6
Extract the createRetry function out of the component
dkotter Nov 24, 2025
36fecba
Extract the createFocusBlurHandlers function out of the component
dkotter Nov 24, 2025
378116f
Extract the setupEventListeners function out of the component
dkotter Nov 24, 2025
ef1b112
Disconnect the observer when no longer needed
dkotter Nov 24, 2025
587233c
Fix lint errors
dkotter Nov 24, 2025
f755562
Add new eslint config file. Change structure of prettier config file
dkotter Nov 25, 2025
eb8f523
Move packages to dependencies
dkotter Nov 25, 2025
fc4d178
Fix new lint errors
dkotter Nov 25, 2025
4b89dea
Remove auto formatting in our JS lint test so we can see failures
dkotter Nov 25, 2025
277c054
Remove dependencies we don't need to ensure wp-prettier is installed
dkotter Nov 25, 2025
c02047e
Lint fixes
dkotter Nov 25, 2025
fb62804
Revert back to old prettier file
dkotter Nov 25, 2025
77ac717
Update minimum required WordPress version to 6.8
jeffpaul Nov 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"rules": {
// React best practices
"react/jsx-boolean-value": "error",
"react/jsx-curly-brace-presence": [
"error",
{ "props": "never", "children": "never" }
],

// WordPress-specific rules, lifted from gutenberg
"@wordpress/dependency-group": "error",
"@wordpress/data-no-store-string-literals": "error",
"@wordpress/wp-global-usage": "error",
"@wordpress/react-no-unsafe-timeout": "error",
"@wordpress/i18n-hyphenated-range": "error",
"@wordpress/i18n-no-flanking-whitespace": "error",
"@wordpress/i18n-text-domain": [
"error",
{
"allowedTextDomain": "ai"
}
],
"@wordpress/no-unsafe-wp-apis": "off",
"import/default": "error",
"import/named": "error"
},
"overrides": [
{
"files": [ "**/*.ts?(x)" ],
"rules": {
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": false
}
],
"@typescript-eslint/no-shadow": "error",
"no-shadow": "off",
"jsdoc/require-param": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off"
}
}
]
}
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ jobs:
permissions:
contents: read
timeout-minutes: 20
if: false # Temporarily disabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary for this PR? Or what?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was disabled when we initially added our default workflows as we didn't have any JS files at the time (and thus it would always fail). Now that this PR is adding JS files, turning this on


steps:
- name: Checkout repository
Expand All @@ -278,8 +277,5 @@ jobs:
- name: Install NPM dependencies
run: npm ci

- name: Run Prettier format check
run: npm run format

- name: Run JavaScript linting
run: npm run lint:js
2 changes: 1 addition & 1 deletion ai.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin URI: https://github.com/WordPress/ai
* Description: AI experiments and capabilities for WordPress.
* Version: 0.1.0
* Requires at least: 6.9
* Requires at least: 6.8
* Requires PHP: 7.4
* Author: WordPress.org Contributors
* Author URI: https://make.wordpress.org/ai/
Expand Down
36 changes: 36 additions & 0 deletions includes/Experiments/Title_Generation/Title_Generation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use WordPress\AI\Abilities\Title_Generation\Title_Generation as Title_Generation_Ability;
use WordPress\AI\Abstracts\Abstract_Experiment;
use WordPress\AI\Asset_Loader;

/**
* Title generation experiment.
Expand Down Expand Up @@ -41,6 +42,7 @@ protected function load_experiment_metadata(): array {
*/
public function register(): void {
add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
}

/**
Expand All @@ -58,4 +60,38 @@ public function register_abilities(): void {
),
);
}

/**
* Enqueues and localizes the admin script.
*
* @since 0.1.0
*
* @param string $hook_suffix The current admin page hook suffix.
*/
public function enqueue_assets( string $hook_suffix ): void {
// Load asset in new post and edit post screens only.
if ( 'post.php' !== $hook_suffix && 'post-new.php' !== $hook_suffix ) {
return;
}

$screen = get_current_screen();

// Load the assets only if the post type supports titles and is not an attachment.
if (
! $screen ||
! post_type_supports( $screen->post_type, 'title' ) ||
in_array( $screen->post_type, array( 'attachment' ), true )
) {
return;
}

Asset_Loader::enqueue_script( 'title_generation', 'experiments/title-generation' );
Asset_Loader::localize_script(
'title_generation',
'TitleGenerationData',
array(
'enabled' => $this->is_enabled(),
)
);
}
}
Loading