From bbd7bd7c52b99e6f2131607c5c3041a8f7017e54 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Thu, 6 Jul 2023 14:53:34 +0530 Subject: [PATCH 01/28] Update release date of 2.1.0 --- CHANGELOG.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05491f0e..130e8ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] - TBD -## [2.1.0] - 2023-07-05 +## [2.1.0] - 2023-07-06 ### Added - Support for tweeting via multiple Twitter accounts (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@Sidsector9](https://github.com/Sidsector9) via [#238](https://github.com/10up/autoshare-for-twitter/pull/238)). - Obfuscation of saved Twitter keys in the UI (props [@lgrzegorski](https://github.com/lgrzegorski), [@bmarshall511](https://github.com/bmarshall511), [@iamdharmesh](https://github.com/iamdharmesh) via [#245](https://github.com/10up/autoshare-for-twitter/pull/245)). diff --git a/readme.txt b/readme.txt index 46d1ca63..c3024168 100644 --- a/readme.txt +++ b/readme.txt @@ -110,7 +110,7 @@ To avoid encountering this error in the future and to have higher usage limits, 4. Autoshare for Twitter Settings, found under `Settings` > `Autoshare for Twitter`. == Changelog == -= 2.1.0 - 2023-07-05 = += 2.1.0 - 2023-07-06 = * **Added:** Support for tweeting via multiple Twitter accounts (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@Sidsector9](https://github.com/Sidsector9) via [#238](https://github.com/10up/autoshare-for-twitter/pull/238)). * **Added:** Obfuscation of saved Twitter keys in the UI (props [@lgrzegorski](https://github.com/lgrzegorski), [@bmarshall511](https://github.com/bmarshall511), [@iamdharmesh](https://github.com/iamdharmesh) via [#245](https://github.com/10up/autoshare-for-twitter/pull/245)). * **Added:** GitHub Action summary for end-to-end tests (props [@iamdharmesh](https://github.com/iamdharmesh), [@ravinderk](https://github.com/ravinderk) via [#247](https://github.com/10up/autoshare-for-twitter/pull/247)). From 867a2435e76849ba9d2a0c4419a42764e0065887 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 14 Jul 2023 20:09:38 +0530 Subject: [PATCH 02/28] Fix setup instructions. --- includes/admin/settings.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/admin/settings.php b/includes/admin/settings.php index ce8660a4..787f34db 100644 --- a/includes/admin/settings.php +++ b/includes/admin/settings.php @@ -381,10 +381,8 @@ function cred_section_cb() { ?>
  • -
  • Generate button in the API Key and Secret section.', 'autoshare-for-twitter' ) ); ?>
  • +
  • Generate/Regenerate button in the Consumer Keys section.', 'autoshare-for-twitter' ) ); ?>
  • API Key and API Key Secret values and paste them below.', 'autoshare-for-twitter' ) ); ?>
  • -
  • Generate button in the Access Token and Secret section.', 'autoshare-for-twitter' ) ); ?>
  • -
  • Access Token and Access Token Secret values and paste them below.', 'autoshare-for-twitter' ) ); ?>
  • From c68f98b18a987c1c0ee5d983177ba227a14db93d Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 14 Jul 2023 20:10:10 +0530 Subject: [PATCH 03/28] Provider Error message from Twitter if it is available. --- includes/class-twitter-api.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/includes/class-twitter-api.php b/includes/class-twitter-api.php index f1e91fba..68b9eaa0 100644 --- a/includes/class-twitter-api.php +++ b/includes/class-twitter-api.php @@ -44,13 +44,6 @@ class Twitter_API { */ protected $access_token_secret; - /** - * The twitter handle. - * - * @var string The twitter handle. - */ - protected $twitter_handle; - /** * The TwitterOAuth client. * @@ -172,6 +165,9 @@ public function get_current_account() { ); if ( ! $user || ! isset( $user->data ) || ! isset( $user->data->id ) ) { + if ( ! empty( $user->detail ) ) { + return new \WP_Error( 'error_get_twitter_user', $user->detail ); + } return new \WP_Error( 'error_get_twitter_user', __( 'Something went wrong during getting user details', 'autoshare-for-twitter' ) ); } From 6fb5255415c213cf0037cd5c5f92f4f69376a3be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 01:22:13 +0000 Subject: [PATCH 04/28] Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 86a88df1..153696c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16572,9 +16572,9 @@ "dev": true }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -29441,9 +29441,9 @@ "dev": true }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true }, "workerpool": { From 81f3aea13bac078e0e3684788c7e3dd8a0d6a5ec Mon Sep 17 00:00:00 2001 From: Rahul Prajapati Date: Thu, 20 Jul 2023 17:27:14 +0530 Subject: [PATCH 05/28] Add PHP version check for plugin. --- autoshare-for-twitter.php | 51 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/autoshare-for-twitter.php b/autoshare-for-twitter.php index ee8c4e84..9788e0a1 100644 --- a/autoshare-for-twitter.php +++ b/autoshare-for-twitter.php @@ -3,7 +3,7 @@ * Plugin Name: Autoshare for Twitter * Description: Automatically tweets the post title or custom message and a link to the post. * Disclaimer: TWITTER, TWEET, RETWEET and the Twitter logo are trademarks of Twitter, Inc. or its affiliates. - * Version: 2.1.0 + * Version: 2.1.1 * Requires at least: 5.7 * Requires PHP: 7.4 * Author: 10up @@ -20,11 +20,58 @@ } define( 'AUTOSHARE_FOR_TWITTER', __FILE__ ); -define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.0' ); +define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.1' ); define( 'AUTOSHARE_FOR_TWITTER_URL', plugin_dir_url( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_PATH', plugin_dir_path( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_INC', AUTOSHARE_FOR_TWITTER_PATH . 'includes/' ); +/** + * Get the minimum version of PHP required by this plugin. + * + * @since 2.1.1 + * + * @return string Minimum version required. + */ +function minimum_php_requirement() { + return '7.4'; +} + +/** + * Whether PHP installation meets the minimum requirements + * + * @since 2.1.1 + * + * @return bool True if meets minimum requirements, false otherwise. + */ +function site_meets_php_requirements() { + return version_compare( phpversion(), minimum_php_requirement(), '>=' ); +} + +// Ensuring our PHP version requirement is met first before loading plugin. +if ( ! site_meets_php_requirements() ) { + add_action( + 'admin_notices', + function() { + ?> +
    +

    + +

    +
    + Date: Fri, 28 Jul 2023 17:52:48 +0530 Subject: [PATCH 06/28] Revert version change and add namespace for plugin file. --- autoshare-for-twitter.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/autoshare-for-twitter.php b/autoshare-for-twitter.php index 9788e0a1..19575f67 100644 --- a/autoshare-for-twitter.php +++ b/autoshare-for-twitter.php @@ -3,7 +3,7 @@ * Plugin Name: Autoshare for Twitter * Description: Automatically tweets the post title or custom message and a link to the post. * Disclaimer: TWITTER, TWEET, RETWEET and the Twitter logo are trademarks of Twitter, Inc. or its affiliates. - * Version: 2.1.1 + * Version: 2.1.0 * Requires at least: 5.7 * Requires PHP: 7.4 * Author: 10up @@ -15,12 +15,14 @@ * @package TenUp\AutoshareForTwitter */ +namespace TenUp\AutoshareForTwitter; + if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } define( 'AUTOSHARE_FOR_TWITTER', __FILE__ ); -define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.1' ); +define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.0' ); define( 'AUTOSHARE_FOR_TWITTER_URL', plugin_dir_url( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_PATH', plugin_dir_path( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_INC', AUTOSHARE_FOR_TWITTER_PATH . 'includes/' ); @@ -28,8 +30,6 @@ /** * Get the minimum version of PHP required by this plugin. * - * @since 2.1.1 - * * @return string Minimum version required. */ function minimum_php_requirement() { @@ -39,8 +39,6 @@ function minimum_php_requirement() { /** * Whether PHP installation meets the minimum requirements * - * @since 2.1.1 - * * @return bool True if meets minimum requirements, false otherwise. */ function site_meets_php_requirements() { From aaad2d3d38502624a26cd62af6b576b6a2a834b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Fri, 4 Aug 2023 06:22:25 -0500 Subject: [PATCH 07/28] Update and rename .github/workflows/wordpress-latest.yml to .github/workflows/.github/workflows/wordpress-version-checker.yml --- .../workflows/wordpress-version-checker.yml} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename .github/workflows/{wordpress-latest.yml => .github/workflows/wordpress-version-checker.yml} (80%) diff --git a/.github/workflows/wordpress-latest.yml b/.github/workflows/.github/workflows/wordpress-version-checker.yml similarity index 80% rename from .github/workflows/wordpress-latest.yml rename to .github/workflows/.github/workflows/wordpress-version-checker.yml index b134ea59..34e44107 100644 --- a/.github/workflows/wordpress-latest.yml +++ b/.github/workflows/.github/workflows/wordpress-version-checker.yml @@ -10,11 +10,14 @@ on: schedule: - cron: '0 0 * * 1' +permissions: + issues: write + jobs: wordpress-version-checker: runs-on: ubuntu-latest steps: - name: WordPress version checker - uses: skaut/wordpress-version-checker@v1.2.0 + uses: skaut/wordpress-version-checker@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} From 1e933a6ed51b4c4163c789d88007f6556bccf02d Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Fri, 4 Aug 2023 06:22:59 -0500 Subject: [PATCH 08/28] Create .wordpress-version-checker.json --- .wordpress-version-checker.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .wordpress-version-checker.json diff --git a/.wordpress-version-checker.json b/.wordpress-version-checker.json new file mode 100644 index 00000000..b20af627 --- /dev/null +++ b/.wordpress-version-checker.json @@ -0,0 +1,3 @@ +{ + "channel": "rc" +} From 5e266c2f3f904a2a4a37d78a50885dacca157c78 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Fri, 4 Aug 2023 06:23:23 -0500 Subject: [PATCH 09/28] Update .distignore --- .distignore | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.distignore b/.distignore index 4eb6476a..45fc7d69 100644 --- a/.distignore +++ b/.distignore @@ -9,11 +9,7 @@ # DO NOT EXCLUDE /vendor # Files -.babelrc -.distignore -.eslintignore -.eslintrc.json -.gitignore +.* CHANGELOG.md CODE_OF_CONDUCT.md composer.json @@ -28,5 +24,3 @@ phpunit.xml README.md webpack.config.js webpack.gutenberg.config.js -.wp-env.json -.nvmrc From c8c5f51e2406103653ea6998a7c7ca5e18219140 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Fri, 4 Aug 2023 06:24:18 -0500 Subject: [PATCH 10/28] Rename .github/workflows/.github/workflows/wordpress-version-checker.yml to .github/workflows/wordpress-version-checker.yml --- .../{.github/workflows => }/wordpress-version-checker.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{.github/workflows => }/wordpress-version-checker.yml (100%) diff --git a/.github/workflows/.github/workflows/wordpress-version-checker.yml b/.github/workflows/wordpress-version-checker.yml similarity index 100% rename from .github/workflows/.github/workflows/wordpress-version-checker.yml rename to .github/workflows/wordpress-version-checker.yml From 643a7470c204306987a805d4a1094b7836cb9891 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 11:39:26 +0530 Subject: [PATCH 11/28] Fix Block editor test failure issue. --- package.json | 1 + tests/bin/initialize.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 54f713af..afbc1466 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "env": "wp-env", "env:start": "wp-env start", "env:stop": "wp-env stop", + "env:destroy": "wp-env destroy", "postenv:start": "./tests/bin/initialize.sh", "cypress:open": "cypress open --config-file tests/cypress/cypress.config.js --e2e --browser chrome", "cypress:run": "cypress run --config-file tests/cypress/cypress.config.js", diff --git a/tests/bin/initialize.sh b/tests/bin/initialize.sh index 9d06a85b..7e4d4dda 100755 --- a/tests/bin/initialize.sh +++ b/tests/bin/initialize.sh @@ -1,3 +1,4 @@ #!/bin/bash npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" +npm run env run tests-cli "wp user meta update 1 enable_custom_fields 1" \ No newline at end of file From e500730c9bdc0c7d9ea3910c44be06ab8cbf6a6e Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 11:46:42 +0530 Subject: [PATCH 12/28] Run E2E on every PR. --- .github/workflows/cypress.yml | 4 ---- tests/bin/initialize.sh | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 86a59515..28449559 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -8,10 +8,6 @@ on: pull_request: branches: - develop - paths: - - '**.js' - - '**.php' - - '**.css' jobs: build: diff --git a/tests/bin/initialize.sh b/tests/bin/initialize.sh index 7e4d4dda..85b34a59 100755 --- a/tests/bin/initialize.sh +++ b/tests/bin/initialize.sh @@ -1,4 +1,4 @@ #!/bin/bash npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" -npm run env run tests-cli "wp user meta update 1 enable_custom_fields 1" \ No newline at end of file +npm run env run tests-cli "wp user meta update 1 enable_custom_fields 1" From 6754b541ad8402f0be7e91c20ae2c86f982f168a Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 15:40:32 +0530 Subject: [PATCH 13/28] Fix WP 6.3 issue. --- package-lock.json | 38 +++++++++++++++++++++++++++++++ package.json | 1 + tests/bin/initialize.sh | 1 - tests/cypress/cypress.config.js | 1 + tests/cypress/support/commands.js | 31 +++++++++++++++++++++++-- tests/cypress/support/e2e.js | 1 + 6 files changed, 70 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 153696c5..13a98173 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "babel-eslint": "^10.0.3", "babel-loader": "^8.0.6", "cypress": "^11.2.0", + "cypress-iframe": "^1.0.1", "cypress-mochawesome-reporter": "^3.5.1", "eslint": "^6.3.0", "husky": "^3.0.5", @@ -3745,6 +3746,17 @@ "@types/responselike": "*" } }, + "node_modules/@types/cypress": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/cypress/-/cypress-1.1.3.tgz", + "integrity": "sha512-OXe0Gw8LeCflkG1oPgFpyrYWJmEKqYncBsD/J0r17r0ETx/TnIGDNLwXt/pFYSYuYTpzcq1q3g62M9DrfsBL4g==", + "deprecated": "This is a stub types definition for cypress (https://cypress.io). cypress provides its own type definitions, so you don't need @types/cypress installed!", + "dev": true, + "peer": true, + "dependencies": { + "cypress": "*" + } + }, "node_modules/@types/eslint": { "version": "8.4.7", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.7.tgz", @@ -6031,6 +6043,15 @@ "node": ">=12.0.0" } }, + "node_modules/cypress-iframe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cypress-iframe/-/cypress-iframe-1.0.1.tgz", + "integrity": "sha512-Ne+xkZmWMhfq3x6wbfzK/SzsVTCrJru3R3cLXsoSAZyfUtJDamXyaIieHXeea3pQDXF4wE2w4iUuvCYHhoD31g==", + "dev": true, + "peerDependencies": { + "@types/cypress": "^1.1.0" + } + }, "node_modules/cypress-mochawesome-reporter": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/cypress-mochawesome-reporter/-/cypress-mochawesome-reporter-3.5.1.tgz", @@ -19515,6 +19536,16 @@ "@types/responselike": "*" } }, + "@types/cypress": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/cypress/-/cypress-1.1.3.tgz", + "integrity": "sha512-OXe0Gw8LeCflkG1oPgFpyrYWJmEKqYncBsD/J0r17r0ETx/TnIGDNLwXt/pFYSYuYTpzcq1q3g62M9DrfsBL4g==", + "dev": true, + "peer": true, + "requires": { + "cypress": "*" + } + }, "@types/eslint": { "version": "8.4.7", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.7.tgz", @@ -21424,6 +21455,13 @@ } } }, + "cypress-iframe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cypress-iframe/-/cypress-iframe-1.0.1.tgz", + "integrity": "sha512-Ne+xkZmWMhfq3x6wbfzK/SzsVTCrJru3R3cLXsoSAZyfUtJDamXyaIieHXeea3pQDXF4wE2w4iUuvCYHhoD31g==", + "dev": true, + "requires": {} + }, "cypress-mochawesome-reporter": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/cypress-mochawesome-reporter/-/cypress-mochawesome-reporter-3.5.1.tgz", diff --git a/package.json b/package.json index afbc1466..391c95a3 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "babel-eslint": "^10.0.3", "babel-loader": "^8.0.6", "cypress": "^11.2.0", + "cypress-iframe": "^1.0.1", "cypress-mochawesome-reporter": "^3.5.1", "eslint": "^6.3.0", "husky": "^3.0.5", diff --git a/tests/bin/initialize.sh b/tests/bin/initialize.sh index 85b34a59..9d06a85b 100755 --- a/tests/bin/initialize.sh +++ b/tests/bin/initialize.sh @@ -1,4 +1,3 @@ #!/bin/bash npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" -npm run env run tests-cli "wp user meta update 1 enable_custom_fields 1" diff --git a/tests/cypress/cypress.config.js b/tests/cypress/cypress.config.js index 0c2aae74..8d458e65 100644 --- a/tests/cypress/cypress.config.js +++ b/tests/cypress/cypress.config.js @@ -2,6 +2,7 @@ const { defineConfig } = require('cypress'); const { readConfig } = require('@wordpress/env/lib/config'); module.exports = defineConfig({ + chromeWebSecurity: false, fixturesFolder: 'tests/cypress/fixtures', screenshotsFolder: 'tests/cypress/screenshots', videosFolder: 'tests/cypress/videos', diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 2cba4c36..11c6c7b3 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -30,10 +30,13 @@ Cypress.Commands.add( 'startCreatePost', () => { const titleInput = 'h1.editor-post-title__input, #post-title-0'; // Make sure editor loaded properly. - cy.get(titleInput).should('exist'); + cy.getBlockEditor().find(titleInput).should('exist'); cy.closeWelcomeGuide(); - cy.get(titleInput).clear().type(`Random Post Title ${getRandomText(6)}`); + cy.getBlockEditor() + .find(titleInput) + .clear() + .type(`Random Post Title ${getRandomText(6)}`); }); @@ -165,3 +168,27 @@ Cypress.Commands.add( 'publishPost', () => { cy.get('[aria-disabled="false"].editor-post-publish-button').click(); cy.wait('@publishPost'); }); + +Cypress.Commands.add('getBlockEditor', () => { + cy.get('.edit-post-visual-editor').should('be.visible'); + return cy + .get('body') + .then(($body) => { + if ($body.find('iframe[name="editor-canvas"]').length) { + return cy.iframe('iframe[name="editor-canvas"]'); + } + return $body; + }) + .then(cy.wrap); +}); + +Cypress.Commands.add('closeWelcomeGuide', () => { + // Wait for edit page to load + cy.getBlockEditor(); + const closeButtonSelector = '.edit-post-welcome-guide .components-modal__header button'; + cy.get('body').then($body => { + if ($body.find(closeButtonSelector).length > 0) { + cy.get(closeButtonSelector).click(); + } + }); +}); diff --git a/tests/cypress/support/e2e.js b/tests/cypress/support/e2e.js index 2f8b8334..592aa277 100644 --- a/tests/cypress/support/e2e.js +++ b/tests/cypress/support/e2e.js @@ -1,4 +1,5 @@ import '@10up/cypress-wp-utils'; +import 'cypress-iframe'; import './commands'; beforeEach(() => { From 45ff706814e0db430ed7d8e3ac4b68077013868f Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 15:56:56 +0530 Subject: [PATCH 14/28] Updated closeWelcomeGuide. --- tests/bin/set-wp-config.js | 2 +- tests/cypress/support/commands.js | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/bin/set-wp-config.js b/tests/bin/set-wp-config.js index 9125a305..c1f438dc 100755 --- a/tests/bin/set-wp-config.js +++ b/tests/bin/set-wp-config.js @@ -4,7 +4,7 @@ const fs = require( 'fs' ); const path = `${ process.cwd() }/.wp-env.json`; -let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.', 'https://downloads.wordpress.org/plugin/classic-editor.1.6.1.zip' ] }; +let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.', 'https://downloads.wordpress.org/plugin/classic-editor.zip' ] }; const args = {}; process.argv diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 11c6c7b3..4f9b8a36 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -30,8 +30,8 @@ Cypress.Commands.add( 'startCreatePost', () => { const titleInput = 'h1.editor-post-title__input, #post-title-0'; // Make sure editor loaded properly. - cy.getBlockEditor().find(titleInput).should('exist'); cy.closeWelcomeGuide(); + cy.getBlockEditor().find(titleInput).should('exist'); cy.getBlockEditor() .find(titleInput) @@ -183,12 +183,16 @@ Cypress.Commands.add('getBlockEditor', () => { }); Cypress.Commands.add('closeWelcomeGuide', () => { - // Wait for edit page to load - cy.getBlockEditor(); - const closeButtonSelector = '.edit-post-welcome-guide .components-modal__header button'; - cy.get('body').then($body => { - if ($body.find(closeButtonSelector).length > 0) { - cy.get(closeButtonSelector).click(); - } - }); + cy.window().then((win) => { + const { wp } = win; + if ( + wp.data + .select('core/edit-post') + .isFeatureActive('welcomeGuide') + ) { + wp.data + .dispatch('core/edit-post') + .toggleFeature('welcomeGuide'); + } + }); }); From 5d8fb1e00401e6fee90912a05ed75eac54ef800a Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 18:03:52 +0530 Subject: [PATCH 15/28] Bump WordPress "tested up to" version 6.3 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index c3024168..c355b788 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: 10up, johnwatkins0, adamsilverstein, scottlee, dinhtungdu, jeffpaul, dharm1025 Tags: twitter, tweet, autoshare, auto-share, auto share, share, sharing, social media, posse Requires at least: 5.7 -Tested up to: 6.2 +Tested up to: 6.3 Requires PHP: 7.4 Stable tag: 2.1.0 License: GPL-2.0-or-later From 5314ebaec33fe3dac06d23aa8018d543e89fbe6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 13:35:20 +0000 Subject: [PATCH 16/28] Bump tough-cookie and @cypress/request Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) and [@cypress/request](https://github.com/cypress-io/request). These dependencies needed to be updated together. Updates `tough-cookie` from 2.5.0 to 4.1.3 - [Release notes](https://github.com/salesforce/tough-cookie/releases) - [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md) - [Commits](https://github.com/salesforce/tough-cookie/compare/v2.5.0...v4.1.3) Updates `@cypress/request` from 2.88.10 to 2.88.12 - [Release notes](https://github.com/cypress-io/request/releases) - [Changelog](https://github.com/cypress-io/request/blob/master/CHANGELOG.md) - [Commits](https://github.com/cypress-io/request/compare/v2.88.10...v2.88.12) --- updated-dependencies: - dependency-name: tough-cookie dependency-type: indirect - dependency-name: "@cypress/request" dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 128 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 101 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 13a98173..96df8eb6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1962,9 +1962,9 @@ } }, "node_modules/@cypress/request": { - "version": "2.88.10", - "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.10.tgz", - "integrity": "sha512-Zp7F+R93N0yZyG34GutyTNr+okam7s/Fzc1+i3kcqOP8vk6OuajuE9qZJ6Rs+10/1JFtXFYMdyarnU1rZuJesg==", + "version": "2.88.12", + "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.12.tgz", + "integrity": "sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA==", "dev": true, "dependencies": { "aws-sign2": "~0.7.0", @@ -1980,9 +1980,9 @@ "json-stringify-safe": "~5.0.1", "mime-types": "~2.1.19", "performance-now": "^2.1.0", - "qs": "~6.5.2", + "qs": "~6.10.3", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", + "tough-cookie": "^4.1.3", "tunnel-agent": "^0.6.0", "uuid": "^8.3.2" }, @@ -13756,14 +13756,26 @@ } }, "node_modules/qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz", + "integrity": "sha512-OQiU+C+Ds5qiH91qh/mg0w+8nwQuLjM4F4M/PbmhDOoYehPh+Fb0bDjtR1sOvy7YKxvj28Y/M0PhP5uVX0kB+g==", "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, "engines": { "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -14250,6 +14262,12 @@ "node": ">=0.10.5" } }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, "node_modules/resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -15858,16 +15876,27 @@ } }, "node_modules/tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", "dev": true, "dependencies": { - "psl": "^1.1.28", - "punycode": "^2.1.1" + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" }, "engines": { - "node": ">=0.8" + "node": ">=6" + } + }, + "node_modules/tough-cookie/node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" } }, "node_modules/tr46": { @@ -16157,6 +16186,16 @@ "integrity": "sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==", "deprecated": "Please see https://github.com/lydell/urix#deprecated" }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "node_modules/use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -18132,9 +18171,9 @@ "optional": true }, "@cypress/request": { - "version": "2.88.10", - "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.10.tgz", - "integrity": "sha512-Zp7F+R93N0yZyG34GutyTNr+okam7s/Fzc1+i3kcqOP8vk6OuajuE9qZJ6Rs+10/1JFtXFYMdyarnU1rZuJesg==", + "version": "2.88.12", + "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.12.tgz", + "integrity": "sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA==", "dev": true, "requires": { "aws-sign2": "~0.7.0", @@ -18150,9 +18189,9 @@ "json-stringify-safe": "~5.0.1", "mime-types": "~2.1.19", "performance-now": "^2.1.0", - "qs": "~6.5.2", + "qs": "~6.10.3", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", + "tough-cookie": "^4.1.3", "tunnel-agent": "^0.6.0", "uuid": "^8.3.2" } @@ -27293,9 +27332,18 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz", + "integrity": "sha512-OQiU+C+Ds5qiH91qh/mg0w+8nwQuLjM4F4M/PbmhDOoYehPh+Fb0bDjtR1sOvy7YKxvj28Y/M0PhP5uVX0kB+g==", + "dev": true, + "requires": { + "side-channel": "^1.0.4" + } + }, + "querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", "dev": true }, "queue-microtask": { @@ -27673,6 +27721,12 @@ "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", "dev": true }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, "resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -28931,13 +28985,23 @@ "peer": true }, "tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", "dev": true, "requires": { - "psl": "^1.1.28", - "punycode": "^2.1.1" + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "dependencies": { + "universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "dev": true + } } }, "tr46": { @@ -29154,6 +29218,16 @@ "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==" }, + "url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", From 6472e21b082c34a1c4993a4b015b9ebfec30a98b Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 19:53:59 +0530 Subject: [PATCH 17/28] Made custom tweet body persistent in Guternberg. --- includes/admin/assets.php | 2 ++ src/js/store/reducer.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/admin/assets.php b/includes/admin/assets.php index 715e7605..b77147f0 100644 --- a/includes/admin/assets.php +++ b/includes/admin/assets.php @@ -206,6 +206,7 @@ function localize_data( $handle = SCRIPT_HANDLE ) { $status_meta = get_autoshare_for_twitter_meta( $post_id, TWITTER_STATUS_KEY ); $accounts = ( new Twitter_Accounts() )->get_twitter_accounts( true ); $tweet_accounts = get_tweet_accounts( $post_id ); + $tweet_body = trim( get_autoshare_for_twitter_meta( $post_id, TWEET_BODY_KEY ) ); if ( empty( $tweet_accounts ) ) { $tweet_accounts = get_default_autoshare_accounts(); } @@ -217,6 +218,7 @@ function localize_data( $handle = SCRIPT_HANDLE ) { 'nonce' => wp_create_nonce( 'wp_rest' ), 'restUrl' => rest_url( post_autoshare_for_twitter_meta_rest_route( $post_id ) ), 'tweetBodyKey' => TWEET_BODY_KEY, + 'customTweetBody' => $tweet_body, 'status' => $status_meta && is_array( $status_meta ) ? $status_meta : null, 'unknownErrorText' => __( 'An unknown error occurred', 'autoshare-for-twitter' ), 'siteUrl' => home_url(), diff --git a/src/js/store/reducer.js b/src/js/store/reducer.js index 825161ca..71dfd058 100644 --- a/src/js/store/reducer.js +++ b/src/js/store/reducer.js @@ -1,4 +1,4 @@ -import { enabled, allowTweetImage, tweetAccounts } from 'admin-autoshare-for-twitter'; +import { enabled, allowTweetImage, tweetAccounts, customTweetBody } from 'admin-autoshare-for-twitter'; import { SET_AUTOSHARE_FOR_TWITTER_ENABLED, @@ -15,9 +15,9 @@ export const DEFAULT_STATE = { autoshareEnabled: ( ! ! enabled && '0' !== enabled ), errorMessage: '', loaded: false, - overriding: false, + overriding: customTweetBody ? true : false, overrideLength: 0, - tweetText: '', + tweetText : customTweetBody || '', allowTweetImage: ! ! allowTweetImage, tweetAccounts: tweetAccounts || [], }; From f39ab6c153acbcae4f2f15f80b82f18bf705e9ff Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 11 Aug 2023 19:54:56 +0530 Subject: [PATCH 18/28] Made Tweetbody persistent in classic editor. --- includes/admin/post-meta.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/admin/post-meta.php b/includes/admin/post-meta.php index bfa73655..16172f08 100644 --- a/includes/admin/post-meta.php +++ b/includes/admin/post-meta.php @@ -546,6 +546,8 @@ function markup_unknown( $status_meta ) { * @return string */ function _safe_markup_default() { + $custom_tweet_body = Utils\get_autoshare_for_twitter_meta( get_the_ID(), TWEET_BODY_KEY ); + $count = ( strlen( get_permalink( get_the_ID() ) ) + 5 ); $max_length = 280 - $count; ob_start(); @@ -560,7 +562,9 @@ function _safe_markup_default() { > - + + +