diff --git a/.github/files/setup-wordpress-env.sh b/.github/files/setup-wordpress-env.sh index 49adb0479c108..2caa7692c58b5 100755 --- a/.github/files/setup-wordpress-env.sh +++ b/.github/files/setup-wordpress-env.sh @@ -46,7 +46,7 @@ case "$WP_BRANCH" in previous) # We hard-code the version here because there's a time near WP releases where # we've dropped the old 'previous' but WP hasn't actually released the new 'latest' - git clone --depth=1 --branch 5.7 git://develop.git.wordpress.org/ /tmp/wordpress-previous + git clone --depth=1 --branch 5.8 git://develop.git.wordpress.org/ /tmp/wordpress-previous ;; *) echo "Unrecognized value for WP_BRANCH: $WP_BRANCH" >&2 diff --git a/.github/versions.sh b/.github/versions.sh index 930407347e65e..83e0958a8941f 100644 --- a/.github/versions.sh +++ b/.github/versions.sh @@ -2,7 +2,7 @@ PHP_VERSION=8.0 COMPOSER_VERSION=2.1.8 NODE_VERSION=16.11.1 -PNPM_VERSION=6.16.0 +PNPM_VERSION=6.23.6 # Other useful version numbers. MIN_PHP_VERSION=5.6 diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 677660397b967..d3a8d956ad7d4 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -109,10 +109,18 @@ jobs: misc_js: # If package or eslint config changed, there may be new checks - 'package.json' + - 'tools/js-tools/package.json' - 'pnpm-lock.yaml' - '.eslintignore' - '.eslintrc' - '**/.eslintrc' + # Also changes to the E2E workspace package.json and pnpm lock have caused linting problems. + - 'projects/plugins/boost/tests/e2e/package.json' + - 'projects/plugins/boost/tests/e2e/pnpm-lock.yaml' + - 'projects/plugins/jetpack/tests/e2e/package.json' + - 'projects/plugins/jetpack/tests/e2e/pnpm-lock.yaml' + - 'tools/e2e-commons/package.json' + - 'tools/e2e-commons/pnpm-lock.yaml' # If the excludelist changed, run to ensure newly non-excluded files pass. - 'tools/eslint-excludelist.json' misc_excludelist: diff --git a/.phpcs.config.xml b/.phpcs.config.xml index 61dfc51722e34..0e241dfd06461 100644 --- a/.phpcs.config.xml +++ b/.phpcs.config.xml @@ -1,6 +1,6 @@ - + diff --git a/package.json b/package.json index f751ea3756f01..0e3ba9a1fb3b7 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" }, "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b2f38da2a3c2a..da3aba8c183ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -77,7 +77,7 @@ importers: projects/js-packages/api: specifiers: - '@automattic/jetpack-config': workspace:^0.1.0 + '@automattic/jetpack-config': workspace:^0.1.1-alpha '@wordpress/url': 3.3.1 chai-fetch-mock: 3.0.0 fetch-mock: 9.11.0 @@ -116,7 +116,7 @@ importers: projects/js-packages/components: specifiers: '@automattic/format-currency': 1.0.0-alpha.0 - '@automattic/jetpack-base-styles': workspace:^0.1.2 + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha '@wordpress/browserslist-config': 4.1.0 '@wordpress/components': 19.1.1 '@wordpress/i18n': 4.2.4 @@ -152,11 +152,11 @@ importers: projects/js-packages/connection: specifiers: - '@automattic/jetpack-analytics': workspace:^0.1.3 - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-base-styles': workspace:^0.1.2 - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-config': workspace:^0.1.0 + '@automattic/jetpack-analytics': workspace:^0.1.4-alpha + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-config': workspace:^0.1.1-alpha '@wordpress/base-styles': 4.0.4 '@wordpress/browserslist-config': 4.1.0 '@wordpress/components': 19.1.1 @@ -261,9 +261,9 @@ importers: projects/js-packages/idc: specifiers: - '@automattic/jetpack-analytics': workspace:^0.1.3 - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-components': workspace:^0.9.0 + '@automattic/jetpack-analytics': workspace:^0.1.4-alpha + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha '@wordpress/base-styles': 4.0.4 '@wordpress/components': 19.1.1 '@wordpress/compose': 5.0.6 @@ -296,9 +296,9 @@ importers: projects/js-packages/licensing: specifiers: - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-base-styles': workspace:^0.1.2 - '@automattic/jetpack-components': workspace:^0.9.0 + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha '@wordpress/components': 19.1.1 '@wordpress/element': 4.0.4 '@wordpress/i18n': 4.2.4 @@ -323,8 +323,8 @@ importers: projects/js-packages/partner-coupon: specifiers: - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-connection': workspace:^0.11.3 + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-connection': workspace:^0.11.4-alpha '@wordpress/i18n': 4.2.4 classnames: 2.3.1 jetpack-js-test-runner: workspace:* @@ -353,10 +353,10 @@ importers: projects/js-packages/storybook: specifiers: - '@automattic/jetpack-base-styles': workspace:^0.1.2 - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-connection': workspace:^0.11.3 - '@automattic/jetpack-idc': workspace:^0.7.0 + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-connection': workspace:^0.11.4-alpha + '@automattic/jetpack-idc': workspace:^0.7.1-alpha '@babel/core': 7.16.0 '@babel/plugin-syntax-jsx': 7.16.0 '@babel/runtime-corejs3': 7.16.3 @@ -434,8 +434,9 @@ importers: projects/js-packages/webpack-config: specifiers: '@automattic/babel-plugin-preserve-i18n': 1.0.0 - '@automattic/babel-plugin-replace-textdomain': workspace:^0.1.0 - '@automattic/i18n-check-webpack-plugin': workspace:^0.1.0 + '@automattic/babel-plugin-replace-textdomain': workspace:^0.1.1-alpha + '@automattic/i18n-check-webpack-plugin': workspace:^0.1.1-alpha + '@automattic/i18n-loader-webpack-plugin': workspace:^0.1.0-alpha '@automattic/webpack-rtl-plugin': 5.1.0 '@babel/compat-data': 7.16.4 '@babel/core': 7.16.0 @@ -462,6 +463,7 @@ importers: '@automattic/babel-plugin-preserve-i18n': 1.0.0 '@automattic/babel-plugin-replace-textdomain': link:../babel-plugin-replace-textdomain '@automattic/i18n-check-webpack-plugin': link:../i18n-check-webpack-plugin + '@automattic/i18n-loader-webpack-plugin': link:../i18n-loader-webpack-plugin '@automattic/webpack-rtl-plugin': 5.1.0_webpack@5.64.1 '@babel/compat-data': 7.16.4 '@babel/helper-compilation-targets': 7.16.3_@babel+core@7.16.0 @@ -491,10 +493,10 @@ importers: projects/packages/connection-ui: specifiers: - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-connection': workspace:^0.11.3 - '@automattic/jetpack-idc': workspace:^0.7.0 - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-connection': workspace:^0.11.4-alpha + '@automattic/jetpack-idc': workspace:^0.7.1-alpha + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@babel/core': 7.16.0 '@babel/preset-env': 7.16.4 '@babel/register': 7.16.0 @@ -534,7 +536,7 @@ importers: projects/packages/identity-crisis: specifiers: - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@babel/core': 7.16.0 '@babel/preset-env': 7.16.4 '@babel/register': 7.16.0 @@ -573,7 +575,7 @@ importers: projects/packages/jitm: specifiers: - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@wordpress/browserslist-config': 4.1.0 sass: 1.43.3 sass-loader: 12.2.0 @@ -589,7 +591,7 @@ importers: projects/packages/lazy-images: specifiers: - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha copy-webpack-plugin: 9.0.1 intersection-observer: 0.12.0 webpack: 5.64.1 @@ -601,10 +603,10 @@ importers: projects/packages/my-jetpack: specifiers: - '@automattic/jetpack-base-styles': workspace:^0.1.2 - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-connection': workspace:^0.11.3 - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-connection': workspace:^0.11.4-alpha + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@babel/core': 7.16.0 '@babel/preset-env': 7.16.4 '@babel/register': 7.16.0 @@ -642,10 +644,10 @@ importers: specifiers: '@automattic/calypso-color-schemes': 2.1.1 '@automattic/color-studio': 2.5.0 - '@automattic/jetpack-analytics': workspace:^0.1.3 - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-analytics': workspace:^0.1.4-alpha + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@babel/core': 7.16.0 '@babel/plugin-proposal-nullish-coalescing-operator': 7.16.0 '@babel/preset-env': 7.16.4 @@ -741,11 +743,11 @@ importers: projects/plugins/backup: specifiers: - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-base-styles': workspace:^0.1.2 - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-connection': workspace:^0.11.3 - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-connection': workspace:^0.11.4-alpha + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@babel/core': 7.16.0 '@babel/preset-env': 7.16.4 '@babel/register': 7.16.0 @@ -865,16 +867,16 @@ importers: '@automattic/color-studio': 2.5.0 '@automattic/components': 1.0.0-alpha.3 '@automattic/format-currency': 1.0.0-alpha.0 - '@automattic/jetpack-analytics': workspace:^0.1.3 - '@automattic/jetpack-api': workspace:^0.8.0 - '@automattic/jetpack-base-styles': workspace:^0.1.2 - '@automattic/jetpack-components': workspace:^0.9.0 - '@automattic/jetpack-connection': workspace:^0.11.3 - '@automattic/jetpack-licensing': workspace:^0.3.2 - '@automattic/jetpack-partner-coupon': workspace:^0.1.2 - '@automattic/jetpack-webpack-config': workspace:^0.5.0 + '@automattic/jetpack-analytics': workspace:^0.1.4-alpha + '@automattic/jetpack-api': workspace:^0.8.1-alpha + '@automattic/jetpack-base-styles': workspace:^0.1.3-alpha + '@automattic/jetpack-components': workspace:^0.9.1-alpha + '@automattic/jetpack-connection': workspace:^0.11.4-alpha + '@automattic/jetpack-licensing': workspace:^0.3.3-alpha + '@automattic/jetpack-partner-coupon': workspace:^0.1.3-alpha + '@automattic/jetpack-webpack-config': workspace:^0.6.0-alpha '@automattic/popup-monitor': 1.0.0 - '@automattic/remove-asset-webpack-plugin': workspace:^0.1.1 + '@automattic/remove-asset-webpack-plugin': workspace:^0.1.2-alpha '@automattic/request-external-access': 1.0.0 '@automattic/social-previews': 1.1.1 '@automattic/viewport': 1.0.0 diff --git a/projects/github-actions/repo-gardening/changelog/update-min-pnpm-version b/projects/github-actions/repo-gardening/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/github-actions/repo-gardening/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/github-actions/repo-gardening/package.json b/projects/github-actions/repo-gardening/package.json index b9568922c2cf3..f3ec63bb794d3 100644 --- a/projects/github-actions/repo-gardening/package.json +++ b/projects/github-actions/repo-gardening/package.json @@ -1,6 +1,6 @@ { "name": "repo-gardening", - "version": "2.0.0", + "version": "2.0.1-alpha", "description": "Manage PR and issues in your Open Source project (automate labelling, milestones, feedback to PR authors, ...)", "author": "Automattic", "license": "GPL-2.0-or-later", @@ -28,7 +28,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" } } diff --git a/projects/github-actions/required-review/changelog/update-min-pnpm-version b/projects/github-actions/required-review/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/github-actions/required-review/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/github-actions/required-review/package.json b/projects/github-actions/required-review/package.json index 10e3726d23ee8..ce9eef925b671 100644 --- a/projects/github-actions/required-review/package.json +++ b/projects/github-actions/required-review/package.json @@ -1,6 +1,6 @@ { "name": "required-review", - "version": "2.2.1", + "version": "2.2.2-alpha", "description": "Check that a PR has reviews from required teams.", "main": "index.js", "author": "Automattic", @@ -20,7 +20,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" } } diff --git a/projects/js-packages/analytics/changelog/update-min-pnpm-version b/projects/js-packages/analytics/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/js-packages/analytics/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/js-packages/analytics/package.json b/projects/js-packages/analytics/package.json index acf15a6c47746..acb376279e08c 100644 --- a/projects/js-packages/analytics/package.json +++ b/projects/js-packages/analytics/package.json @@ -1,6 +1,6 @@ { "name": "@automattic/jetpack-analytics", - "version": "0.1.3", + "version": "0.1.4-alpha", "description": "Jetpack Analytics Package", "author": "Automattic", "license": "GPL-2.0-or-later", @@ -21,7 +21,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" } } diff --git a/projects/js-packages/api/changelog/update-min-pnpm-version b/projects/js-packages/api/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/js-packages/api/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/js-packages/api/package.json b/projects/js-packages/api/package.json index 1e1d60fa0133a..5c3a1136f04b7 100644 --- a/projects/js-packages/api/package.json +++ b/projects/js-packages/api/package.json @@ -1,12 +1,12 @@ { "name": "@automattic/jetpack-api", - "version": "0.8.0", + "version": "0.8.1-alpha", "description": "Jetpack Api Package", "author": "Automattic", "license": "GPL-2.0-or-later", "dependencies": { "@wordpress/url": "3.3.1", - "@automattic/jetpack-config": "workspace:^0.1.0", + "@automattic/jetpack-config": "workspace:^0.1.1-alpha", "lodash": "4.17.21" }, "devDependencies": { @@ -24,7 +24,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" } } diff --git a/projects/js-packages/babel-plugin-replace-textdomain/changelog/update-min-pnpm-version b/projects/js-packages/babel-plugin-replace-textdomain/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/js-packages/babel-plugin-replace-textdomain/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/js-packages/babel-plugin-replace-textdomain/package.json b/projects/js-packages/babel-plugin-replace-textdomain/package.json index 1b03c57cbe1ef..5f535a8673724 100644 --- a/projects/js-packages/babel-plugin-replace-textdomain/package.json +++ b/projects/js-packages/babel-plugin-replace-textdomain/package.json @@ -1,6 +1,6 @@ { "name": "@automattic/babel-plugin-replace-textdomain", - "version": "0.1.0", + "version": "0.1.1-alpha", "description": "A Babel plugin to replace the textdomain in gettext-style function calls.", "homepage": "https://jetpack.com", "bugs": { @@ -26,7 +26,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" }, "exports": { diff --git a/projects/js-packages/base-styles/changelog/update-min-pnpm-version b/projects/js-packages/base-styles/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/js-packages/base-styles/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/js-packages/base-styles/package.json b/projects/js-packages/base-styles/package.json index 3b6fccfb6abee..2a0d893fda787 100644 --- a/projects/js-packages/base-styles/package.json +++ b/projects/js-packages/base-styles/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-base-styles", - "version": "0.1.2", + "version": "0.1.3-alpha", "description": "Jetpack components base styles", "homepage": "https://jetpack.com", "bugs": { @@ -27,7 +27,7 @@ }, "engines": { "node": "^14.17.6 || ^16.7.0", - "pnpm": "^6.5.0", + "pnpm": "^6.23.6", "yarn": "use pnpm instead - see docs/yarn-upgrade.md" } } diff --git a/projects/js-packages/components/changelog/fix-style-inconsistencies-in-action-button b/projects/js-packages/components/changelog/fix-style-inconsistencies-in-action-button new file mode 100644 index 0000000000000..60b7d21c8e232 --- /dev/null +++ b/projects/js-packages/components/changelog/fix-style-inconsistencies-in-action-button @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix styling conflict that occurs for ActionButton when Gutenberg plugin is used diff --git a/projects/js-packages/components/changelog/update-min-pnpm-version b/projects/js-packages/components/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..d824134990470 --- /dev/null +++ b/projects/js-packages/components/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Update minimum pnpm version. + + diff --git a/projects/js-packages/components/components/action-button/style.scss b/projects/js-packages/components/components/action-button/style.scss index d4bea5ec0717a..bed9ff7dd44fb 100644 --- a/projects/js-packages/components/components/action-button/style.scss +++ b/projects/js-packages/components/components/action-button/style.scss @@ -1,6 +1,11 @@ .jp-action-button { &--button { + // Allow color to be overridden by the .is-primary class from the + + + + ); + } +} + +export default connect( state => ( { + hasActiveSecurityPurchase: getHasActiveSecurityPurchase( state ), + isFetchingSitePurchases: getIsFetchingSitePurchases( state ), + productDescriptionUrl: getProductDescriptionUrl( state, 'security' ), +} ) )( DashSecurityBundle ); diff --git a/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/remove-bug.svg b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/remove-bug.svg new file mode 100644 index 0000000000000..fcd718bbd1962 --- /dev/null +++ b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/remove-bug.svg @@ -0,0 +1,3 @@ + + + diff --git a/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/shield-with-check.svg b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/shield-with-check.svg new file mode 100644 index 0000000000000..464c8d13b590a --- /dev/null +++ b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/shield-with-check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/shield.svg b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/shield.svg new file mode 100644 index 0000000000000..49c7b62c40eb3 --- /dev/null +++ b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/shield.svg @@ -0,0 +1,3 @@ + + + diff --git a/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/style.scss b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/style.scss new file mode 100644 index 0000000000000..d4c743947ef18 --- /dev/null +++ b/projects/plugins/jetpack/_inc/client/at-a-glance/security-bundle/style.scss @@ -0,0 +1,88 @@ +@import '../../scss/calypso-mixins'; + +.dash-security-bundle { + display: flex; + flex-direction: column; + padding: 32px; + + // match aag responsive styling + @include breakpoint( '>660px' ) { + flex-direction: row; + } + + .dash-security-bundle--icon { + display: flex; + align-items: flex-start; + margin-bottom: 16px; + margin-right: 0; + margin-top: 16px; + + @include breakpoint( '>660px' ) { + align-items: center; + margin-bottom: 0; + margin-right: 32px; + margin-top: 0; + } + } + + .dash-security-bundle--content { + display: flex; + flex-direction: column; + flex: 1; + justify-content: space-between; + + @include breakpoint( '>660px' ) { + flex-direction: row; + } + + .dash-security-bundle--content-info { + display: flex; + flex-direction: column; + + h3 { + font-size: 22px; + font-weight: 700; + margin-bottom: 0; + } + + p { + font-size: 14px; + } + + .dash-security-bundle--content-info-features { + display: flex; + flex-direction: row; + + .dash-security-bundle--content-info-features-single-feature { + display: flex; + flex-direction: row; + + img { + width: 24px; + } + + p { + font-weight: 700; + } + + &:not(:last-child) { + margin-right: 16px; + } + } + } + } + + .dash-security-bundle--content-cta { + display: flex; + flex-direction: row; + align-items: center; + margin-top: 16px; + margin-left: 0; + + @include breakpoint( '>660px' ) { + margin-top: 0; + margin-left: 16px; + } + } + } +} diff --git a/projects/plugins/jetpack/_inc/client/components/banner/style.scss b/projects/plugins/jetpack/_inc/client/components/banner/style.scss index 398b24aa5b7b8..edc38895129a7 100644 --- a/projects/plugins/jetpack/_inc/client/components/banner/style.scss +++ b/projects/plugins/jetpack/_inc/client/components/banner/style.scss @@ -104,10 +104,6 @@ color: white; display: none; padding: 3px 4px 4px 3px; - - .gridicon { - margin-bottom: -7px; - } } @include breakpoint( '>480px' ) { diff --git a/projects/plugins/jetpack/_inc/client/lib/plans/constants.js b/projects/plugins/jetpack/_inc/client/lib/plans/constants.js index 33390636f4b02..d3e1d0da8525a 100644 --- a/projects/plugins/jetpack/_inc/client/lib/plans/constants.js +++ b/projects/plugins/jetpack/_inc/client/lib/plans/constants.js @@ -97,6 +97,21 @@ export const JETPACK_BUNDLES = [ PLAN_JETPACK_SECURITY_REALTIME_MONTHLY, ]; +// while this is currently a identical set to JETPACK_BUNDLES above it may eventually not be +export const JETPACK_SECURITY_BUNDLES = [ + PLAN_JETPACK_SECURITY_T1_YEARLY, + PLAN_JETPACK_SECURITY_T1_MONTHLY, + PLAN_JETPACK_SECURITY_T2_YEARLY, + PLAN_JETPACK_SECURITY_T2_MONTHLY, + + // DEPRECATED: Daily and Real-time variations will soon be retired. + // Remove after all customers are migrated to new products. + PLAN_JETPACK_SECURITY_DAILY, + PLAN_JETPACK_SECURITY_DAILY_MONTHLY, + PLAN_JETPACK_SECURITY_REALTIME, + PLAN_JETPACK_SECURITY_REALTIME_MONTHLY, +]; + export const JETPACK_BACKUP_PRODUCTS = [ PLAN_JETPACK_BACKUP_T1_YEARLY, PLAN_JETPACK_BACKUP_T1_MONTHLY, @@ -257,6 +272,15 @@ export function isJetpackProduct( product ) { export function isJetpackBundle( product ) { return JETPACK_BUNDLES.includes( product ); } +/** + * Determine if the given product is a Security Bundle. + * + * @param {number} product - productId to check + * @returns {boolean} if the given product is a Security Bundle + */ +export function isJetpackSecurityBundle( product ) { + return JETPACK_SECURITY_BUNDLES.includes( product ); +} export function isJetpackLegacyPlan( product ) { return JETPACK_LEGACY_PLANS.includes( product ); diff --git a/projects/plugins/jetpack/_inc/client/state/site/reducer.js b/projects/plugins/jetpack/_inc/client/state/site/reducer.js index 46ddfc14bc6e5..5c9c65d235de4 100644 --- a/projects/plugins/jetpack/_inc/client/state/site/reducer.js +++ b/projects/plugins/jetpack/_inc/client/state/site/reducer.js @@ -14,6 +14,7 @@ import { isJetpackBackup, isJetpackScan, isJetpackSearch, + isJetpackSecurityBundle, isJetpackVideoPress, } from 'lib/plans/constants'; import { @@ -333,6 +334,31 @@ export function hasActiveScanPurchase( state ) { return !! getActiveScanPurchase( state ); } +/** + * Return any active security bundles on the site + * + * @param {*} state - Global state tree + * @returns {object} A active security bundle on the site, undefined otherwise + */ +export function getActiveSecurityPurchase( state ) { + return find( getActiveSitePurchases( state ), purchase => + isJetpackSecurityBundle( purchase.product_slug ) + ); +} + +/** + * Determines if the site has an active security or complete plan + * + * @param {*} state - Global state tree + * @returns {boolean} True if the site has an active security or complete plan, false otherwise. + */ +export function hasActiveSecurityPurchase( state ) { + return ( + !! getActiveSecurityPurchase( state ) || + 'is-complete-plan' === getPlanClass( getSitePlan( state ).product_slug ) + ); +} + export function getActiveSearchPurchase( state ) { return find( getActiveProductPurchases( state ), product => isJetpackSearch( product.product_slug ) diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php index 2a5bfce8a3af8..2c386ad814e9a 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php @@ -25,6 +25,14 @@ class WPCOM_REST_API_V2_Endpoint_Admin_Menu extends WP_REST_Controller { */ public $rest_base = 'admin-menu'; + /** + * + * Set of core dashicons. + * + * @var array + */ + private $dashicon_list; + /** * WPCOM_REST_API_V2_Endpoint_Admin_Menu constructor. */ @@ -322,13 +330,37 @@ private function prepare_menu_item_icon( $icon ) { if ( 0 === strpos( $icon, 'data:image/svg+xml' ) ) { $img = $icon; } elseif ( 0 === strpos( $icon, 'dashicons-' ) ) { - $img = sanitize_html_class( $icon ); + $img = $this->prepare_dashicon( $icon ); } } return $img; } + /** + * Prepares the dashicon for consumption by Calypso. If the dashicon isn't found in a list of known icons + * we will return the default dashicon. + * + * @param string $icon The dashicon string to check. + * + * @return string If the dashicon exists in core we return the dashicon, otherwise we return the default dashicon. + */ + private function prepare_dashicon( $icon ) { + if ( empty( $this->dashicon_set ) ) { + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + $this->dashicon_list = include WP_CONTENT_DIR . '/mu-plugins/masterbar/admin-menu/dashicon-set.php'; + } else { + $this->dashicon_list = include JETPACK__PLUGIN_DIR . '/modules/masterbar/admin-menu/dashicon-set.php'; + } + } + + if ( isset( $this->dashicon_list[ $icon ] ) && $this->dashicon_list[ $icon ] ) { + return $icon; + } + + return 'dashicons-admin-generic'; + } + /** * Prepares a menu item url for consumption by Calypso. * diff --git a/projects/plugins/jetpack/changelog/2021-12-10-22-17-18-511573 b/projects/plugins/jetpack/changelog/2021-12-10-22-17-18-511573 new file mode 100644 index 0000000000000..a11860ef02dbf --- /dev/null +++ b/projects/plugins/jetpack/changelog/2021-12-10-22-17-18-511573 @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Banner: fix icon CSS margin offset. + + diff --git a/projects/plugins/jetpack/changelog/add-assets-textdomain-aliasing b/projects/plugins/jetpack/changelog/add-assets-textdomain-aliasing new file mode 100644 index 0000000000000..a1c1831fa1ef7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-assets-textdomain-aliasing @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Updated composer.lock. + + diff --git a/projects/plugins/jetpack/changelog/add-composer-plugin-i18n-map b/projects/plugins/jetpack/changelog/add-composer-plugin-i18n-map new file mode 100644 index 0000000000000..1eaea6a769e84 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-composer-plugin-i18n-map @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Updated package dependencies. diff --git a/projects/plugins/jetpack/changelog/add-security-bundle-dash-item b/projects/plugins/jetpack/changelog/add-security-bundle-dash-item new file mode 100644 index 0000000000000..5106bfe17af63 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-security-bundle-dash-item @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Add Jetpack Security Bundle upsell to AAG diff --git a/projects/plugins/jetpack/changelog/add-use-i18n-loader-webpack-plugin b/projects/plugins/jetpack/changelog/add-use-i18n-loader-webpack-plugin new file mode 100644 index 0000000000000..754c9ef3e1cfa --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-use-i18n-loader-webpack-plugin @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Use `@automattic/i18n-loader-webpack-plugin` to remove the hack for Instant Search's lazy-loaded bundle. diff --git a/projects/plugins/jetpack/changelog/e2e-bump-dependencies b/projects/plugins/jetpack/changelog/e2e-bump-dependencies new file mode 100644 index 0000000000000..05ce2b72cfe7b --- /dev/null +++ b/projects/plugins/jetpack/changelog/e2e-bump-dependencies @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +E2E tests renovate: bump dependencies diff --git a/projects/plugins/jetpack/changelog/e2e-update-docs b/projects/plugins/jetpack/changelog/e2e-update-docs new file mode 100644 index 0000000000000..93cbd73aa5396 --- /dev/null +++ b/projects/plugins/jetpack/changelog/e2e-update-docs @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +E2E tests: update readme docs diff --git a/projects/plugins/jetpack/changelog/fix-add-settings-menu-for-scan-products b/projects/plugins/jetpack/changelog/fix-add-settings-menu-for-scan-products new file mode 100644 index 0000000000000..94951d4916ea3 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-add-settings-menu-for-scan-products @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Settings menu: add Jetpack item for sites with Scan product diff --git a/projects/plugins/jetpack/changelog/fix-admin-menu-icons-plugin-edge-cases b/projects/plugins/jetpack/changelog/fix-admin-menu-icons-plugin-edge-cases new file mode 100644 index 0000000000000..0915e7bbd2ce6 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-admin-menu-icons-plugin-edge-cases @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +We now identify admin menu dashicons that won't be rendered in Calypso, and provide a default icon for them. diff --git a/projects/plugins/jetpack/changelog/fix-assert-node-14 b/projects/plugins/jetpack/changelog/fix-assert-node-14 new file mode 100644 index 0000000000000..1eaea6a769e84 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-assert-node-14 @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Updated package dependencies. diff --git a/projects/plugins/jetpack/changelog/fix-eslint-tests b/projects/plugins/jetpack/changelog/fix-eslint-tests new file mode 100644 index 0000000000000..3219e382bd6cc --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-eslint-tests @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Sync some E2E deps with the rest of the monorepo to avoid breaking eslint tests. diff --git a/projects/plugins/jetpack/changelog/fix-jetpack-legacy-full-sync-test-php-8 b/projects/plugins/jetpack/changelog/fix-jetpack-legacy-full-sync-test-php-8 new file mode 100644 index 0000000000000..637578e8e5608 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-jetpack-legacy-full-sync-test-php-8 @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Fix a legacy sync test in PHPUnit 9.5. diff --git a/projects/plugins/jetpack/changelog/fix-style-inconsistencies-in-action-button b/projects/plugins/jetpack/changelog/fix-style-inconsistencies-in-action-button new file mode 100644 index 0000000000000..1eaea6a769e84 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-style-inconsistencies-in-action-button @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Updated package dependencies. diff --git a/projects/plugins/jetpack/changelog/phpcs-seo-tools b/projects/plugins/jetpack/changelog/phpcs-seo-tools new file mode 100644 index 0000000000000..101cc6f0633eb --- /dev/null +++ b/projects/plugins/jetpack/changelog/phpcs-seo-tools @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: PHPCS: SEO Tools + + diff --git a/projects/plugins/jetpack/changelog/update-min-pnpm-version b/projects/plugins/jetpack/changelog/update-min-pnpm-version new file mode 100644 index 0000000000000..a4fb34aa0e7a8 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-min-pnpm-version @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Update minimum pnpm version. + + diff --git a/projects/plugins/jetpack/changelog/update-phpcs-widgets-2 b/projects/plugins/jetpack/changelog/update-phpcs-widgets-2 new file mode 100644 index 0000000000000..08e57e7105b55 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-phpcs-widgets-2 @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Janitorial: fix phpcs warnings in multiple widget files. diff --git a/projects/plugins/jetpack/changelog/update-wp-requirements-wp58 b/projects/plugins/jetpack/changelog/update-wp-requirements-wp58 new file mode 100644 index 0000000000000..7f6df83f66241 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-wp-requirements-wp58 @@ -0,0 +1,4 @@ +Significance: patch +Type: compat + +General: update WordPress version requirements to WordPress 5.8. diff --git a/projects/plugins/jetpack/composer.json b/projects/plugins/jetpack/composer.json index ef843ff7e5f0b..4765d3009ca41 100644 --- a/projects/plugins/jetpack/composer.json +++ b/projects/plugins/jetpack/composer.json @@ -13,12 +13,12 @@ "ext-openssl": "*", "automattic/jetpack-a8c-mc-stats": "1.4.x-dev", "automattic/jetpack-abtest": "1.9.x-dev", - "automattic/jetpack-assets": "1.14.x-dev", + "automattic/jetpack-assets": "1.15.x-dev", "automattic/jetpack-autoloader": "2.10.x-dev", "automattic/jetpack-backup": "1.1.x-dev", "automattic/jetpack-blocks": "1.4.x-dev", "automattic/jetpack-compat": "1.6.x-dev", - "automattic/jetpack-composer-plugin": "0.1.x-dev", + "automattic/jetpack-composer-plugin": "0.2.x-dev", "automattic/jetpack-config": "1.5.x-dev", "automattic/jetpack-connection": "1.33.x-dev", "automattic/jetpack-connection-ui": "2.2.x-dev", diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index a4dbd1a2bac81..aff16cc3826dd 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -177,7 +177,7 @@ "dist": { "type": "path", "url": "../../packages/assets", - "reference": "79f3118db7691394547c3b21105a6e34efb919f0" + "reference": "eada358ef29aa64b35432c2baacb8975a4efdb31" }, "require": { "automattic/jetpack-constants": "^1.6" @@ -185,6 +185,7 @@ "require-dev": { "automattic/jetpack-changelogger": "^3.0", "brain/monkey": "2.6.1", + "wikimedia/testing-access-wrapper": "^1.0 | ^2.0", "yoast/phpunit-polyfills": "1.0.2" }, "type": "jetpack-library", @@ -195,7 +196,7 @@ "link-template": "https://github.com/Automattic/jetpack-assets/compare/v${old}...v${new}" }, "branch-alias": { - "dev-master": "1.14.x-dev" + "dev-master": "1.15.x-dev" } }, "autoload": { @@ -450,7 +451,7 @@ "dist": { "type": "path", "url": "../../packages/composer-plugin", - "reference": "31302c1993ebdbdc6a3b3f23ab296a108a71aaa4" + "reference": "890b8c21a300d3b0ed5022bd3aa9a466d735f273" }, "require": { "composer-plugin-api": "^2.1.0" @@ -469,7 +470,7 @@ }, "autotagger": true, "branch-alias": { - "dev-master": "0.1.x-dev" + "dev-master": "0.2.x-dev" } }, "autoload": { @@ -611,10 +612,10 @@ "dist": { "type": "path", "url": "../../packages/connection-ui", - "reference": "7e66dcb91fc171d2c6dd32ea7577383f46c9713a" + "reference": "324391767bedf3f55344993e8fca80248882dac6" }, "require": { - "automattic/jetpack-assets": "^1.14", + "automattic/jetpack-assets": "^1.15", "automattic/jetpack-connection": "^1.33", "automattic/jetpack-constants": "^1.6", "automattic/jetpack-device-detection": "^1.4", @@ -932,11 +933,11 @@ "dist": { "type": "path", "url": "../../packages/jitm", - "reference": "fefedd87770502b5f74998fd91a8abeb1c11d627" + "reference": "c654b26c8a645bb8c3ab427d36f51fc24de46872" }, "require": { "automattic/jetpack-a8c-mc-stats": "^1.4", - "automattic/jetpack-assets": "^1.14", + "automattic/jetpack-assets": "^1.15", "automattic/jetpack-connection": "^1.33", "automattic/jetpack-device-detection": "^1.4", "automattic/jetpack-logo": "^1.5", @@ -1006,10 +1007,10 @@ "dist": { "type": "path", "url": "../../packages/lazy-images", - "reference": "8ad70d0affc48b1fac679e0784bcf1c8d672b966" + "reference": "b3f5c18b00298f84d6f73c1f9c663ac0dbadb4a7" }, "require": { - "automattic/jetpack-assets": "^1.14", + "automattic/jetpack-assets": "^1.15", "automattic/jetpack-constants": "^1.6" }, "require-dev": { @@ -1180,11 +1181,11 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "ee2aa1d10634d764536a53ca1aa2fb5b39fefafe" + "reference": "9ec2ffc40a13fb67c5783d4e8888d10a692546ca" }, "require": { "automattic/jetpack-admin-ui": "^0.2", - "automattic/jetpack-assets": "^1.14", + "automattic/jetpack-assets": "^1.15", "automattic/jetpack-connection": "^1.33" }, "require-dev": { @@ -1752,10 +1753,10 @@ "dist": { "type": "path", "url": "../../packages/tracking", - "reference": "6ca70d07e77418303bb798c4cd430906af03509e" + "reference": "f727a1f82029f200bf7d4b4b63b080963edda25e" }, "require": { - "automattic/jetpack-assets": "^1.14", + "automattic/jetpack-assets": "^1.15", "automattic/jetpack-options": "^1.14", "automattic/jetpack-status": "^1.9", "automattic/jetpack-terms-of-service": "^1.9" diff --git a/projects/plugins/jetpack/extensions/blocks/videopress/seekbar-color-settings.js b/projects/plugins/jetpack/extensions/blocks/videopress/seekbar-color-settings.js index ebbc29feef572..e0b38af32f49b 100644 --- a/projects/plugins/jetpack/extensions/blocks/videopress/seekbar-color-settings.js +++ b/projects/plugins/jetpack/extensions/blocks/videopress/seekbar-color-settings.js @@ -66,19 +66,19 @@ class SeekbarColorSettings extends Component { value: seekbarColor, onChange: this.handleChangeSeekbarColor, label: __( 'Main', 'jetpack' ), - showTitle + showTitle, }, { value: seekbarLoadingColor, onChange: this.handleChangeSeekbarLoadingColor, label: __( 'Loaded', 'jetpack' ), - showTitle + showTitle, }, { value: seekbarPlayedColor, onChange: this.handleChangeSeekbarPlayedColor, label: __( 'Progress', 'jetpack' ), - showTitle + showTitle, }, ] } > diff --git a/projects/plugins/jetpack/jetpack.php b/projects/plugins/jetpack/jetpack.php index 4a27bdbf8ce2a..58196f045ba17 100644 --- a/projects/plugins/jetpack/jetpack.php +++ b/projects/plugins/jetpack/jetpack.php @@ -8,7 +8,7 @@ * Author URI: https://jetpack.com * License: GPL2+ * Text Domain: jetpack - * Requires at least: 5.7 + * Requires at least: 5.8 * Requires PHP: 5.6 * * @package automattic/jetpack @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -define( 'JETPACK__MINIMUM_WP_VERSION', '5.7' ); +define( 'JETPACK__MINIMUM_WP_VERSION', '5.8' ); define( 'JETPACK__MINIMUM_PHP_VERSION', '5.6' ); define( 'JETPACK__VERSION', '10.5-a.4' ); diff --git a/projects/plugins/jetpack/load-jetpack.php b/projects/plugins/jetpack/load-jetpack.php index cb6407a5ae89c..fa7ba5af84fe1 100644 --- a/projects/plugins/jetpack/load-jetpack.php +++ b/projects/plugins/jetpack/load-jetpack.php @@ -57,9 +57,9 @@ function jetpack_should_use_minified_assets() { require_once JETPACK__PLUGIN_DIR . 'class.jetpack-connection-banner.php'; require_once JETPACK__PLUGIN_DIR . 'class.jetpack-plan.php'; // Used by the API endpoints. -require_once JETPACK__PLUGIN_DIR . 'modules/seo-tools/jetpack-seo-utils.php'; -require_once JETPACK__PLUGIN_DIR . 'modules/seo-tools/jetpack-seo-titles.php'; -require_once JETPACK__PLUGIN_DIR . 'modules/seo-tools/jetpack-seo-posts.php'; +require_once JETPACK__PLUGIN_DIR . 'modules/seo-tools/class-jetpack-seo-utils.php'; +require_once JETPACK__PLUGIN_DIR . 'modules/seo-tools/class-jetpack-seo-titles.php'; +require_once JETPACK__PLUGIN_DIR . 'modules/seo-tools/class-jetpack-seo-posts.php'; require_once JETPACK__PLUGIN_DIR . 'modules/verification-tools/verification-tools-utils.php'; require_once JETPACK__PLUGIN_DIR . 'class-jetpack-xmlrpc-methods.php'; diff --git a/projects/plugins/jetpack/modules/copy-post.php b/projects/plugins/jetpack/modules/copy-post.php index dc92af45a1970..3aea777d0381f 100644 --- a/projects/plugins/jetpack/modules/copy-post.php +++ b/projects/plugins/jetpack/modules/copy-post.php @@ -44,7 +44,6 @@ public function __construct() { * @return void */ public function update_post_data( $target_post_id, $post, $update ) { - global $wp_version; // This `$update` check avoids infinite loops of trying to update our updated post. if ( $update ) { return; @@ -70,15 +69,8 @@ public function update_post_data( $target_post_id, $post, $update ) { add_filter( 'default_content', array( $this, 'filter_content' ), 10, 2 ); add_filter( 'default_excerpt', array( $this, 'filter_excerpt' ), 10, 2 ); - /* - * Required to avoid the block editor from adding default blocks according to post format. - * @todo: simplify once WordPress 5.8 is the minimum required version. - */ - if ( version_compare( $wp_version, '5.8', '>=' ) ) { - add_filter( 'block_editor_settings_all', array( $this, 'remove_post_format_template' ) ); - } else { - add_filter( 'block_editor_settings', array( $this, 'remove_post_format_template' ) ); - } + // Required to avoid the block editor from adding default blocks according to post format. + add_filter( 'block_editor_settings_all', array( $this, 'remove_post_format_template' ) ); /** * Fires after all updates have been performed, and default content filters have been added. diff --git a/projects/plugins/jetpack/modules/masterbar/admin-menu/class-jetpack-admin-menu.php b/projects/plugins/jetpack/modules/masterbar/admin-menu/class-jetpack-admin-menu.php index 30494d0fce62e..c61628b5bae7f 100644 --- a/projects/plugins/jetpack/modules/masterbar/admin-menu/class-jetpack-admin-menu.php +++ b/projects/plugins/jetpack/modules/masterbar/admin-menu/class-jetpack-admin-menu.php @@ -214,7 +214,20 @@ public function add_options_menu() { add_submenu_page( $slug, esc_attr__( 'Writing', 'jetpack' ), __( 'Writing', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/writing/' . $this->domain ); add_submenu_page( $slug, esc_attr__( 'Discussion', 'jetpack' ), __( 'Discussion', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/discussion/' . $this->domain ); - $has_scan = \Jetpack_Plan::supports( 'scan' ); + $plan_supports_scan = \Jetpack_Plan::supports( 'scan' ); + $products = \Jetpack_Plan::get_products(); + $has_scan_product = false; + + if ( is_array( $products ) ) { + foreach ( $products as $product ) { + if ( strpos( $product['product_slug'], 'jetpack_scan' ) === 0 ) { + $has_scan_product = true; + break; + } + } + } + + $has_scan = $plan_supports_scan || $has_scan_product; $rewind_state = get_transient( 'jetpack_rewind_state' ); $has_backup = $rewind_state && in_array( $rewind_state->state, array( 'awaiting_credentials', 'provisioning', 'active' ), true ); if ( $has_scan || $has_backup ) { diff --git a/projects/plugins/jetpack/modules/masterbar/admin-menu/dashicon-set.php b/projects/plugins/jetpack/modules/masterbar/admin-menu/dashicon-set.php new file mode 100644 index 0000000000000..41695b060bc9b --- /dev/null +++ b/projects/plugins/jetpack/modules/masterbar/admin-menu/dashicon-set.php @@ -0,0 +1,358 @@ + true, + 'dashicons-admin-collapse' => true, + 'dashicons-admin-comments' => true, + 'dashicons-admin-customizer' => true, + 'dashicons-admin-generic' => true, + 'dashicons-admin-home' => true, + 'dashicons-admin-links' => true, + 'dashicons-admin-media' => true, + 'dashicons-admin-multisite' => true, + 'dashicons-admin-network' => true, + 'dashicons-admin-page' => true, + 'dashicons-admin-plugins' => true, + 'dashicons-admin-post' => true, + 'dashicons-admin-settings' => true, + 'dashicons-admin-site-alt' => true, + 'dashicons-admin-site-alt2' => true, + 'dashicons-admin-site-alt3' => true, + 'dashicons-admin-site' => true, + 'dashicons-admin-tools' => true, + 'dashicons-admin-users' => true, + 'dashicons-airplane' => true, + 'dashicons-album' => true, + 'dashicons-align-center' => true, + 'dashicons-align-full-width' => true, + 'dashicons-align-left' => true, + 'dashicons-align-none' => true, + 'dashicons-align-pull-left' => true, + 'dashicons-align-pull-right' => true, + 'dashicons-align-right' => true, + 'dashicons-align-wide' => true, + 'dashicons-amazon' => true, + 'dashicons-analytics' => true, + 'dashicons-archive' => true, + 'dashicons-arrow-down-alt' => true, + 'dashicons-arrow-down-alt2' => true, + 'dashicons-arrow-down' => true, + 'dashicons-arrow-left-alt' => true, + 'dashicons-arrow-left-alt2' => true, + 'dashicons-arrow-left' => true, + 'dashicons-arrow-right-alt' => true, + 'dashicons-arrow-right-alt2' => true, + 'dashicons-arrow-right' => true, + 'dashicons-arrow-up-alt' => true, + 'dashicons-arrow-up-alt2' => true, + 'dashicons-arrow-up-duplicate' => true, + 'dashicons-arrow-up' => true, + 'dashicons-art' => true, + 'dashicons-awards' => true, + 'dashicons-backup' => true, + 'dashicons-bank' => true, + 'dashicons-beer' => true, + 'dashicons-bell' => true, + 'dashicons-block-default' => true, + 'dashicons-book-alt' => true, + 'dashicons-book' => true, + 'dashicons-buddicons-activity' => true, + 'dashicons-buddicons-bbpress-logo' => true, + 'dashicons-buddicons-buddypress-logo' => true, + 'dashicons-buddicons-community' => true, + 'dashicons-buddicons-forums' => true, + 'dashicons-buddicons-friends' => true, + 'dashicons-buddicons-groups' => true, + 'dashicons-buddicons-pm' => true, + 'dashicons-buddicons-replies' => true, + 'dashicons-buddicons-topics' => true, + 'dashicons-buddicons-tracking' => true, + 'dashicons-building' => true, + 'dashicons-businessman' => true, + 'dashicons-businessperson' => true, + 'dashicons-businesswoman' => true, + 'dashicons-button' => true, + 'dashicons-calculator' => true, + 'dashicons-calendar-alt' => true, + 'dashicons-calendar' => true, + 'dashicons-camera-alt' => true, + 'dashicons-camera' => true, + 'dashicons-car' => true, + 'dashicons-carrot' => true, + 'dashicons-cart' => true, + 'dashicons-category' => true, + 'dashicons-chart-area' => true, + 'dashicons-chart-bar' => true, + 'dashicons-chart-line' => true, + 'dashicons-chart-pie' => true, + 'dashicons-clipboard' => true, + 'dashicons-clock' => true, + 'dashicons-cloud-saved' => true, + 'dashicons-cloud-upload' => true, + 'dashicons-cloud' => true, + 'dashicons-code-standards' => true, + 'dashicons-coffee' => true, + 'dashicons-color-picker' => true, + 'dashicons-columns' => true, + 'dashicons-controls-back' => true, + 'dashicons-controls-forward' => true, + 'dashicons-controls-pause' => true, + 'dashicons-controls-play' => true, + 'dashicons-controls-repeat' => true, + 'dashicons-controls-skipback' => true, + 'dashicons-controls-skipforward' => true, + 'dashicons-controls-volumeoff' => true, + 'dashicons-controls-volumeon' => true, + 'dashicons-cover-image' => true, + 'dashicons-dashboard' => true, + 'dashicons-database-add' => true, + 'dashicons-database-export' => true, + 'dashicons-database-import' => true, + 'dashicons-database-remove' => true, + 'dashicons-database-view' => true, + 'dashicons-database' => true, + 'dashicons-desktop' => true, + 'dashicons-dismiss' => true, + 'dashicons-download' => true, + 'dashicons-drumstick' => true, + 'dashicons-edit-large' => true, + 'dashicons-edit-page' => true, + 'dashicons-edit' => true, + 'dashicons-editor-aligncenter' => true, + 'dashicons-editor-alignleft' => true, + 'dashicons-editor-alignright' => true, + 'dashicons-editor-bold' => true, + 'dashicons-editor-break' => true, + 'dashicons-editor-code-duplicate' => true, + 'dashicons-editor-code' => true, + 'dashicons-editor-contract' => true, + 'dashicons-editor-customchar' => true, + 'dashicons-editor-expand' => true, + 'dashicons-editor-help' => true, + 'dashicons-editor-indent' => true, + 'dashicons-editor-insertmore' => true, + 'dashicons-editor-italic' => true, + 'dashicons-editor-justify' => true, + 'dashicons-editor-kitchensink' => true, + 'dashicons-editor-ltr' => true, + 'dashicons-editor-ol-rtl' => true, + 'dashicons-editor-ol' => true, + 'dashicons-editor-outdent' => true, + 'dashicons-editor-paragraph' => true, + 'dashicons-editor-paste-text' => true, + 'dashicons-editor-paste-word' => true, + 'dashicons-editor-quote' => true, + 'dashicons-editor-removeformatting' => true, + 'dashicons-editor-rtl' => true, + 'dashicons-editor-spellcheck' => true, + 'dashicons-editor-strikethrough' => true, + 'dashicons-editor-table' => true, + 'dashicons-editor-textcolor' => true, + 'dashicons-editor-ul' => true, + 'dashicons-editor-underline' => true, + 'dashicons-editor-unlink' => true, + 'dashicons-editor-video' => true, + 'dashicons-ellipsis' => true, + 'dashicons-email-alt' => true, + 'dashicons-email-alt2' => true, + 'dashicons-email' => true, + 'dashicons-embed-audio' => true, + 'dashicons-embed-generic' => true, + 'dashicons-embed-photo' => true, + 'dashicons-embed-post' => true, + 'dashicons-embed-video' => true, + 'dashicons-excerpt-view' => true, + 'dashicons-exit' => true, + 'dashicons-external' => true, + 'dashicons-facebook-alt' => true, + 'dashicons-facebook' => true, + 'dashicons-feedback' => true, + 'dashicons-filter' => true, + 'dashicons-flag' => true, + 'dashicons-food' => true, + 'dashicons-format-aside' => true, + 'dashicons-format-audio' => true, + 'dashicons-format-chat' => true, + 'dashicons-format-gallery' => true, + 'dashicons-format-image' => true, + 'dashicons-format-quote' => true, + 'dashicons-format-status' => true, + 'dashicons-format-video' => true, + 'dashicons-forms' => true, + 'dashicons-fullscreen-alt' => true, + 'dashicons-fullscreen-exit-alt' => true, + 'dashicons-games' => true, + 'dashicons-google' => true, + 'dashicons-googleplus' => true, + 'dashicons-grid-view' => true, + 'dashicons-groups' => true, + 'dashicons-hammer' => true, + 'dashicons-heading' => true, + 'dashicons-heart' => true, + 'dashicons-hidden' => true, + 'dashicons-hourglass' => true, + 'dashicons-html' => true, + 'dashicons-id-alt' => true, + 'dashicons-id' => true, + 'dashicons-image-crop' => true, + 'dashicons-image-filter' => true, + 'dashicons-image-flip-horizontal' => true, + 'dashicons-image-flip-vertical' => true, + 'dashicons-image-rotate-left' => true, + 'dashicons-image-rotate-right' => true, + 'dashicons-image-rotate' => true, + 'dashicons-images-alt' => true, + 'dashicons-images-alt2' => true, + 'dashicons-index-card' => true, + 'dashicons-info-outline' => true, + 'dashicons-info' => true, + 'dashicons-insert-after' => true, + 'dashicons-insert-before' => true, + 'dashicons-insert' => true, + 'dashicons-instagram' => true, + 'dashicons-laptop' => true, + 'dashicons-layout' => true, + 'dashicons-leftright' => true, + 'dashicons-lightbulb' => true, + 'dashicons-linkedin' => true, + 'dashicons-list-view' => true, + 'dashicons-location-alt' => true, + 'dashicons-location' => true, + 'dashicons-lock-duplicate' => true, + 'dashicons-lock' => true, + 'dashicons-marker' => true, + 'dashicons-media-archive' => true, + 'dashicons-media-audio' => true, + 'dashicons-media-code' => true, + 'dashicons-media-default' => true, + 'dashicons-media-document' => true, + 'dashicons-media-interactive' => true, + 'dashicons-media-spreadsheet' => true, + 'dashicons-media-text' => true, + 'dashicons-media-video' => true, + 'dashicons-megaphone' => true, + 'dashicons-menu-alt' => true, + 'dashicons-menu-alt2' => true, + 'dashicons-menu-alt3' => true, + 'dashicons-menu' => true, + 'dashicons-microphone' => true, + 'dashicons-migrate' => true, + 'dashicons-minus' => true, + 'dashicons-money-alt' => true, + 'dashicons-money' => true, + 'dashicons-move' => true, + 'dashicons-nametag' => true, + 'dashicons-networking' => true, + 'dashicons-no-alt' => true, + 'dashicons-no' => true, + 'dashicons-open-folder' => true, + 'dashicons-palmtree' => true, + 'dashicons-paperclip' => true, + 'dashicons-pdf' => true, + 'dashicons-performance' => true, + 'dashicons-pets' => true, + 'dashicons-phone' => true, + 'dashicons-pinterest' => true, + 'dashicons-playlist-audio' => true, + 'dashicons-playlist-video' => true, + 'dashicons-plugins-checked' => true, + 'dashicons-plus-alt' => true, + 'dashicons-plus-alt2' => true, + 'dashicons-plus' => true, + 'dashicons-podio' => true, + 'dashicons-portfolio' => true, + 'dashicons-post-status' => true, + 'dashicons-pressthis' => true, + 'dashicons-printer' => true, + 'dashicons-privacy' => true, + 'dashicons-products' => true, + 'dashicons-randomize' => true, + 'dashicons-reddit' => true, + 'dashicons-redo' => true, + 'dashicons-remove' => true, + 'dashicons-rest-api' => true, + 'dashicons-rss' => true, + 'dashicons-saved' => true, + 'dashicons-schedule' => true, + 'dashicons-screenoptions' => true, + 'dashicons-search' => true, + 'dashicons-share-alt' => true, + 'dashicons-share-alt2' => true, + 'dashicons-share' => true, + 'dashicons-shield-alt' => true, + 'dashicons-shield' => true, + 'dashicons-shortcode' => true, + 'dashicons-slides' => true, + 'dashicons-smartphone' => true, + 'dashicons-smiley' => true, + 'dashicons-sort' => true, + 'dashicons-sos' => true, + 'dashicons-spotify' => true, + 'dashicons-star-empty' => true, + 'dashicons-star-filled' => true, + 'dashicons-star-half' => true, + 'dashicons-sticky' => true, + 'dashicons-store' => true, + 'dashicons-superhero-alt' => true, + 'dashicons-superhero' => true, + 'dashicons-table-col-after' => true, + 'dashicons-table-col-before' => true, + 'dashicons-table-col-delete' => true, + 'dashicons-table-row-after' => true, + 'dashicons-table-row-before' => true, + 'dashicons-table-row-delete' => true, + 'dashicons-tablet' => true, + 'dashicons-tag' => true, + 'dashicons-tagcloud' => true, + 'dashicons-testimonial' => true, + 'dashicons-text-page' => true, + 'dashicons-text' => true, + 'dashicons-thumbs-down' => true, + 'dashicons-thumbs-up' => true, + 'dashicons-tickets-alt' => true, + 'dashicons-tickets' => true, + 'dashicons-tide' => true, + 'dashicons-translation' => true, + 'dashicons-trash' => true, + 'dashicons-twitch' => true, + 'dashicons-twitter-alt' => true, + 'dashicons-twitter' => true, + 'dashicons-undo' => true, + 'dashicons-universal-access-alt' => true, + 'dashicons-universal-access' => true, + 'dashicons-unlock' => true, + 'dashicons-update-alt' => true, + 'dashicons-update' => true, + 'dashicons-upload' => true, + 'dashicons-vault' => true, + 'dashicons-video-alt' => true, + 'dashicons-video-alt2' => true, + 'dashicons-video-alt3' => true, + 'dashicons-visibility' => true, + 'dashicons-warning' => true, + 'dashicons-welcome-add-page' => true, + 'dashicons-welcome-comments' => true, + 'dashicons-welcome-learn-more' => true, + 'dashicons-welcome-view-site' => true, + 'dashicons-welcome-widgets-menus' => true, + 'dashicons-welcome-write-blog' => true, + 'dashicons-whatsapp' => true, + 'dashicons-wordpress-alt' => true, + 'dashicons-wordpress' => true, + 'dashicons-xing' => true, + 'dashicons-yes-alt' => true, + 'dashicons-yes' => true, + 'dashicons-youtube' => true, + 'dashicons-editor-distractionfree' => true, + 'dashicons-exerpt-view' => true, + 'dashicons-format-links' => true, + 'dashicons-format-standard' => true, + 'dashicons-post-trash' => true, + 'dashicons-share1' => true, + 'dashicons-welcome-edit-page' => true, +); diff --git a/projects/plugins/jetpack/modules/search/class-jetpack-instant-search.php b/projects/plugins/jetpack/modules/search/class-jetpack-instant-search.php index 68bd0b113a951..afe391e9ff279 100644 --- a/projects/plugins/jetpack/modules/search/class-jetpack-instant-search.php +++ b/projects/plugins/jetpack/modules/search/class-jetpack-instant-search.php @@ -130,35 +130,6 @@ public function load_assets_with_parameters( $path_prefix, $plugin_base_path ) { Assets::enqueue_script( 'jetpack-instant-search' ); $this->load_and_initialize_tracks(); $this->inject_javascript_options(); - - // It only inlines the translations for the script, but does not actually load the script. - $this->inject_translation_for_script( - plugins_url( - $path_prefix . '_inc/build/instant-search/jp-search.chunk-main-payload.js', - $plugin_base_path - ) - ); - } - - /** - * Add inline translations for script `$payload_url` before loading `$before_handle` script. - * - * @param string $payload_url - The payload url for which we load the translations. - * @param string $before_handle - Inline the translations before this handle. - */ - protected function inject_translation_for_script( $payload_url, $before_handle = 'jetpack-instant-search' ) { - // Set a random name for the script. - $handle = 'jetpack-instant-search-' . wp_unique_id(); - // Then register it, which is required for the next steps. - // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NoExplicitVersion - wp_register_script( $handle, $payload_url, array(), false, false ); - // Set translation domain to `jetpack`, and we need to explicitly set the `path` to load translations files for WPCOM. - // Otherwise WPCOM would try to load from `WP_LANG_DIR . '/mu-plugins'` and fails. - wp_set_script_translations( $handle, 'jetpack', WP_LANG_DIR . '/plugins' ); - // Inline the translations before `$before_handle` handle. - wp_add_inline_script( $before_handle, wp_scripts()->print_translations( $handle, false ), 'before' ); - // Deregister the script as we don't really enqueue it from PHP side. - wp_deregister_script( $handle ); } /** diff --git a/projects/plugins/jetpack/modules/search/class-jetpack-search-customberg.php b/projects/plugins/jetpack/modules/search/class-jetpack-search-customberg.php index bb54403e11ba8..bdc54eaa6f359 100644 --- a/projects/plugins/jetpack/modules/search/class-jetpack-search-customberg.php +++ b/projects/plugins/jetpack/modules/search/class-jetpack-search-customberg.php @@ -65,13 +65,8 @@ public function add_wp_admin_page() { array( $this, 'jetpack_search_admin_page' ) ); - // Only load assets if Customberg is supported. - if ( $this->wp_supports_customberg() ) { - add_action( "admin_print_scripts-$hook", array( $this, 'load_assets' ) ); - add_action( 'admin_footer', array( 'Automattic\Jetpack\Search\Helper', 'print_instant_search_sidebar' ) ); - } else { - add_action( "admin_print_scripts-$hook", array( $this, 'add_redirect_if_necessary' ) ); - } + add_action( "admin_print_scripts-$hook", array( $this, 'load_assets' ) ); + add_action( 'admin_footer', array( 'Automattic\Jetpack\Search\Helper', 'print_instant_search_sidebar' ) ); } /** @@ -94,20 +89,6 @@ public function jetpack_search_admin_page() { wp_supports_customberg() ) { - ?> - - =' ); - } - /** * Determine if the requisite page should be added to wp-admin. * diff --git a/projects/plugins/jetpack/modules/seo-tools.php b/projects/plugins/jetpack/modules/seo-tools.php index 1553e65c99471..ed025f3f70173 100644 --- a/projects/plugins/jetpack/modules/seo-tools.php +++ b/projects/plugins/jetpack/modules/seo-tools.php @@ -39,8 +39,8 @@ } } -/** This filter is documented in modules/seo-tools/jetpack-seo-utils.php */ +/** This filter is documented in modules/seo-tools/class-jetpack-seo-utils.php */ if ( ! apply_filters( 'jetpack_disable_seo_tools', false ) ) { - require_once __DIR__ . '/seo-tools/jetpack-seo.php'; + require_once __DIR__ . '/seo-tools/class-jetpack-seo.php'; new Jetpack_SEO(); } diff --git a/projects/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php b/projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-posts.php similarity index 81% rename from projects/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php rename to projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-posts.php index 82c9b0a582285..140bc5ef52f95 100644 --- a/projects/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php +++ b/projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-posts.php @@ -1,7 +1,12 @@ 'string', - 'description' => __( 'Custom post description to be used in HTML tag.', 'jetpack' ), - 'single' => true, - 'default' => '', + 'type' => 'string', + 'description' => __( 'Custom post description to be used in HTML tag.', 'jetpack' ), + 'single' => true, + 'default' => '', 'show_in_rest' => array( - 'name' => self::DESCRIPTION_META_KEY + 'name' => self::DESCRIPTION_META_KEY, ), ); diff --git a/projects/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php b/projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-titles.php similarity index 95% rename from projects/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php rename to projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-titles.php index f7360eaf946d1..82564ff9674c4 100644 --- a/projects/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php +++ b/projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-titles.php @@ -1,4 +1,9 @@ $format_array ) { - if ( ! in_array( $format_type, array_keys( $allowed_tokens ) ) ) { + if ( ! array_key_exists( $format_type, $allowed_tokens ) ) { return false; } @@ -265,8 +271,8 @@ public static function are_valid_title_formats( $title_formats ) { return false; } - if ( 'token' == $item['type'] ) { - if ( ! in_array( $item['value'], $allowed_tokens[ $format_type ] ) ) { + if ( 'token' === $item['type'] ) { + if ( ! in_array( $item['value'], $allowed_tokens[ $format_type ], true ) ) { return false; } } diff --git a/projects/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php b/projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php similarity index 97% rename from projects/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php rename to projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php index 96277a09cae94..c6d8c2943f0ff 100644 --- a/projects/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php +++ b/projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php @@ -1,4 +1,9 @@ tags. + */ public function meta_tags() { global $wp_query; @@ -148,6 +171,7 @@ public function meta_tags() { $authors = $this->get_authors(); $meta['description'] = wp_sprintf( + /* translators: %1$s: A post category. %2$l: Post authors. */ _x( 'Posts about %1$s written by %2$l', 'Posts about Category written by John and Bob', 'jetpack' ), single_term_title( '', false ), $authors @@ -155,36 +179,39 @@ public function meta_tags() { } } elseif ( is_date() ) { if ( is_year() ) { - $period = get_query_var( 'year' ); + $period = get_query_var( 'year' ); + /* translators: %1$s: Number of posts published. %2$l: Post author. %3$s: A year date. */ $template = _nx( - '%1$s post published by %2$l in the year %3$s', // singular - '%1$s posts published by %2$l in the year %3$s', // plural - count( $wp_query->posts ), // number - '10 posts published by John in the year 2012', // context + '%1$s post published by %2$l in the year %3$s', // Singular. + '%1$s posts published by %2$l in the year %3$s', // Plural. + count( $wp_query->posts ), // Number. + '10 posts published by John in the year 2012', // Context. 'jetpack' ); } elseif ( is_month() ) { - $period = date( 'F Y', mktime( 0, 0, 0, get_query_var( 'monthnum' ), 1, get_query_var( 'year' ) ) ); + $period = gmdate( 'F Y', mktime( 0, 0, 0, get_query_var( 'monthnum' ), 1, get_query_var( 'year' ) ) ); + /* translators: %1$s: Number of posts published. %2$l: Post author. %3$s: A month/year date. */ $template = _nx( - '%1$s post published by %2$l during %3$s', // singular - '%1$s posts published by %2$l during %3$s', // plural - count( $wp_query->posts ), // number - '10 posts publishes by John during May 2012', // context + '%1$s post published by %2$l during %3$s', // Singular. + '%1$s posts published by %2$l during %3$s', // Plural. + count( $wp_query->posts ), // Number. + '10 posts publishes by John during May 2012', // Context. 'jetpack' ); } elseif ( is_day() ) { - $period = date( + $period = gmdate( 'F j, Y', mktime( 0, 0, 0, get_query_var( 'monthnum' ), get_query_var( 'day' ), get_query_var( 'year' ) ) ); + /* translators: %1$s: Number of posts published. %2$l: Post author. %3$s: A month/day/year date. */ $template = _nx( - '%1$s post published by %2$l on %3$s', // singular - '%1$s posts published by %2$l on %3$s', // plural - count( $wp_query->posts ), // number - '10 posts published by John on May 30, 2012', // context + '%1$s post published by %2$l on %3$s', // Singular. + '%1$s posts published by %2$l on %3$s', // Plural. + count( $wp_query->posts ), // Number. + '10 posts published by John on May 30, 2012', // Context. 'jetpack' ); } @@ -204,7 +231,7 @@ public function meta_tags() { */ $meta = apply_filters( 'jetpack_seo_meta_tags', $meta ); - // Output them + // Output them. foreach ( $meta as $name => $content ) { if ( ! empty( $content ) ) { echo '' . "\n"; diff --git a/projects/plugins/jetpack/modules/stats.php b/projects/plugins/jetpack/modules/stats.php index adcc51623b76c..091063e48eb12 100644 --- a/projects/plugins/jetpack/modules/stats.php +++ b/projects/plugins/jetpack/modules/stats.php @@ -1232,7 +1232,7 @@ function stats_dashboard_widget_content() { } $_width = $width - 5; - $_height = $height - ( $GLOBALS['is_winIE'] ? 16 : 5 ); // Hack! @todo Remove WordPress 5.8 is minimum. IE should be fully deprecated. + $_height = $height - 5; $options = stats_dashboard_widget_options(); $blog_id = Jetpack_Options::get_option( 'id' ); diff --git a/projects/plugins/jetpack/modules/subscriptions/views.php b/projects/plugins/jetpack/modules/subscriptions/views.php index 33d13769345b7..85806e74178c2 100644 --- a/projects/plugins/jetpack/modules/subscriptions/views.php +++ b/projects/plugins/jetpack/modules/subscriptions/views.php @@ -144,17 +144,17 @@ static function render_widget_title( $args, $instance ) { if ( self::is_wpcom() && ! $show_only_email_and_button ) { if ( self::is_current_user_subscribed() ) { if ( ! empty( $instance['title_following'] ) ) { - echo $before_title . '' . $after_title . "\n"; + echo $before_title . '' . $after_title . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } else { if ( ! empty( $instance['title'] ) ) { - echo $before_title . '' . $after_title . "\n"; + echo $before_title . '' . $after_title . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } if ( self::is_jetpack() && empty( $instance['show_only_email_and_button'] ) ) { - echo $args['before_title'] . esc_attr( $instance['title'] ) . $args['after_title'] . "\n"; + echo $args['before_title'] . $instance['title'] . $args['after_title'] . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } diff --git a/projects/plugins/jetpack/modules/widgets/authors.php b/projects/plugins/jetpack/modules/widgets/authors.php index 741856d84ccc1..402794fc9cc97 100644 --- a/projects/plugins/jetpack/modules/widgets/authors.php +++ b/projects/plugins/jetpack/modules/widgets/authors.php @@ -116,7 +116,7 @@ public function widget( $args, $instance ) { echo $args['before_widget']; /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', $instance['title'] ); - echo $args['before_title'] . esc_html( $title ) . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo '
    '; $default_post_type = 'post'; diff --git a/projects/plugins/jetpack/modules/widgets/blog-stats.php b/projects/plugins/jetpack/modules/widgets/blog-stats.php index b28718c99ce2b..7265d1142a26c 100644 --- a/projects/plugins/jetpack/modules/widgets/blog-stats.php +++ b/projects/plugins/jetpack/modules/widgets/blog-stats.php @@ -137,7 +137,7 @@ function widget( $args, $instance ) { echo $args['before_widget']; if ( ! empty( $title ) ) { - echo $args['before_title'] . esc_html( $title ) . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } // Get the Site Stats. diff --git a/projects/plugins/jetpack/modules/widgets/class-jetpack-instagram-widget.php b/projects/plugins/jetpack/modules/widgets/class-jetpack-instagram-widget.php index 1ae6ebc0eecfb..c334f0fb21b0b 100644 --- a/projects/plugins/jetpack/modules/widgets/class-jetpack-instagram-widget.php +++ b/projects/plugins/jetpack/modules/widgets/class-jetpack-instagram-widget.php @@ -284,7 +284,7 @@ public function widget( $args, $instance ) { if ( ! empty( $instance['title'] ) ) { echo $args['before_title']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - echo esc_html( $instance['title'] ); + echo $instance['title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $args['after_title']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } diff --git a/projects/plugins/jetpack/modules/widgets/contact-info.php b/projects/plugins/jetpack/modules/widgets/contact-info.php index fe37ad69577df..de9afc9d5afad 100644 --- a/projects/plugins/jetpack/modules/widgets/contact-info.php +++ b/projects/plugins/jetpack/modules/widgets/contact-info.php @@ -108,7 +108,7 @@ public function widget( $args, $instance ) { echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( '' !== $instance['title'] ) { - echo $args['before_title'] . esc_html( $instance['title'] ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $args['before_title'] . $instance['title'] . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** diff --git a/projects/plugins/jetpack/modules/widgets/facebook-likebox.php b/projects/plugins/jetpack/modules/widgets/facebook-likebox.php index 5059d18e3fccd..c7e38e6416c7c 100644 --- a/projects/plugins/jetpack/modules/widgets/facebook-likebox.php +++ b/projects/plugins/jetpack/modules/widgets/facebook-likebox.php @@ -122,7 +122,7 @@ public function widget( $args, $instance ) { if ( ! empty( $title ) ) : echo $before_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - $likebox_widget_title = '' . esc_html( $title ) . ''; + $likebox_widget_title = '' . $title . ''; /** * Filter Facebook Likebox's widget title. * diff --git a/projects/plugins/jetpack/modules/widgets/flickr.php b/projects/plugins/jetpack/modules/widgets/flickr.php index ebf0fc2c3a1f6..9fb809629c353 100644 --- a/projects/plugins/jetpack/modules/widgets/flickr.php +++ b/projects/plugins/jetpack/modules/widgets/flickr.php @@ -156,7 +156,7 @@ public function widget( $args, $instance ) { ); } } else { - echo $args['before_title'] . esc_html( $instance['title'] ) . $args['after_title']; + echo $args['before_title'] . $instance['title'] . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped require( dirname( __FILE__ ) . '/flickr/widget.php' ); } echo $args['after_widget']; diff --git a/projects/plugins/jetpack/modules/widgets/gallery.php b/projects/plugins/jetpack/modules/widgets/gallery.php index 58655b934d070..65c3a60cd8713 100644 --- a/projects/plugins/jetpack/modules/widgets/gallery.php +++ b/projects/plugins/jetpack/modules/widgets/gallery.php @@ -107,7 +107,7 @@ public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); if ( $title ) { - echo $before_title . esc_html( $title ) . $after_title . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $before_title . $title . $after_title . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
    ' . "\n"; diff --git a/projects/plugins/jetpack/modules/widgets/goodreads.php b/projects/plugins/jetpack/modules/widgets/goodreads.php index d6ea651549b7f..f9b3db769011f 100644 --- a/projects/plugins/jetpack/modules/widgets/goodreads.php +++ b/projects/plugins/jetpack/modules/widgets/goodreads.php @@ -80,7 +80,7 @@ function widget( $args, $instance ) { } echo $args['before_widget']; - echo $args['before_title'] . $title . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode( $instance['user_id'] ) . '.' . urlencode( $instance['title'] ) . ':%20' . urlencode( $instance['shelf'] ) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode( $instance['shelf'] ) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr( $this->goodreads_widget_id ); diff --git a/projects/plugins/jetpack/modules/widgets/google-translate.php b/projects/plugins/jetpack/modules/widgets/google-translate.php index b00f13cd85174..0e270677af779 100644 --- a/projects/plugins/jetpack/modules/widgets/google-translate.php +++ b/projects/plugins/jetpack/modules/widgets/google-translate.php @@ -146,7 +146,7 @@ public function widget( $args, $instance ) { echo $args['before_widget']; if ( ! empty( $title ) ) { - echo $args['before_title'] . esc_html( $title ) . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
    '; echo $args['after_widget']; diff --git a/projects/plugins/jetpack/modules/widgets/gravatar-profile.php b/projects/plugins/jetpack/modules/widgets/gravatar-profile.php index b9091bbe9aed6..d2b13d12fcd42 100644 --- a/projects/plugins/jetpack/modules/widgets/gravatar-profile.php +++ b/projects/plugins/jetpack/modules/widgets/gravatar-profile.php @@ -65,7 +65,7 @@ function widget( $args, $instance ) { if ( current_user_can( 'edit_theme_options' ) ) { echo $args['before_widget']; if ( ! empty( $title ) ) { - echo $args['before_title'] . $title . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '

    ' . sprintf( __( 'You need to select what to show in this Gravatar Profile widget.', 'jetpack' ), admin_url( 'widgets.php' ) ) . '

    '; echo $args['after_widget']; diff --git a/projects/plugins/jetpack/modules/widgets/image-widget.php b/projects/plugins/jetpack/modules/widgets/image-widget.php index d455b4c2993ab..e498f577e6766 100644 --- a/projects/plugins/jetpack/modules/widgets/image-widget.php +++ b/projects/plugins/jetpack/modules/widgets/image-widget.php @@ -67,9 +67,8 @@ public function widget( $args, $instance ) { /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', $instance['title'] ); - if ( $title ) { - echo $args['before_title'] . esc_html( $title ) . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } if ( '' != $instance['img_url'] ) { diff --git a/projects/plugins/jetpack/modules/widgets/mailchimp.php b/projects/plugins/jetpack/modules/widgets/mailchimp.php index a2aff1ba7b254..6f43b4db3d148 100644 --- a/projects/plugins/jetpack/modules/widgets/mailchimp.php +++ b/projects/plugins/jetpack/modules/widgets/mailchimp.php @@ -1,4 +1,10 @@ - '' ) ); // Regular expresion that will match maichimp shortcode. @@ -60,23 +68,21 @@ function widget( $args, $instance ) { do_action( 'jetpack_stats_extra', 'widget_view', 'mailchimp_subscriber_popup' ); } - /** * Deals with the settings when they are saved by the admin. * - * @param array $new_instance New configuration values - * @param array $old_instance Old configuration values + * @param array $new_instance New configuration values. + * @param array $old_instance Old configuration values. * * @return array */ - function update( $new_instance, $old_instance ) { + public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $instance = array(); $instance['code'] = MailChimp_Subscriber_Popup::reversal( $new_instance['code'] ); return $instance; } - /** * Displays the form for this widget on the Widgets page of the WP Admin area. * @@ -84,20 +90,30 @@ function update( $new_instance, $old_instance ) { * * @return void */ - function form( $instance ) { + public function form( $instance ) { $instance = wp_parse_args( $instance, array( 'code' => '' ) ); - ?> -

    - - -

    + $label = sprintf( + wp_kses( + /* Translators: %s is a link to the MailChimp support docs. */ + __( 'Code: ( ? )', 'jetpack' ), + array( + 'a' => array( + 'href' => array(), + 'target' => array(), + ), + ) + ), + 'https://en.support.wordpress.com/mailchimp/' + ); -

    ', + esc_attr( $this->get_field_id( 'code' ) ), + esc_attr( $this->get_field_name( 'code' ) ), + esc_textarea( $instance['code'] ), + $label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. + ); } - } - } diff --git a/projects/plugins/jetpack/modules/widgets/migrate-to-core/gallery-widget.php b/projects/plugins/jetpack/modules/widgets/migrate-to-core/gallery-widget.php index b31c7d91b7652..ffee5b5b7a686 100644 --- a/projects/plugins/jetpack/modules/widgets/migrate-to-core/gallery-widget.php +++ b/projects/plugins/jetpack/modules/widgets/migrate-to-core/gallery-widget.php @@ -6,22 +6,23 @@ * * @package automattic/jetpack */ + /** * Migrates all active instances of Jetpack's Gallery widget to Core's Media Gallery widget. */ function jetpack_migrate_gallery_widget() { - // Only trigger the migration from wp-admin and outside unit tests + // Only trigger the migration from wp-admin and outside unit tests. if ( ! is_admin() || defined( 'PHPUNIT_JETPACK_TESTSUITE' ) ) { return; } - // Only migrate if the new widget is available and we haven't yet migrated + // Only migrate if the new widget is available and we haven't yet migrated. if ( ! class_exists( 'WP_Widget_Media_Gallery' ) || Jetpack_Options::get_option( 'gallery_widget_migration' ) ) { return; } - $old_widgets = get_option( 'widget_gallery', array() ); - $media_gallery = get_option( 'widget_media_gallery', array() ); + $old_widgets = get_option( 'widget_gallery', array() ); + $media_gallery = get_option( 'widget_media_gallery', array() ); $sidebars_widgets = wp_get_sidebars_widgets(); // Array to store legacy widget ids in to unregister on success. @@ -30,10 +31,13 @@ function jetpack_migrate_gallery_widget() { $old_widgets = array_filter( $old_widgets, 'jetpack_migrate_gallery_widget_is_importable' ); foreach ( $old_widgets as $id => $widget ) { $new_id = $id; - // Try to get an unique id for the new type of widget. - // It may be the case that the user has already created a core Gallery Widget - // before the migration begins. (Maybe Jetpack was deactivated during core's upgrade). - for( $i = 0; $i < 10 && in_array( $new_id, array_keys( $media_gallery ) ); $i++, $new_id++ ); + + /* + * Try to get an unique id for the new type of widget. + * It may be the case that the user has already created a core Gallery Widget + * before the migration begins. (Maybe Jetpack was deactivated during core's upgrade). + */ + for ( $i = 0; $i < 10 && array_key_exists( $new_id, array( $media_gallery ) ); $i++, $new_id++ ); // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed $widget_copy = jetpack_migrate_gallery_widget_upgrade_widget( $widget ); @@ -64,24 +68,35 @@ function jetpack_migrate_gallery_widget() { wp_set_sidebars_widgets( $sidebars_widgets ); // Log if we migrated all, or some for this site. - foreach ( $widgets_to_unregister as $w ) { + foreach ( $widgets_to_unregister as $w ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable jetpack_migrate_gallery_widget_bump_stats( 'gallery-widget-migrated' ); } - // We need to refresh on widgets page for changes to take effect. - // The jetpack_refresh_on_widget_page function is already defined in migrate-to-core/image-widget.php + /* + * We need to refresh on widgets page for changes to take effect. + * The jetpack_refresh_on_widget_page function is already defined + * in migrate-to-core/image-widget.php + */ add_action( 'current_screen', 'jetpack_refresh_on_widget_page' ); } Jetpack_Options::update_option( 'gallery_widget_migration', true ); } +/** + * Check if the widget can be imported. + * + * @param array $widget One of the Jetpack Gallery widgets to be transformed into a new Core Media Gallery Widget. + */ function jetpack_migrate_gallery_widget_is_importable( $widget ) { // Can be caused by instantiating but not populating a widget in the Customizer. if ( empty( $widget ) ) { return false; } - // The array as stored in the option constains two keys and one - // is a string `_multiwidget` which does not represent a widget, so we skip it + + /* + * The array as stored in the option constains two keys and one + * is a string `_multiwidget` which does not represent a widget, so we skip it + */ if ( ! is_array( $widget ) ) { return false; } @@ -92,28 +107,28 @@ function jetpack_migrate_gallery_widget_is_importable( $widget ) { * Returns a transformed version of the Gallery Widget. * Will return null if the widget is either empty, is not an array or has more keys than expected * - * @param $widget One of the Jetpack Gallery widgets to be transformed into a new Core Media Gallery Widget + * @param array $widget One of the Jetpack Gallery widgets to be transformed into a new Core Media Gallery Widget. * * @return array|null */ function jetpack_migrate_gallery_widget_upgrade_widget( $widget ) { $allowed_keys = array( - 'ids' => '', - 'link' => '', - 'title' => '', - 'type' => '', - 'random' => '', + 'ids' => '', + 'link' => '', + 'title' => '', + 'type' => '', + 'random' => '', 'conditions' => '', ); $default_data = array( - 'columns' => 3, - 'ids' => array(), - 'link_type' => '', + 'columns' => 3, + 'ids' => array(), + 'link_type' => '', 'orderby_random' => false, - 'size' => 'thumbnail', - 'title' => '', - 'type' => '', + 'size' => 'thumbnail', + 'title' => '', + 'type' => '', ); if ( ! jetpack_migrate_gallery_widget_is_importable( $widget ) ) { @@ -121,30 +136,37 @@ function jetpack_migrate_gallery_widget_upgrade_widget( $widget ) { } // Ensure widget has no keys other than those expected. // Not all widgets have conditions, so lets add it in. - $widget_copy = array_merge( array( 'conditions' => null ), $widget ); + $widget_copy = array_merge( array( 'conditions' => null ), $widget ); $non_allowed_keys = array_diff_key( $widget_copy, $allowed_keys ); if ( count( $non_allowed_keys ) > 0 ) { jetpack_migrate_gallery_widget_bump_stats( 'extra-key' ); // Log the names of the keys not in our allowed list. foreach ( $non_allowed_keys as $key => $value ) { - jetpack_migrate_gallery_widget_bump_stats( "extra-key-$key", "migration-extra-key" ); + jetpack_migrate_gallery_widget_bump_stats( "extra-key-$key", 'migration-extra-key' ); } } - $widget_copy = array_merge( $default_data, $widget, array( - // ids in Jetpack's Gallery are a string of comma-separated values. - // Core's Media Gallery Widget stores ids in an array - 'ids' => explode( ',', $widget['ids'] ), - 'link_type' => $widget['link'], - 'orderby_random' => isset( $widget['random'] ) && $widget['random'] === 'on', - ) ); + $widget_copy = array_merge( + $default_data, + $widget, + array( + // ids in Jetpack's Gallery are a string of comma-separated values. + // Core's Media Gallery Widget stores ids in an array. + 'ids' => explode( ',', $widget['ids'] ), + 'link_type' => $widget['link'], + 'orderby_random' => isset( $widget['random'] ) && 'on' === $widget['random'], + ) + ); - // Unsetting old widget fields - $widget_copy = array_diff_key( $widget_copy, array( - 'link' => false, - 'random' => false, - ) ); + // Unsetting old widget fields. + $widget_copy = array_diff_key( + $widget_copy, + array( + 'link' => false, + 'random' => false, + ) + ); return $widget_copy; } @@ -152,21 +174,23 @@ function jetpack_migrate_gallery_widget_upgrade_widget( $widget ) { /** * Replaces the references to Jetpack Gallery Widget in the sidebars for references to the new version of the widget * - * @param $sidebars_widgets The sidebar widgets array to update - * @param $id Old id of the widget (basically its index in the array ) - * @param $new_id New id that will be using on the sidebar as a new widget + * @param array $sidebars_widgets The sidebar widgets array to update. + * @param string $id Old id of the widget (basically its index in the array ). + * @param string $new_id New id that will be using on the sidebar as a new widget. * - * @return mixed Updated sidebar widgets array + * @return mixed Updated sidebar widgets array */ function jetpack_migrate_gallery_widget_update_sidebars( $sidebars_widgets, $id, $new_id ) { foreach ( $sidebars_widgets as $sidebar => $widgets ) { - if ( - is_array( $widgets ) - && false !== ( $key = array_search( "gallery-{$id}", $widgets, true ) ) - ) { + $key = is_array( $widgets ) ? array_search( "gallery-{$id}", $widgets, true ) : false; + + if ( false !== $key ) { $sidebars_widgets[ $sidebar ][ $key ] = "media_gallery-{$new_id}"; - // Check if the inactive widgets sidebar exists - // Related: https://core.trac.wordpress.org/ticket/14893 + + /* + * Check if the inactive widgets sidebar exists + * Related: https://core.trac.wordpress.org/ticket/14893 + */ if ( ! isset( $sidebars_widgets['wp_inactive_widgets'] ) || ! is_array( $sidebars_widgets['wp_inactive_widgets'] ) ) { $sidebars_widgets['wp_inactive_widgets'] = array(); } @@ -190,9 +214,8 @@ function jetpack_migrate_gallery_widget_bump_stats( $bin, $group = 'widget-migra } else { // $group is prepended with 'jetpack-' $jetpack = Jetpack::init(); - $jetpack->stat( $group, $bin ) ; + $jetpack->stat( $group, $bin ); } } - add_action( 'widgets_init', 'jetpack_migrate_gallery_widget' ); diff --git a/projects/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php b/projects/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php index ee74745fe879c..06f317ff496d3 100644 --- a/projects/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php +++ b/projects/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php @@ -11,38 +11,38 @@ * Migrates all active instances of Jetpack's image widget to Core's media image widget. */ function jetpack_migrate_image_widget() { - // Only trigger the migration from wp-admin + // Only trigger the migration from wp-admin. if ( ! is_admin() ) { return; } - // Only migrate if the new widget is available and we haven't yet migrated + // Only migrate if the new widget is available and we haven't yet migrated. if ( ! class_exists( 'WP_Widget_Media_Image' ) || Jetpack_Options::get_option( 'image_widget_migration' ) ) { return; } $default_data = array( - 'attachment_id' => 0, - 'url' => '', - 'title' => '', - 'size' => 'custom', - 'width' => 0, - 'height' => 0, - 'align' => 'none', - 'caption' => '', - 'alt' => '', - 'link_type' => '', - 'link_url' => '', - 'image_classes' => '', - 'link_classes' => '', - 'link_rel' => '', - 'image_title' => '', + 'attachment_id' => 0, + 'url' => '', + 'title' => '', + 'size' => 'custom', + 'width' => 0, + 'height' => 0, + 'align' => 'none', + 'caption' => '', + 'alt' => '', + 'link_type' => '', + 'link_url' => '', + 'image_classes' => '', + 'link_classes' => '', + 'link_rel' => '', + 'image_title' => '', 'link_target_blank' => false, - 'conditions' => null, + 'conditions' => null, ); - $old_widgets = get_option( 'widget_image', array() ); - $media_image = get_option( 'widget_media_image', array() ); + $old_widgets = get_option( 'widget_image', array() ); + $media_image = get_option( 'widget_media_image', array() ); $sidebars_widgets = wp_get_sidebars_widgets(); // Persist old and current widgets in backup table. @@ -71,7 +71,7 @@ function jetpack_migrate_image_widget() { // Ensure widget has no keys other than those expected. // Not all widgets have conditions, so lets add it in. - $widget_copy = array_merge( array( 'conditions' => null ), $widget ); + $widget_copy = array_merge( array( 'conditions' => null ), $widget ); $non_allowed_keys = array_diff_key( $widget_copy, array( @@ -90,30 +90,37 @@ function jetpack_migrate_image_widget() { ); if ( count( $non_allowed_keys ) > 0 ) { - // skipping the widget in question + // skipping the widget in question. continue; } - $media_image[ $id ] = array_merge( $default_data, $widget, array( - 'alt' => $widget['alt_text'], - 'height' => $widget['img_height'], - 'image_classes' => ! empty( $widget['align'] ) ? 'align' . $widget['align'] : '', - 'image_title' => $widget['img_title'], - 'link_url' => $widget['link'], - 'url' => $widget['img_url'], - 'width' => $widget['img_width'], - ) ); - - // Unsetting old widget fields - $media_image[ $id ] = array_diff_key( $media_image[ $id ], array( - 'align' => false, - 'alt_text' => false, - 'img_height' => false, - 'img_title' => false, - 'img_url' => false, - 'img_width' => false, - 'link' => false, - ) ); + $media_image[ $id ] = array_merge( + $default_data, + $widget, + array( + 'alt' => $widget['alt_text'], + 'height' => $widget['img_height'], + 'image_classes' => ! empty( $widget['align'] ) ? 'align' . $widget['align'] : '', + 'image_title' => $widget['img_title'], + 'link_url' => $widget['link'], + 'url' => $widget['img_url'], + 'width' => $widget['img_width'], + ) + ); + + // Unsetting old widget fields. + $media_image[ $id ] = array_diff_key( + $media_image[ $id ], + array( + 'align' => false, + 'alt_text' => false, + 'img_height' => false, + 'img_title' => false, + 'img_url' => false, + 'img_width' => false, + 'link' => false, + ) + ); // Check if the image is in the media library. $image_basename = basename( $widget['img_url'] ); @@ -122,32 +129,34 @@ function jetpack_migrate_image_widget() { continue; } - $attachment_ids = get_posts( array( - 'fields' => 'ids', - 'meta_query' => array( - array( - 'value' => basename( $image_basename ), - 'compare' => 'LIKE', - 'key' => '_wp_attachment_metadata', + $attachment_ids = get_posts( + array( + 'fields' => 'ids', + 'meta_query' => array( + array( + 'value' => basename( $image_basename ), + 'compare' => 'LIKE', + 'key' => '_wp_attachment_metadata', + ), ), - ), - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'suppress_filters' => false, - ) ); + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'suppress_filters' => false, + ) + ); foreach ( $attachment_ids as $attachment_id ) { $image_meta = wp_get_attachment_metadata( $attachment_id ); // Is it a full size image? $image_path_pieces = explode( '/', $image_meta['file'] ); - if ( $image_basename === array_pop( $image_path_pieces ) ) { + if ( array_pop( $image_path_pieces ) === $image_basename ) { $media_image[ $id ]['attachment_id'] = $attachment_id; // Set correct size if dimensions fit. if ( - $media_image[ $id ]['width'] == $image_meta['width'] || - $media_image[ $id ]['height'] == $image_meta['height'] + $media_image[ $id ]['width'] == $image_meta['width'] || // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + $media_image[ $id ]['height'] == $image_meta['height'] // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison ) { $media_image[ $id ]['size'] = 'full'; } @@ -156,13 +165,13 @@ function jetpack_migrate_image_widget() { // Is it a down-sized image? foreach ( $image_meta['sizes'] as $size => $image ) { - if ( false !== array_search( $image_basename, $image ) ) { + if ( false !== array_search( $image_basename, $image, true ) ) { $media_image[ $id ]['attachment_id'] = $attachment_id; // Set correct size if dimensions fit. if ( - $media_image[ $id ]['width'] == $image['width'] || - $media_image[ $id ]['height'] == $image['height'] + $media_image[ $id ]['width'] == $image['width'] || // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + $media_image[ $id ]['height'] == $image['height'] // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison ) { $media_image[ $id ]['size'] = $size; } @@ -176,10 +185,9 @@ function jetpack_migrate_image_widget() { } foreach ( $sidebars_widgets as $sidebar => $widgets ) { - if ( - is_array( $widgets ) - && false !== ( $key = array_search( "image-{$id}", $widgets, true ) ) - ) { + $key = is_array( $widgets ) ? array_search( "image-{$id}", $widgets, true ) : false; + + if ( false !== $key ) { $sidebars_widgets[ $sidebar ][ $key ] = "media_image-{$id}"; } } @@ -215,6 +223,11 @@ function jetpack_migrate_image_widget() { } add_action( 'widgets_init', 'jetpack_migrate_image_widget' ); +/** + * Refresh the widgets page to save changes + * + * @param WP_Screen $current Current WP_Screen object. + */ function jetpack_refresh_on_widget_page( $current ) { if ( 'widgets' === $current->base ) { wp_safe_redirect( admin_url( 'widgets.php' ) ); diff --git a/projects/plugins/jetpack/modules/widgets/milestone/class-milestone-widget.php b/projects/plugins/jetpack/modules/widgets/milestone/class-milestone-widget.php index 3ce97d248ab4e..a28e85f57f9e5 100644 --- a/projects/plugins/jetpack/modules/widgets/milestone/class-milestone-widget.php +++ b/projects/plugins/jetpack/modules/widgets/milestone/class-milestone-widget.php @@ -212,7 +212,7 @@ public function widget( $args, $instance ) { /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $instance['title'] ); if ( ! empty( $title ) ) { - echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } $widget_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : 'milestone_widget'; diff --git a/projects/plugins/jetpack/modules/widgets/my-community.php b/projects/plugins/jetpack/modules/widgets/my-community.php index 13efc1d5e4a20..c16baf21ccdc4 100644 --- a/projects/plugins/jetpack/modules/widgets/my-community.php +++ b/projects/plugins/jetpack/modules/widgets/my-community.php @@ -1,4 +1,4 @@ -default_title; } - $number = isset( $instance['number'] ) ? $instance['number'] : 10; - if ( ! in_array( $number, array( 10, 50 ) ) ) { + $number = isset( $instance['number'] ) ? (int) $instance['number'] : 10; + if ( ! in_array( $number, array( 10, 50 ), true ) ) { $number = 10; } @@ -85,35 +85,35 @@ function form( $instance ) { ?>

    - - + +

      -
    • -
    • +
    • +

    -

    -

    -

    @@ -131,15 +131,15 @@ function form( $instance ) { * * @return array Updated safe values to be saved. */ - function update( $new_instance, $old_instance ) { + public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $instance = array(); $instance['title'] = wp_kses( $new_instance['title'], array() ); if ( $instance['title'] === $this->default_title ) { - $instance['title'] = false; // Store as false in case of language change + $instance['title'] = false; // Store as false in case of language change. } $instance['number'] = (int) $new_instance['number']; - if ( ! in_array( $instance['number'], array( 10, 50 ) ) ) { + if ( ! in_array( $instance['number'], array( 10, 50 ), true ) ) { $instance['number'] = 10; } @@ -160,9 +160,10 @@ function update( $new_instance, $old_instance ) { * @param array $args Widget arguments. * @param array $instance Saved values from database. */ - function widget( $args, $instance ) { + public function widget( $args, $instance ) { $instance = wp_parse_args( - $instance, array( + $instance, + array( 'title' => false, 'number' => true, 'include_likers' => true, @@ -177,13 +178,12 @@ function widget( $args, $instance ) { $title = $this->default_title; } + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $title ); - - echo $args['before_widget']; - if ( ! empty( $title ) ) { - echo $args['before_title'] . $title . $args['after_title']; + echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } $transient_name = "$this->id-v2-{$instance['number']}" . (int) $instance['include_likers'] . (int) $instance['include_followers'] . (int) $instance['include_commenters']; @@ -196,9 +196,9 @@ function widget( $args, $instance ) { set_transient( $transient_name, $my_community, self::$expiration ); } - echo $my_community; + echo $my_community; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - echo $args['after_widget']; + echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped /** This action is documented in modules/widgets/gravatar-profile.php */ do_action( 'jetpack_stats_extra', 'widget_view', 'my_community' ); @@ -209,11 +209,11 @@ function widget( $args, $instance ) { * * @since 4.0 * - * @param array $query + * @param array $query Saved widget values from database. * * @return string */ - function get_community( $query ) { + private function get_community( $query ) { $members = $this->fetch_remote_community( $query ); if ( ! empty( $members ) ) { @@ -223,10 +223,10 @@ function get_community( $query ) { foreach ( $members as $member ) { $my_community .= sprintf( '
  • %s
  • ', - esc_url( $member->profile_URL ), + esc_url( $member->profile_URL ), // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase esc_attr( $member->name ), esc_attr( $member->name ), - esc_url( $member->avatar_URL ) + esc_url( $member->avatar_URL ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ); } @@ -236,10 +236,12 @@ function get_community( $query ) { if ( current_user_can( 'edit_theme_options' ) ) { $my_community = '

    ' . wp_kses( sprintf( + /* Translators: 1. link to the widgets settings screen. 2. link to support document. */ __( 'There are no users to display in this My Community widget. Want more traffic?', 'jetpack' ), admin_url( 'widgets.php' ), esc_url( Redirect::get_url( 'jetpack-support-getting-more-views-and-traffic' ) ) - ), array( 'a' => array( 'href' => true ) ) + ), + array( 'a' => array( 'href' => true ) ) ) . '

    '; } else { $my_community = '

    ' . esc_html__( "I'm just starting out; leave me a comment or a like :)", 'jetpack' ) . '

    '; @@ -254,11 +256,11 @@ function get_community( $query ) { * * @since 4.0 * - * @param $query + * @param array $query Saved widget values from database. * * @return array */ - function fetch_remote_community( $query ) { + private function fetch_remote_community( $query ) { $jetpack_blog_id = Jetpack_Options::get_option( 'id' ); $url = add_query_arg( array( @@ -296,5 +298,4 @@ function jetpack_my_community_init() { register_widget( 'Jetpack_My_Community_Widget' ); } } - add_action( 'widgets_init', 'jetpack_my_community_init' ); diff --git a/projects/plugins/jetpack/modules/widgets/rsslinks-widget.php b/projects/plugins/jetpack/modules/widgets/rsslinks-widget.php index 60fb9e54796f1..303c0c6dfde0b 100644 --- a/projects/plugins/jetpack/modules/widgets/rsslinks-widget.php +++ b/projects/plugins/jetpack/modules/widgets/rsslinks-widget.php @@ -1,14 +1,26 @@ - 'widget_rss_links', 'description' => __( "Links to your blog's RSS feeds", 'jetpack' ), @@ -41,7 +53,7 @@ public function widget( $args, $instance ) { echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( $title ) { - echo $before_title . esc_html( $title ) . $after_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $before_title . $title . $after_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } if ( 'text' === $instance['format'] ) { @@ -49,12 +61,12 @@ public function widget( $args, $instance ) { } if ( 'posts' === $instance['display'] ) { - $this->_rss_link( 'posts', $instance ); + $this->rss_link( 'posts', $instance ); } elseif ( 'comments' === $instance['display'] ) { - $this->_rss_link( 'comments', $instance ); + $this->rss_link( 'comments', $instance ); } elseif ( 'posts-comments' === $instance['display'] ) { - $this->_rss_link( 'posts', $instance ); - $this->_rss_link( 'comments', $instance ); + $this->rss_link( 'posts', $instance ); + $this->rss_link( 'comments', $instance ); } if ( 'text' === $instance['format'] ) { @@ -73,7 +85,7 @@ public function widget( $args, $instance ) { * * @return array Array of default values for the Widget's options */ - function defaults() { + public function defaults() { return array( 'title' => '', 'display' => 'posts-comments', @@ -81,7 +93,17 @@ function defaults() { ); } - function update( $new_instance, $old_instance ) { + /** + * Sanitize widget form values as they are saved. + * + * @see WP_Widget::update() + * + * @param array $new_instance Values just sent to be saved. + * @param array $old_instance Previously saved values from database. + * + * @return array Updated safe values to be saved. + */ + public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $instance = $old_instance; $instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] ); @@ -93,7 +115,16 @@ function update( $new_instance, $old_instance ) { return $instance; } - function form( $instance ) { + /** + * Back end widget form. + * + * @see WP_Widget::form() + * + * @param array $instance Previously saved values from database. + * + * @return string|void + */ + public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults() ); $title = stripslashes( $instance['title'] ); @@ -102,8 +133,8 @@ function form( $instance ) { $image_size = isset( $instance['imagesize'] ) ? $instance['imagesize'] : 0; $image_color = isset( $instance['imagecolor'] ) ? $instance['imagecolor'] : 'red'; - echo '

    '; $displays = array( @@ -111,11 +142,11 @@ function form( $instance ) { 'comments' => __( 'Comments', 'jetpack' ), 'posts-comments' => __( 'Posts & Comments', 'jetpack' ), ); - echo '

    '; - echo ''; } - function _rss_link( $type, $args ) { - if ( 'posts' == $type ) { - $type_text = __( 'Posts', 'jetpack' ); - $rss_type = 'rss2_url'; - } elseif ( 'comments' == $type ) { - $type_text = __( 'Comments', 'jetpack' ); - $rss_type = 'comments_rss2_url'; + /** + * Output a link with a link to the feed. + * + * @param string $type Widget type (posts or comments). + * @param array $args Widget arguments. + */ + private function rss_link( $type, $args ) { + if ( 'posts' === $type ) { + $subscribe_to = esc_html__( 'Subscribe to posts', 'jetpack' ); + $link_text = esc_html__( 'RSS - Posts', 'jetpack' ); + $rss_type = 'rss2_url'; + } elseif ( 'comments' === $type ) { + $subscribe_to = esc_html__( 'Subscribe to comments', 'jetpack' ); + $link_text = esc_html__( 'RSS - Comments', 'jetpack' ); + $rss_type = 'comments_rss2_url'; } - $subscribe_to = sprintf( __( 'Subscribe to %s', 'jetpack' ), $type_text ); - - $link_item = ''; - $format = $args['format']; - /** * Filters the target link attribute for the RSS link in the RSS widget. * @@ -210,42 +244,60 @@ function _rss_link( $type, $args ) { $link_target = '_self'; } - if ( 'image' == $format || 'text-image' == $format ) { - /** - * Filters the image used as RSS icon in the RSS widget. - * - * @module widgets - * - * @since 3.6.0 - * - * @param string $var URL of RSS Widget icon. - */ - $link_image = apply_filters( 'jetpack_rss_widget_icon', plugins_url( 'images/rss/' . $args['imagecolor'] . '-' . $args['imagesize'] . '.png', dirname( dirname( __FILE__ ) ) ) ); - $link_item = 'RSS Feed'; - } - if ( 'text-image' == $format ) { - $link_item .= ' ' . esc_html__( 'RSS - ' . $type_text, 'jetpack' ) . ''; - } - if ( 'text' == $format ) { - $link_item = '' . esc_html__( 'RSS - ' . $type_text, 'jetpack' ) . ''; + $format = $args['format']; + if ( 'image' === $format ) { + $link_contents = $this->get_image_tag( $args ); + } elseif ( 'text-image' === $format ) { + $link_contents = sprintf( + '%1$s %2$s', + $this->get_image_tag( $args ), + $link_text + ); + } elseif ( 'text' === $format ) { + $link_contents = $link_text; } - if ( 'text' == $format ) { - echo '
  • '; - } else { - echo '

    '; - } - echo $link_item; - if ( 'text' == $format ) { - echo '

  • '; - } else { - echo '

    '; - } + printf( + '%1$s%6$s%2$s', + 'text' === $format ? '
  • ' : '

    ', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + 'text' === $format ? '

  • ' : '

    ', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + esc_attr( $link_target ), + esc_url( get_bloginfo( $rss_type ) ), + esc_attr( $subscribe_to ), + $link_contents // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we are escaping this above. + ); + } + + /** + * Return an image tag for the RSS icon. + * + * @param array $args Widget arguments. + */ + private function get_image_tag( $args ) { + $image_path = sprintf( + 'images/rss/%1$s-%2$s.png', + $args['imagecolor'], + $args['imagesize'] + ); + /** + * Filters the image used as RSS icon in the RSS widget. + * + * @module widgets + * + * @since 3.6.0 + * + * @param string $var URL of RSS Widget icon. + */ + $image = apply_filters( + 'jetpack_rss_widget_icon', + plugins_url( $image_path, dirname( __DIR__ ) ) + ); + + return sprintf( + '%2$s', + esc_url( $image ), + esc_attr__( 'RSS feed', 'jetpack' ) + ); } } // Class Jetpack_RSS_Links_Widget - -function jetpack_rss_links_widget_init() { - register_widget( 'Jetpack_RSS_Links_Widget' ); -} -add_action( 'widgets_init', 'jetpack_rss_links_widget_init' ); diff --git a/projects/plugins/jetpack/modules/widgets/search.php b/projects/plugins/jetpack/modules/widgets/search.php index b6a63cf9285e1..291649f23ee31 100644 --- a/projects/plugins/jetpack/modules/widgets/search.php +++ b/projects/plugins/jetpack/modules/widgets/search.php @@ -15,6 +15,9 @@ add_action( 'widgets_init', 'jetpack_search_widget_init' ); +/** + * Register the widget if Jetpack Search is available and enabled. + */ function jetpack_search_widget_init() { if ( ! Jetpack::is_connection_ready() @@ -64,6 +67,8 @@ class Jetpack_Search_Widget extends WP_Widget { * Jetpack_Search_Widget constructor. * * @since 5.0.0 + * + * @param string $name Widget name. */ public function __construct( $name = null ) { if ( empty( $name ) ) { @@ -124,7 +129,12 @@ public function activate_search() { * @since 5.7.0 */ public function widget_admin_setup() { - wp_enqueue_style( 'widget-jetpack-search-filters', plugins_url( 'search/css/search-widget-admin-ui.css', __FILE__ ) ); + wp_enqueue_style( + 'widget-jetpack-search-filters', + plugins_url( 'search/css/search-widget-admin-ui.css', __FILE__ ), + array(), + JETPACK__VERSION + ); // Register jp-tracks and jp-tracks-functions. Tracking::register_tracks_functions_scripts(); @@ -133,7 +143,8 @@ public function widget_admin_setup() { 'jetpack-search-widget-admin', plugins_url( 'search/js/search-widget-admin.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable', 'jp-tracks-functions' ), - JETPACK__VERSION + JETPACK__VERSION, + false ); wp_localize_script( @@ -175,7 +186,12 @@ public function enqueue_frontend_scripts() { true ); - wp_enqueue_style( 'jetpack-search-widget', plugins_url( 'search/css/search-widget-frontend.css', __FILE__ ) ); + wp_enqueue_style( + 'jetpack-search-widget', + plugins_url( 'search/css/search-widget-frontend.css', __FILE__ ), + array(), + JETPACK__VERSION + ); } /** @@ -204,8 +220,8 @@ private function get_sort_types() { * * @return bool Whether the current filter item is for the current widget. */ - function is_for_current_widget( $item ) { - return isset( $item['widget_id'] ) && $this->id == $item['widget_id']; + public function is_for_current_widget( $item ) { + return isset( $item['widget_id'] ) && $this->id == $item['widget_id']; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison } /** @@ -221,12 +237,12 @@ function is_for_current_widget( $item ) { public function should_display_sitewide_filters() { $filter_widgets = get_option( 'widget_jetpack-search-filters' ); - // This shouldn't be empty, but just for sanity + // This shouldn't be empty, but just for sanity. if ( empty( $filter_widgets ) ) { return false; } - // If any widget has any filters, return false + // If any widget has any filters, return false. foreach ( $filter_widgets as $number => $widget ) { $widget_id = sprintf( '%s-%d', $this->id_base, $number ); if ( ! empty( $widget['filters'] ) && is_active_widget( false, $widget_id, $this->id_base ) ) { @@ -237,6 +253,11 @@ public function should_display_sitewide_filters() { return true; } + /** + * Widget defaults. + * + * @param array $instance Previously saved values from database. + */ public function jetpack_search_populate_defaults( $instance ) { $instance = wp_parse_args( (array) $instance, @@ -601,6 +622,7 @@ private function maybe_render_sort_javascript( $instance, $order, $orderby ) { * @return array Order by and order. */ private function sorting_to_wp_query_param( $sort ) { + // phpcs:disable WordPress.Security.NonceVerification.Recommended $parts = explode( '|', $sort ); $orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] @@ -610,6 +632,8 @@ private function sorting_to_wp_query_param( $sort ) { ? strtoupper( $_GET['order'] ) : ( ( isset( $parts[1] ) && 'ASC' === strtoupper( $parts[1] ) ) ? 'ASC' : 'DESC' ); + // phpcs:enable WordPress.Security.NonceVerification.Recommended + return array( $orderby, $order ); } @@ -623,7 +647,7 @@ private function sorting_to_wp_query_param( $sort ) { * * @return array Settings to save. */ - public function update( $new_instance, $old_instance ) { + public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $new_instance = $this->maybe_reformat_widget( $new_instance ); $instance = array(); @@ -718,7 +742,7 @@ public function form( $instance ) { $instance = $this->jetpack_search_populate_defaults( $instance ); - $title = strip_tags( $instance['title'] ); + $title = wp_strip_all_tags( $instance['title'] ); $hide_filters = Helper::are_filters_by_widget_disabled(); @@ -776,7 +800,7 @@ class="jetpack-search-filters-widget__sort-controls-enabled" type="checkbox" value="name ); ?>" name="get_field_name( 'post_types' ) ); ?>[]" - name, $instance['post_types'] ) ); ?> + name, $instance['post_types'], true ) ); ?> />  label ); ?> @@ -800,7 +824,9 @@ class="widefat jetpack-search-filters-widget__sort-order">
    @@ -893,7 +919,7 @@ class="widefat" * @param bool $is_template Whether this is for an Underscore template or not. */ private function render_widget_attr( $name, $value, $is_template ) { - echo $is_template ? "<%= $name %>" : esc_attr( $value ); + echo $is_template ? "<%= $name %>" : esc_attr( $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** @@ -910,7 +936,7 @@ private function render_widget_attr( $name, $value, $is_template ) { */ private function render_widget_option_selected( $name, $value, $compare, $is_template ) { $compare_js = rawurlencode( $compare ); - echo $is_template ? "<%= decodeURIComponent( '$compare_js' ) === $name ? 'selected=\"selected\"' : '' %>" : selected( $value, $compare ); + echo $is_template ? "<%= decodeURIComponent( '$compare_js' ) === $name ? 'selected=\"selected\"' : '' %>" : selected( $value, $compare ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** @@ -968,7 +994,7 @@ public function render_widget_edit_filter( $filter, $is_template = false ) { true ), 'objects' ) as $taxonomy ) : ?>