From aac23afd5ecc516e8d366b1fcf207d78c27396a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:45:12 +0300 Subject: [PATCH 1/7] chore(deps-dev): Bump lint-staged from 15.2.7 to 15.2.8 (#5774) Bumps [lint-staged](https://github.com/lint-staged/lint-staged) from 15.2.7 to 15.2.8. - [Release notes](https://github.com/lint-staged/lint-staged/releases) - [Changelog](https://github.com/lint-staged/lint-staged/blob/master/CHANGELOG.md) - [Commits](https://github.com/lint-staged/lint-staged/compare/v15.2.7...v15.2.8) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 159 +++++++++++++++++++++++++++------------------- 1 file changed, 94 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3bd92ec0a8..51284a8d86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9907,6 +9907,18 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/environment": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", + "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -15554,9 +15566,9 @@ } }, "node_modules/lilconfig": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.1.tgz", - "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.2.tgz", + "integrity": "sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==", "dev": true, "engines": { "node": ">=14" @@ -15580,21 +15592,21 @@ } }, "node_modules/lint-staged": { - "version": "15.2.7", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.7.tgz", - "integrity": "sha512-+FdVbbCZ+yoh7E/RosSdqKJyUM2OEjTciH0TFNkawKgvFp1zbGlEC39RADg+xKBG1R4mhoH2j85myBQZ5wR+lw==", + "version": "15.2.8", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.8.tgz", + "integrity": "sha512-PUWFf2zQzsd9EFU+kM1d7UP+AZDbKFKuj+9JNVTBkhUFhbg4MAt6WfyMMwBfM4lYqd4D2Jwac5iuTu9rVj4zCQ==", "dev": true, "dependencies": { "chalk": "~5.3.0", "commander": "~12.1.0", - "debug": "~4.3.4", + "debug": "~4.3.6", "execa": "~8.0.1", - "lilconfig": "~3.1.1", - "listr2": "~8.2.1", + "lilconfig": "~3.1.2", + "listr2": "~8.2.4", "micromatch": "~4.0.7", "pidtree": "~0.6.0", "string-argv": "~0.3.2", - "yaml": "~2.4.2" + "yaml": "~2.5.0" }, "bin": { "lint-staged": "bin/lint-staged.js" @@ -15607,12 +15619,15 @@ } }, "node_modules/lint-staged/node_modules/ansi-escapes": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-6.2.1.tgz", - "integrity": "sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.0.0.tgz", + "integrity": "sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==", "dev": true, + "dependencies": { + "environment": "^1.0.0" + }, "engines": { - "node": ">=14.16" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -15655,15 +15670,15 @@ } }, "node_modules/lint-staged/node_modules/cli-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", - "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", + "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", "dev": true, "dependencies": { - "restore-cursor": "^4.0.0" + "restore-cursor": "^5.0.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -15694,6 +15709,23 @@ "node": ">=18" } }, + "node_modules/lint-staged/node_modules/debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/lint-staged/node_modules/emoji-regex": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.3.0.tgz", @@ -15775,16 +15807,16 @@ } }, "node_modules/lint-staged/node_modules/listr2": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.1.tgz", - "integrity": "sha512-irTfvpib/rNiD637xeevjO2l3Z5loZmuaRi0L0YE5LfijwVY96oyVn0DFD3o/teAok7nfobMG1THvvcHh/BP6g==", + "version": "8.2.4", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.4.tgz", + "integrity": "sha512-opevsywziHd3zHCVQGAj8zu+Z3yHNkkoYhWIGnq54RrCVwLz0MozotJEDnKsIBLvkfLGN6BLOyAeRrYI0pKA4g==", "dev": true, "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", - "log-update": "^6.0.0", - "rfdc": "^1.3.1", + "log-update": "^6.1.0", + "rfdc": "^1.4.1", "wrap-ansi": "^9.0.0" }, "engines": { @@ -15792,14 +15824,14 @@ } }, "node_modules/lint-staged/node_modules/log-update": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.0.0.tgz", - "integrity": "sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", + "integrity": "sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==", "dev": true, "dependencies": { - "ansi-escapes": "^6.2.0", - "cli-cursor": "^4.0.0", - "slice-ansi": "^7.0.0", + "ansi-escapes": "^7.0.0", + "cli-cursor": "^5.0.0", + "slice-ansi": "^7.1.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" }, @@ -15896,51 +15928,36 @@ } }, "node_modules/lint-staged/node_modules/restore-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", - "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", + "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", "dev": true, "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" + "onetime": "^7.0.0", + "signal-exit": "^4.1.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lint-staged/node_modules/restore-cursor/node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/lint-staged/node_modules/restore-cursor/node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", + "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", "dev": true, "dependencies": { - "mimic-fn": "^2.1.0" + "mimic-function": "^5.0.0" }, "engines": { - "node": ">=6" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lint-staged/node_modules/restore-cursor/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, "node_modules/lint-staged/node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", @@ -15970,9 +15987,9 @@ } }, "node_modules/lint-staged/node_modules/string-width": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.1.0.tgz", - "integrity": "sha512-SEIJCWiX7Kg4c129n48aDRwLbFb2LJmXXFrWBG4NGaRtMQ3myKPKbwrD1BKqQn74oCoNMBVrfDEr5M9YxCsrkw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", "dev": true, "dependencies": { "emoji-regex": "^10.3.0", @@ -16784,6 +16801,18 @@ "node": ">=6" } }, + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -20750,9 +20779,9 @@ } }, "node_modules/rfdc": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.1.tgz", - "integrity": "sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", "dev": true }, "node_modules/rimraf": { @@ -24075,9 +24104,9 @@ "dev": true }, "node_modules/yaml": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", - "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", "dev": true, "bin": { "yaml": "bin.mjs" From bc4fffe4aa41028887d0dec2c57b8e74d611bef1 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 6 Aug 2024 18:57:57 +0100 Subject: [PATCH 2/7] WP Parse.ly: Allow VIP Support to access PCH features (#5765) * Add filter to `wp_parsely_current_user_can_use_pch_feature` to allow `vip_support` users to access PCH * Fix linting * Change filter priority to 999 Co-authored-by: Rebecca Hum --------- Co-authored-by: Rebecca Hum --- vip-parsely/vip-parsely.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vip-parsely/vip-parsely.php b/vip-parsely/vip-parsely.php index 1615e68356..45c36324a7 100644 --- a/vip-parsely/vip-parsely.php +++ b/vip-parsely/vip-parsely.php @@ -76,3 +76,22 @@ function (): void { } ); } + +/** + * Allows VIP Support users to use the Parse.ly Content Helper feature. + * + * @param bool $current_user_can_use_pch_feature Whether the current user can use the Parse.ly Content Helper feature. + * @param string $feature_name The name of the feature. + * @param WP_User $current_user The current user. + * + * @return bool Whether the current user can use the Parse.ly Content Helper feature. + */ +add_filter( 'wp_parsely_current_user_can_use_pch_feature', function ( $current_user_can_use_pch_feature, $feature_name, $current_user ) { + $user_id = $current_user->ID; + + if ( user_can( $user_id, 'vip_support' ) ) { + return true; + } + + return $current_user_can_use_pch_feature; +}, 999, 3 ); From 44e6293555331be77646e30ee2df97c961fcd34c Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Tue, 6 Aug 2024 22:01:00 +0300 Subject: [PATCH 3/7] test(e2e): add tests for `login-error.php` (#5777) --- __tests__/e2e/lib/pages/wp-login-page.ts | 24 +++++++++++++++++++++ __tests__/e2e/specs/security.spec.ts | 27 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/__tests__/e2e/lib/pages/wp-login-page.ts b/__tests__/e2e/lib/pages/wp-login-page.ts index a39331e39c..8cfccef395 100644 --- a/__tests__/e2e/lib/pages/wp-login-page.ts +++ b/__tests__/e2e/lib/pages/wp-login-page.ts @@ -3,8 +3,10 @@ import type { Page } from '@playwright/test'; const selectors = { userField: '#user_login', passwordField: '#user_pass', + rememberMeField: 'input#rememberme', submitButton: '#wp-submit', lostPasswordLink: '#nav a[href*="wp-login.php?action=lostpassword"]', + loginErrorBlock: 'div#login_error', }; export class LoginPage { @@ -38,10 +40,32 @@ export class LoginPage { return Promise.all( [ this.page.waitForURL( '**/wp-admin/**' ), this.page.click( selectors.submitButton ) ] ); } + public async loginEx( login: string, password: string, rememberMe: boolean ): Promise { + await this.page.locator( selectors.userField ).fill( login ); + await this.page.locator( selectors.passwordField ).fill( password ); + if ( rememberMe ) { + await this.page.locator( selectors.rememberMeField ).check(); + } else { + await this.page.locator( selectors.rememberMeField ).uncheck(); + } + + await this.page.click( selectors.submitButton ); + return this.page.waitForLoadState( 'load' ); + } + public lostPassword(): Promise { return Promise.all( [ this.page.waitForURL( /\/wp-login\.php\?action=lostpassword/ ), this.page.locator( selectors.lostPasswordLink ).click(), ] ); } + + public async getLoginError(): Promise { + const locator = this.page.locator( selectors.loginErrorBlock ); + if ( await locator.count() > 0 ) { + return locator.textContent(); + } + + return null; + } } diff --git a/__tests__/e2e/specs/security.spec.ts b/__tests__/e2e/specs/security.spec.ts index 9f01048903..29af559ab7 100644 --- a/__tests__/e2e/specs/security.spec.ts +++ b/__tests__/e2e/specs/security.spec.ts @@ -3,6 +3,9 @@ import { expect, test } from '@playwright/test'; import { LostPasswordPage } from '../lib/pages/lost-password-page'; import { LoginPage } from '../lib/pages/wp-login-page'; +const genericLoginError = 'Error: The username/email address or password is incorrect'; +const resetConfirmation = 'If there is an account associated with the username/email address, you will receive an email with a link to reset your password.'; + test.describe( 'Security', () => { test.beforeEach( async ( { page, context } ) => { await context.clearCookies(); @@ -18,6 +21,8 @@ test.describe( 'Security', () => { expect( response.status() ).toBe( 200 ); expect( response.url() ).toContain( '/wp-login.php?checkemail=confirm' ); + + await expect( page.locator( '#login .message' ) ).toHaveText( resetConfirmation ); } ); test( 'Reset password for existing non-existing user', async ( { page } ) => { @@ -29,5 +34,27 @@ test.describe( 'Security', () => { expect( response.status() ).toBe( 200 ); expect( response.url() ).toContain( '/wp-login.php?checkemail=confirm' ); + + await expect( page.locator( '#login .message' ) ).toHaveText( resetConfirmation ); + } ); + + test( 'Login with incorrect password', async ( { page } ) => { + const loginPage = new LoginPage( page ); + await loginPage.loginEx( process.env.E2E_USER!, 'bad-password', false ); + + expect( page.url() ).toContain( '/wp-login.php' ); + + const loginError = await loginPage.getLoginError(); + expect( loginError ).toContain( genericLoginError ); + } ); + + test( 'Login with incorrect credentials', async ( { page } ) => { + const loginPage = new LoginPage( page ); + await loginPage.loginEx( 'no-such-user', 'bad-password', false ); + + expect( page.url() ).toContain( '/wp-login.php' ); + + const loginError = await loginPage.getLoginError(); + expect( loginError ).toContain( genericLoginError ); } ); } ); From 4d236a4d90a6e6e58dffb8899b9a494813585f46 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Wed, 7 Aug 2024 15:00:36 -0600 Subject: [PATCH 4/7] Update block data API to 1.3 (#5780) --- integrations/block-data-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/block-data-api.php b/integrations/block-data-api.php index 15f81fd5a8..ad863ba23b 100644 --- a/integrations/block-data-api.php +++ b/integrations/block-data-api.php @@ -20,7 +20,7 @@ class BlockDataApiIntegration extends Integration { * * @var string */ - protected string $version = '1.2'; + protected string $version = '1.3'; /** * Returns `true` if `Block Data API` is already available e.g. via customer code. We will use From 6b8cbb9dd88df6c2ff25692cd17b084b99ca5c27 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 8 Aug 2024 14:14:34 +0100 Subject: [PATCH 5/7] Update wp-parsely submodule to version 3.16.3 (#5781) --- wp-parsely | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-parsely b/wp-parsely index 0e44216f8e..5c89a4fd4f 160000 --- a/wp-parsely +++ b/wp-parsely @@ -1 +1 @@ -Subproject commit 0e44216f8e2b9668b9cccd5ee80c5e815788cc38 +Subproject commit 5c89a4fd4f84b180052715710a0a4e8b720e6f08 From 861d8aac122dcc5fe546b4a5042e87e1b4d7afff Mon Sep 17 00:00:00 2001 From: Rebecca Hum Date: Tue, 13 Aug 2024 14:24:38 -0600 Subject: [PATCH 6/7] WP-admin Support Contact Form: Fix being able to send to ZD from outside mapped domain (#5794) --- vip-dashboard/vip-dashboard.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/vip-dashboard/vip-dashboard.php b/vip-dashboard/vip-dashboard.php index 38f5d24afc..4f1815caa0 100644 --- a/vip-dashboard/vip-dashboard.php +++ b/vip-dashboard/vip-dashboard.php @@ -12,6 +12,8 @@ * Domain Path: /languages/ */ +const VIP_SUPPORT_EMAIL = 'support@wpvip.com'; + /** * Boot the new VIP Dashboard * @@ -97,7 +99,6 @@ function vip_contact_form_handler() { die(); } - $vipsupportemailaddy = 'vip-support@wordpress.com'; $cc_headers_to_kayako = ''; $current_user = wp_get_current_user(); @@ -177,16 +178,18 @@ function vip_contact_form_handler() { // Filter from name/email. NOTE - not un-hooking the filter because we die() immediately after wp_mail() add_filter( 'wp_mail_from', function () use ( $email ) { - return $email; + return VIP_SUPPORT_EMAIL; }, PHP_INT_MAX ); add_filter( 'wp_mail_from_name', function () use ( $name ) { return $name; }, PHP_INT_MAX ); - $headers = "From: \"$name\" <$email>\r\n"; + $headers = "From: \"$name\" <" . VIP_SUPPORT_EMAIL . ">\r\n"; + $headers .= "Reply-To: $email\r\n"; // Add the Reply-To header so ZD can map correct email + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_mail_wp_mail - if ( wp_mail( $vipsupportemailaddy, $subject, $content, $headers . $cc_headers_to_kayako ) ) { + if ( wp_mail( VIP_SUPPORT_EMAIL, $subject, $content, $headers . $cc_headers_to_kayako ) ) { $return = array( 'status' => 'success', 'message' => __( 'Your support request is on its way, we will be in touch soon.', 'vip-dashboard' ), @@ -247,7 +250,7 @@ function vip_echo_mailto_vip_hosting( $linktext = 'Send an email to VIP Hosting. $url = add_query_arg( array( 'subject' => rawurlencode( __( 'Descriptive subject please', 'vip-dashboard' ) ), 'body' => rawurlencode( $email ), - ), 'mailto:vip-support@wordpress.com' ); + ), 'mailto:' . VIP_SUPPORT_EMAIL ); $html = '' . esc_html( $linktext ) . ''; From a90ce81cb0e23af4d144e093e64bdb1e742ad3ff Mon Sep 17 00:00:00 2001 From: Rebecca Hum Date: Wed, 14 Aug 2024 14:56:11 -0600 Subject: [PATCH 7/7] ACL: Default to restricting all on non-prod if ACL is enabled but no options are set (#5796) --- files/acl/acl.php | 24 ++++++++++++++++++------ tests/files/acl/test-acl.php | 6 +++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/files/acl/acl.php b/files/acl/acl.php index 4d177e706c..c61de59136 100644 --- a/files/acl/acl.php +++ b/files/acl/acl.php @@ -18,8 +18,9 @@ function maybe_load_restrictions() { $is_files_acl_enabled = defined( 'VIP_FILES_ACL_ENABLED' ) && true === constant( 'VIP_FILES_ACL_ENABLED' ); - $is_restrict_all_enabled = get_option_as_bool( 'vip_files_acl_restrict_all_enabled' ); - $is_restrict_unpublished_enabled = get_option_as_bool( 'vip_files_acl_restrict_unpublished_enabled' ); + $is_restrict_all_enabled = get_option_as_bool_if_exists( 'vip_files_acl_restrict_all_enabled' ); + $is_restrict_unpublished_enabled = get_option_as_bool_if_exists( 'vip_files_acl_restrict_unpublished_enabled' ); + $no_option_set = null === $is_restrict_all_enabled && null === $is_restrict_unpublished_enabled; if ( ! $is_files_acl_enabled ) { // Throw warning if restrictions are enabled but ACL constant is not set. @@ -32,11 +33,11 @@ function maybe_load_restrictions() { return; } - if ( $is_restrict_all_enabled ) { + if ( true === $is_restrict_all_enabled || ( $no_option_set && ( defined( 'VIP_GO_ENV' ) && 'production' !== VIP_GO_ENV ) ) ) { require_once __DIR__ . '/restrict-all-files.php'; add_filter( 'vip_files_acl_file_visibility', __NAMESPACE__ . '\Restrict_All_Files\check_file_visibility', 10, 2 ); - } elseif ( $is_restrict_unpublished_enabled ) { + } elseif ( true === $is_restrict_unpublished_enabled ) { require_once __DIR__ . '/restrict-unpublished-files.php'; add_filter( 'vip_files_acl_file_visibility', __NAMESPACE__ . '\Restrict_Unpublished_Files\check_file_visibility', 10, 2 ); @@ -45,8 +46,19 @@ function maybe_load_restrictions() { } } -function get_option_as_bool( $option_name ) { - $value = get_option( $option_name, false ); +/** + * Get an option as a boolean if it exists. If it does not exist, return null. + * + * @param string $option_name The name of the option to get. + * + * @return boolean|null The option value as a boolean, or null if the option does not exist. + */ +function get_option_as_bool_if_exists( $option_name ) { + $value = get_option( $option_name, null ); + + if ( null === $value ) { + return $value; + } return in_array( $value, [ true, diff --git a/tests/files/acl/test-acl.php b/tests/files/acl/test-acl.php index 156479154d..e2948cc90c 100644 --- a/tests/files/acl/test-acl.php +++ b/tests/files/acl/test-acl.php @@ -111,9 +111,9 @@ public function test__maybe_load_restrictions__constant_and_restrict_unpublished } public function test__get_option_as_bool__option_not_exists() { - $actual_value = get_option_as_bool( 'my_test_get_option_as_bool_option_not_exists' ); + $actual_value = get_option_as_bool_if_exists( 'my_test_get_option_as_bool_option_not_exists' ); - $this->assertEquals( false, $actual_value ); + $this->assertEquals( null, $actual_value ); } public function data_provider__get_option_as_bool__option_exists() { @@ -166,7 +166,7 @@ public function data_provider__get_option_as_bool__option_exists() { public function test__get_option_as_bool__option_exists( $option_value, $expected_value ) { update_option( 'my_test_get_option_as_bool_option', $option_value ); - $actual_value = get_option_as_bool( 'my_test_get_option_as_bool_option' ); + $actual_value = get_option_as_bool_if_exists( 'my_test_get_option_as_bool_option' ); $this->assertEquals( $expected_value, $actual_value ); }