diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44d50cdbb21b1..0d50f7f558382 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -367,8 +367,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -387,9 +387,6 @@ importers: '@types/react-slider': specifier: 1.3.6 version: 1.3.6 - '@types/testing-library__jest-dom': - specifier: 5.14.9 - version: 5.14.9 jest: specifier: 29.7.0 version: 29.7.0 @@ -497,8 +494,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -879,8 +876,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -937,8 +934,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -1079,8 +1076,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -1221,9 +1218,12 @@ importers: '@storybook/react': specifier: 8.2.9 version: 8.2.9(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.2.9)(typescript@5.0.4) + '@testing-library/dom': + specifier: 10.4.0 + version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@types/jest': specifier: 29.5.12 version: 29.5.12 @@ -1303,8 +1303,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -1772,8 +1772,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -2540,8 +2540,8 @@ importers: specifier: 6.5.0 version: 6.5.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -2761,8 +2761,8 @@ importers: specifier: 3.2.4 version: 3.2.4(preact@10.22.1) '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@wordpress/babel-plugin-import-jsx-pragma': specifier: 5.7.0 version: 5.7.0(@babel/core@7.24.7) @@ -2946,8 +2946,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@types/jest': specifier: 29.5.12 version: 29.5.12 @@ -2957,9 +2957,6 @@ importers: '@types/react-dom': specifier: 18.3.0 version: 18.3.0 - '@types/testing-library__jest-dom': - specifier: 5.14.9 - version: 5.14.9 '@wordpress/browserslist-config': specifier: 6.7.0 version: 6.7.0 @@ -3118,8 +3115,8 @@ importers: specifier: 3.2.4 version: 3.2.4(preact@10.22.1) '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@wordpress/babel-plugin-import-jsx-pragma': specifier: 5.7.0 version: 5.7.0(@babel/core@7.24.7) @@ -3281,8 +3278,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@wordpress/browserslist-config': specifier: 6.7.0 version: 6.7.0 @@ -3526,8 +3523,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@wordpress/browserslist-config': specifier: 6.7.0 version: 6.7.0 @@ -3641,8 +3638,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@types/jest': specifier: 29.5.12 version: 29.5.12 @@ -4001,8 +3998,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@testing-library/user-event': specifier: 14.5.2 version: 14.5.2(@testing-library/dom@10.4.0) @@ -4404,8 +4401,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@types/react': specifier: 18.3.3 version: 18.3.3 @@ -4513,8 +4510,8 @@ importers: specifier: 10.4.0 version: 10.4.0 '@testing-library/react': - specifier: 15.0.7 - version: 15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 16.0.1 + version: 16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@wordpress/browserslist-config': specifier: 6.7.0 version: 6.7.0 @@ -4847,8 +4844,8 @@ importers: specifier: 6.21.0 version: 6.21.0(eslint@8.57.0)(typescript@5.0.4) '@wordpress/eslint-plugin': - specifier: 20.3.0 - version: 20.3.0(2g4wiqq3ubewvaaot6et2pay5m) + specifier: 21.0.0 + version: 21.0.0(2g4wiqq3ubewvaaot6et2pay5m) '@wordpress/jest-console': specifier: 8.7.0 version: 8.7.0(jest@29.7.0) @@ -7264,16 +7261,20 @@ packages: peerDependencies: preact: '>=10 || ^10.0.0-alpha.0 || ^10.0.0-beta.0' - '@testing-library/react@15.0.7': - resolution: {integrity: sha512-cg0RvEdD1TIhhkm1IeYMQxrzy0MtUNfa3minv4MjbgcYzJAZ7yD0i0lwoPOTPr+INtiXFezt2o8xMSnyHhEn2Q==} + '@testing-library/react@16.0.1': + resolution: {integrity: sha512-dSmwJVtJXmku+iocRhWOUFbrERC76TX2Mnf0ATODz8brzAZrMBbzLwQixlBSanZxR6LddK3eiwpSFZgDET1URg==} engines: {node: '>=18'} peerDependencies: + '@testing-library/dom': ^10.0.0 '@types/react': ^18.0.0 + '@types/react-dom': ^18.0.0 react: ^18.0.0 react-dom: ^18.0.0 peerDependenciesMeta: '@types/react': optional: true + '@types/react-dom': + optional: true '@testing-library/user-event@14.5.2': resolution: {integrity: sha512-YAh82Wh4TIrxYLmfGcixwD18oIjyC1pFQC2Y01F2lzV2HTMiYrI0nze0FD0ocB//CKS/7jIUgae+adPqxK5yCQ==} @@ -7502,9 +7503,6 @@ packages: '@types/stack-utils@2.0.3': resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} - '@types/testing-library__jest-dom@5.14.9': - resolution: {integrity: sha512-FSYhIjFlfOpGSRyVoMBMuS3ws5ehFQODymf3vlI7U1K8c7PHwWwFY7VREfmsuzHSOnoKs/9/Y983ayOs7eRzqw==} - '@types/tough-cookie@4.0.5': resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==} @@ -7870,8 +7868,8 @@ packages: resolution: {integrity: sha512-VqLQGNMs1BF6LnS+5eNjpM/sCUQhjn4QOfhDlWdVDi0ZxpZgssPzKhJ1ils/7FC0qF3vrMg8EH5xXxw2xz8A/w==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} - '@wordpress/eslint-plugin@20.3.0': - resolution: {integrity: sha512-Y272ZtosmXPJJ0K5X7j0ufcpuDf1unEEDOmdyStHhYV3DGjfETPKgMBVjpmWIObu5oMlqqkTiiQaNb+lho3EIQ==} + '@wordpress/eslint-plugin@21.0.0': + resolution: {integrity: sha512-4ioakbwSZNL8eXkfK0hcY93e5Fj9dZljxj3lEFkCBWMkSpU8/pPw/7UMS0OBbGQK8rqmvnXF1y/LFH7ihCxuww==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} peerDependencies: '@babel/core': '>=7' @@ -17534,21 +17532,29 @@ snapshots: '@testing-library/dom': 8.20.1 preact: 10.22.1 - '@testing-library/react@15.0.7(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + '@testing-library/react@16.0.1(@testing-library/dom@10.4.0)(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 '@testing-library/dom': 10.4.0 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + optionalDependencies: + '@types/react': 18.3.3 '@types/react-dom': 18.3.0 + + '@testing-library/react@16.0.1(@testing-library/dom@10.4.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@babel/runtime': 7.24.7 + '@testing-library/dom': 10.4.0 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) optionalDependencies: '@types/react': 18.3.3 - '@testing-library/react@15.0.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + '@testing-library/react@16.0.1(@testing-library/dom@10.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 '@testing-library/dom': 10.4.0 - '@types/react-dom': 18.3.0 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) @@ -17804,10 +17810,6 @@ snapshots: '@types/stack-utils@2.0.3': {} - '@types/testing-library__jest-dom@5.14.9': - dependencies: - '@types/jest': 29.5.12 - '@types/tough-cookie@4.0.5': {} '@types/triple-beam@1.3.5': {} @@ -19241,7 +19243,7 @@ snapshots: dependencies: '@babel/runtime': 7.24.7 - '@wordpress/eslint-plugin@20.3.0(2g4wiqq3ubewvaaot6et2pay5m)': + '@wordpress/eslint-plugin@21.0.0(2g4wiqq3ubewvaaot6et2pay5m)': dependencies: '@babel/core': 7.24.7 '@babel/eslint-parser': 7.24.7(@babel/core@7.24.7)(eslint@8.57.0) diff --git a/projects/js-packages/components/changelog/renovate-major-js-unit-testing-packages b/projects/js-packages/components/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/components/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/components/package.json b/projects/js-packages/components/package.json index c4794eb0127a5..0d7b6e59a4553 100644 --- a/projects/js-packages/components/package.json +++ b/projects/js-packages/components/package.json @@ -43,14 +43,13 @@ "@storybook/blocks": "8.2.9", "@storybook/react": "8.2.9", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@types/jest": "29.5.12", "@types/qrcode.react": "1.0.5", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", "@types/react-slider": "1.3.6", - "@types/testing-library__jest-dom": "5.14.9", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "react": "18.3.1", diff --git a/projects/js-packages/connection/changelog/renovate-major-js-unit-testing-packages b/projects/js-packages/connection/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/connection/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/connection/package.json b/projects/js-packages/connection/package.json index d84a872e95f12..254f1c82f0961 100644 --- a/projects/js-packages/connection/package.json +++ b/projects/js-packages/connection/package.json @@ -36,7 +36,7 @@ "@babel/preset-react": "7.24.7", "@storybook/addon-actions": "8.2.9", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@types/react": "18.3.3", "jest": "29.7.0", diff --git a/projects/js-packages/licensing/changelog/renovate-major-js-unit-testing-packages b/projects/js-packages/licensing/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/licensing/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/licensing/package.json b/projects/js-packages/licensing/package.json index 03cf53da4b8fe..c0b9080349075 100644 --- a/projects/js-packages/licensing/package.json +++ b/projects/js-packages/licensing/package.json @@ -37,7 +37,7 @@ "@babel/plugin-transform-react-jsx": "7.24.7", "@babel/preset-react": "7.24.7", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@wordpress/babel-plugin-import-jsx-pragma": "5.7.0", "babel-jest": "29.7.0", diff --git a/projects/js-packages/partner-coupon/changelog/renovate-major-js-unit-testing-packages b/projects/js-packages/partner-coupon/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/partner-coupon/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/partner-coupon/package.json b/projects/js-packages/partner-coupon/package.json index 9d1fa0cf2a8d5..80ce295b344cd 100644 --- a/projects/js-packages/partner-coupon/package.json +++ b/projects/js-packages/partner-coupon/package.json @@ -24,7 +24,7 @@ "@babel/core": "7.24.7", "@babel/preset-react": "7.24.7", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@wordpress/base-styles": "5.7.0", "@wordpress/data": "10.7.0", diff --git a/projects/js-packages/publicize-components/changelog/renovate-major-js-unit-testing-packages b/projects/js-packages/publicize-components/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/publicize-components/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/publicize-components/changelog/update-social-share-status-show-spinner-on-retry b/projects/js-packages/publicize-components/changelog/update-social-share-status-show-spinner-on-retry new file mode 100644 index 0000000000000..0ff9bf1ff31e5 --- /dev/null +++ b/projects/js-packages/publicize-components/changelog/update-social-share-status-show-spinner-on-retry @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Social: Share status | Updated retry to show spinner and start polling diff --git a/projects/js-packages/publicize-components/package.json b/projects/js-packages/publicize-components/package.json index fec716cbd7164..010aaca8e53e5 100644 --- a/projects/js-packages/publicize-components/package.json +++ b/projects/js-packages/publicize-components/package.json @@ -57,7 +57,7 @@ "@babel/preset-react": "7.24.7", "@babel/runtime": "7.24.7", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@types/jest": "29.5.12", "@types/react": "18.3.3", diff --git a/projects/js-packages/publicize-components/src/components/share-status/retry.tsx b/projects/js-packages/publicize-components/src/components/share-status/retry.tsx index e95e56625a88d..3917ec6aa9992 100644 --- a/projects/js-packages/publicize-components/src/components/share-status/retry.tsx +++ b/projects/js-packages/publicize-components/src/components/share-status/retry.tsx @@ -1,14 +1,17 @@ import { IconTooltip } from '@automattic/jetpack-components'; import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; -import { Button } from '@wordpress/components'; -import { useSelect } from '@wordpress/data'; +import { Button, Spinner } from '@wordpress/components'; +import { useDispatch, useSelect } from '@wordpress/data'; import { store as editorStore } from '@wordpress/editor'; import { __, _x } from '@wordpress/i18n'; -import { useCallback } from 'react'; +import { useCallback, useState } from 'react'; import useSharePost from '../../hooks/use-share-post'; import { store as socialStore } from '../../social-store'; import { ShareStatusItem } from '../../social-store/types'; -import { connectionMatchesShareItem } from '../../utils/share-status'; +import { + areShareItemsForSameConnection, + connectionMatchesShareItem, +} from '../../utils/share-status'; import styles from './styles.module.scss'; export type RetryProps = { @@ -31,6 +34,9 @@ export function Retry( { shareItem }: RetryProps ) { const connectionStillExists = connections.some( connectionMatchesShareItem( shareItem ) ); const { doPublicize } = useSharePost( postId ); + const { pollForPostShareStatus } = useDispatch( socialStore ); + + const [ isRetrying, setIsRetrying ] = useState( false ); const onRetry = useCallback( async () => { recordEvent( 'jetpack_social_share_status_retry', { @@ -50,8 +56,30 @@ export function Retry( { shareItem }: RetryProps ) { return; } + setIsRetrying( true ); + await doPublicize( skippedConnections ); - }, [ shareItem, connections, doPublicize, recordEvent ] ); + + await pollForPostShareStatus( { + isRequestComplete( { postShareStatus, lastTimestamp } ) { + const isComplete = postShareStatus.shares.some( share => { + return ( + share.timestamp > lastTimestamp && areShareItemsForSameConnection( shareItem, share ) + ); + } ); + + if ( isComplete ) { + setIsRetrying( false ); + } + + return isComplete; + }, + } ); + }, [ recordEvent, shareItem, connections, doPublicize, pollForPostShareStatus ] ); + + if ( isRetrying ) { + return ; + } return (
diff --git a/projects/js-packages/publicize-components/src/components/share-status/share-list.tsx b/projects/js-packages/publicize-components/src/components/share-status/share-list.tsx index 03d93c2560b82..c311b8f2158b4 100644 --- a/projects/js-packages/publicize-components/src/components/share-status/share-list.tsx +++ b/projects/js-packages/publicize-components/src/components/share-status/share-list.tsx @@ -1,9 +1,6 @@ -import { Spinner } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; import { store as socialStore } from '../../social-store'; import { SharesDataView } from './shares-dataview'; -import styles from './styles.module.scss'; /** * ShareList component @@ -15,11 +12,6 @@ export function ShareList() { return (
- { shareStatus.loading && ( -
- { __( 'Loading…', 'jetpack' ) } -
- ) }
); diff --git a/projects/js-packages/publicize-components/src/components/share-status/styles.module.scss b/projects/js-packages/publicize-components/src/components/share-status/styles.module.scss index 3ff62cb3dde86..0cd241f349d0d 100644 --- a/projects/js-packages/publicize-components/src/components/share-status/styles.module.scss +++ b/projects/js-packages/publicize-components/src/components/share-status/styles.module.scss @@ -10,10 +10,6 @@ padding-block: 1rem; } -.spinner { - margin: 0 1rem 1rem 1rem; -} - .modal { width: 60rem; min-height: 20rem; diff --git a/projects/js-packages/publicize-components/src/utils/share-status.ts b/projects/js-packages/publicize-components/src/utils/share-status.ts index c5e75e19ec672..f848ac928c828 100644 --- a/projects/js-packages/publicize-components/src/utils/share-status.ts +++ b/projects/js-packages/publicize-components/src/utils/share-status.ts @@ -38,3 +38,29 @@ export function connectionMatchesShareItem( shareItem: ShareStatusItem ) { return connection.connection_id === shareItem.connection_id.toString(); }; } + +/** + * Check if two share items are for the same connection. + * + * @param {ShareStatusItem} a - The first share item. + * @param {ShareStatusItem} b - The second share item. + * + * @return {boolean} - Whether the share items are for the same connection. + */ +export function areShareItemsForSameConnection( a: ShareStatusItem, b: ShareStatusItem ) { + if ( a.service !== b.service ) { + return false; + } + + // If the connection_id matches, they are definitely for the same connection + if ( a.connection_id === b.connection_id ) { + return true; + } + + // external_id may not be present in old data, so we need to check for it + if ( a.external_id || b.external_id ) { + return a.external_id === b.external_id; + } + + return false; +} diff --git a/projects/js-packages/scan/changelog/renovate-major-js-unit-testing-packages#2 b/projects/js-packages/scan/changelog/renovate-major-js-unit-testing-packages#2 new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/scan/changelog/renovate-major-js-unit-testing-packages#2 @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/scan/package.json b/projects/js-packages/scan/package.json index 002abc21bc582..f37ff9a05717d 100644 --- a/projects/js-packages/scan/package.json +++ b/projects/js-packages/scan/package.json @@ -29,7 +29,8 @@ "@storybook/addon-actions": "8.2.9", "@storybook/blocks": "8.2.9", "@storybook/react": "8.2.9", - "@testing-library/react": "15.0.7", + "@testing-library/dom": "10.4.0", + "@testing-library/react": "16.0.1", "@types/jest": "29.5.12", "@types/react": "18.3.3", "@wordpress/babel-plugin-import-jsx-pragma": "5.7.0", diff --git a/projects/js-packages/shared-extension-utils/changelog/renovate-major-js-unit-testing-packages b/projects/js-packages/shared-extension-utils/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/shared-extension-utils/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/shared-extension-utils/package.json b/projects/js-packages/shared-extension-utils/package.json index ea3dd2d5ff6ea..68c711da5edf6 100644 --- a/projects/js-packages/shared-extension-utils/package.json +++ b/projects/js-packages/shared-extension-utils/package.json @@ -40,7 +40,7 @@ "jetpack-js-tools": "workspace:*", "@automattic/jetpack-webpack-config": "workspace:*", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@babel/plugin-transform-react-jsx": "7.24.7", "@wordpress/babel-plugin-import-jsx-pragma": "5.7.0" diff --git a/projects/packages/backup/changelog/renovate-major-js-unit-testing-packages b/projects/packages/backup/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/packages/backup/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/packages/backup/changelog/update-wordpress-eslint-plugin b/projects/packages/backup/changelog/update-wordpress-eslint-plugin new file mode 100644 index 0000000000000..79c05e77ac0cb --- /dev/null +++ b/projects/packages/backup/changelog/update-wordpress-eslint-plugin @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Remove unnecessary leading space from i18n message. diff --git a/projects/packages/backup/package.json b/projects/packages/backup/package.json index 5bb7925a0f9ad..b07c148f34d03 100644 --- a/projects/packages/backup/package.json +++ b/projects/packages/backup/package.json @@ -48,7 +48,7 @@ "@babel/preset-env": "7.24.7", "@babel/runtime": "7.24.7", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@wordpress/browserslist-config": "6.7.0", "concurrently": "7.6.0", diff --git a/projects/packages/backup/src/js/components/Backups.js b/projects/packages/backup/src/js/components/Backups.js index 9d809fb9a2ce9..bfe641cdb4f18 100644 --- a/projects/packages/backup/src/js/components/Backups.js +++ b/projects/packages/backup/src/js/components/Backups.js @@ -62,7 +62,7 @@ const NoGoodBackups = () => {

{ createInterpolateElement( __( - ' Get in touch with us to get your site backups going again.', + 'Get in touch with us to get your site backups going again.', 'jetpack-backup-pkg' ), { diff --git a/projects/packages/classic-theme-helper/changelog/add-require-content-options-in-classic-theme-helper-package b/projects/packages/classic-theme-helper/changelog/add-require-content-options-in-classic-theme-helper-package new file mode 100644 index 0000000000000..58e968282a271 --- /dev/null +++ b/projects/packages/classic-theme-helper/changelog/add-require-content-options-in-classic-theme-helper-package @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Content Options: Ensuring feature is now required. diff --git a/projects/packages/classic-theme-helper/src/class-main.php b/projects/packages/classic-theme-helper/src/class-main.php index 8b230e3d2a7c6..27dce7a41d518 100644 --- a/projects/packages/classic-theme-helper/src/class-main.php +++ b/projects/packages/classic-theme-helper/src/class-main.php @@ -26,6 +26,7 @@ class Main { 'site-breadcrumbs.php', 'social-menu.php', 'jetpack-color.php', + 'content-options.php', ); /** Holds the singleton instance of the Loader diff --git a/projects/packages/classic-theme-helper/src/content-options/customizer.js b/projects/packages/classic-theme-helper/src/content-options/customizer.js index e853604242cdd..5170db0277d57 100644 --- a/projects/packages/classic-theme-helper/src/content-options/customizer.js +++ b/projects/packages/classic-theme-helper/src/content-options/customizer.js @@ -1,4 +1,4 @@ -/* global blogDisplay, postDetails */ +/* global blogDisplay, postDetails, wp */ /** * customizer.js @@ -6,213 +6,143 @@ * Theme Customizer enhancements for a better user experience. * * Contains handlers to make Theme Customizer preview reload changes asynchronously. - * @param $ */ -jQuery( function ( $, wp ) { - // Blog Display - wp.customize( 'jetpack_content_blog_display', function ( value ) { - if ( 'content' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'excerpt' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-content' ).css( { +/** + * Function to apply styles to elements based on the display type + * @param {object} selectors - HTML selectors which styles will apply to. + * @param {object} styles - Styles to be applied to selectors. + */ +function applyStyles( selectors, styles ) { + document.querySelectorAll( selectors ).forEach( el => { + for ( const [ key, value ] of Object.entries( styles ) ) { + el.style[ key ] = value; + } + } ); +} + +// Blog Display +wp.customize( 'jetpack_content_blog_display', function ( value ) { + /** + * Updates the blog display based on the selected option. + * @param {string} to - Content display option. + */ + function updateBlogDisplay( to ) { + const contentSelectors = '.jetpack-blog-display.jetpack-the-content'; + const excerptSelectors = '.jetpack-blog-display.jetpack-the-excerpt'; + const featuredContentSelectors = '.featured-content .jetpack-blog-display'; + + if ( to === 'content' ) { + applyStyles( `${ excerptSelectors }, ${ featuredContentSelectors }.jetpack-the-excerpt`, { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', } ); - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { + applyStyles( `${ contentSelectors }, ${ featuredContentSelectors }.jetpack-the-content`, { clip: 'auto', position: 'relative', } ); - } else if ( 'mixed' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( { + } else if ( to === 'excerpt' ) { + applyStyles( `${ contentSelectors }, ${ featuredContentSelectors }.jetpack-the-content`, { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( { + applyStyles( `${ excerptSelectors }, ${ featuredContentSelectors }.jetpack-the-excerpt`, { clip: 'auto', position: 'relative', } ); - } - value.bind( function ( to ) { - if ( 'content' === to ) { - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'excerpt' === to ) { - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'mixed' === to ) { - $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( { + } else if ( to === 'mixed' ) { + applyStyles( + `${ contentSelectors }.output-the-content, ${ featuredContentSelectors }.jetpack-the-content.output-the-content`, + { clip: 'auto', position: 'relative', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( { + } + ); + applyStyles( + `${ excerptSelectors }.output-the-content, ${ contentSelectors }.output-the-excerpt, ${ featuredContentSelectors }.jetpack-the-excerpt.output-the-content, ${ featuredContentSelectors }.jetpack-the-content.output-the-excerpt`, + { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( { + } + ); + applyStyles( + `${ excerptSelectors }.output-the-excerpt, ${ featuredContentSelectors }.jetpack-the-excerpt.output-the-excerpt`, + { clip: 'auto', position: 'relative', - } ); - } - if ( blogDisplay.masonry ) { - $( blogDisplay.masonry ).masonry(); + } + ); + } + + if ( blogDisplay.masonry ) { + const masonryElement = document.querySelector( blogDisplay.masonry ); + if ( masonryElement ) { + masonryElement.masonry(); } - } ); + } + } + + updateBlogDisplay( blogDisplay.display ); + value.bind( updateBlogDisplay ); +} ); + +/** + * Function to update post details visibility + * @param {object} selectors - HTML selectors which styles will apply to. + * @param {string} to - Content display option. + * @param {string} hiddenClass - Class to be added to the body when the post details are hidden. + */ +function updatePostDetails( selectors, to, hiddenClass ) { + document.querySelectorAll( selectors ).forEach( element => { + if ( to === false ) { + element.style.clip = 'rect(1px, 1px, 1px, 1px)'; + element.style.height = '1px'; + element.style.overflow = 'hidden'; + element.style.position = 'absolute'; + element.style.width = '1px'; + document.body.classList.add( hiddenClass ); + } else { + element.style.clip = 'auto'; + element.style.height = 'auto'; + element.style.overflow = 'auto'; + element.style.position = 'relative'; + element.style.width = 'auto'; + document.body.classList.remove( hiddenClass ); + } } ); +} - // Post Details: Date. - wp.customize( 'jetpack_content_post_details_date', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.date ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'date-hidden' ); - } else { - $( postDetails.date ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'date-hidden' ); - } - } ); +// Post Details: Date +wp.customize( 'jetpack_content_post_details_date', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.date, to, 'date-hidden' ); } ); +} ); - // Post Details: Categories. - wp.customize( 'jetpack_content_post_details_categories', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.categories ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'categories-hidden' ); - } else { - $( postDetails.categories ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'categories-hidden' ); - } - } ); +// Post Details: Categories +wp.customize( 'jetpack_content_post_details_categories', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.categories, to, 'categories-hidden' ); } ); +} ); - // Post Details: Tags. - wp.customize( 'jetpack_content_post_details_tags', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.tags ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'tags-hidden' ); - } else { - $( postDetails.tags ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'tags-hidden' ); - } - } ); +// Post Details: Tags +wp.customize( 'jetpack_content_post_details_tags', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.tags, to, 'tags-hidden' ); } ); +} ); - // Post Details: Author. - wp.customize( 'jetpack_content_post_details_author', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.author ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'author-hidden' ); - } else { - $( postDetails.author ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'author-hidden' ); - } - } ); +// Post Details: Author +wp.customize( 'jetpack_content_post_details_author', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.author, to, 'author-hidden' ); } ); +} ); - // Post Details: Comment link. - wp.customize( 'jetpack_content_post_details_comment', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.comment ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'comment-hidden' ); - } else { - $( postDetails.comment ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'comment-hidden' ); - } - } ); +// Post Details: Comment link +wp.customize( 'jetpack_content_post_details_comment', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.comment, to, 'comment-hidden' ); } ); -} )( jQuery ); +} ); diff --git a/projects/packages/classic-theme-helper/src/content-options/customizer.php b/projects/packages/classic-theme-helper/src/content-options/customizer.php index 7cbe45cac7a59..b5305c97d0baa 100644 --- a/projects/packages/classic-theme-helper/src/content-options/customizer.php +++ b/projects/packages/classic-theme-helper/src/content-options/customizer.php @@ -5,6 +5,8 @@ * @package automattic/jetpack-classic-theme-helper */ +use Automattic\Jetpack\Assets; + if ( ! function_exists( 'jetpack_content_options_customize_register' ) ) { /** @@ -493,7 +495,18 @@ function jetpack_content_options_customize_preview_js() { $author = ( ! empty( $post_details['author'] ) ) ? $post_details['author'] : null; $comment = ( ! empty( $post_details['comment'] ) ) ? $post_details['comment'] : null; - wp_enqueue_script( 'jetpack-content-options-customizer', plugins_url( 'customizer.js', __FILE__ ), array( 'jquery', 'customize-preview' ), '1.0', true ); + Assets::register_script( + 'jetpack-content-options-customizer', + '../../dist/content-options/customizer.js', + __FILE__, + array( + 'dependencies' => array( + 'customize-preview', + ), + 'in_footer' => true, + 'enqueue' => true, + ) + ); wp_localize_script( 'jetpack-content-options-customizer', diff --git a/projects/packages/classic-theme-helper/src/content-options/post-details.php b/projects/packages/classic-theme-helper/src/content-options/post-details.php index 3e4fbc3f9f526..dc21f60d3b6bb 100644 --- a/projects/packages/classic-theme-helper/src/content-options/post-details.php +++ b/projects/packages/classic-theme-helper/src/content-options/post-details.php @@ -60,8 +60,10 @@ function jetpack_post_details_enqueue_scripts() { $css = $elements . ' { clip: rect(1px, 1px, 1px, 1px); height: 1px; position: absolute; overflow: hidden; width: 1px; }'; // Add the CSS to the stylesheet. - // @phan-suppress-next-line PhanTypeArraySuspiciousNullable. - wp_add_inline_style( $post_details['stylesheet'], $css ); + + if ( is_array( $post_details ) && isset( $post_details['stylesheet'] ) ) { + wp_add_inline_style( $post_details['stylesheet'], $css ); + } } add_action( 'wp_enqueue_scripts', 'jetpack_post_details_enqueue_scripts' ); diff --git a/projects/packages/connection/changelog/fix-connected-plugins-on-multisites b/projects/packages/connection/changelog/fix-connected-plugins-on-multisites new file mode 100644 index 0000000000000..a608ebf17009c --- /dev/null +++ b/projects/packages/connection/changelog/fix-connected-plugins-on-multisites @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix the connected plugins option on multisites. diff --git a/projects/packages/connection/src/class-plugin-storage.php b/projects/packages/connection/src/class-plugin-storage.php index 21d9402bf0e29..c722a7f022a60 100644 --- a/projects/packages/connection/src/class-plugin-storage.php +++ b/projects/packages/connection/src/class-plugin-storage.php @@ -144,7 +144,10 @@ private static function ensure_configured() { } if ( is_multisite() && get_current_blog_id() !== self::$current_blog_id ) { - self::$plugins = (array) get_option( self::ACTIVE_PLUGINS_OPTION_NAME, array() ); + if ( self::$current_blog_id ) { + // If blog ID got changed, pull the list of active plugins for that blog from the database. + self::$plugins = (array) get_option( self::ACTIVE_PLUGINS_OPTION_NAME, array() ); + } self::$current_blog_id = get_current_blog_id(); } diff --git a/projects/packages/device-detection/changelog/update-device-detection b/projects/packages/device-detection/changelog/update-device-detection new file mode 100644 index 0000000000000..e413e8177c7f6 --- /dev/null +++ b/projects/packages/device-detection/changelog/update-device-detection @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Device_Detection::get_info() will now memoize its result diff --git a/projects/packages/device-detection/src/class-device-detection.php b/projects/packages/device-detection/src/class-device-detection.php index 767a552ccbee6..62361d7edb498 100644 --- a/projects/packages/device-detection/src/class-device-detection.php +++ b/projects/packages/device-detection/src/class-device-detection.php @@ -23,6 +23,20 @@ */ class Device_Detection { + /** + * Memoization cache for get_info() results. + * + * @var array + */ + private static $get_info_memo = array(); + + /** + * Maximum size of the memoization cache. + * + * @var int + */ + private static $max_memo_size = 100; + /** * Returns information about the current device accessing the page. * @@ -41,6 +55,16 @@ class Device_Detection { * ); */ public static function get_info( $ua = '' ) { + // Return memoized result if available. + // phpcs:disable WordPress.Security.ValidatedSanitizedInput + $memo_key = ! empty( $ua ) ? $ua : ( $_SERVER['HTTP_USER_AGENT'] ?? '' ); + // Note: UA string used raw for compatibility reasons. + // No sanitization is needed as the value is never output or persisted, and is only used for memoization. + // phpcs:enable WordPress.Security.ValidatedSanitizedInput + if ( isset( self::$get_info_memo[ $memo_key ] ) ) { + return self::$get_info_memo[ $memo_key ]; + } + $ua_info = new User_Agent_Info( $ua ); $info = array( @@ -68,6 +92,13 @@ public static function get_info( $ua = '' ) { */ $info = apply_filters( 'jetpack_device_detection_get_info', $info, $ua, $ua_info ); } + + // Memoize the result. + self::$get_info_memo[ $memo_key ] = $info; + if ( count( self::$get_info_memo ) > self::$max_memo_size ) { + array_shift( self::$get_info_memo ); + } + return $info; } diff --git a/projects/packages/forms/changelog/update-wordpress-eslint-plugin b/projects/packages/forms/changelog/update-wordpress-eslint-plugin new file mode 100644 index 0000000000000..b7741525f5678 --- /dev/null +++ b/projects/packages/forms/changelog/update-wordpress-eslint-plugin @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Use en-dash in numeric range in i18n message to conform to guidelines. diff --git a/projects/packages/forms/src/blocks/contact-form/components/jetpack-salesforce-lead-form/jetpack-salesforce-lead-form-settings.js b/projects/packages/forms/src/blocks/contact-form/components/jetpack-salesforce-lead-form/jetpack-salesforce-lead-form-settings.js index 4feab8bb8a60a..989d8aa665215 100644 --- a/projects/packages/forms/src/blocks/contact-form/components/jetpack-salesforce-lead-form/jetpack-salesforce-lead-form-settings.js +++ b/projects/packages/forms/src/blocks/contact-form/components/jetpack-salesforce-lead-form/jetpack-salesforce-lead-form-settings.js @@ -141,7 +141,7 @@ export default ( { salesforceData, setAttributes, instanceId } ) => { { organizationIdError && ( { __( - 'Invalid Organization ID. Should be a 15 - 18 characters long alphanumeric string.', + 'Invalid Organization ID. Should be a 15 – 18 characters long alphanumeric string.', 'jetpack-forms' ) } diff --git a/projects/packages/jetpack-mu-wpcom/changelog/admin-bar-consistency b/projects/packages/jetpack-mu-wpcom/changelog/admin-bar-consistency new file mode 100644 index 0000000000000..f77b240b96091 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/admin-bar-consistency @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Admin bar: fix paddings around wpcom and reader logos diff --git a/projects/packages/jetpack-mu-wpcom/changelog/feat-launchpad_draft_post b/projects/packages/jetpack-mu-wpcom/changelog/feat-launchpad_draft_post new file mode 100644 index 0000000000000..bc79a3faa41e1 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/feat-launchpad_draft_post @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Launchpad first_post_published task reuses existing draft if there is one diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-prevent-undefined-get-current-screen-function-errors b/projects/packages/jetpack-mu-wpcom/changelog/fix-prevent-undefined-get-current-screen-function-errors new file mode 100644 index 0000000000000..e8d18e87a56d1 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-prevent-undefined-get-current-screen-function-errors @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Prevent undefined `get_current_screen` function errors resulting from invoking the function in contexts where it is undefined. diff --git a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php index eae27e22c0867..5f2203aae55d6 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php @@ -99,13 +99,28 @@ function wpcom_launchpad_get_task_definitions() { ), 'first_post_published' => array( 'get_title' => function () { - return __( 'Write your first post', 'jetpack-mu-wpcom' ); + $latest_draft_id = wpcom_launchpad_get_latest_draft_id(); + return $latest_draft_id === false + ? __( 'Write your first post', 'jetpack-mu-wpcom' ) + : __( 'Continue to write your first post', 'jetpack-mu-wpcom' ); }, 'add_listener_callback' => function () { add_action( 'publish_post', 'wpcom_launchpad_track_publish_first_post_task' ); }, 'get_calypso_path' => function ( $task, $default, $data ) { - $base_path = wpcom_launchpad_should_use_wp_admin_link() + $is_blog_onboarding_flow = in_array( get_option( 'site_intent' ), array( 'start-writing', 'design-first' ), true ); + $use_wp_admin_link = wpcom_launchpad_should_use_wp_admin_link() || $is_blog_onboarding_flow; + $latest_draft_id = wpcom_launchpad_get_latest_draft_id(); + + if ( is_int( $latest_draft_id ) ) { + // There is a draft post, redirect the user to the draft instead of making a fresh post. + if ( $use_wp_admin_link ) { + return admin_url( 'post.php?action=edit&post=' . rawurlencode( $latest_draft_id ) ); + } + return '/post/' . $data['site_slug_encoded'] . '/' . rawurlencode( $latest_draft_id ); + } + + $base_path = $use_wp_admin_link ? admin_url( 'post-new.php' ) : '/post/' . $data['site_slug_encoded']; @@ -2720,3 +2735,38 @@ function wpcom_launchpad_mark_theme_selected_complete( $new_theme, $old_theme ) wpcom_mark_launchpad_task_complete( 'site_theme_selected' ); } add_action( 'jetpack_sync_current_theme_support', 'wpcom_launchpad_mark_theme_selected_complete', 10, 2 ); + +/** + * Returns the latest draft post ID, otherwise false. + * Similar to wp_get_recent_posts, except we only need the ID. + * + * The response is cached for the lifetime of the current request. + * + * @return int | boolean + */ +function wpcom_launchpad_get_latest_draft_id() { + // The result is cached for the current request + static $cached_blog_id = null; + static $cached_draft_id = null; + + if ( $cached_blog_id === get_current_blog_id() && $cached_draft_id !== null ) { + return $cached_draft_id; + } + + // Query for the latest draft post + $args = array( + 'posts_per_page' => 1, + 'post_status' => 'draft', + 'post_type' => 'post', + 'orderby' => 'date', + 'order' => 'DESC', + 'fields' => 'ids', + ); + + $latest_draft_id = get_posts( $args ); + + $cached_blog_id = get_current_blog_id(); + $cached_draft_id = reset( $latest_draft_id ); + + return $cached_draft_id; +} diff --git a/projects/packages/jetpack-mu-wpcom/src/features/starter-page-templates/class-starter-page-templates.php b/projects/packages/jetpack-mu-wpcom/src/features/starter-page-templates/class-starter-page-templates.php index 46fde04717979..d61ef08094aec 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/starter-page-templates/class-starter-page-templates.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/starter-page-templates/class-starter-page-templates.php @@ -176,6 +176,10 @@ public function pass_error_to_frontend( $message ) { * Enqueue block editor assets. */ public function enqueue_assets() { + if ( ! function_exists( 'get_current_screen' ) ) { + return; + } + $screen = get_current_screen(); $user_locale = Common\get_iso_639_locale( get_user_locale() ); diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.scss b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.scss index bbeadbd5feca4..698b5378ba878 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.scss +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.scss @@ -40,10 +40,18 @@ /** * WP logo menu */ -#wpadminbar #wp-admin-bar-wpcom-logo>.ab-item .ab-icon { - width: 15px; +#wpadminbar #wp-admin-bar-wpcom-logo>.ab-item { + padding: 0 10px; + @media (max-width: 782px) { - width: revert; + padding: 0; + } +} +#wpadminbar #wp-admin-bar-wpcom-logo>.ab-item .ab-icon { + margin-right: 0 !important; + + @media (max-width: 480px) { + width: 44px; } } #wpadminbar #wp-admin-bar-wpcom-logo>.ab-item .ab-icon:before { @@ -134,7 +142,7 @@ .ab-icon { display: flex; align-items: center; - padding: 0 10px; + padding: 0 8px; margin: 0; height: 100%; diff --git a/projects/packages/my-jetpack/changelog/renovate-major-js-unit-testing-packages b/projects/packages/my-jetpack/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/packages/my-jetpack/changelog/update-my-jetpack-menu-item-and-page-loading-order b/projects/packages/my-jetpack/changelog/update-my-jetpack-menu-item-and-page-loading-order new file mode 100644 index 0000000000000..e37e7d9e99dab --- /dev/null +++ b/projects/packages/my-jetpack/changelog/update-my-jetpack-menu-item-and-page-loading-order @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: This is a performance internal change + + diff --git a/projects/packages/my-jetpack/package.json b/projects/packages/my-jetpack/package.json index add310f8b0f69..18df813c1a189 100644 --- a/projects/packages/my-jetpack/package.json +++ b/projects/packages/my-jetpack/package.json @@ -62,7 +62,7 @@ "@storybook/react": "8.2.9", "@testing-library/dom": "10.4.0", "@testing-library/jest-dom": "6.5.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@testing-library/user-event": "14.5.2", "@types/jest": "29.5.12", "@types/react": "18.3.3", diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index 334180f6695e9..3ff30e9b1ab64 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -99,16 +99,8 @@ public static function init() { // Add custom WP REST API endoints. add_action( 'rest_api_init', array( __CLASS__, 'register_rest_endpoints' ) ); - $page_suffix = Admin_Menu::add_menu( - __( 'My Jetpack', 'jetpack-my-jetpack' ), - __( 'My Jetpack', 'jetpack-my-jetpack' ), - 'edit_posts', - 'my-jetpack', - array( __CLASS__, 'admin_page' ), - -1 - ); + add_action( 'admin_menu', array( __CLASS__, 'add_my_jetpack_menu_item' ) ); - add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) ); add_action( 'admin_init', array( __CLASS__, 'setup_historically_active_jetpack_modules_sync' ) ); // This is later than the admin-ui package, which runs on 1000 add_action( 'admin_init', array( __CLASS__, 'maybe_show_red_bubble' ), 1001 ); @@ -166,6 +158,23 @@ public static function is_licensing_ui_enabled() { ); } + /** + * Add My Jetpack menu item to the admin menu. + * + * @return void + */ + public static function add_my_jetpack_menu_item() { + $page_suffix = Admin_Menu::add_menu( + __( 'My Jetpack', 'jetpack-my-jetpack' ), + __( 'My Jetpack', 'jetpack-my-jetpack' ), + 'edit_posts', + 'my-jetpack', + array( __CLASS__, 'admin_page' ), + -1 + ); + add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) ); + } + /** * Callback for the load my jetpack page hook. * diff --git a/projects/packages/publicize/.phan/baseline.php b/projects/packages/publicize/.phan/baseline.php index 9de3f4af616bf..b3e516345e315 100644 --- a/projects/packages/publicize/.phan/baseline.php +++ b/projects/packages/publicize/.phan/baseline.php @@ -30,7 +30,6 @@ // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'src/auto-conversion-settings/class-rest-settings-controller.php' => ['PhanPluginMixedKeyNoKey'], 'src/class-connections-post-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-keyring-helper.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault'], 'src/class-publicize-base.php' => ['PhanImpossibleCondition', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn'], @@ -42,7 +41,6 @@ 'src/social-image-generator/class-rest-settings-controller.php' => ['PhanPluginMixedKeyNoKey'], 'src/social-image-generator/class-settings.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/social-image-generator/class-setup.php' => ['PhanTypeMismatchArgumentNullable'], - 'tests/php/jetpack-social-settings/test-auto-conversion.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing'], 'tests/php/jetpack-social-settings/test-jetpack-social-settings.php' => ['PhanDeprecatedFunction'], 'tests/php/test-connections-post-field.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgument'], 'tests/php/test-publicize-og-optimization.php' => ['PhanDeprecatedFunction'], diff --git a/projects/packages/publicize/changelog/update-publicize-ui-init-on-admin-only b/projects/packages/publicize/changelog/update-publicize-ui-init-on-admin-only new file mode 100644 index 0000000000000..ab5c5069aacb4 --- /dev/null +++ b/projects/packages/publicize/changelog/update-publicize-ui-init-on-admin-only @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Moved initialization of Publicize UI from init action to admin_init action diff --git a/projects/packages/publicize/changelog/update-social-clean-up-media-auto-conversion-backend-logic b/projects/packages/publicize/changelog/update-social-clean-up-media-auto-conversion-backend-logic new file mode 100644 index 0000000000000..db4b11231fe0a --- /dev/null +++ b/projects/packages/publicize/changelog/update-social-clean-up-media-auto-conversion-backend-logic @@ -0,0 +1,4 @@ +Significance: minor +Type: removed + +Social: Cleaned up media auto-conversion backend logic diff --git a/projects/packages/publicize/src/auto-conversion-settings/class-rest-settings-controller.php b/projects/packages/publicize/src/auto-conversion-settings/class-rest-settings-controller.php deleted file mode 100644 index 6b3704bdeb8c5..0000000000000 --- a/projects/packages/publicize/src/auto-conversion-settings/class-rest-settings-controller.php +++ /dev/null @@ -1,138 +0,0 @@ - WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_auto_coversion_settings' ), - 'permission_callback' => array( $this, 'settings_permissions_callback' ), - ), - array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'update_auto_coversion_settings' ), - 'permission_callback' => array( $this, 'settings_permissions_callback' ), - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) - ); - } - - /** - * GET `/jetpack/v4/auto-conversion/settings` - * - * @return WP_REST_Response - */ - public function get_auto_coversion_settings() { - $settings = ( new Jetpack_Social_Settings() )->get_settings(); - $response = array(); - $schema = $this->get_item_schema(); - $properties = array_keys( $schema['properties'] ); - - if ( in_array( 'image', $properties, true ) ) { - $response['image'] = $settings['autoConversionSettings']['enabled']; - } - - if ( in_array( 'auto-conversion', $properties, true ) ) { - $response['auto-conversion'] = $settings['autoConversionSettings']['enabled']; - } - - return rest_ensure_response( $response ); - } - - /** - * POST `/jetpack/v4/auto-conversion/settings` - * - * @param WP_REST_Request $request The API request. - * - * @return WP_REST_Response|WP_Error - */ - public function update_auto_coversion_settings( $request ) { - $settings = new Jetpack_Social_Settings(); - - if ( isset( $request['image'] ) ) { - $settings->update_auto_conversion_setting( array( 'enabled' => $request['image'] ) ); - } - - return rest_ensure_response( $this->get_auto_coversion_settings() ); - } - - /** - * Check the permissions for accessing and updating the settings endpoint. - * - * @return bool|WP_Error True if user can manage options. - */ - public function settings_permissions_callback() { - if ( ! current_user_can( 'edit_posts' ) ) { - return new WP_Error( - 'rest_forbidden_context', - __( 'Sorry, you are not allowed to access this endpoint.', 'jetpack-publicize-pkg' ), - array( 'status' => rest_authorization_required_code() ) - ); - } - - return true; - } - - /** - * Retrieves the settings schema, conforming to JSON Schema. - * - * @return array Schema data. - */ - public function get_item_schema() { - $schema = array( - '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'auto-conversion-settings', - 'type' => 'object', - 'properties' => array( - 'image' => array( - 'description' => __( 'Whether or not auto-conversion for images is enabled.', 'jetpack-publicize-pkg' ), - 'type' => 'boolean', - 'context' => array( 'view', 'edit' ), - ), - 'video' => array( - 'description' => __( 'Whether or not auto-conversion for videos is enabled.', 'jetpack-publicize-pkg' ), - 'type' => 'boolean', - 'context' => array( 'view', 'edit' ), - ), - 'auto-conversion' => array( - 'description' => __( 'Whether or not auto-conversion is enabled.', 'jetpack-publicize-pkg' ), - 'type' => 'boolean', - 'context' => array( 'view', 'edit' ), - ), - ), - ); - - return rest_default_additional_properties_to_false( $schema ); - } -} diff --git a/projects/packages/publicize/src/auto-conversion-settings/class-settings.php b/projects/packages/publicize/src/auto-conversion-settings/class-settings.php deleted file mode 100644 index d6cc96f17c3b8..0000000000000 --- a/projects/packages/publicize/src/auto-conversion-settings/class-settings.php +++ /dev/null @@ -1,76 +0,0 @@ -settings = $this->get_settings(); - } - - /** - * Get the current auto conversion settings. - * - * @return array - */ - private function get_settings() { - $new_settings = ( new Jetpack_Social_Settings() )->get_settings(); - - return array( - 'image' => $new_settings['autoConversionSettings']['enabled'], - ); - } - - /** - * Check if the auto conversion feature is available. - * - * @param string $type Whether video or image. - * @return bool True if available, false otherwise. - */ - public function is_available( $type ) { - return ( new Jetpack_Social_Settings() )->is_auto_conversion_available( $type ); - } - - /** - * Check if the auto conversion feature is enabled. - * - * @param string $type Whether video or image. - * - * @return bool True if the feature is enabled, false otherwise. - */ - public function is_enabled( $type ) { - if ( 'image' === $type ) { - $new_settings = ( new Jetpack_Social_Settings() )->get_settings(); - return $new_settings['autoConversionSettings']['enabled']; - } - } -} diff --git a/projects/packages/publicize/src/class-publicize-base.php b/projects/packages/publicize/src/class-publicize-base.php index 2a53803a66339..c807d20babdcc 100644 --- a/projects/packages/publicize/src/class-publicize-base.php +++ b/projects/packages/publicize/src/class-publicize-base.php @@ -2028,6 +2028,8 @@ public function has_social_image_generator_feature() { /** * Check if the auto-conversion feature is one of the active features. * + * TODO: Remove this after certain releases of Jetpack v15. + * * @param string $type Whether image or video. * * @return bool diff --git a/projects/packages/publicize/src/class-publicize-setup.php b/projects/packages/publicize/src/class-publicize-setup.php index 57caa858eecc8..383ef289fab5e 100644 --- a/projects/packages/publicize/src/class-publicize-setup.php +++ b/projects/packages/publicize/src/class-publicize-setup.php @@ -46,10 +46,6 @@ public static function on_jetpack_feature_publicize_enabled() { add_action( 'rest_api_init', array( static::class, 'register_core_options' ) ); add_action( 'admin_init', array( static::class, 'register_core_options' ) ); - // Flagged to be removed after deprecation. - // @deprecated 0.38.3 - add_action( 'rest_api_init', array( new Auto_Conversion\REST_Settings_Controller(), 'register_routes' ) ); - ( new Social_Image_Generator\Setup() )->init(); } diff --git a/projects/packages/publicize/src/class-publicize-ui.php b/projects/packages/publicize/src/class-publicize-ui.php index a478d88894105..ccb307783bf85 100644 --- a/projects/packages/publicize/src/class-publicize-ui.php +++ b/projects/packages/publicize/src/class-publicize-ui.php @@ -38,7 +38,7 @@ public function __construct() { } $this->publicize = $publicize; - add_action( 'init', array( $this, 'init' ) ); + add_action( 'admin_init', array( $this, 'init' ) ); } /** diff --git a/projects/packages/publicize/src/class-rest-controller.php b/projects/packages/publicize/src/class-rest-controller.php index 57f2cd564bc85..48da0259315a6 100644 --- a/projects/packages/publicize/src/class-rest-controller.php +++ b/projects/packages/publicize/src/class-rest-controller.php @@ -339,7 +339,7 @@ public function get_dismiss_notice_endpoint_schema() { 'notice' => array( 'description' => __( 'Name of the notice to dismiss', 'jetpack-publicize-pkg' ), 'type' => 'string', - 'enum' => array( 'instagram', 'advanced-upgrade-nudge-admin', 'advanced-upgrade-nudge-editor', 'auto-conversion-editor-notice' ), + 'enum' => array( 'instagram', 'advanced-upgrade-nudge-admin', 'advanced-upgrade-nudge-editor' ), 'required' => true, ), 'reappearance_time' => array( diff --git a/projects/packages/publicize/src/jetpack-social-settings/class-dismissed-notices.php b/projects/packages/publicize/src/jetpack-social-settings/class-dismissed-notices.php index bc68614adf146..0936ece2ea76f 100644 --- a/projects/packages/publicize/src/jetpack-social-settings/class-dismissed-notices.php +++ b/projects/packages/publicize/src/jetpack-social-settings/class-dismissed-notices.php @@ -28,7 +28,6 @@ public function register() { 'schema' => array( 'type' => 'object', 'properties' => array( - 'auto-conversion-editor-notice' => array( 'type' => 'number' ), 'advanced-upgrade-nudge-admin' => array( 'type' => 'number' ), 'advanced-upgrade-nudge-editor' => array( 'type' => 'number' ), ), diff --git a/projects/packages/publicize/src/jetpack-social-settings/class-settings.php b/projects/packages/publicize/src/jetpack-social-settings/class-settings.php index c6ede04471f17..7b5db1037146f 100644 --- a/projects/packages/publicize/src/jetpack-social-settings/class-settings.php +++ b/projects/packages/publicize/src/jetpack-social-settings/class-settings.php @@ -16,7 +16,6 @@ * This class is used to get and update Jetpack_Social_Settings. * Currently supported features: * - Social Image Generator - * - Auto Conversion */ class Settings { /** @@ -24,9 +23,7 @@ class Settings { * * @var string */ - const OPTION_PREFIX = 'jetpack_social_'; - // cSpell:ignore AUTOCONVERT - const AUTOCONVERT_IMAGES = 'autoconvert_images'; + const OPTION_PREFIX = 'jetpack_social_'; const IMAGE_GENERATOR_SETTINGS = 'image_generator_settings'; const DEFAULT_IMAGE_GENERATOR_SETTINGS = array( @@ -34,10 +31,6 @@ class Settings { 'template' => Templates::DEFAULT_TEMPLATE, ); - const DEFAULT_AUTOCONVERT_IMAGES_SETTINGS = array( - 'enabled' => true, - ); - /** * Feature flags. Each item has 3 keys because of the naming conventions: * - flag_name: The name of the feature flag for the option check. @@ -61,31 +54,24 @@ class Settings { /** * Migrate old options to the new settings. Previously SIG settings were stored in the - * jetpack_social_image_generator_settings option. Now they are stored in the jetpack_social_settings - * together with the auto conversion settings. + * jetpack_social_image_generator_settings option. Now they are stored in the jetpack_social_settings. * * TODO: Work out if this is possible on plugin upgrade * * @return void */ private function migrate_old_option() { - // Migrating from the old option. - $old_auto_conversion_settings = get_option( 'jetpack_social_settings' ); - if ( ! empty( $old_auto_conversion_settings ) ) { - update_option( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES, array( 'enabled' => ! empty( $old_auto_conversion_settings['image'] ) ) ); + // Delete the old options if they exist. + if ( get_option( 'jetpack_social_settings' ) ) { delete_option( 'jetpack_social_settings' ); } - // Checking if the new option is valid. - $auto_conversion_settings = get_option( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES ); - // If the option is not set, we don't need to delete it. - // If it is set, but it is not an array or it does not have the enabled key, we delete it. - if ( false !== $auto_conversion_settings && ( ! is_array( $auto_conversion_settings ) || ! isset( $auto_conversion_settings['enabled'] ) ) ) { - delete_option( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES ); + if ( get_option( 'jetpack_social_autoconvert_images' ) ) { + delete_option( 'jetpack_social_autoconvert_images' ); } $sig_settings = get_option( 'jetpack_social_image_generator_settings' ); // If the option is not set, we don't need to migrate. - if ( $sig_settings === false ) { + if ( false === $sig_settings ) { return; } @@ -117,26 +103,6 @@ private function migrate_old_option() { * @return void */ public function register_settings() { - register_setting( - 'jetpack_social', - self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES, - array( - 'default' => array( - 'enabled' => true, - ), - 'type' => 'object', - 'show_in_rest' => array( - 'schema' => array( - 'type' => 'object', - 'properties' => array( - 'enabled' => array( - 'type' => 'boolean', - ), - ), - ), - ), - ) - ); register_setting( 'jetpack_social', @@ -177,18 +143,15 @@ public function get_settings( $with_available = false ) { $this->migrate_old_option(); $settings = array( - 'autoConversionSettings' => get_option( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES, self::DEFAULT_AUTOCONVERT_IMAGES_SETTINGS ), 'socialImageGeneratorSettings' => get_option( self::OPTION_PREFIX . self::IMAGE_GENERATOR_SETTINGS, self::DEFAULT_IMAGE_GENERATOR_SETTINGS ), ); // The feature cannot be enabled without Publicize. if ( ! ( new Modules() )->is_active( 'publicize' ) ) { - $settings['autoConversionSettings']['enabled'] = false; $settings['socialImageGeneratorSettings']['enabled'] = false; } if ( $with_available ) { - $settings['autoConversionSettings']['available'] = $this->is_auto_conversion_available(); $settings['socialImageGeneratorSettings']['available'] = $this->is_sig_available(); } @@ -246,9 +209,6 @@ public function get_initial_state() { * @return bool */ public function update_settings( $updated, $name, $value ) { - if ( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES === $name ) { - return $this->update_auto_conversion_setting( $value ); - } if ( self::OPTION_PREFIX . self::IMAGE_GENERATOR_SETTINGS === $name ) { return $this->update_social_image_generator_settings( $value ); @@ -256,24 +216,6 @@ public function update_settings( $updated, $name, $value ) { return $updated; } - /** - * Update the auto conversion settings. - * - * @param array $new_setting The new settings. - * - * @return bool - */ - public function update_auto_conversion_setting( $new_setting ) { - $this->migrate_old_option(); - $auto_conversion_settings = get_option( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES ); - - if ( empty( $auto_conversion_settings ) || ! is_array( $auto_conversion_settings ) ) { - $auto_conversion_settings = self::DEFAULT_AUTOCONVERT_IMAGES_SETTINGS; - } - - return update_option( self::OPTION_PREFIX . self::AUTOCONVERT_IMAGES, array_replace_recursive( $auto_conversion_settings, $new_setting ) ); - } - /** * Update the social image generator settings. * @@ -307,23 +249,6 @@ public function is_sig_available() { return $publicize->has_social_image_generator_feature(); } - /** - * Check if the auto conversion feature is available. - * - * @param string $type Whether video or image. - - * @return bool True if available, false otherwise. - */ - public function is_auto_conversion_available( $type = 'image' ) { - global $publicize; - - if ( ! $publicize ) { - return false; - } - - return $publicize->has_social_auto_conversion_feature( $type ); - } - /** * Get the default template. * diff --git a/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php b/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php deleted file mode 100644 index 67dcffaf3609c..0000000000000 --- a/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php +++ /dev/null @@ -1,98 +0,0 @@ -getMockBuilder( Publicize::class )->setMethods( array( 'has_social_auto_conversion_feature' ) )->getMock(); - $publicize->method( 'has_social_auto_conversion_feature' ) - ->withAnyParameters() - ->willReturn( true ); - $this->settings = new SocialSettings(); - $this->settings->register_settings(); - } - - /** - * Tear down - * - * @after - */ - public function tear_down() { - wp_set_current_user( 0 ); - - global $publicize; - $publicize = new Publicize(); - - remove_filter( 'jetpack_active_modules', array( $this, 'mock_publicize_being_active' ) ); - WorDBless_Options::init()->clear_options(); - WorDBless_Posts::init()->clear_all_posts(); - WorDBless_Users::init()->clear_all_users(); - } - - /** - * Mock Publicize being active. - * - * @return array - */ - public function mock_publicize_being_active() { - return array( 'publicize' ); - } - - /** - * Test that Auto-Conversion is available based on the plan check. - */ - public function test_correctly_returns_available_status() { - $this->assertTrue( $this->settings->is_auto_conversion_available() ); - } - - /** - * Test that it correctly returns enabled or disabled. - */ - public function test_correctly_returns_enabled_status() { - $auto_conversion_settings = $this->settings->get_settings()['autoConversionSettings']; - $this->assertTrue( $auto_conversion_settings['enabled'] ); - $this->assertFalse( isset( $auto_conversion_settings['video'] ) ? $auto_conversion_settings['video'] : false ); - } - - /** - * Test that it correctly returns enabled or disabled. - */ - public function test_correctly_updates_enabled_status() { - $this->settings->update_auto_conversion_setting( array( 'enabled' => false ) ); - $auto_conversion_settings = $this->settings->get_settings()['autoConversionSettings']; - $this->assertFalse( $auto_conversion_settings['enabled'] ); - - $this->settings->update_auto_conversion_setting( array( 'video' => true ) ); - $auto_conversion_settings = $this->settings->get_settings()['autoConversionSettings']; - $this->assertFalse( $auto_conversion_settings['enabled'] ); - $this->assertTrue( $auto_conversion_settings['video'] ); - } -} diff --git a/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php b/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php index c3bbd5789382e..db790a9f29a35 100644 --- a/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php +++ b/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php @@ -33,10 +33,7 @@ class Jetpack_Social_Settings_Test extends BaseTestCase { public function set_up() { add_filter( 'jetpack_active_modules', array( $this, 'mock_publicize_being_active' ) ); global $publicize; - $publicize = $this->getMockBuilder( Publicize::class )->setMethods( array( 'has_social_auto_conversion_feature', 'has_social_image_generator_feature' ) )->getMock(); - $publicize->method( 'has_social_auto_conversion_feature' ) - ->withAnyParameters() - ->willReturn( true ); + $publicize = $this->getMockBuilder( Publicize::class )->setMethods( array( 'has_social_image_generator_feature' ) )->getMock(); $publicize->method( 'has_social_image_generator_feature' ) ->withAnyParameters() ->willReturn( true ); @@ -76,12 +73,9 @@ public function mock_publicize_being_active() { public function test_get_settings_with_availability() { $settings = $this->settings->get_settings( true ); - $this->assertArrayHasKey( 'autoConversionSettings', $settings ); $this->assertArrayHasKey( 'socialImageGeneratorSettings', $settings ); - $this->assertArrayHasKey( 'available', $settings['autoConversionSettings'] ); $this->assertArrayHasKey( 'available', $settings['socialImageGeneratorSettings'] ); - $this->assertTrue( $settings['autoConversionSettings']['available'] ); $this->assertTrue( $settings['socialImageGeneratorSettings']['available'] ); } @@ -91,12 +85,10 @@ public function test_get_settings_with_availability() { public function test_settings_on_new_site() { $settings = $this->settings->get_settings(); - $this->assertArrayHasKey( 'autoConversionSettings', $settings ); $this->assertArrayHasKey( 'socialImageGeneratorSettings', $settings ); $this->assertArrayHasKey( 'enabled', $settings['socialImageGeneratorSettings'] ); $this->assertArrayHasKey( 'template', $settings['socialImageGeneratorSettings'] ); - $this->assertTrue( $settings['autoConversionSettings']['enabled'] ); $this->assertFalse( $settings['socialImageGeneratorSettings']['enabled'] ); $this->assertEquals( Templates::DEFAULT_TEMPLATE, $settings['socialImageGeneratorSettings']['template'] ); } @@ -115,7 +107,6 @@ public function test_migrate_old_options() { ); $expected_options = array( - 'autoConversionSettings' => array( 'enabled' => true ), 'socialImageGeneratorSettings' => array( 'enabled' => true, 'template' => 'example_template', @@ -134,7 +125,6 @@ public function test_migrate_old_options_with_missing() { update_option( 'jetpack_social_settings', array( 'image' => true ) ); $expected_options = array( - 'autoConversionSettings' => array( 'enabled' => true ), 'socialImageGeneratorSettings' => array( 'enabled' => false, 'template' => Templates::DEFAULT_TEMPLATE, @@ -144,15 +134,4 @@ public function test_migrate_old_options_with_missing() { $this->settings = new SocialSettings(); $this->assertEquals( $expected_options, $this->settings->get_settings() ); } - - /** - * Tests that the auto-conversion settings are migrated even if it was false before. - */ - public function test_migrate_old_options_with_disabled_autoconversion() { - update_option( 'jetpack_social_settings', array( 'image' => false ) ); - $expected_options = array( 'enabled' => false ); - - $this->settings = new SocialSettings(); - $this->assertEquals( $expected_options, $this->settings->get_settings()['autoConversionSettings'] ); - } } diff --git a/projects/packages/search/changelog/renovate-major-js-unit-testing-packages b/projects/packages/search/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/packages/search/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/packages/search/changelog/update-wordpress-eslint-plugin b/projects/packages/search/changelog/update-wordpress-eslint-plugin new file mode 100644 index 0000000000000..fb574fa3a5eb5 --- /dev/null +++ b/projects/packages/search/changelog/update-wordpress-eslint-plugin @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Move trailing spaces out of i18n messages. diff --git a/projects/packages/search/package.json b/projects/packages/search/package.json index 56ebbe24ed3ca..132530edb8cea 100644 --- a/projects/packages/search/package.json +++ b/projects/packages/search/package.json @@ -74,7 +74,7 @@ "@size-limit/preset-app": "11.1.4", "@testing-library/dom": "10.4.0", "@testing-library/preact": "3.2.4", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@wordpress/babel-plugin-import-jsx-pragma": "5.7.0", "@wordpress/browserslist-config": "6.7.0", "@wordpress/dependency-extraction-webpack-plugin": "6.7.0", diff --git a/projects/packages/search/src/dashboard/components/upsell-nudge/index.jsx b/projects/packages/search/src/dashboard/components/upsell-nudge/index.jsx index df266550d91ba..e7751ce44f534 100644 --- a/projects/packages/search/src/dashboard/components/upsell-nudge/index.jsx +++ b/projects/packages/search/src/dashboard/components/upsell-nudge/index.jsx @@ -14,10 +14,10 @@ export default function InstantSearchUpsellNudge( props = { upgrade: true } ) { { __( - 'Offer instant search results to your visitors as soon as they start typing. ', + 'Offer instant search results to your visitors as soon as they start typing.', 'jetpack-search-pkg' ) } - + { ' ' } { __( 'Try Jetpack Instant Search for free now', 'jetpack-search-pkg' ) } diff --git a/projects/packages/search/src/instant-search/components/search-sort.jsx b/projects/packages/search/src/instant-search/components/search-sort.jsx index 39445a74a18d6..2301567f44a6a 100644 --- a/projects/packages/search/src/instant-search/components/search-sort.jsx +++ b/projects/packages/search/src/instant-search/components/search-sort.jsx @@ -59,7 +59,7 @@ export default class SearchSort extends Component { aria-controls="jetpack-instant-search__search-results-content" className="jetpack-instant-search__search-sort jetpack-instant-search__search-sort-with-links" > -

{ __( 'Sort by: ', 'jetpack-search-pkg' ) }
+
{ __( 'Sort by:', 'jetpack-search-pkg' ) }
{ [ ...sortOptions.entries() ].map( ( [ sortKey, label ] ) => ( <>
diff --git a/projects/plugins/social/changelog/renovate-major-js-unit-testing-packages b/projects/plugins/social/changelog/renovate-major-js-unit-testing-packages new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/plugins/social/changelog/renovate-major-js-unit-testing-packages @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/plugins/social/changelog/update-social-clean-up-media-auto-conversion-backend-logic b/projects/plugins/social/changelog/update-social-clean-up-media-auto-conversion-backend-logic new file mode 100644 index 0000000000000..db4b11231fe0a --- /dev/null +++ b/projects/plugins/social/changelog/update-social-clean-up-media-auto-conversion-backend-logic @@ -0,0 +1,4 @@ +Significance: minor +Type: removed + +Social: Cleaned up media auto-conversion backend logic diff --git a/projects/plugins/social/package.json b/projects/plugins/social/package.json index 8989343a4c922..32fcbef41fa1d 100644 --- a/projects/plugins/social/package.json +++ b/projects/plugins/social/package.json @@ -52,7 +52,7 @@ "@babel/runtime": "7.24.7", "@csstools/postcss-global-data": "2.1.1", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", "@wordpress/browserslist-config": "6.7.0", diff --git a/projects/plugins/social/src/class-jetpack-social.php b/projects/plugins/social/src/class-jetpack-social.php index 9a4954d4c55eb..7fc24fabae4e9 100644 --- a/projects/plugins/social/src/class-jetpack-social.php +++ b/projects/plugins/social/src/class-jetpack-social.php @@ -339,7 +339,6 @@ class_exists( 'Jetpack' ) || 'isEnhancedPublishingEnabled' => $publicize->has_enhanced_publishing_feature(), 'isSocialImageGeneratorAvailable' => $social_state['socialImageGeneratorSettings']['available'], 'isSocialImageGeneratorEnabled' => $social_state['socialImageGeneratorSettings']['enabled'], - 'autoConversionSettings' => $social_state['autoConversionSettings'], 'useAdminUiV1' => $social_state['useAdminUiV1'], 'dismissedNotices' => Dismissed_Notices::get_dismissed_notices(), 'supportedAdditionalConnections' => $publicize->get_supported_additional_connections(), diff --git a/projects/plugins/starter-plugin/changelog/renovate-major-js-unit-testing-packages#2 b/projects/plugins/starter-plugin/changelog/renovate-major-js-unit-testing-packages#2 new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/plugins/starter-plugin/changelog/renovate-major-js-unit-testing-packages#2 @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/plugins/starter-plugin/package.json b/projects/plugins/starter-plugin/package.json index 7e133c7e232eb..64ee2209bc42c 100644 --- a/projects/plugins/starter-plugin/package.json +++ b/projects/plugins/starter-plugin/package.json @@ -42,7 +42,7 @@ "@babel/preset-env": "7.24.7", "@babel/runtime": "7.24.7", "@testing-library/dom": "10.4.0", - "@testing-library/react": "15.0.7", + "@testing-library/react": "16.0.1", "@wordpress/browserslist-config": "6.7.0", "babel-jest": "29.4.3", "concurrently": "7.6.0", diff --git a/projects/plugins/super-cache/changelog/update-wordpress-eslint-plugin b/projects/plugins/super-cache/changelog/update-wordpress-eslint-plugin new file mode 100644 index 0000000000000..1b5211fc7fb1d --- /dev/null +++ b/projects/plugins/super-cache/changelog/update-wordpress-eslint-plugin @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Move trailing space out of i18n message. diff --git a/projects/plugins/super-cache/js/preload-notification.js b/projects/plugins/super-cache/js/preload-notification.js index 0aebefe29fb41..50ad92d2d864d 100644 --- a/projects/plugins/super-cache/js/preload-notification.js +++ b/projects/plugins/super-cache/js/preload-notification.js @@ -108,7 +108,7 @@ jQuery( document ).ready( function () { if ( data.previous ) { const p = jQuery( '

' ); - p.append( jQuery( '' ).text( __( 'Last preload finished: ', 'wp-super-cache' ) ) ); + p.append( jQuery( '' ).text( __( 'Last preload finished:', 'wp-super-cache' ) + ' ' ) ); p.append( jQuery( '' ).text( new Date( data.previous * 1000 ).toLocaleString() ) ); panel.append( p ); } diff --git a/projects/plugins/wpcomsh/changelog/change-wpcom-purchases-check-order b/projects/plugins/wpcomsh/changelog/change-wpcom-purchases-check-order new file mode 100644 index 0000000000000..129271710c757 --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/change-wpcom-purchases-check-order @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +WPCOMSH: change call to so it doesn't trigger if not necessary diff --git a/projects/plugins/wpcomsh/wpcom-features/functions-wpcom-features.php b/projects/plugins/wpcomsh/wpcom-features/functions-wpcom-features.php index 50159a383866c..fc6a0aa440949 100644 --- a/projects/plugins/wpcomsh/wpcom-features/functions-wpcom-features.php +++ b/projects/plugins/wpcomsh/wpcom-features/functions-wpcom-features.php @@ -54,8 +54,6 @@ function wpcom_site_has_feature( $feature, $blog_id = 0 ) { $blog_id = _wpcom_get_current_blog_id(); } - $purchases = wpcom_get_site_purchases( $blog_id ); - $blog = null; if ( defined( 'IS_ATOMIC' ) && IS_ATOMIC ) { $site_type = 'wpcom'; @@ -83,6 +81,8 @@ function wpcom_site_has_feature( $feature, $blog_id = 0 ) { return true; } + $purchases = wpcom_get_site_purchases( $blog_id ); + if ( isset( $blog->registered ) ) { WPCOM_Features::add_free_plan_purchase( $purchases, $site_type, $blog->registered ); } diff --git a/tools/js-tools/package.json b/tools/js-tools/package.json index 1105a227da2cc..b40ead7153009 100644 --- a/tools/js-tools/package.json +++ b/tools/js-tools/package.json @@ -22,7 +22,7 @@ "@testing-library/jest-dom": "6.5.0", "@typescript-eslint/eslint-plugin": "6.21.0", "@typescript-eslint/parser": "6.21.0", - "@wordpress/eslint-plugin": "20.3.0", + "@wordpress/eslint-plugin": "21.0.0", "@wordpress/jest-console": "8.7.0", "babel-jest": "29.4.3", "chalk": "4.1.2", diff --git a/tools/js-tools/tsconfig.base.json b/tools/js-tools/tsconfig.base.json index 1d73361155b47..9bb1b4b15cc11 100644 --- a/tools/js-tools/tsconfig.base.json +++ b/tools/js-tools/tsconfig.base.json @@ -18,5 +18,5 @@ "moduleResolution": "bundler", "noEmit": true }, - "files": [ "./types/global.d.ts" ] + "files": [ "./types/global.d.ts", "./types/jest-dom.d.ts" ] } diff --git a/tools/js-tools/types/jest-dom.d.ts b/tools/js-tools/types/jest-dom.d.ts new file mode 100644 index 0000000000000..ac634fc1f503c --- /dev/null +++ b/tools/js-tools/types/jest-dom.d.ts @@ -0,0 +1,2 @@ +// Needed so TypeScript can find @testing-lubrary/jest-dom's types +import '@testing-library/jest-dom';