Skip to content

Commit 1256292

Browse files
authored
Merge branch 'trunk' into renovate/pnpm-9.x
2 parents 708c2a4 + fff7c95 commit 1256292

File tree

1,138 files changed

+15555
-12032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,138 files changed

+15555
-12032
lines changed

.cursor/rules/adding-changelog.mdc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: How changelog entries must be structured for each change
3+
globs:
4+
---
5+
Every change in the `/projects` directory will need to add a specially-formatted file to the project's specified `changelog` directory.
6+
7+
The change file is a text file with a header-and-body format, like HTTP or email. A change file might look like this:
8+
9+
```
10+
Significance: patch
11+
Type: compat
12+
13+
Block Editor: update all blocks to be fully compatible with WordPress 5.7.
14+
```
15+
16+
The “Significance” header specifies the significance of change in the style of semantic versioning: patch, minor, or major.
17+
18+
The “Type” header categorizes the change in the changelog. In Jetpack, for example, our changelog divides changes into “Major Enhancements”, “Enhancements”, “Improved compatibility”, and “Bugfixes”.
19+
Type must be "security", "added", "changed", "deprecated", "removed", or "fixed"
20+
21+
The body is separated from the headers by a blank line, and is the text that actually goes into the changelog. This should follow our recommendations at [writing-a-good-changelog-entry.md](mdc:jetpack/jetpack/jetpack/docs/writing-a-good-changelog-entry.md).
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description: General guidelines on code style and structure
3+
globs:
4+
---
5+
General guidelines are defined in [coding-guidelines.md](mdc:jetpack/jetpack/jetpack/jetpack/jetpack/jetpack/jetpack/jetpack/jetpack/jetpack/docs/coding-guidelines.md).
6+
7+
### Naming Conventions
8+
9+
- Use WordPress naming conventions for functions and classes
10+
- Prefix any global php functions or hooks with `jetpack_`
11+
- Use lowercase with underscores for PHP functions
12+
- Follow WordPress React component naming patterns
13+
- Use BEM-like naming for SCSS
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
description: General development guidelines
3+
globs:
4+
---
5+
You are an expert WordPress plugin developer specializing in site building tools, with deep expertise in WordPress core, React, PHP, and modern frontend development. You prioritize WordPress coding standards while delivering maintainable, accessible solutions.
6+
7+
## Short codes
8+
9+
Check the start of any user message for the following short codes and act appropriately:
10+
11+
- ddc - short for `discuss don't code` so do not make any code changes only discuss the options until given the go ahead to make changes.
12+
- jdi - short for `just do it` so this is giving approval to go ahead and make the changes that have been discussed.
13+
14+
## Analysis Process
15+
16+
Before responding to any request, follow these steps:
17+
18+
1. Request Analysis
19+
20+
- Determine if task involves plugin core (PHP) or frontend (JS/React)
21+
- Identify WordPress hooks and filters needed
22+
- Note compatibility requirements (WordPress version, PHP version), based on the different versions specified in [versions.sh](mdc:jetpack/jetpack/jetpack/jetpack/jetpack/.github/versions.sh)
23+
- Define core functionality and user experience goals
24+
- Consider WordPress coding standards compliance
25+
26+
2. Solution Planning
27+
28+
- Break down solution into WordPress-compatible components
29+
- Consider plugin activation/deactivation hooks
30+
- Identify necessary WordPress API integrations
31+
- Plan for internationalization (i18n)
32+
- Evaluate security implications
33+
34+
3. Implementation Strategy
35+
36+
- Choose appropriate WordPress design patterns
37+
- Consider performance impact on WordPress site
38+
- Plan for WordPress error handling conventions
39+
- Ensure WordPress coding standards compliance
40+
- Verify accessibility requirements
41+
42+
Always prioritize WordPress coding standards and best practices while delivering functionality that enhances the WordPress site-building experience.

.cursor/rules/js-react-standards.mdc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
description: JavaScript/React Standards
3+
globs: *.js, *.jsx, *.ts, *.tsx
4+
---
5+
## General guidelines
6+
7+
- Write modern ES6+ code following WordPress JS standards
8+
- Use WordPress data store for state management
9+
- Follow WordPress component patterns
10+
- Implement proper WordPress hooks system
11+
- Structure components using WordPress conventions
12+
- Where it applies, make strings available for translation.
13+
- Use Gutenberg's `@wordpress/i18n` package to handle translations.
14+
- Use an appropriate unique text domain in your JS code.
15+
16+
## React Components
17+
18+
- Use WordPress `@wordpress/element` instead of direct React import
19+
- Implement WordPress hooks system
20+
- Follow WordPress component lifecycle patterns
21+
- Use the WordPress block editor data stores for state management of WordPress block editor components
22+
- Follow WordPress accessibility guidelines
23+
24+
## TypeScript
25+
26+
- When using TypeScript in Webpack, use `@babel/preset-typescript` rather than `ts-loader`.

.cursor/rules/js-testing.mdc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: Guidelines to write JavaScript tests
3+
globs:
4+
---
5+
- Use Jest with WordPress test utilities
6+
- Follow WordPress testing patterns
7+
- Test React components with `@testing-library/react`
8+
- Implement proper async testing
9+
- Use WordPress mocking patterns
10+
11+
12+
Check [component.tsx](mdc:jetpack/jetpack/jetpack/jetpack/projects/packages/my-jetpack/_inc/components/connection-status-card/test/component.tsx) for an example.
13+
14+
Find out more about how to develop tests at [automated-testing.md](mdc:jetpack/jetpack/docs/automated-testing.md)

.cursor/rules/php-standards.mdc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: PHP coding standards
3+
globs: *.php
4+
---
5+
- Follow WordPress PHP Coding Standards
6+
- Use proper WordPress prefix for functions and classes
7+
- Implement WordPress nonce verification
8+
- Follow WordPress database operations best practices
9+
- Structure plugin hooks logically
10+
11+
## Package Version Annotations
12+
13+
When needing to add a package version number inside a DocBlock, please use `$$next-version$$` as such:
14+
15+
- `@since $$next-version$$`
16+
- `@deprecated $$next-version$$`
17+
- `@deprecated since $$next-version$$`
18+
- `_deprecated_function( __METHOD__, 'package-$$next-version$$' );` (other WordPress deprecation functions also work, but note it must be all on one line).
19+
20+
The `$$next-version$$` specifier will be automatically replaced with the correct package version number the next time a new version of that package is released.

.cursor/rules/php-testing.mdc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: Guidelines when testing PHP
3+
globs:
4+
---
5+
When developing Unit Tests in PHP, follow these guidelines:
6+
7+
- Use PHPUnit with WordPress test framework
8+
- Follow WordPress testing conventions
9+
- Use WordPress fixtures and mocks
10+
- Test WordPress hooks and filters
11+
12+
Check [test_Manager_integration.php](mdc:jetpack/jetpack/jetpack/jetpack/projects/packages/connection/tests/php/test_Manager_integration.php) for an example.
13+
14+
Find out more rules on how to write tests at [automated-testing.md](mdc:jetpack/jetpack/docs/automated-testing.md)

.github/files/setup-wordpress-env.sh

+6-13
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ git clone --depth=1 --branch "$WORDPRESS_TAG" git://develop.git.wordpress.org/ "
3333
# We need a built version of WordPress to test against, so download that into the src directory instead of what's in wordpress-develop.
3434
rm -rf "/tmp/wordpress-$WP_BRANCH/src"
3535
git clone --depth=1 --branch "$WORDPRESS_TAG" git://core.git.wordpress.org/ "/tmp/wordpress-$WP_BRANCH/src"
36+
37+
echo "::group::Setting up WordPress uploads directory"
38+
mkdir -p "/tmp/wordpress-$WP_BRANCH/src/wp-content/uploads"
39+
chmod -R 777 "/tmp/wordpress-$WP_BRANCH/src/wp-content/uploads"
40+
echo "::endgroup::"
41+
3642
echo "::endgroup::"
3743

3844
if [[ -n "$GITHUB_ENV" ]]; then
@@ -105,19 +111,6 @@ for PLUGIN in projects/plugins/*/composer.json; do
105111
fi
106112
cd "$BASE"
107113

108-
# Upgrade/downgrade WorDBless if necessary.
109-
if [[ ( "$WP_BRANCH" == 'trunk' || "$WP_BRANCH" == 'previous' ) && "$TEST_SCRIPT" == "test-php" ]]; then
110-
VER=$(composer --format=json --working-dir="$DIR" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
111-
if [[ -n "$VER" ]]; then
112-
INSVER=$WORDPRESS_TAG
113-
[[ "$WORDPRESS_TAG" == 'trunk' ]] && INSVER="dev-main as $VER"
114-
echo "Supposed to run tests against WordPress $WORDPRESS_TAG, so setting roots/wordpress and roots/wordpress-no-content to \"$INSVER\""
115-
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
116-
rm -rf "$DIR/wordpress"
117-
composer --working-dir="$DIR" require --dev roots/wordpress="$INSVER" roots/wordpress-no-content="$INSVER"
118-
fi
119-
fi
120-
121114
cp -r "$DIR" "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/$NAME"
122115
# Plugin dir for tests in WP >= 5.6-beta1
123116
ln -s "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/$NAME" "/tmp/wordpress-$WP_BRANCH/tests/phpunit/data/plugins/$NAME"

.github/workflows/tests.yml

+37-21
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ jobs:
8686
pnpm install
8787
echo "::endgroup::"
8888
89-
# If we're going to be making WorDBless use WP "nightlies", remove the relevant package from Composer's cache to get the latest version.
90-
if [[ "$WP_BRANCH" == 'trunk' && ( "$TEST_SCRIPT" == "test-php" || "$TEST_SCRIPT" == "test-coverage" ) ]]; then
91-
echo "::group::Clear composer cache for roots/wordpress"
92-
DIR=$(composer config cache-files-dir)
93-
rm -rf "$DIR/roots/wordpress" "$DIR/roots/wordpress-no-content"
94-
echo "::endgroup::"
95-
fi
96-
9789
- name: Detect changed projects
9890
id: changed
9991
run: |
@@ -110,9 +102,45 @@ jobs:
110102
echo "any-plugins=${ANY_PLUGINS}" >> "$GITHUB_OUTPUT"
111103
112104
- name: Select WordPress version
113-
if: steps.changed.outputs.any-plugins != 'true' && matrix.wp != 'none'
105+
if: matrix.wp != 'none'
114106
run: .github/files/select-wordpress-tag.sh
115107

108+
- name: Composer Install
109+
run: |
110+
# If we're going to be making WorDBless use WP "nightlies", remove the relevant package from Composer's cache to get the latest version.
111+
if [[ "$WP_BRANCH" == 'trunk' && ( "$TEST_SCRIPT" == "test-php" || "$TEST_SCRIPT" == "test-coverage" ) ]]; then
112+
echo "::group::Clear composer cache for roots/wordpress"
113+
DIR=$(composer config cache-files-dir)
114+
rm -rf "$DIR/roots/wordpress" "$DIR/roots/wordpress-no-content"
115+
echo "::endgroup::"
116+
fi
117+
118+
echo "::group::Composer"
119+
composer install --working-dir=tools/php-test-env
120+
121+
# Add WorDBless for various package tests that use uploads since concurrency can nuke uploads that are in use.
122+
# @todo Update WorDBless to be able to use a customized upload dir, do that, and remove this.
123+
if [[ "$TEST_SCRIPT" =~ ^test-(php|coverage)$ ]]; then
124+
VER=$( jq -r '.require["automattic/wordbless"]' tools/php-test-env/composer.json )
125+
for pkg in packages/image-cdn packages/publicize packages/videopress; do
126+
echo "Adding WordBless for $pkg tests"
127+
composer require --working-dir="projects/$pkg" "automattic/wordbless:$VER" --dev --no-update
128+
done
129+
fi
130+
131+
if [[ ( "$TEST_SCRIPT" == "test-php" || "$TEST_SCRIPT" == "test-coverage" ) && ( "$WP_BRANCH" == 'trunk' || "$WP_BRANCH" == 'previous' ) ]]; then
132+
VER=$(composer --format=json --working-dir="tools/php-test-env" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
133+
if [[ -n "$VER" ]]; then
134+
INSVER=$WORDPRESS_TAG
135+
[[ "$WORDPRESS_TAG" == 'trunk' ]] && INSVER="dev-main as $VER"
136+
echo "Supposed to run tests against WordPress $WORDPRESS_TAG, so setting roots/wordpress and roots/wordpress-no-content to \"$INSVER\""
137+
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
138+
rm -rf "tools/php-test-env/wordpress"
139+
composer --working-dir="tools/php-test-env" require --dev "roots/wordpress:$INSVER" "roots/wordpress-no-content:$INSVER"
140+
fi
141+
fi
142+
echo "::endgroup::"
143+
116144
- name: Setup WordPress environment for plugin tests
117145
env:
118146
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
@@ -196,18 +224,6 @@ jobs:
196224
echo 'Platform reqs failed, running `composer update`'
197225
composer --working-dir="$DIR" update
198226
fi
199-
200-
if [[ "$WP_BRANCH" == 'trunk' || "$WP_BRANCH" == 'previous' ]]; then
201-
VER=$(composer --format=json --working-dir="$DIR" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
202-
if [[ -n "$VER" ]]; then
203-
INSVER=$WORDPRESS_TAG
204-
[[ "$WORDPRESS_TAG" == 'trunk' ]] && INSVER="dev-main as $VER"
205-
echo "Supposed to run tests against WordPress $WORDPRESS_TAG, so setting roots/wordpress and roots/wordpress-no-content to \"$INSVER\""
206-
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
207-
rm -rf "$DIR/wordpress"
208-
composer --working-dir="$DIR" require --dev roots/wordpress="$INSVER" roots/wordpress-no-content="$INSVER"
209-
fi
210-
fi
211227
fi
212228
fi
213229

.github/workflows/update-phan-stubs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
git checkout -b update/phan-custom-stubs
6464
git commit -am 'phan: Update custom stubs'
6565
git push origin HEAD
66-
gh pr create --title 'phan: Update custom stubs' --body 'This is an automatic update generated by a GitHub Action. If closed it will be recreated the next time the action runs.' --label '[Pri] Normal' --label '[Type] Janitorial' --label '[Status] Needs Review'
66+
gh pr create --title 'phan: Update custom stubs' --body 'This is an automatic update generated by a GitHub Action. If closed it will be recreated the next time the action runs.' --label '[Pri] Normal' --label '[Type] Janitorial' --label '[Status] Needs Review' --reviewer Automattic/jetpack-garage
6767
6868
- name: Update existing branch
6969
if: steps.changes.outputs.needed == 'true' && steps.changes.outputs.has-branch == 'true'

.phan/config.base.php

+19
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ function make_phan_config( $dir, $options = array() ) {
137137
$internal_stubs[ $stub ] = $stub_file_path;
138138
}
139139

140+
// Check if test-environment is a dependency and add WorDBless if it is
141+
$composer_json = $dir . '/composer.json';
142+
if ( file_exists( $composer_json ) ) {
143+
$composer_data = json_decode( file_get_contents( $composer_json ), true );
144+
foreach ( array( 'require', 'require-dev' ) as $require_type ) {
145+
if ( isset( $composer_data[ $require_type ]['automattic/jetpack-test-environment'] ) ) {
146+
// Use absolute path to ensure WorDBless is found
147+
$wordbless_path = dirname( __DIR__ ) . '/tools/php-test-env/vendor/automattic/wordbless';
148+
if ( is_dir( $wordbless_path ) ) {
149+
// Only include the src directory
150+
$options['directory_list'][] = $wordbless_path . '/src';
151+
// Exclude from analysis
152+
$options['exclude_analysis_directory_list'][] = $wordbless_path;
153+
}
154+
break;
155+
}
156+
}
157+
}
158+
140159
$config = array(
141160
// Apparently this is only useful when upgrading from php 5, not for 7-to-8.
142161
'backward_compatibility_checks' => false,

.phan/config.php

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
// Ignore stuff in various subdirs too.
2828
'.*/node_modules/',
2929
'tools/docker/',
30+
'tools/php-test-env/wordpress/',
31+
'tools/php-test-env/vendor/',
3032
// Don't load the stubs. (if we need to start loading _a_ stub for the "monorepo", do like `(?!filename\.php)` to exclude it from the exclusion.)
3133
'.phan/stubs/',
3234
),

.phan/stubs/akismet-stubs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Stubs automatically generated from Akismet 5.3.5
3+
* Stubs automatically generated from Akismet 5.3.6
44
* using the definition file `tools/stubs/akismet-stub-defs.php` in the Jetpack monorepo.
55
*
66
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.

.phan/stubs/gutenberg-stubs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Stubs automatically generated from Gutenberg 20.1.0
3+
* Stubs automatically generated from Gutenberg 20.2.0
44
* using the definition file `tools/stubs/gutenberg-stub-defs.php` in the Jetpack monorepo.
55
*
66
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.

.phan/stubs/woocommerce-internal-stubs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Stubs automatically generated from WooCommerce 9.7.0-dev
3+
* Stubs automatically generated from WooCommerce 9.6.1
44
* using the definition file `tools/stubs/woocommerce-internal-stub-defs.php` in the Jetpack monorepo.
55
*
66
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.

.phan/stubs/woocommerce-payments-stubs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Stubs automatically generated from WooPayments 8.7.0
3+
* Stubs automatically generated from WooPayments 8.9.0
44
* using the definition file `tools/stubs/woocommerce-payments-stub-defs.php` in the Jetpack monorepo.
55
*
66
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.

.phan/stubs/wpcom-stubs.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* `bin/teamcity-builds/jetpack-stubs/stub-defs.php` and regenerate the stubs
55
* by triggering the Jetpack Staging → Update WPCOM Stubs job in TeamCity.
66
*
7-
* Stubs automatically generated from WordPress.com commit 58daa278d1c6807cf18400dee1d9f45815e24fae.
7+
* Stubs automatically generated from WordPress.com commit 57b033879305add761d5f6f4ae7858580a986d8e.
88
*/
99

1010
namespace {
@@ -1070,7 +1070,7 @@ function show_subscription_checkbox($id = \false)
10701070
{
10711071
}
10721072
/**
1073-
* @return bool
1073+
* @return int|bool
10741074
*/
10751075
function wpcom_subs_is_subscribed($args = array())
10761076
{

composer.json

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
],
7070
"test-js": [
7171
"cd tools/cli && pnpm test"
72+
],
73+
"post-install-cmd": [
74+
"cd tools/php-test-env && composer install"
75+
],
76+
"post-update-cmd": [
77+
"cd tools/php-test-env && composer update"
7278
]
7379
},
7480
"scripts-descriptions": {

0 commit comments

Comments
 (0)